正在加载图片...
11.10.PROJECTS 353 You must write a MATLAB script M-file that does the following: (a)Prompt the user for: i.Chamber height and width ii.Connecting pipe height and width. The pipe height must be less than or equal to the chamber height and greater than 0. iii.The number of molecules to simulate. (b)Display the initial geometry as in first figure. (c)Place the molecules in the left chamber and display the initial configuration as in the second figure. (d)Execute the time steps until all the molecules stick to the right most wall.Display the final configuration as in fourth figure as well as the number of time-steps it took to do the simulation. Some hints: .When testing your code,use geometries with just a few cells for height and width and just a few molecules.This will allow the simulations to complete quickly and will test the more subtle parts of the code,the wall collisions and the action of sticking to the cold wall. When testing your code,make lots of use of visual output.Put in some graph- ical output for some or all of the time-steps with a pause statement following the graphics instruction.For example,the third figure shows some intermediate graphical output.This is a very valuable way of debugging the operation of your code. You may need the following MATLAB function in your code (it is not mentioned in the book!)to place the molecules randomly at the start.Using help uint32: UINT32 Convert to unsigned 32-bit integer. I UINT32(X)converts the elements of the array X into unsigned 32-bit integers.X can be any numeric object (such as a DOUBLE).The values of a UINT32 range from 0 to 4294967295.Values outside this range are mapped to 0 or 4294967295.If X is already an unsigned 32-bit integer array,UINT32 has no effect. See also ...UINT8,UINT16,INT8,INT16,INT32.11.10. PROJECTS 353 You must write a MATLAB script M-file that does the following: (a) Prompt the user for: i. Chamber height andwidth ii. Connecting pipe height andwidth. The pipe height must be less than or equal to the chamber height andgreater than 0. iii. The number of molecules to simulate. (b) Display the initial geometry as in first figure. (c) Place the molecules in the left chamber anddisplay the initial configuration as in the secondfigure. (d) Execute the time steps until all the molecules stick to the right most wall. Display the final configuration as in fourth figure as well as the number of time-steps it took to do the simulation. Some hints: • When testing your code, use geometries with just a few cells for height and width andjust a few molecules. This will allow the simulations to complete quickly and will test the more subtle parts of the code, the wall collisions and the action of sticking to the coldwall. • When testing your code, make lots of use of visual output. Put in some graph￾ical output for some or all of the time-steps with a pause statement following the graphics instruction. For example, the thirdfigure shows some intermediate graphical output. This is a very valuable way of debugging the operation of your code. • You may needthe following MATLAB function in your code (it is not mentioned in the book!) to place the molecules randomly at the start. Using help uint32: UINT32 Convert to unsigned 32-bit integer. I = UINT32(X) converts the elements of the array X into unsigned 32-bit integers. X can be any numeric object (such as a DOUBLE). The values of a UINT32 range from 0 to 4294967295. Values outside this range are mapped to 0 or 4294967295. If X is already an unsigned 32-bit integer array, UINT32 has no effect. . . . See also ...UINT8, UINT16, INT8, INT16, INT32
<<向上翻页
©2008-现在 cucdc.com 高等教育资讯网 版权所有