-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim_surface93.cpp
142 lines (116 loc) · 3.6 KB
/
sim_surface93.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
Copyright 2013, Vasudevan Venkateshwaran, Garde group @ RPI
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
sim_harmonicpin.cpp
Routines to deal with 9-3 surface.
*/
#include <string>
#include <fstream>
#include <iostream>
#include "constants.h"
#include "sim_surface93.h"
surface93:: surface93 ()
{
}
surface93:: ~surface93 ()
{
}
void surface93:: init ( int argc, char **argv, std::ofstream& fp )
{
if ( argc < 5 )
{
std::cout << "Incorrect parameters for 9-3 surface.\n";
std::cout << "Format: surface93 zlocation sigma epsilon rho "
<< "(R_0 = 0.337 nm) (rho_l = 33.33 nm**-3 ) \n";
std::cout << "The parameters in paranthesis are optional. \n";
exit (EXIT_FAILURE);
}
zref = strtod(argv[1], NULL);
sigma = strtod(argv[2], NULL);
epsilon = strtod(argv[3], NULL);
rho = strtod(argv[4], NULL);
switch ( argc )
{
case 5:
R_0 = 0.337; // nm
rho_l = 33.3333; // #/nm^3
break;
case 6:
R_0 = strtod(argv[5], NULL);
rho_l = 33.3333;
break;
case 7:
R_0 = strtod(argv[5], NULL);
rho_l = strtod(argv[6], NULL);
break;
default:
std::cout << "Incorrect parameters for 9-3 surface. \n";
std::cout << "Format: surface93 zlocation sigma epsilon rho "
<< "(R_0 = 0.337 nm) (rho_l = 33.33 nm**-3 ) \n";
std::cout << "The parameters in paranthesis are optional. \n";
exit (EXIT_FAILURE);
}
d_skin = 0.01; // skin depth in nm
sigmasq = sigma*sigma;
std::cout << "Initializing 9-3 surface with parameters : \n";
std::cout << "zref_surface = " << zref << "\n"
<< "sigma_surface = " << sigma << "\n"
<< "epsilon_surface = " << epsilon << "\n"
<< "rho_surface = " << rho << "\n"
<< "R_0 = " << R_0 << "\n"
<< "rho_liquid = " << rho_l << "\n";
fp << "Initializing 9-3 surface with parameters : \n";
fp << "zref_surface = " << zref << "\n"
<< "sigma_surface = " << sigma << "\n"
<< "epsilon_surface = " << epsilon << "\n"
<< "rho_surface = " << rho << "\n"
<< "R_0 = " << R_0 << "\n"
<< "rho_liquid = " << rho_l << "\n";
}
void surface93:: calc_forces ( double* h, double *force, t_Grid* grid )
{
/*
Calculate the force due to a 9-3 surface potential
*/
int kx,ky,el;
double rx,ry,rz;
double dsq;
double rzsq, ratio, ratiosq;
double prefactor;
prefactor = rho_l * grid->dx * grid->dy;
for ( kx = 0; kx < grid->nx; kx++ )
{
for ( ky = 0; ky < grid->ny; ky++ )
{
el = kx * grid->ny + ky;
rz = h[el] - zref;
ratio = (sigma/rz);
ratiosq = ratio*ratio;
if ( rz < 0 )
{
std::cout<< "rz error";
exit(EXIT_FAILURE);
}
if ( rz > R_0 )
{
force[el] += prefactor*(TWOPI)*rho*epsilon*sigmasq*
ratiosq*ratiosq*
(1 - (2.0/5.0)*(ratiosq*ratiosq*ratiosq));
}
else
{
force[el] += prefactor*(-2.0/rho_l)* k_b * T *
(R_0 - rz)/(d_skin*d_skin);
}
}
}
}