-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmorse_potential_interactions.m
More file actions
38 lines (29 loc) · 1.23 KB
/
morse_potential_interactions.m
File metadata and controls
38 lines (29 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function m_j = morse_potential_interactions(xpos, ypos, j , n , P)
% The Morse potential is a degree of affinity between two particles. This
% stems from the knowledge that particles not repel each other but also
% have an affinity for each other. This effect will be compiled within the
% function morse_potential_interactions, returning a list of attractive
% forces per particle j.
%% Initialisation
% A number of constants must be defined within the Mathematical formula for
% the Morse Potential, done here:
ca = 1;
la = 100;
cr = 1;
lr = 200;
m_j = zeros(4*P,1);
% An empty array is created to aid with retaining the interactive forces.
%% Compiling the Morse Potential
m_j(1:2*P) = -(xpos(j) - xpos);
m_j(2*P+1:4*P) = -(ypos(j) - ypos);
m_j = m_j + (m_j == 0);
% In these steps we compile the distance between the point j and each other
% point, in both x and y direction.
for i = 1:4*P
m_j(i) = (((ca/la)*exp((-abs(m_j(i)))/la))-((cr/lr)*exp((-abs(m_j(i)))/lr)))*((m_j(i))/(abs(m_j(i))));
end
% This then is the formula for the Morse Potential. m_j(i) is iterated so
% that each distance is plugged into the formula, creating a new value
% which we will take as the morse potential between particle j and each
% other particle.
end