正在加载图片...
function nTrapped coldTrap (sizes,numMolecules,iterationsteps) &COLDTRAP will simulate the cold trap algorithm described in the project &6 of Chapter 11 of ICP book 号inputs: 号 sizes is defined as IN,M,ChamberH,ChamberL,PipeH,PipeL]. 号 For your initial test,it is set to [32,32,30,10,16,10]; 号 numMolecues is the number of molecules initially existed in the left 号 chamber.For your initial test,it is set to 100; iterationsteps specify the iteration steps for simulation. 号 For your initial test,it is set to 1000; 号outputs: nTrapped:number of molecules traped to the right most columns after given number of iterations rand ('state',0); chamber chamberset (sizes); &the following code will plot the figure 11-9 N=sizes (1); M=sizes (2); plotC zeros (N+1,M+1)+4; plotc (1:N,1:M)=chamber; pcolor (1:M+1,1:N+1,plotC); colorbar; disp ('hit return to continue') pause; $wait for user's command to continue 号numMolecules=100; molecules moleculesSet (sizes,numMolecules); $the following codes will update chamber cells according to the random &distribution of those molecules for index 1:length (molecules) ii=molecules (index,2); jj=molecules (index,3); chamber (ii,jj)=chamber (ii,jj)+1; one added for boundary end &plot the initial state of the molecules distribution (Figure 11-10) plotc (1:N,1:M)=chamber; pcolor (1:M+1,1:N+1,plotc); colorbar; hold on disp ('hit return to continue') pause; $wait for user's command to continue $iterationsteps 1000; [chamber,molecules]moveMolecules (chamber,molecules,sizes, iterationsteps); nTrapped sum (molecules (:4)==1); fprintf ('&d molecules reached the destination.\n',nTrapped); plotc (1:N,1:M)=chamber; pcolor (1:M+1,1:N+1,plotC); colorbar;function nTrapped = coldTrap (sizes, numMolecules, iterationSteps) % COLDTRAP will simulate the cold trap algorithm described in the project % 6 of Chapter 11 of ICP book % inputs: % sizes is defined as [N, M, ChamberH, ChamberL, PipeH, PipeL]. % For your initial test, it is set to [32, 32, 30, 10, 16, 10]; % numMolecues is the number of molecules initially existed in the left % chamber. For your initial test, it is set to 100; % iterationSteps specify the iteration steps for simulation. % For your initial test, it is set to 1000; % outputs: % nTrapped: number of molecules traped to the right most columns after % given number of iterations rand ('state', 0); chamber = chamberSet (sizes); % the following code will plot the figure 11-9 N = sizes (1); M = sizes (2); plotC = zeros (N+1, M+1)+4; plotC (1:N, 1:M) = chamber; pcolor (1:M+1, 1:N+1, plotC); colorbar; disp ('hit return to continue') pause; % wait for user's command to continue % numMolecules = 100; molecules = moleculesSet (sizes, numMolecules); % the following codes will update chamber cells according to the random % distribution of those molecules for index = 1:length (molecules) ii = molecules (index, 2); jj = molecules (index, 3); chamber (ii, jj) = chamber (ii, jj) + 1; % one added for boundary end % plot the initial state of the molecules distribution (Figure 11-10) plotC (1:N, 1:M) = chamber; pcolor (1:M+1, 1:N+1, plotC); colorbar; hold on disp ('hit return to continue') pause; % wait for user's command to continue % iterationSteps = 1000; [chamber, molecules] = moveMolecules (chamber, molecules, sizes, iterationSteps); nTrapped = sum (molecules (:, 4) == 1); fprintf ('%d molecules reached the destination.\n', nTrapped); plotC (1:N, 1:M) = chamber; pcolor (1:M+1, 1:N+1, plotC); colorbar;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有