1 / 8

MATLAB Stochastic Simulations

MATLAB Stochastic Simulations. Wednesday, 9/13/2002. Diffusion. nPart = 400; %number of particles sizeRandomStep = .02; %temperature related parameter rMax = 10; %initial particles x = rand(nPart,1)-0.5; y = rand(nPart,1)-0.5; h = plot(x,y,'.'); %plot particles as dots hold on

rossa
Download Presentation

MATLAB Stochastic Simulations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MATLAB Stochastic Simulations Wednesday, 9/13/2002

  2. Diffusion

  3. nPart = 400; %number of particles • sizeRandomStep = .02; %temperature related parameter • rMax = 10; • %initial particles • x = rand(nPart,1)-0.5; • y = rand(nPart,1)-0.5; • h = plot(x,y,'.'); %plot particles as dots • hold on • axis([-20 20 -20 20]) • axis square • grid off • set(h,'EraseMode','xor','MarkerSize',18) • % draw the circle the diffusion will finally reach to • theta = linspace( 0, pi*2, 50 ); • plot(rMax*cos(theta),rMax*sin(theta),'r-'); • nStep = 0; • while ( max(sqrt(x.^2+y.^2)) < rMax ) • drawnow • x = x + sizeRandomStep * randn(nPart,1); • y = y + sizeRandomStep * randn(nPart,1); • nStep = nStep + 1; • set(h,'XData',x,'YData',y) • End • nStep % display how many steps cost to reach to the circle DiffusionSimulation

  4. Erase Mode for Animation

  5. Brownian Motion in a Closed Box

  6. Boundary Treatment Reflection for the random movement with tendency to go outside.

  7. Pressure Momentum change for particle hit on the boundary surface with random movement of distance s and hit angle q is mass = 1 unit mass timestep = 1 unit time

  8. Extension of particles from one room to two rooms

More Related