-
Notifications
You must be signed in to change notification settings - Fork 1
/
shape_substrate.py
220 lines (190 loc) · 7.78 KB
/
shape_substrate.py
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
### PYTHON FOR MD ###
"""
Current script for creating corrugated substartes
(uncomment some parts!)
"""
import os
import mdconf as mdc
import numpy as np
from math import ceil
from math import sqrt
from math import pi
import scipy as sc
import scipy.special
gmx = 'gmx'
substrates_dir = '/home/michele/python_for_md/TestSub'
f_rough = lambda a2 : (2.0/pi) * np.sqrt(a2+1.0) * sc.special.ellipe(a2/(a2+1.0))
per_y = 1.0
a = 0.7
R0 = 250.0 # [Å]
lambda0 = 0.25*R0
k0 = 2.0*np.pi/lambda0
r0 = f_rough(a**2)
Lx = 1750.5 # [Å]
Ly = per_y*46.70 # [Å]
Lz = 850.0 # [Å]
bf = 500.0 # [Å]
sp = 4.50 # [Å]
alpha_1 = sqrt(3.0/4.0)
alpha_2 = sqrt(2.0/3.0)
dy = sp*alpha_1
dz = sp*alpha_2
nj = int( np.round(Ly/(sp*alpha_1)) )
nk = 1
h0 = a/k0
h_off = 5.0+h0
w_off = 0
bend = True
box_y = nj*dy
box_z = Lz
ni = int( np.round(r0*(Lx+bf)/sp) )
file_substrate_pdb = '/home/michele/python_for_md/SpreadingAdjust/sub_wave.pdb'
mdc.quad_substrate_wave(h0, h_off, k0, w_off, bend, ni, nj, nk, file_substrate_pdb)
file_uncut_gro = '/home/michele/python_for_md/SpreadingAdjust/sub_wave_uc.gro'
os.system( gmx+" editconf -f " + file_substrate_pdb + " -o " + file_uncut_gro )
file_substrate_gro = '/home/michele/python_for_md/SpreadingAdjust/sub_wave.gro'
mdc.shift_and_resize_gro(-0.1*Ly, 0.0, 0.0, 0.1*Lx, 0.1*Ly, 0.1*Lz, file_uncut_gro, file_substrate_gro)
"""
###########################################################
### CASE 1: fixing substrate height and change wavelenght ###
###########################################################
# Parameters defining the space substrate structure
h = 10.0 # [Å]
h_off = 8*h # [Å]
w_off = 0.0 # [Å^-1]
bend = True
box_y = nj*dy
box_z = nk*dz+h_off
# Flat
# ni = int( np.round((Lx+bf)/sp) )
ni = int( np.round(Lx/sp) )
file_substrate_pdb = substrates_dir+'/sub_flat.pdb'
file_uncut_gro = substrates_dir+'/uncut_flat.gro'
mdc.quad_substrate(ni, nj, nk, file_substrate_pdb)
print( gmx+" editconf -f " + file_substrate_pdb + " -o " + file_uncut_gro )
os.system( gmx+" editconf -f " + file_substrate_pdb + " -o " + file_uncut_gro )
# NB in .gro files units are expressed in nanometers
file_substrate_gro = substrates_dir+'/sub_flat.gro'
mdc.shift_and_resize_gro(-Ly/10, 0.0, 0.0, Lx/10, box_y/10, box_z/10, file_uncut_gro, file_substrate_gro)
print('\n### FLAT ###\n')
print('h = '+str(0))
print('r = '+str(1))
print('a = '+str(0))
print('omega = 0')
print('lambda = inf')
# Rough
for idx in range(4) :
w_n = (0.5+idx*0.5)*(1.0/h) # [Å^-1]
a2 = (w_n*h)**2
r0 = f_rough(a2)
# ni = int( np.round(r0*(Lx+bf)/sp) )
file_substrate_pdb = substrates_dir+'/sub_lambda'+str(int(idx+1))+'.pdb'
file_uncut_gro = substrates_dir+'/uncut_lambda'+str(int(idx+1))+'.gro'
mdc.quad_substrate_wave(h, h_off, w_n, w_off, bend, ni, nj, nk, file_substrate_pdb)
print( gmx+" editconf -f " + file_substrate_pdb + " -o " + file_uncut_gro )
os.system( gmx+" editconf -f " + file_substrate_pdb + " -o " + file_uncut_gro )
# NB in .gro files units are expressed in nanometers
file_substrate_gro = substrates_dir+'/sub_lambda'+str(int(idx+1))+'.gro'
mdc.shift_and_resize_gro(-Ly/10, 0.0, -3.0*h/10.0, Lx/10, box_y/10, box_z/10, file_uncut_gro, file_substrate_gro)
print('\n### LAMBDA '+str(idx+1)+' ###\n')
print('h = '+str(h))
print('r = '+str(r0))
print('a = '+str(np.sqrt(a2)))
print('omega = '+str(w_n))
print('lambda = '+str(2*np.pi/w_n))
"""
###########################################################
### CASE 2: fixing substrate wavelenght and change height ###
###########################################################
"""
# Probing a = 0.25 and a = 0.50
lambda_star = 35.0 # [Å]
w_0 = 2.0*np.pi/lambda_star # [Å^-1]
# Flat substrate has already been produced
# Rough
for idx in range(4) :
a = (0.5+idx*0.5) # [nondim.]
h_var = a/w_0
r0 = f_rough(a**2)
# ni = int( np.round(r0*(Lx+bf)/sp) )
file_substrate_pdb = substrates_dir+'/sub_height'+str(int(idx+1))+'.pdb'
file_uncut_gro = substrates_dir+'/uncut_height'+str(int(idx+1))+'.gro'
mdc.quad_substrate_wave(h_var, h_off, w_0, w_off, bend, ni, nj, nk, file_substrate_pdb)
print( gmx+" editconf -f " + file_substrate_pdb + " -o " + file_uncut_gro )
os.system( gmx+" editconf -f " + file_substrate_pdb + " -o " + file_uncut_gro )
# NB in .gro files units are expressed in nanometers
file_substrate_gro = substrates_dir+'/sub_height'+str(int(idx+1))+'.gro'
mdc.shift_and_resize_gro(-Ly/10, 0.0, -3.0*h/10.0, Lx/10, box_y/10, box_z/10, file_uncut_gro, file_substrate_gro)
print('\n### HEIGHT '+str(idx+1)+' ###\n')
print('h = '+str(h_var))
print('r = '+str(r0))
print('a = '+str(a))
print('omega = '+str(w_0))
print('lambda = '+str(2*np.pi/w_n))
"""
#############
# OLD STUFF #
#############
"""
a2 = 0.50
h_var = a2/w_0
r0 = f_rough(a2)
print('\n### H | a2=0.5 ###\n')
print('h = '+str(h_var))
print('r = '+str(r0))
print('a = '+str(np.sqrt(a2)))
print('omega = '+str(w_0))
print('lambda = '+str(2*np.pi/w_0))
ni = int( np.round(r0*(Lx+bf)/sp) )
file_substrate_pdb = '/home/michele/python_for_md/Droplet20nmExp/Substrates/sub_height1.pdb'
file_uncut_gro = '/home/michele/python_for_md/Droplet20nmExp/Substrates/uncut_height1.gro'
mdc.quad_substrate_wave(h_var, h_off, w_0, w_off, bend, ni, nj, nk, file_substrate_pdb)
print( gmx+" editconf -f " + file_substrate_pdb + " -o " + file_uncut_gro )
os.system( gmx+" editconf -f " + file_substrate_pdb + " -o " + file_uncut_gro )
# NB in .gro files units are expressed in nanometers
file_substrate_gro = '/home/michele/python_for_md/Droplet20nmExp/Substrates/sub_height1.gro'
mdc.shift_and_resize_gro(-Ly/10, 0.0, 0.0, Lx/10, box_y/10, box_z/10, file_uncut_gro, file_substrate_gro)
a2 = 0.25
h_var = a2/w_0
r0 = f_rough(a2)
print('\n### H | a2=0.5 ###\n')
print('h = '+str(h_var))
print('r = '+str(r0))
print('a = '+str(np.sqrt(a2)))
print('omega = '+str(w_0))
print('lambda = '+str(2*np.pi/w_0))
ni = int( np.round(r0*(Lx+bf)/sp) )
file_substrate_pdb = '/home/michele/python_for_md/Droplet20nmExp/Substrates/sub_height2.pdb'
file_uncut_gro = '/home/michele/python_for_md/Droplet20nmExp/Substrates/uncut_height2.gro'
mdc.quad_substrate_wave(h_var, h_off, w_0, w_off, bend, ni, nj, nk, file_substrate_pdb)
print( gmx+" editconf -f " + file_substrate_pdb + " -o " + file_uncut_gro )
os.system( gmx+" editconf -f " + file_substrate_pdb + " -o " + file_uncut_gro )
# NB in .gro files units are expressed in nanometers
file_substrate_gro = '/home/michele/python_for_md/Droplet20nmExp/Substrates/sub_height2.gro'
mdc.shift_and_resize_gro(-Ly/10, 0.0, 0.0, Lx/10, box_y/10, box_z/10, file_uncut_gro, file_substrate_gro)
"""
"""
# Determine new dimensions and resize water box
file_water_in = 'wat_equil.pdb'
file_water_out = '2dCylDropRoughSubTest4/wat_equil_ext.pdb'
qs = open(file_substrate_pdb, 'r')
we = open(file_water_in, 'r')
line1_qs = qs.readline().split()
line1_we = we.readline().split()
# safety check
print(line1_qs)
print(line1_we)
alpha = 0.525
nx = int(ceil(float(line1_qs[1])/float(line1_we[1])))
# Add 1 to ensure the droplet won't shrink past lattice y dimension after imposing EOS
ny = int(ceil(float(line1_qs[2])/float(line1_we[2])))+1
nz = int(ceil(alpha*float(line1_qs[1])/float(line1_we[1])))
we.close()
qs.close()
print("gmx genconf -f " + file_water_in + " -o " + file_water_out + " -nbox %.3f %.3f %.3f" % (nx, ny, nz))
os.system("gmx genconf -f " + file_water_in + " -o " + file_water_out + " -nbox %.3f %.3f %.3f" % (nx, ny, nz))
# Carve droplet
file_droplet = '2dCylDropRoughSubTest4/droplet/wat_droplet.pdb'
beta = 0.225
mdc.carve_2D_droplet(beta, file_water_out, file_droplet, 'p')
"""