-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.py
executable file
·186 lines (166 loc) · 6.97 KB
/
driver.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
#!/bin/env python2.7
"""
@description: Performs a 1D Langevin dynamics simulation to validate the results
of the milestoning permeability derivation
@authors: Christopher T. Lee (ctlee@ucsd.edu)
@copyright Amaro Lab 2015. All rights reserved.
"""
import argparse, logging, matplotlib, os, pdb
import numpy as np
import matplotlib.pyplot as plt
import cPickle as pickle
# Import custom modules
import plottools
import membranesystem as ms
import permeability as perm
from samplefunctions import PMF, Viscosity
if __name__ == '__main__':
# parse the arguments
# TODO: add more arguments for arbitrary system definition and run
parser = argparse.ArgumentParser(description="Runs 1-Dimensional " +
"permeability calculations using a Langevin integrator. Both " +
"non-milestoned and milestoned permeability values are computed.")
parser.add_argument('-c',
"--copt",
action = 'store_true',
dest = 'cOpt',
help="Use the faster C integrator")
parser.add_argument('-v',
action='count',
dest='verbosity',
help = 'Set the output verbosity')
args = parser.parse_args() # parse the args into a dictionary
if args.verbosity == 0:
logging.basicConfig(level=logging.ERROR,
format='[%(levelname)s] %(process)d %(processName)s: %(message)s')
elif args.verbosity == 1:
logging.basicConfig(level=logging.WARNING,
format='[%(levelname)s] %(process)d %(processName)s: %(message)s')
elif args.verbosity == 2:
logging.basicConfig(level=logging.INFO,
format='[%(levelname)s] %(process)d %(processName)s: %(message)s')
elif args.verbosity >= 3:
logging.basicConfig(level=logging.DEBUG,
format='[%(levelname)s] %(process)d %(processName)s: %(message)s')
cOpt = args.cOpt
if cOpt == False:
raw_input("Using non-accelerated, hit enter to continue...")
milestones = np.arange(-25, 26, 1)
"""
# Flat system
print '#'*30 + '\n# Flat System #\n' + '#'*30
name = 'flat'
if not os.path.exists('systems/%s_system.p'%(name)):
pmf = PMF(25, 0, 0, 0, 21, 13)
nu = Viscosity(25, 3.21e-14, 3.21e-14, 3.21e-14, 3.21e-14, 18, 10, 6)
system = ms.MembraneSystem(name, pmf, nu, 20, 5, step = 0.01)
pickle.dump(system, open('systems/%s_system.p'%(name), 'wb'), -1)
else:
system = pickle.load(open('systems/%s_system.p'%(name), 'rb'))
fig1, fig2 = system.plotProfiles()
fig1.savefig('figures/%s_pmf.png'%(name), dpi=300)
fig2.savefig('figures/%s_dz.png'%(name), dpi=300)
#plt.show()
ihsdP = system.inhomogenousSolDiff()
smolP = system.smolPerm()
if abs(ihsdP - smolP) > 1e-4:
logging.warning("Equation 22 is not equal")
perm.bruteMPCrossing(system, numSims = 1000, length = 1e-6,
dt = 1e-12, cOpt = cOpt)
perm.bruteMPTimes(system, numSims = 1000, length = 1e-6,
dt = 1e-12, cOpt = cOpt)
#perm.processBrute(system)
perm.milestoneMP(system, milestones, numSims = 10000,
length = 1e-6, dt = 1e-15, cOpt = cOpt)
#perm.processMilestones(system, milestones)
print '\n\n'
"""
# Small hill system
print '#'*30 + '\n# Small Hill System #\n' + '#'*30
name = 'smallhill'
if not os.path.exists('systems/%s_system.p'%(name)):
pmf = PMF(25, 0, 0.25, 0.5, 21, 13)
nu = Viscosity(25, 3.21e-14, 5e-13, 5e-13, 5e-13, 18, 10, 6)
system = ms.MembraneSystem(name, pmf, nu, 20, 5, step = 0.01)
pickle.dump(system, open('systems/%s_system.p'%(name), 'wb'), -1)
else:
system = pickle.load(open('systems/%s_system.p'%(name), 'rb'))
"""
fig1, fig2 = system.plotProfiles()
fig1.savefig('figures/%s_pmf.png'%(name), dpi=300)
fig2.savefig('figures/%s_dz.png'%(name), dpi=300)
fig1.clear()
fig2.clear()
ihsdP = system.inhomogenousSolDiff()
smolP = system.smolPerm()
if abs(ihsdP - smolP) > 1e-4:
logging.warning("Equation 22 is not equal")
perm.bruteMPCrossing(system, numSims=1000, length = 1e-4,
dt = 1e-12, cOpt = cOpt)
perm.bruteMPTimes(system, numSims=500, length = 1e-4,
dt = 1e-12, cOpt = cOpt)
"""
#perm.processBrute(system)
perm.milestoneMP(system, milestones, numSims = 5000,
length = 1e-4, dt = 1e-15, cOpt = cOpt)
#perm.processMilestones(system, milestones)
print '\n\n'
"""
# Urea like system
print '#'*30 + '\n# Urea System #\n' + '#'*30
name = 'urea'
if not os.path.exists('systems/%s_system.p'%(name)):
pmf = PMF(25, 0, 0.694785, 5.558286, 21, 13)
nu = Viscosity(25, 3.21e-14, 5e-13, 5e-13, 5e-13, 18, 10, 6)
system = ms.MembraneSystem(name, pmf, nu, 60, 2.86, step = 0.01)
pickle.dump(system, open('systems/%s_system.p'%(name), 'wb'), -1)
else:
system = pickle.load(open('systems/%s_system.p'%(name), 'rb'))
fig1, fig2 = system.plotProfiles()
fig1.savefig('figures/%s_pmf.png'%(name), dpi=300)
fig2.savefig('figures/%s_dz.png'%(name), dpi=300)
fig1.clear()
fig2.clear()
ihsdP = system.inhomogenousSolDiff()
smolP = system.smolPerm()
if abs(ihsdP - smolP) > 1e-4:
logging.warning("Equation 22 is not equal")
perm.bruteMPCrossing(system, numSims=1000, length = 1,
dt = 1e-12, cOpt = cOpt)
perm.bruteMPTimes(system, numSims=500, length = 1,
dt = 1e-12, cOpt = cOpt)
#perm.processBrute(system)
milestones = np.arange(-25, 26, 1)
perm.milestoneMP(system, milestones, numSims = 10000,
length = 1, dt = 1e-15, cOpt = cOpt)
#perm.processMilestones(system, milestones)
print '\n\n'
# codeine system
print '#'*30 + '\n# Codeine System #\n' + '#'*30
name = 'codeine'
if not os.path.exists('systems/%s_system.p'%(name)):
pmf = PMF(25, 0.25, -2, -0.5, 21, 13)
nu = Viscosity(25, 3.21e-14, 5e-13, 5e-13, 5e-13, 18, 10, 6)
system = ms.MembraneSystem(name, pmf, nu, 299, 4.315, step = 0.01)
pickle.dump(system, open('systems/%s_system.p'%(name), 'wb'), -1)
else:
system = pickle.load(open('systems/%s_system.p'%(name), 'rb'))
fig1, fig2 = system.plotProfiles()
fig1.savefig('figures/%s_pmf.png'%(name), dpi=300)
fig2.savefig('figures/%s_dz.png'%(name), dpi=300)
fig1.clear()
fig2.clear()
ihsdP = system.inhomogenousSolDiff()
smolP = system.smolPerm()
if abs(ihsdP - smolP) > 1e-4:
logging.warning("Equation 22 is not equal")
perm.bruteMPCrossing(system, numSims=1000, length = 1e-4,
dt = 1e-12, cOpt = cOpt)
perm.bruteMPTimes(system, numSims=500, length = 1e-4,
dt = 1e-12, cOpt = cOpt)
#perm.processBrute(system)
perm.milestoneMP(system, milestones, numSims = 10000,
length = 1e-4, dt = 1e-15, cOpt = cOpt)
#perm.processMilestones(system, milestones)
print '\n\n'
"""