this is for a thermodynamics and condensed matter physics assignment. I have attached the matlab code. Please only use the code provided in the zip file i have uploaded today

1 answer below »
this is for a thermodynamics and condensed matter physics assignment. I have attached the matlab code. Please only use the code provided in the zip file i have uploaded today
Answered Same DayMay 17, 2021

Answer To: this is for a thermodynamics and condensed matter physics assignment. I have attached the matlab...

Rahul answered on May 21 2021
152 Votes
Matlab_Thermo_20052020/ASSIGNMENT 3.docx
ASSIGNMENT 3
a) Lennard Jones Potential
Matlab Code to find the Lennard Jones Potential
%% Matlab code for Leonard Jones Potential
clearvars;
tic;
epsilon = 4.184*2.4; %kJ/mol for the nitrogen
sigma = 3.310; %Unit Angstrom for the nitrogen molecules
r = linspace(0.01*sigma,6*sigma,10000);% Define the position
for i = 1:length(r)
V(i) = 4*epsilon*((sigma/r(i))^12-(sigma/r(i))^6);
end
plot(V,r)
ylim([-1 1])
rmin = ((2)^(1/6))*sigma; % A
display(['The particale Seperation at minimum potential is ',num2str(rmin),' Angstrom']);
%rmin is the distance where the pot
ential reaches a minimum, i.e. the equilibrium position of the two particles
toc;
Figure 1: Lennard Jones Potential
b) Particle separation at minima of the Lennard Jones Potential
rmin = ((2)^(1/6))*sigma
The particale Seperation at minimum potential is 3.7153 Angstrom
rmin is the distance where the potential reaches a minimum, i.e. the equilibrium position of the two particles
c) Matlab Code simulation of trajectories with Lennard Jones Potential
%Basic simulation of trajectories of particles (and temperature) in a two
%dimensional
%ideal gas
%Saves postions and temperature of particles as a function of time, and a
%movie showing the trajectories
clc;
clearvars;
tic;

T_i=300; %Temperature in Kelvin
k=1.38e-23; %Boltzmann constant
m=1e-26; %Mass of a particle in kg
epsilon = 4.184*2.4*1000; %Unit in J/mol
sigma = 3.310e-10; %unit in m

v_rms=sqrt(k*T_i/m); %Mean particle velocity expected

N=100; %number of particles is decrease to decrease the computation time
L=1; %length of cube side in meters
%A=L^2; %area of cube

Tau=L/v_rms; %typical time for particle to traverse box
tmax=Tau*100; %simulation time. I.e. choosing a simulation time for which each particle collides many times with the walls.
tres=Tau/100; %time step. I.e. choosing a time resolution small compared to the time between collisions with walls

%particle position: randomly locating particles
x_i=rand(N,1);
y_i=rand(N,1);

%particle velocity: randomly selecting their vwlocity components from a Gaussian
%distribution
vx_i=v_rms*randn(N,1);
vy_i=v_rms*randn(N,1);
figure(1) %plotting the initial positions of the particles
plot(x_i, y_i,'.')
axis([0 1 0 1])
f = getframe;
[im,map] = rgb2ind(f.cdata,256,'nodither');
im(1,1,1,20) = 0;
% N_time=round(tmax/tres); %number of time steps in simulation, dues to define length of loop
N_time = 2000;% Number of timesteps is also decrease
vx=vx_i; %Initialising velocities in loop
vy=vy_i;

x=zeros(N,N_time); %Initialising positions in loop
x(:,1)=x_i;
y=zeros(N,N_time);
y(:,1)=y_i;
U = zeros(length(N_time));
U(1) = 0;
T=[]; %Initialising temperature of ensemble (note, without any potential energy this will not change during the simulation)
T_wol = [];
for ring=2:N_time
x(:,ring)=x(:,ring-1)+vx*tres;
y(:,ring)=y(:,ring-1)+vy*tres;

ind=find(x(:,ring)>L);
vx(ind)=-vx(ind);

ind=find(x(:,ring)<0);
vx(ind)=-vx(ind);

ind=find(y(:,ring)>L);
vy(ind)=-vy(ind);

ind=find(y(:,ring)<0);
vy(ind)=-vy(ind);
r = zeros(N,N);
for n = 1:N %% loop to find lennard jones potential and force
for n_1 = 1:N
r(n,n_1) = pdist([x(n,ring),y(n,ring);x(n_1,ring),y(n_1,ring)]);
V(n,n_1) = 4*epsilon*((sigma/r(n,n_1))^12-(sigma/r(n,n_1))^6);
F(n,n_1) = 4*epsilon*((12*(sigma^12)/r(n,n_1)^13)-(6*(sigma^6)/r(n,n_1)^7));
end
end

V(isnan(V)) = 0;
F(isnan(F)) = 0;
U(ring) = -sum(sum(V));% In this i am doing potential positive to increase the temperature
KE(ring) = m*mean(vx.^2+vy.^2)/2;
TE(ring) = KE(ring) + U(ring);% Potential energy added with KE and increase the temperature as compare to previous case
T=[T, TE(ring)/k];
T_wol = [T_wol,KE(ring)/k];

if round(ring/50)==ring/50 %updating the particle positions only every 50th cycle of the loop
plot(x(:,ring), y(:,ring),'.');
axis([0 1 0 1])
f = getframe;
im(:,:,1,ring/50) = rgb2ind(f.cdata,map,'nodither'); %saving the time steps of the plot in a movie
end
end
imwrite(im,map,'particle_trajectories.gif','DelayTime',0,'LoopCount',inf) %saving the movie as a gif
time=[2:N_time]*tres; %creating a time axis for figure 2

figure(2)
plot(time,T)
xlabel('time');
ylabel('Temperature');
legend('With Lennard Jones Potential')
figure(3)
plot(time,T_wol)
xlabel('time');
ylabel('Temperature');
legend('Without Lennard Jones Potential')
% hold on
% plot([min(time) max(time)], [T_i T_i])
% hold off
% ylabel('Temperature')
% xlabel('Time')
toc;

Temperature Vs time graph without Potential Energy
Figure 2: Temperature Vs time Graph Without Lennard Potential
Temperature Vs time graph with Potential Energy
Figure 3: Temperature Vs time Graph With Lennard Potential
Discussion
1. There are two graph is there where find the temperature without and with Lennard jones potential energy
2. In first temperature vs graph shows that temperature is found using kinetic energy only so there is no consideration of Lennard Jones Potential energy
3. In second temperature vs graph shows that temperature is found using total energy(Kinetic energy + Lennard Jones Potential Energy)
4. In second at certain timestep temperature is increases due to adding of potential energy
5. If value of Lennard potential energy is significant that can effect the temperature difference between cases
d) Matlab Code for the simulation
%Basic simulation of trajectories of particles (and temperature) in a two
%dimensional
%ideal gas
%Saves postions and temperature of particles as a function of time, and a
%movie showing the trajectories
clc;
clearvars;
tic;

T_i=300; %Temperature in Kelvin
k=1.38e-23; %Boltzmann constant
m=1e-26; %Mass of a particle in kg
epsilon = 4.184*2.4*1000; %Unit in kJ/mol
sigma = 3.310e-10; %unit in m

v_rms=sqrt(k*T_i/m); %Mean particle velocity expected

N=50; %number of particles is decrease to decrease the computation time
L=1; %length of cube side in meters
%A=L^2; %area of cube
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here