Skip to content

Instantly share code, notes, and snippets.

@bagustris
Created July 5, 2015 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bagustris/5de3410885ddf5e52758 to your computer and use it in GitHub Desktop.
Save bagustris/5de3410885ddf5e52758 to your computer and use it in GitHub Desktop.
%% 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