-
Notifications
You must be signed in to change notification settings - Fork 2
/
energyFunctionMCMC.m
33 lines (28 loc) · 959 Bytes
/
energyFunctionMCMC.m
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
%Brandon Ameglio (bamegli1)
%Inputs = sigma, epsilon, box lengh, and a data set.
%Outputs = potential energy of data.
%Energy funciton for finding LJP of a dataset based on distances.
%LD energy function of a particle
function[tempP]=energyFunctionMCMC(sigma,epsilon,data,pmatrix)
k = 20;
le = 1;
epsilonnb = 2/3;
tempP = 0;
for i=1:length(data)
for j=i+1:length(data)
point = [data(i,1)-data(j,1),data(i,2)-data(j,2),data(i,3)-data(j,3)];
dis = sqrt(point(1,1)^2+point(1,2)^2+point(1,3)^2);
if j==i+1
%bounded calculations
valVB = 0.5*k*(dis-le)^2;
tempP = tempP + valVB;
else
if ismember(i,pmatrix) || ismember(j,pmatrix)
valV = 4*epsilonnb*((sigma/dis)^12-(sigma/dis)^6);
else
valV = 4*epsilon*((sigma/dis)^12-(sigma/dis)^6);
end
tempP = tempP + valV;
end
end
end