pyctramer 0.1.32__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyctramer/AnalyzeQC.py +249 -0
- pyctramer/ConstructFF.py +1191 -0
- pyctramer/FGR.py +238 -0
- pyctramer/JobControl.py +120 -0
- pyctramer/MarcusAA.py +297 -0
- pyctramer/PyCTRAMER.py +73 -0
- pyctramer/RunMD.py +313 -0
- pyctramer/SpinBoson.py +193 -0
- pyctramer/SubmitQC.py +256 -0
- pyctramer/Utilities.py +305 -0
- pyctramer/__init__.py +2 -0
- pyctramer/pyctramer.py +73 -0
- pyctramer-0.1.32.dist-info/METADATA +10 -0
- pyctramer-0.1.32.dist-info/RECORD +16 -0
- pyctramer-0.1.32.dist-info/WHEEL +5 -0
- pyctramer-0.1.32.dist-info/top_level.txt +1 -0
pyctramer/SubmitQC.py
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import sys
|
|
4
|
+
import os
|
|
5
|
+
from .Utilities import *
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def run_step1(i, job_control, dict_of_simulation):
|
|
10
|
+
print("run_step1")
|
|
11
|
+
project = dict_of_simulation['project']
|
|
12
|
+
work_dir = dict_of_simulation['work_dir']
|
|
13
|
+
structure_dir = dict_of_simulation['structure_dir']
|
|
14
|
+
print("job_control[i]['caseid'] " ,job_control[i]['caseid'] )
|
|
15
|
+
caseid = job_control[i]['caseid'] #str(i)
|
|
16
|
+
case_dir = work_dir + '/' + project +"_"+ caseid
|
|
17
|
+
# Quantum chemistry set up
|
|
18
|
+
qc_dir,md_dir = prepare_folder_structure(case_dir)
|
|
19
|
+
## charge of the molecule of interest
|
|
20
|
+
charge = dict_of_simulation['charge']
|
|
21
|
+
## mulitiplicity
|
|
22
|
+
multiplicity = dict_of_simulation['multiplicity']
|
|
23
|
+
# write the input structure location
|
|
24
|
+
input_structure = structure_dir + '/' + project + "_" + caseid + ".xyz"
|
|
25
|
+
## write the structure file into the target QC folder
|
|
26
|
+
write_txt_for_qchem(structure_dir,input_structure, charge, multiplicity)
|
|
27
|
+
input_structure_qchem = structure_dir + '/' + project + "_" + caseid + ".txt"
|
|
28
|
+
# prepare pdb in target folder
|
|
29
|
+
input_structure_pdb = structure_dir + '/' + project + "_" + caseid + ".pdb"
|
|
30
|
+
os.popen("mkdir -p " +qc_dir+"/mulliken").read()
|
|
31
|
+
prepare_QC(input_structure_qchem, qc_dir)
|
|
32
|
+
prepare_QC(input_structure_qchem, qc_dir+"/mulliken/.")
|
|
33
|
+
prepare_QC(input_structure, qc_dir)
|
|
34
|
+
prepare_QC(input_structure_pdb, qc_dir)
|
|
35
|
+
|
|
36
|
+
print(dict_of_simulation)
|
|
37
|
+
template_dir = dict_of_simulation['template_dir']
|
|
38
|
+
|
|
39
|
+
# loading quantum chemistry parameters
|
|
40
|
+
N_atom = dict_of_simulation['N_atom']
|
|
41
|
+
N_cis = dict_of_simulation['N_cis']
|
|
42
|
+
|
|
43
|
+
QC_method = dict_of_simulation['QC_method']
|
|
44
|
+
basis_set = dict_of_simulation['basis_set']
|
|
45
|
+
RSH_omega = dict_of_simulation['RSH_omega']
|
|
46
|
+
TD_approx = dict_of_simulation['TD_approx']
|
|
47
|
+
charge_type = dict_of_simulation['charge_type']
|
|
48
|
+
|
|
49
|
+
DA_type = dict_of_simulation['DA_type']
|
|
50
|
+
D_range = dict_of_simulation['D_range']
|
|
51
|
+
B_range = dict_of_simulation['B_range']
|
|
52
|
+
A_range = dict_of_simulation['A_range']
|
|
53
|
+
A1_range = dict_of_simulation['A1_range']
|
|
54
|
+
A2_range = dict_of_simulation['A2_range']
|
|
55
|
+
CT_donor_fragment = dict_of_simulation['CT_donor_fragments']
|
|
56
|
+
CT_acceptor_fragment = dict_of_simulation['CT_acceptor_fragments']
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
jobs = []
|
|
61
|
+
returning_info = submitQC(template_dir, qc_dir, QC_method, basis_set, caseid, D_range, B_range, A_range, A1_range, A2_range,CT_donor_fragment,CT_acceptor_fragment,N_cis, project, qc_dir,TD_approx,RSH_omega,DA_type,charge_type,N_atom)
|
|
62
|
+
|
|
63
|
+
find_job_id(returning_info, jobs)
|
|
64
|
+
dependency_at_this_step = list_to_dep_line(jobs)
|
|
65
|
+
job_control[i]['QC_jobids'] = dependency_at_this_step
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
stroutput = "\n"
|
|
69
|
+
stroutput = stroutput + "Input: \n solute structure: "+ input_structure + "\n"
|
|
70
|
+
stroutput = stroutput + "Job submit script:\n Quantum chemistry: " + qc_dir + "\n"
|
|
71
|
+
stroutput = stroutput + " SLURM script: " + qc_dir + "submitQC_flexible*.slurm \n"
|
|
72
|
+
stroutput = stroutput + " QChem input file: " + qc_dir + project +"_"+ caseid + ".inp \n"
|
|
73
|
+
stroutput = stroutput + " " + qc_dir + 'mulliken/' + project +"_"+ caseid + ".inp \n"
|
|
74
|
+
stroutput = stroutput + "Output: \n QChem output file: \n" + " " + qc_dir + project +"_"+ caseid + ".out \n"
|
|
75
|
+
stroutput = stroutput + " " + qc_dir + project +"_"+ caseid + ".fchk \n"
|
|
76
|
+
stroutput = stroutput + " " + qc_dir + "mulliken/" + project +"_"+ caseid + ".out \n"
|
|
77
|
+
stroutput = stroutput + " " + qc_dir + "mulliken/" + project +"_"+ caseid + ".fchk \n \n"
|
|
78
|
+
stroutput = stroutput + "#######################################################\n"
|
|
79
|
+
write_to_output(i, job_control, dict_of_simulation, stroutput)
|
|
80
|
+
return job_control
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def submitQC(template_dir,running_dir,QCmethod,basis_set,testing_str,D_range,B_range,A_range,A1_range,A2_range,CT_donor_fragment,CT_acceptor_fragment,N_cis, project,basedir,TD_approx,RSH_omega,DA_type,charge_type,N_atom):
|
|
84
|
+
"""
|
|
85
|
+
template_dir: slrum script template for the project
|
|
86
|
+
running_dir: where to run this quantum chemistry jobs
|
|
87
|
+
QCmethod: quantum chemistry calculation method like HF or DFT method like b3lyp, wb97x-b, should be a string
|
|
88
|
+
basis_set: basis set for quantum chemistry electronic structure calculation
|
|
89
|
+
testing_str: a string containing several space separated values utilized as part of the name of quantum chemistry jobs
|
|
90
|
+
Drange: string like '1-60'
|
|
91
|
+
Arange: string like '61-207'
|
|
92
|
+
N_cis: number of singlets are calculated, int
|
|
93
|
+
case: series name for the calculation
|
|
94
|
+
|
|
95
|
+
This function prepare and submit QC job based on a submitQC_template.sh
|
|
96
|
+
|
|
97
|
+
check the template for platform and cluster specific parameters
|
|
98
|
+
in the next release the cluster control can be performed from external function ctr.job_submit_setup()
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
os.chdir(running_dir)
|
|
102
|
+
|
|
103
|
+
if QCmethod == "BNL":
|
|
104
|
+
submitQC_file = shell_copy_template(template_dir,running_dir, filename='submitQC_flexible1')
|
|
105
|
+
else :
|
|
106
|
+
submitQC_file = shell_copy_template(template_dir,running_dir, filename='submitQC_flexible')
|
|
107
|
+
|
|
108
|
+
if TD_approx == "TDA":
|
|
109
|
+
TD_token = "false"
|
|
110
|
+
elif TD_approx == "RPA":
|
|
111
|
+
TD_token = "true"
|
|
112
|
+
else:
|
|
113
|
+
TD_token = "2"
|
|
114
|
+
print("Full TDDFT would be running ")
|
|
115
|
+
if charge_type == "Mulliken":
|
|
116
|
+
charge_token = "Mulliken"
|
|
117
|
+
elif charge_type == "RESP":
|
|
118
|
+
raise ValueError("charge_type RESP is not implemented yet")
|
|
119
|
+
else:
|
|
120
|
+
raise ValueError("charge_type should be Mulliken or RESP")
|
|
121
|
+
|
|
122
|
+
if RSH_omega == "":
|
|
123
|
+
sed_inplace(submitQC_file,"omega=","omega=114514")
|
|
124
|
+
sed_inplace(submitQC_file,"OMEGA", "! OMEGA")
|
|
125
|
+
else:
|
|
126
|
+
sed_inplace(submitQC_file,"omega=","omega="+RSH_omega)
|
|
127
|
+
|
|
128
|
+
ordersD = np.fromstring(D_range, dtype=int, sep='-')
|
|
129
|
+
if B_range != "":
|
|
130
|
+
ordersB = np.fromstring(B_range, dtype=int, sep='-')
|
|
131
|
+
ordersA = np.fromstring(A_range, dtype=int, sep='-')
|
|
132
|
+
if A1_range != "":
|
|
133
|
+
ordersA1 = np.fromstring(A1_range, dtype=int, sep='-')
|
|
134
|
+
if A2_range != "":
|
|
135
|
+
ordersA2 = np.fromstring(A2_range, dtype=int, sep='-')
|
|
136
|
+
|
|
137
|
+
dsegmentnum = len(CT_donor_fragment)
|
|
138
|
+
asegmentnum = len(CT_acceptor_fragment)
|
|
139
|
+
for i in [dsegmentnum,asegmentnum]:
|
|
140
|
+
print(i)
|
|
141
|
+
if i > 1:
|
|
142
|
+
i = i - 1
|
|
143
|
+
else:
|
|
144
|
+
pass # doing nothing
|
|
145
|
+
|
|
146
|
+
donor_fragment = np.ones(dsegmentnum)
|
|
147
|
+
acceptor_fragment = np.ones(asegmentnum)
|
|
148
|
+
|
|
149
|
+
if len(CT_donor_fragment) != 1:
|
|
150
|
+
# print(CT_donor_fragment, type(CT_donor_fragment))
|
|
151
|
+
donor_fragment = np.fromstring(CT_donor_fragment, sep=',',dtype=int)
|
|
152
|
+
if len(CT_acceptor_fragment) != 1:
|
|
153
|
+
acceptor_fragment = np.fromstring(CT_acceptor_fragment, sep=',',dtype=int)
|
|
154
|
+
|
|
155
|
+
if DA_type == "DBA":
|
|
156
|
+
orders = np.array([ordersD[0],ordersD[1],ordersB[0],ordersB[1],ordersA[0],ordersA[1]])
|
|
157
|
+
if len(donor_fragment) == 2:
|
|
158
|
+
D_range = str( min([min(ordersD),min(ordersB)]) ) + "-" + str( max([max(ordersB),max(ordersD)] ))
|
|
159
|
+
|
|
160
|
+
if len(acceptor_fragment) == 2:
|
|
161
|
+
A_range = str( min([min(ordersA),min(ordersB)]) ) + "-" + str( max([max(ordersB),max(ordersA)] ))
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
os.chdir(running_dir)
|
|
165
|
+
QC_DIR = f'{running_dir}'
|
|
166
|
+
#QC_DIR=f'{project_dir}/'+case+'/QC/'
|
|
167
|
+
|
|
168
|
+
sed_inplace(submitQC_file,'WORKDIR=','WORKDIR='+QC_DIR)
|
|
169
|
+
sed_inplace(submitQC_file,'SRCDIR=','SRCDIR='+template_dir)
|
|
170
|
+
sed_inplace(submitQC_file,'RUNDIR=','RUNDIR='+QC_DIR)
|
|
171
|
+
sed_inplace(submitQC_file,'system=','system='+project +'_')
|
|
172
|
+
sed_inplace(submitQC_file,'basis_set=','basis_set='+basis_set)
|
|
173
|
+
sed_inplace(submitQC_file,'method=','method='+QCmethod)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
sed_inplace(submitQC_file,'D_range=','D_range='+D_range)
|
|
177
|
+
sed_inplace(submitQC_file,'B_range=','B_range='+B_range)
|
|
178
|
+
sed_inplace(submitQC_file,'A_range=','A_range='+A_range)
|
|
179
|
+
sed_inplace(submitQC_file,'STATE_NUM=','STATE_NUM='+str(N_cis))
|
|
180
|
+
sed_inplace(submitQC_file,'GIVEN_STRUC=','GIVEN_STRUC='+ testing_str)
|
|
181
|
+
sed_inplace(submitQC_file, "TD_approx=","TD_approx="+TD_token)
|
|
182
|
+
# if RSH_omega == "":
|
|
183
|
+
# sed_inplace(submitQC_file,"omega=","omega=114514")
|
|
184
|
+
# sed_inplace(submitQC_file,"OMEGA", "!OMEGA")
|
|
185
|
+
# else:
|
|
186
|
+
# sed_inplace(submitQC_file,"omega=","omega="+RSH_omega)
|
|
187
|
+
|
|
188
|
+
os.chdir(running_dir)
|
|
189
|
+
if QCmethod == "BNL":
|
|
190
|
+
jobid = os.popen('sh submitQC_flexible1.sh').read()
|
|
191
|
+
else:
|
|
192
|
+
jobid = os.popen('sh submitQC_flexible.sh').read()
|
|
193
|
+
|
|
194
|
+
return jobid
|
|
195
|
+
|
|
196
|
+
def read_xyz(filename, debug=False):
|
|
197
|
+
# read xyz file fr
|
|
198
|
+
with open(filename) as fi:
|
|
199
|
+
lines = fi.readlines()
|
|
200
|
+
|
|
201
|
+
if debug == True:
|
|
202
|
+
print('DEBUG MODE ON: def read_xyz')
|
|
203
|
+
print(lines)
|
|
204
|
+
return lines
|
|
205
|
+
|
|
206
|
+
def write_txt_for_qchem(structure_dir,filename,charge,multiplicity,debug=False):
|
|
207
|
+
# read files of a given name and write the txt files for Q-Chem calculation in txt format
|
|
208
|
+
# return filename of the xyz and txt in string
|
|
209
|
+
lines_in_txt_files = read_xyz(filename,debug=debug)
|
|
210
|
+
Output_File_name = filename[0:-3]+"txt"
|
|
211
|
+
# edit Output File
|
|
212
|
+
lines_in_txt_files[0] = '$molecule \n'
|
|
213
|
+
lines_in_txt_files[1] = str(charge) + ' ' + str(multiplicity) + ' \n'
|
|
214
|
+
lines_in_txt_files[-1]=('$end')
|
|
215
|
+
os.chdir(structure_dir)
|
|
216
|
+
os.popen("cp "+filename + " " +Output_File_name ).read()
|
|
217
|
+
os.popen("sed -i '1c " + lines_in_txt_files[0] + "' " + Output_File_name).read()
|
|
218
|
+
os.popen("sed -i '2c " + lines_in_txt_files[1] + "' " + Output_File_name).read()
|
|
219
|
+
os.popen("sed -i '$a " + lines_in_txt_files[-1] + "' " + Output_File_name).read()
|
|
220
|
+
|
|
221
|
+
return filename.split('/')[-1][0:-4]
|
|
222
|
+
|
|
223
|
+
def prepare_QC(input_structure, QC_path):
|
|
224
|
+
os.popen('cp '+input_structure+' '+QC_path+' ').read()
|
|
225
|
+
return
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def main_SubmitQC():
|
|
229
|
+
dict_of_simulation = parse_input()
|
|
230
|
+
# prepare for quantum chemistry simulation
|
|
231
|
+
work_dir = dict_of_simulation['work_dir']
|
|
232
|
+
# where we have the structure directory
|
|
233
|
+
structure_dir = dict_of_simulation['structure_dir']
|
|
234
|
+
# load the project folder
|
|
235
|
+
project = dict_of_simulation['project']
|
|
236
|
+
# get case id for the simulation
|
|
237
|
+
caseid = dict_of_simulation['caseid']
|
|
238
|
+
# get job list
|
|
239
|
+
case_id_list = separate_idlist(caseid)
|
|
240
|
+
# get list of job control token
|
|
241
|
+
job_control = init_job_control(case_id_list)
|
|
242
|
+
|
|
243
|
+
startime = time.time
|
|
244
|
+
print("SubmitQC begins at "+str(startime))
|
|
245
|
+
# print("Input parameters ")
|
|
246
|
+
# print(simulation_parameter)
|
|
247
|
+
for ind, ctr_ele in enumerate(job_control):
|
|
248
|
+
print(ind, job_control)
|
|
249
|
+
run_step1(ind, job_control, dict_of_simulation)
|
|
250
|
+
|
|
251
|
+
# run_submitQC(simulation_parameter)
|
|
252
|
+
end_time = time.time
|
|
253
|
+
print("SubmitQC ends at "+str(end_time))
|
|
254
|
+
|
|
255
|
+
if __name__ == "__main__":
|
|
256
|
+
main_SubmitQC()
|
pyctramer/Utilities.py
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
from shutil import copyfile
|
|
3
|
+
import re, os, sys
|
|
4
|
+
import tempfile
|
|
5
|
+
import argparse
|
|
6
|
+
import fileinput
|
|
7
|
+
import time
|
|
8
|
+
|
|
9
|
+
def shell_copy_template(template_dir, running_dir, filename):
|
|
10
|
+
"""
|
|
11
|
+
check into srcdir,
|
|
12
|
+
then copy the file called filename_template.sh to filename.sh
|
|
13
|
+
return filename.sh as a python string
|
|
14
|
+
"""
|
|
15
|
+
the_template =f'{template_dir}/{filename}_template.sh'
|
|
16
|
+
the_file =f'{running_dir}/{filename}.sh'
|
|
17
|
+
copyfile(the_template,the_file)
|
|
18
|
+
return the_file
|
|
19
|
+
|
|
20
|
+
def parse_input_for_jupyter(file_path):
|
|
21
|
+
Simulation_Param = {'PyCTRAMER': '0.1'}
|
|
22
|
+
f = open(file_path)
|
|
23
|
+
inputfile = f.readlines() #fileinput.input()
|
|
24
|
+
for line in inputfile:
|
|
25
|
+
print("line ",line,len(line))
|
|
26
|
+
for t_len in range(len(line)):
|
|
27
|
+
#print('tlen',t_len, line[t_len+1])
|
|
28
|
+
if line[t_len] == "#":
|
|
29
|
+
line = line[:t_len]
|
|
30
|
+
break
|
|
31
|
+
a = line.split()
|
|
32
|
+
if len(a) >= 2 :
|
|
33
|
+
if a[0][0] == "#":
|
|
34
|
+
pass
|
|
35
|
+
else:
|
|
36
|
+
Simulation_Param.update({a[0]:a[1]})
|
|
37
|
+
elif len(a) >= 1 :
|
|
38
|
+
Simulation_Param.update({a[0]:""})
|
|
39
|
+
return Simulation_Param
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def separate_idlist(string):
|
|
43
|
+
id_list = []
|
|
44
|
+
string_list = string.split(',')
|
|
45
|
+
for num in string_list:
|
|
46
|
+
elements = num.split('-')
|
|
47
|
+
if len(elements) == 2:
|
|
48
|
+
for i in range(int(elements[0]),int(elements[1])+1):
|
|
49
|
+
id_list.append(str(i))
|
|
50
|
+
elif len(elements) == 1:
|
|
51
|
+
id_list.append(elements[0])
|
|
52
|
+
else :
|
|
53
|
+
return "error"
|
|
54
|
+
return id_list
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def get_output_perfix(string1, string2, argu):
|
|
58
|
+
return string1 + "_" + string2
|
|
59
|
+
|
|
60
|
+
def sed_inplace(filename, pattern, repl):
|
|
61
|
+
'''
|
|
62
|
+
repl: string to be replaced
|
|
63
|
+
pattern: pattern to be found and matched
|
|
64
|
+
Perform the pure-Python equivalent of in-place `sed` substitution:
|
|
65
|
+
e.g.,
|
|
66
|
+
`sed -i -e 's/'${pattern}'/'${repl}' "${filename}"`.
|
|
67
|
+
'''
|
|
68
|
+
# For efficiency, precompile the passed regular expression.
|
|
69
|
+
pattern_compiled = re.compile(pattern)
|
|
70
|
+
|
|
71
|
+
# For portability, NamedTemporaryFile() defaults to mode "w+b" (i.e., binary
|
|
72
|
+
# writing with updating). This is usually a good thing. In this case,
|
|
73
|
+
# however, binary writing imposes non-trivial encoding constraints trivially
|
|
74
|
+
# resolved by switching to text writing. Let's do that.
|
|
75
|
+
with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_file:
|
|
76
|
+
with open(filename) as src_file:
|
|
77
|
+
for line in src_file:
|
|
78
|
+
tmp_file.write(pattern_compiled.sub(repl, line))
|
|
79
|
+
|
|
80
|
+
# Overwrite the original file with the munged temporary file in a
|
|
81
|
+
# manner preserving file attributes (e.g., permissions).
|
|
82
|
+
shutil.copystat(filename, tmp_file.name)
|
|
83
|
+
shutil.move(tmp_file.name, filename)
|
|
84
|
+
|
|
85
|
+
def find_job_id(token, jobs_list):
|
|
86
|
+
token_lst = token.split()
|
|
87
|
+
print(token_lst)
|
|
88
|
+
ind = 0
|
|
89
|
+
for lines in token_lst:
|
|
90
|
+
ind+=1
|
|
91
|
+
if lines == 'Submitted':
|
|
92
|
+
jobs_list.append(token_lst[ind+2])
|
|
93
|
+
return jobs_list
|
|
94
|
+
|
|
95
|
+
def prepare_folder_structure(datapath):
|
|
96
|
+
QC_dir = datapath+'/QC/'
|
|
97
|
+
MD_dir = datapath+"/MD/"
|
|
98
|
+
|
|
99
|
+
os.popen('mkdir -p '+QC_dir).read()
|
|
100
|
+
os.popen('mkdir -p '+MD_dir).read()
|
|
101
|
+
return QC_dir,MD_dir
|
|
102
|
+
|
|
103
|
+
def get_folder_path(datapath):
|
|
104
|
+
QC_dir = datapath+'/QC/'
|
|
105
|
+
MD_dir = datapath+"/MD/"
|
|
106
|
+
return QC_dir,MD_dir
|
|
107
|
+
|
|
108
|
+
def list_to_dep_line(jobs_list):
|
|
109
|
+
print(len(jobs_list))
|
|
110
|
+
inner_str = jobs_list[0]
|
|
111
|
+
for j in range(len(jobs_list)-1):
|
|
112
|
+
inner_str = inner_str + ','+ jobs_list[j+1]
|
|
113
|
+
return inner_str
|
|
114
|
+
|
|
115
|
+
def parse_input():
|
|
116
|
+
inputfile = fileinput.input()
|
|
117
|
+
Simulation_Param = {'PyCTRAMER': '0.1'}
|
|
118
|
+
#f = open(file_path)
|
|
119
|
+
#inputfile = f.readlines() #fileinput.input()
|
|
120
|
+
for line in inputfile:
|
|
121
|
+
# print("line ",line,len(line))
|
|
122
|
+
for t_len in range(len(line)):
|
|
123
|
+
#print('tlen',t_len, line[t_len+1])
|
|
124
|
+
if line[t_len] == "#":
|
|
125
|
+
line = line[:t_len]
|
|
126
|
+
break
|
|
127
|
+
a = line.split()
|
|
128
|
+
if len(a) >= 2 :
|
|
129
|
+
if a[0][0] == "#":
|
|
130
|
+
pass
|
|
131
|
+
else:
|
|
132
|
+
Simulation_Param.update({a[0]:a[1]})
|
|
133
|
+
elif len(a) >= 1 :
|
|
134
|
+
Simulation_Param.update({a[0]:""})
|
|
135
|
+
return Simulation_Param
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
#def parse_input():
|
|
140
|
+
# inputfile = fileinput.input()
|
|
141
|
+
# Simulation_Param= {}
|
|
142
|
+
#
|
|
143
|
+
# for line in inputfile:
|
|
144
|
+
# a = line.split()
|
|
145
|
+
# if len(a) >= 2 :
|
|
146
|
+
# if a[0][0] == "#":
|
|
147
|
+
# pass
|
|
148
|
+
# else:
|
|
149
|
+
# Simulation_Param.update({a[0]:a[1]})
|
|
150
|
+
# if len(a) == 1:
|
|
151
|
+
# Simulation_Param.update({a[0]:""})
|
|
152
|
+
# return Simulation_Param
|
|
153
|
+
|
|
154
|
+
def sort_and_index(df,column_name):
|
|
155
|
+
"""
|
|
156
|
+
df : dataframe
|
|
157
|
+
column_name : string , header of column to be sorted
|
|
158
|
+
sort data
|
|
159
|
+
"""
|
|
160
|
+
final_list=[]
|
|
161
|
+
mylist= list(df[column_name])
|
|
162
|
+
sorted_list = sorted(mylist,reverse=True)
|
|
163
|
+
for i in sorted_list:
|
|
164
|
+
a = mylist.index(i) + 1 # 1 because python index start from 0 and excited states = from 1
|
|
165
|
+
final_list.append(a)
|
|
166
|
+
return final_list, sorted_list
|
|
167
|
+
|
|
168
|
+
def write_output(filename, new_line_of_string):
|
|
169
|
+
f = open(filename,'w')
|
|
170
|
+
f.write(new_line_of_string + '\n')
|
|
171
|
+
f.close()
|
|
172
|
+
return
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def init_job_control(case_id_list):
|
|
176
|
+
job_control = []
|
|
177
|
+
for caseid in case_id_list:
|
|
178
|
+
current_job_control = {}
|
|
179
|
+
current_job_control['caseid'] = caseid
|
|
180
|
+
current_job_control['QC_jobids'] = []
|
|
181
|
+
current_job_control['MD_jobids'] = []
|
|
182
|
+
current_job_control['status'] = [0,'unstarted','unstarted','unstarted','unstarted','unstarted','unstarted','unstarted']
|
|
183
|
+
job_control.append(current_job_control)
|
|
184
|
+
|
|
185
|
+
return job_control
|
|
186
|
+
|
|
187
|
+
def init_job_info(case_id_list):
|
|
188
|
+
job_info = []
|
|
189
|
+
for caseid in case_id_list:
|
|
190
|
+
current_job_info = {}
|
|
191
|
+
job_info.append(current_job_info)
|
|
192
|
+
|
|
193
|
+
return job_info
|
|
194
|
+
|
|
195
|
+
def check_slurm_status(job_ids_list):
|
|
196
|
+
""" if all jobs are finished, return True; else, return false """
|
|
197
|
+
list_of_str_job_ids = job_ids_list.split(",")
|
|
198
|
+
for jobid in list_of_str_job_ids:
|
|
199
|
+
one_piece = os.popen('sacct -j ' + jobid).read()
|
|
200
|
+
# print(one_piece,'\n jobid',jobid,job_ids_list)
|
|
201
|
+
num_Complete = one_piece.count("COMPLETED")
|
|
202
|
+
num_Line = one_piece.count("\n")
|
|
203
|
+
if num_Complete != num_Line-2 or num_Line == 2:
|
|
204
|
+
return False
|
|
205
|
+
return True
|
|
206
|
+
|
|
207
|
+
def check_job_unfinished(job_control):
|
|
208
|
+
final_step = 5
|
|
209
|
+
for i in range(len(job_control)):
|
|
210
|
+
if job_control[i]['status'][final_step] != 'finished':
|
|
211
|
+
return True
|
|
212
|
+
return False
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def check_job_status(job_control, dict_of_simulation, job_info):
|
|
216
|
+
for i in range(len(job_control)):
|
|
217
|
+
curr_step = job_control[i]['status'][0]
|
|
218
|
+
if curr_step == 0 and job_control[i]['status'][curr_step+1] == 'unstarted':
|
|
219
|
+
if dict_of_simulation['skip_QC']=='True':
|
|
220
|
+
curr_step = 1
|
|
221
|
+
job_control[i]['status'][curr_step] = 'finished'
|
|
222
|
+
else:
|
|
223
|
+
job_control = run_step1(i,job_control,dict_of_simulation)
|
|
224
|
+
curr_step = 1
|
|
225
|
+
job_control[i]['status'][curr_step] = 'running'
|
|
226
|
+
print('curr_step',curr_step,check_slurm_status(job_control[i]['QC_jobids']), job_control[i]['status'][curr_step])
|
|
227
|
+
|
|
228
|
+
if curr_step == 1 and job_control[i]['status'][curr_step] == 'running':
|
|
229
|
+
if check_slurm_status(job_control[i]['QC_jobids']):
|
|
230
|
+
job_control[i]['status'][curr_step] = 'finished'
|
|
231
|
+
#pass
|
|
232
|
+
else:
|
|
233
|
+
pass
|
|
234
|
+
#job_control[i]['status'][curr_step] = 'finished'
|
|
235
|
+
if dict_of_simulation['skip_QC']=='True':
|
|
236
|
+
job_control[i]['status'][curr_step] = 'finished'
|
|
237
|
+
else:
|
|
238
|
+
pass
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
if curr_step == 1 and job_control[i]['status'][curr_step] == 'finished':
|
|
242
|
+
job_control = run_step2(i,job_control,dict_of_simulation)
|
|
243
|
+
curr_step = 2
|
|
244
|
+
job_control[i]['status'][curr_step] = 'finished'
|
|
245
|
+
|
|
246
|
+
if curr_step == 2 and job_control[i]['status'][curr_step] == 'finished':
|
|
247
|
+
job_control = run_step3(i,job_control,dict_of_simulation, job_info)
|
|
248
|
+
curr_step = 3
|
|
249
|
+
job_control[i]['status'][curr_step] = 'finished'
|
|
250
|
+
|
|
251
|
+
if curr_step == 3 and job_control[i]['status'][curr_step] == 'finished':
|
|
252
|
+
job_control = run_step4(i,job_control,dict_of_simulation)
|
|
253
|
+
curr_step = 4
|
|
254
|
+
job_control[i]['status'][curr_step] = 'running'
|
|
255
|
+
|
|
256
|
+
if curr_step == 4 and job_control[i]['status'][curr_step] == 'running':
|
|
257
|
+
if check_slurm_status(job_control[i]['MD_jobids']):
|
|
258
|
+
print("job_control[i]['MD_jobids']",job_control[i]['MD_jobids'])
|
|
259
|
+
job_control[i]['status'][curr_step] = 'finished'
|
|
260
|
+
else: # returning false and doing nothing in this step
|
|
261
|
+
#if round(time.time()) % 30 == 0:
|
|
262
|
+
print("MD_jobids",job_control[i]['MD_jobids'] )
|
|
263
|
+
pass
|
|
264
|
+
#else :
|
|
265
|
+
# pass
|
|
266
|
+
#pass
|
|
267
|
+
|
|
268
|
+
if curr_step == 4 and job_control[i]['status'][curr_step] == 'finished':
|
|
269
|
+
job_control = run_step5(i,job_control,dict_of_simulation,job_info)
|
|
270
|
+
curr_step = 5
|
|
271
|
+
job_control[i]['status'][curr_step] = 'finished'
|
|
272
|
+
|
|
273
|
+
job_control[i]['status'][0] = curr_step
|
|
274
|
+
|
|
275
|
+
return job_control
|
|
276
|
+
|
|
277
|
+
def write_to_output(i, job_control, dict_of_simulation, str) :
|
|
278
|
+
outdir = dict_of_simulation['work_dir'] +'/'+ dict_of_simulation['project']+'_'+dict_of_simulation['caseid']
|
|
279
|
+
|
|
280
|
+
filename = dict_of_simulation['output_filename']
|
|
281
|
+
if len(filename) == 0:
|
|
282
|
+
filename = dict_of_simulation['project']+'_'+dict_of_simulation['caseid']+ '_PyCTRAMER.out'
|
|
283
|
+
|
|
284
|
+
outfile = outdir + '/' + filename
|
|
285
|
+
if job_control[i]['status'][0] == 0:
|
|
286
|
+
fo = open(outfile, "w")
|
|
287
|
+
else:
|
|
288
|
+
fo = open(outfile,'w+')
|
|
289
|
+
fo.write(str)
|
|
290
|
+
fo.close()
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
cm2au = 4.55633525e-6
|
|
295
|
+
au2cm = 219474.6313632
|
|
296
|
+
ps2au = 41341.373335
|
|
297
|
+
au2ps = 2.4188843266e-5
|
|
298
|
+
fs2au = 41.341373335
|
|
299
|
+
au2fs = 2.4188843266e-3
|
|
300
|
+
au2kT = 315775.024804
|
|
301
|
+
kT2au = 3.16681156e-6
|
|
302
|
+
au2eV = 27.211386246
|
|
303
|
+
eV2au = 0.0367493221
|
|
304
|
+
s2au =4.1341374575751E+16
|
|
305
|
+
header = " ####################################### \n # PyCTRAMER (v1.0) #\n #######################################\n \n \n \n"
|
pyctramer/__init__.py
ADDED
pyctramer/pyctramer.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# PyCTRAMER
|
|
2
|
+
#standard library import
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pandas as pd
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
import tempfile
|
|
8
|
+
import parmed
|
|
9
|
+
from mdtraj.reporters import HDF5Reporter
|
|
10
|
+
|
|
11
|
+
import math
|
|
12
|
+
import os
|
|
13
|
+
import re
|
|
14
|
+
import shutil
|
|
15
|
+
from shutil import copyfile
|
|
16
|
+
import tempfile
|
|
17
|
+
import json
|
|
18
|
+
import pickle as pkl
|
|
19
|
+
import matplotlib
|
|
20
|
+
import matplotlib.pyplot as plt
|
|
21
|
+
|
|
22
|
+
import mdtraj as md
|
|
23
|
+
import argparse
|
|
24
|
+
import fileinput
|
|
25
|
+
import time
|
|
26
|
+
|
|
27
|
+
# SubmitQC
|
|
28
|
+
from .JobControl import *
|
|
29
|
+
from .Utilities import *
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def simulate(input) :
|
|
33
|
+
simulation_parameter = parse_input_for_jupyter(input)
|
|
34
|
+
startime = time.time()
|
|
35
|
+
print("simulation begins at "+ time.ctime(startime) )
|
|
36
|
+
print("Input parameters ")
|
|
37
|
+
print(simulation_parameter)
|
|
38
|
+
run_simulation(simulation_parameter)
|
|
39
|
+
end_time = time.time()
|
|
40
|
+
print("simulation ends at "+ time.ctime(end_time) )
|
|
41
|
+
timecosu = end_time - startime
|
|
42
|
+
hour = timecosu // 3600
|
|
43
|
+
minute = (timecosu - hour * 3600) // 60
|
|
44
|
+
second = timecosu - 3600 * hour - 60 * minute
|
|
45
|
+
print("Computational time "+ str(hour) + " hour " + str(minute) + " minutes " + second + " second " )
|
|
46
|
+
return 0
|
|
47
|
+
|
|
48
|
+
def main() :
|
|
49
|
+
simulation_parameter = parse_input()
|
|
50
|
+
startime = time.time
|
|
51
|
+
print("simulation begins at "+str(startime ))
|
|
52
|
+
print("Input parameters ")
|
|
53
|
+
print(simulation_parameter)
|
|
54
|
+
run_simulation(simulation_parameter)
|
|
55
|
+
end_time = time.time
|
|
56
|
+
print("simulation ends at "+str(end_time ))
|
|
57
|
+
return 0
|
|
58
|
+
|
|
59
|
+
def run_simulation(dict_of_simulation):
|
|
60
|
+
if dict_of_simulation['workflow'] == 'Marcus':
|
|
61
|
+
run_Marcus(dict_of_simulation)
|
|
62
|
+
elif dict_of_simulation['workflow'] == 'FGR':
|
|
63
|
+
run_FGR(dict_of_simulation)
|
|
64
|
+
elif dict_of_simulation['workflow'] == 'alltheway':
|
|
65
|
+
run_Marcus(dict_of_simulation)
|
|
66
|
+
run_FGR(dict_of_simulation)
|
|
67
|
+
# OR define a run_all_the_way(dict_of_simulation)
|
|
68
|
+
else :
|
|
69
|
+
return 'Not defined yet'
|
|
70
|
+
#if __name__ == "__main__":
|
|
71
|
+
# main();
|
|
72
|
+
|
|
73
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pyctramer
|
|
3
|
+
Version: 0.1.32
|
|
4
|
+
Summary: Python package for Charge Transfer Rate from Atomistic Molecular dynamics, Electronic structure, and Rate theory
|
|
5
|
+
Home-page: https://www.github.com/ctramer/PyCTRAMER
|
|
6
|
+
Author: Zengkui Liu, Dominikus Brian, and Xiang Sun
|
|
7
|
+
Author-email: zengkui.liu@nyu.edu
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
Python package for Charge Transfer Rate from Atomistic Molecular dynamics, Electronic structure, and Rate theory
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
pyctramer/AnalyzeQC.py,sha256=dOxGBiRS0L1tBp5eOEmqN8ANMwSPaXL4DjOEXfuXvmQ,10599
|
|
2
|
+
pyctramer/ConstructFF.py,sha256=bZ2c0kJfYds9b9qKywXyu5vYN3qtHvF00qo4DMkr6xk,50158
|
|
3
|
+
pyctramer/FGR.py,sha256=DpNGsBBMLRF85VJuHbFNUsRLQ_oMiVudb3jtas5Rltk,8829
|
|
4
|
+
pyctramer/JobControl.py,sha256=hIC_-oHy6Nf8R0Cm6uXh8hGZihlIJtrKBSnrOmlBAtI,4978
|
|
5
|
+
pyctramer/MarcusAA.py,sha256=kDjpLzKfcB5K8z1ae2v96MzuEHWcqOwF1cp_K6nxxfI,11352
|
|
6
|
+
pyctramer/PyCTRAMER.py,sha256=uCDii35I7nMEwQeb9iwqGaJPB_q_pf_UUM2lubVx9RM,1927
|
|
7
|
+
pyctramer/RunMD.py,sha256=S15srDu_fB6NtmaXWHYc4yke5HFpiCud-CxHh9270l4,14221
|
|
8
|
+
pyctramer/SpinBoson.py,sha256=3uUb8fblgZVb5RQqy5Pzx6XdkL3oxLGOYDFu_oksedc,7282
|
|
9
|
+
pyctramer/SubmitQC.py,sha256=m-6Ej557rG7EWYLSDGE7wFfyOQcBGfqrHg4bshMObA0,10845
|
|
10
|
+
pyctramer/Utilities.py,sha256=x4xx4OgiM9YxfEAawazo6BsUegbivpL6uUnvIhDfhjk,10462
|
|
11
|
+
pyctramer/__init__.py,sha256=s2RlzmPvjcuLCl2-fIQS2LTXNzQKRR4P8pZu_8w2NW0,50
|
|
12
|
+
pyctramer/pyctramer.py,sha256=uCDii35I7nMEwQeb9iwqGaJPB_q_pf_UUM2lubVx9RM,1927
|
|
13
|
+
pyctramer-0.1.32.dist-info/METADATA,sha256=TrXFxvNQux7zE6KmOyYAEB7zutJXQ7hP84R_LPdNR5s,468
|
|
14
|
+
pyctramer-0.1.32.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
15
|
+
pyctramer-0.1.32.dist-info/top_level.txt,sha256=noB7hB_xtNBvrKLaJZfNfRHae_Hq-nYOnctI9wAETAc,10
|
|
16
|
+
pyctramer-0.1.32.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyctramer
|