-
Notifications
You must be signed in to change notification settings - Fork 0
/
V_Morse.cpp
73 lines (63 loc) · 1.66 KB
/
V_Morse.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* V_Morse.cpp
*
* Created on: May 24, 2012
* Author: dstuck
*/
#include "V_Morse.h"
V_Morse::V_Morse(CoordUtil* coords, double deVar, double aVar, double mVar, int N) : coordKeeper(coords) {
vector<double> mass;
vector<double> omega;
for(int j=0; j<N; j++) {
mass.push_back(mVar);
de.push_back(deVar);
a.push_back(aVar);
omega.push_back(aVar*sqrt(2.0*deVar/mVar));
}
coords->reducedMass = mass;
coords->omega = omega;
}
V_Morse::V_Morse(CoordUtil* coords, vector<double> deVar, vector<double> aVar, vector<double> mVar) : coordKeeper(coords) {
if(deVar.size()!=aVar.size()){
cout << "!!!Error: De and a dimensions different in V_Morse initialization!!!" << endl;
}
de = deVar;
a = aVar;
vector<double> omega;
for(int i=0; i<deVar.size(); i++) {
omega.push_back(aVar[i]*sqrt(2.0*deVar[i]/mVar[i]));
}
coords->reducedMass = mVar;
coords->omega = omega;
}
V_Morse::~V_Morse() {
// TODO Auto-generated destructor stub
}
double V_Morse::GetV(vector<Particle> part, Propagator * rho) {
double V = 0;
V += GetV(part);
// cout << "preV: " << V << endl;
V += rho->ModifyPotential(part);
// cout << "V: " << V << endl;
return V;
}
double V_Morse::GetV(vector<Particle> part) {
// Really, should only have dimension 1
double V = 0;
int dim = part[0].pos.size();
double expTemp = 0;
for(int j=0; j<(int)part.size(); j++) {
for(int k=0; k<dim; k++) {
expTemp = exp(-a[j]*part[j].pos[k]);
V += de[j]*(1.0 - expTemp)*(1.0-expTemp);
}
}
return V;
}
string V_Morse::GetType() {
string name = "Morse";
return name;
}
CoordUtil* V_Morse::GetCoordUtil() {
return coordKeeper;
}