-
Notifications
You must be signed in to change notification settings - Fork 0
/
sim_samsurface.cpp
175 lines (149 loc) · 5 KB
/
sim_samsurface.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
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_samsurface.h"
samsurface:: samsurface ()
{
}
samsurface:: ~samsurface ()
{
}
void samsurface:: init ( int argc, char **argv, std::ofstream& fp )
{
if ( argc < 5 )
{
std::cout << "Incorrect parameters for 9-3 surface.\n";
std::cout << "Format: samsurface 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_head = strtod(argv[2], NULL);
epsilon_head = strtod(argv[3], NULL);
rho_head = strtod(argv[4], NULL);
sigma_tail = strtod(argv[5], NULL);
epsilon_tail = strtod(argv[6], NULL);
rho_tail = strtod(argv[7], NULL);
switch ( argc )
{
case 8:
lambda = 1.0;
xi = 0.4525; // nm
R_0 = 0.337; // nm
rho_l = 33.3333; // #/nm^3
break;
case 9:
lambda = strtod(argv[8], NULL);
xi = 0.4525; // nm
R_0 = 0.337; // nm
rho_l = 33.3333; // #/nm^3
break;
case 10:
lambda = strtod(argv[8], NULL);
xi = strtod(argv[8], NULL);
R_0 = 0.337;
rho_l = 33.3333;
break;
case 11:
lambda = strtod(argv[8], NULL);
xi = strtod(argv[8], NULL);
R_0 = strtod(argv[5], NULL);
rho_l = 33.3333;
break;
case 12:
lambda = strtod(argv[8], NULL);
xi = strtod(argv[8], NULL);
R_0 = strtod(argv[5], NULL);
rho_l = strtod(argv[6], NULL);
break;
default:
std::cout << "Incorrect parameters for sam surface. \n";
std::cout << "Format: samsurface zlocation sigma_head epsilon_head rho_head "
<< "sigma_tail epsilon_tail rho_tail xi (lambda = 1.00)"
<< "(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_head = sigma_head*sigma_head;
sigmacu_tail = sigma_tail*sigma_tail*sigma_tail;
std::cout << "Initializing sam surface with parameters : \n";
std::cout << "zref_surface = " << zref << "\n"
<< "sigma_head = " << sigma_head << "\n"
<< "epsilon_head = " << epsilon_head << "\n"
<< "rho_head = " << rho_head << "\n"
<< "sigma_head = " << sigma_tail << "\n"
<< "epsilon_head = " << epsilon_tail << "\n"
<< "rho_head = " << rho_tail << "\n"
<< "lambda = " << lambda << "\n"
<< "R_0 = " << R_0 << "\n"
<< "rho_liquid = " << rho_l << "\n";
fp << "Initializing sam surface with parameters : \n";
fp << "zref_surface = " << zref << "\n"
<< "sigma_head = " << sigma_head << "\n"
<< "epsilon_head = " << epsilon_head << "\n"
<< "rho_head = " << rho_head << "\n"
<< "sigma_head = " << sigma_tail << "\n"
<< "epsilon_head = " << epsilon_tail << "\n"
<< "rho_head = " << rho_tail << "\n"
<< "lambda = " << lambda << "\n"
<< "R_0 = " << R_0 << "\n"
<< "rho_liquid = " << rho_l << "\n";
}
void samsurface:: calc_forces ( double* h, double *force, t_Grid* grid )
{
/*
Calculate the force due to a sam surface potential
*/
int kx,ky,el;
double rx,ry,rz;
double dsq;
double rzsq, ratiosq_head;
double ratiocu_tail;
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;
ratiosq_head = sigmasq_head/(rz*rz);
ratiocu_tail = sigmacu_tail/((rz+xi)*(rz+xi)*(rz+xi));
if ( rz < 0 )
{
std::cout<< "rz error";
exit(EXIT_FAILURE);
}
if ( rz > R_0 )
{
force[el] += lambda*prefactor*(TWOPI)*rho_head*epsilon_head*sigmasq_head*
ratiosq_head*ratiosq_head* (1 - (2.0/5.0)*(ratiosq_head*ratiosq_head*ratiosq_head))
+ (TWOPI/3.0)*rho_tail*epsilon_tail*sigmacu_tail*
(ratiocu_tail)*(1 - (2.0/15.0)*ratiocu_tail*ratiocu_tail) ;
}
else
{
force[el] += prefactor*(-2.0/rho_l)* k_b * T *
(R_0 - rz)/(d_skin*d_skin);
}
}
}
}