Created
July 5, 2015 11:59
-
-
Save bagustris/5de3410885ddf5e52758 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Molecular Dynamics Simulator | |
% <md.m> Mark D. Shattuck 7/22/2010 | |
% revision history: | |
% 7/22/2010 Mark D. Shattuck <mds> md.m | |
% MD Demo for HandsOn 2010 | |
% 000 mds Initial conditions and visualization | |
%% Parmeters | |
N=10; % number of particles | |
D=2; % diameter of particles | |
M=3; % mass of particles | |
Lx=10*D; % size of box | |
Ly=10*D; | |
%% Initial Conditions | |
x=rand(1,N); | |
y=rand(1,N); | |
%% Setup Plotting | |
clf; | |
h=zeros(1,N); | |
for np=1:N | |
h(np)=rectangle('Position',[x(np)-.5*D y(np)-.5*D D D],'Curvature',[1 1],'edgecolor','b'); | |
end | |
axis('equal'); | |
axis([0 Lx 0 Ly]); | |
%% Main Loop | |
for nt=1:1000 | |
for np=1:N | |
set(h(np),'Position',[x(np)-.5*D y(np)-.5*D D D]); | |
end | |
drawnow; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment