pyctramer 0.1.32__tar.gz

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.
@@ -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,249 @@
1
+ from .Utilities import *
2
+ import os
3
+ import numpy as np
4
+
5
+ def run_step2(i, job_control, dict_of_simulation):
6
+ project = dict_of_simulation['project']
7
+ work_dir = dict_of_simulation['work_dir']
8
+ caseid = job_control[i]['caseid']
9
+ case_dir = work_dir + '/' + project +"_"+ caseid
10
+ qc_dir,md_dir = get_folder_path(case_dir)
11
+
12
+ template_dir = dict_of_simulation['template_dir']
13
+
14
+ N_atom = dict_of_simulation['N_atom']
15
+ N_cis = dict_of_simulation['N_cis']
16
+
17
+ QC_method = dict_of_simulation['QC_method']
18
+ basis_set = dict_of_simulation['basis_set']
19
+ RSH_omega = dict_of_simulation['RSH_omega']
20
+ TD_approx = dict_of_simulation['TD_approx']
21
+ charge_type = dict_of_simulation['charge_type']
22
+
23
+ DA_type = dict_of_simulation['DA_type']
24
+ D_range = dict_of_simulation['D_range']
25
+ B_range = dict_of_simulation['B_range']
26
+ A_range = dict_of_simulation['A_range']
27
+ A1_range = dict_of_simulation['A1_range']
28
+ A2_range = dict_of_simulation['A2_range']
29
+ CT_donor_fragment = dict_of_simulation['CT_donor_fragments']
30
+ CT_acceptor_fragment = dict_of_simulation['CT_acceptor_fragments']
31
+
32
+ LE_fragment = dict_of_simulation['LE_fragment']
33
+ CT_amount_threshold = dict_of_simulation['CT_amount_threshold']
34
+ OS_threshold = dict_of_simulation['OS_threshold']
35
+ LE_position_threshold = dict_of_simulation['LE_position_threshold']
36
+ TD_approx = dict_of_simulation["TD_approx"]
37
+ analyzeQC(template_dir, qc_dir, QC_method, basis_set, caseid, D_range,B_range,A_range,A1_range,A2_range,LE_fragment, N_cis, project, qc_dir, DA_type, RSH_omega,TD_approx)
38
+
39
+ stroutput = "\n\n"
40
+ stroutput = stroutput + "STEP 2: AnalyzeQC \n Input: " + qc_dir + project +"_"+ caseid + ".out \n"
41
+ stroutput = stroutput + " " + qc_dir + project +"_"+ caseid + ".fchk \n"
42
+ stroutput = stroutput + " " + qc_dir + "dens_ana.in \n"
43
+ stroutput = stroutput + " " + qc_dir + "dens_ana_fchk.in \n"
44
+ stroutput = stroutput + " " + qc_dir + "dens_ana_tddft.in \n\n"
45
+ stroutput = stroutput + "Job submit script: "+ qc_dir +"analyzeQC_flexible1.sh \n\n"
46
+ stroutput = stroutput + "Output: " + qc_dir + "tden_summ.txt \n"
47
+ stroutput = stroutput + " " + qc_dir + "tden_summ_fchk.txt \n"
48
+ stroutput = stroutput + " " + qc_dir + "tden_summ_tddft.txt \n\n\n"
49
+ stroutput = stroutput + "#######################################################\n"
50
+ write_to_output(i, job_control, dict_of_simulation, stroutput)
51
+ return job_control
52
+
53
+ def analyzeQC(template_dir,running_dir,QC_method,basis_set,testing_str,D_range,B_range,A_range,A1_range,A2_range,LE_fragment,N_cis,project,basedir,DA_type,RSH_omega,TD_approx,dependency=[]):
54
+ """
55
+ template_dir: slrum script template for the project
56
+ running_dir: where to run this quantum chemistry jobs
57
+ QCmethod: quantum chemistry calculation method like HF or DFT method like b3lyp, wb97x-b, should be a string
58
+ basis_set: basis set for quantum chemistry electronic structure calculation
59
+ testing_str: a string containing several space separated values utilized as part of the name of quantum chemistry jobs
60
+ Drange: string like '1-60'
61
+ Arange: string like '61-207'
62
+ N_cis: number of singlets are calculated, int
63
+ case: series name for the calculation
64
+
65
+ This function prepare and submit QC job based on a submitQC_template.sh
66
+
67
+ check the template for platform and cluster specific parameters
68
+ in the next release the cluster control can be performed from external function ctr.job_submit_setup()
69
+ """
70
+ #os.system('mkdir -p '+running_dir)
71
+
72
+ os.chdir(running_dir)
73
+ submitQC_file = shell_copy_template(template_dir,running_dir, filename='analyzeQC_flexible1')
74
+
75
+ os.chdir(running_dir)
76
+ QC_DIR = f'{running_dir}'
77
+ #QC_DIR=f'{project_dir}/'+case+'/QC/'
78
+
79
+ ordersD = np.fromstring(D_range, dtype=int, sep='-')
80
+ ordersA = np.fromstring(A_range, dtype=int, sep='-')
81
+ if B_range != "":
82
+ ordersB = np.fromstring(B_range, dtype=int, sep='-')
83
+ if A1_range != "":
84
+ ordersA1 = np.fromstring(A1_range, dtype=int, sep='-')
85
+ if A2_range != "":
86
+ ordersA2 = np.fromstring(A2_range, dtype=int, sep='-')
87
+ #ordersB = np.fromstring(B_range, dtype=int, sep='-')
88
+ #ordersA1 = np.fromstring(A1_range, dtype=int, sep='-')
89
+ #ordersA2 = np.fromstring(A2_range, dtype=int, sep='-')
90
+
91
+ if RSH_omega == "":
92
+ sed_inplace(submitQC_file,"omega=","omega=114514")
93
+ # sed_inplace(submitQC_file,"OMEGA", "!OMEGA")
94
+ else:
95
+ sed_inplace(submitQC_file,"omega=","omega="+RSH_omega)
96
+
97
+ if TD_approx == "TDA":
98
+ TD_approx = "True"
99
+ else:
100
+ TD_approx = "False"
101
+
102
+ sed_inplace(submitQC_file,'WORKDIR=','WORKDIR='+QC_DIR)
103
+ sed_inplace(submitQC_file,'SRCDIR=','SRCDIR='+template_dir)
104
+ sed_inplace(submitQC_file,'RUNDIR=','RUNDIR='+QC_DIR)
105
+ sed_inplace(submitQC_file,'system=','system='+project+'_')
106
+ sed_inplace(submitQC_file,'basis_set=','basis_set='+basis_set)
107
+ sed_inplace(submitQC_file,'method=','method='+QC_method)
108
+ sed_inplace(submitQC_file,'D_range=','D_range='+D_range)
109
+ sed_inplace(submitQC_file,'B_range=','B_range='+B_range)
110
+ sed_inplace(submitQC_file,'A_range=','A_range='+A_range)
111
+ sed_inplace(submitQC_file,'STATE_NUM=','STATE_NUM='+str(N_cis))
112
+ sed_inplace(submitQC_file,'GIVEN_STRUC=','GIVEN_STRUC='+ testing_str)
113
+ sed_inplace(submitQC_file,'LE_fragment=','LE_fragment='+LE_fragment)
114
+ sed_inplace(submitQC_file,'TD_approx=','TD_approx='+TD_approx)
115
+
116
+ frag_str = "'[["
117
+ if DA_type == "DA" and max(ordersD) < max(ordersA):
118
+ int1 = max(ordersD)-min(ordersD)+1
119
+ for i in range(int1):
120
+ frag_str = frag_str + str(i+1)
121
+ if i != (int1-1):
122
+ frag_str = frag_str + ","
123
+ else :
124
+ frag_str = frag_str + "],["
125
+ # frag_str = frag_str + "],["
126
+
127
+ int1 = max(ordersA)-min(ordersA)+1
128
+ for i in range(int1):
129
+ frag_str = frag_str + str(max(ordersD)-min(ordersD) +2+i)
130
+ if i != (max(ordersA)-1 ):
131
+ frag_str = frag_str + ","
132
+ frag_str = frag_str +"]]' #"
133
+ # print(int1,max(ordersD)-min(ordersD),max(ordersA)-min(ordersA),'max(ordersA)-min(ordersA)')
134
+
135
+ elif DA_type == "DA" and max(ordersA) < max(ordersD):
136
+ int1 = max(ordersA)-min(ordersA)+1
137
+ for i in range(int1):
138
+ frag_str = frag_str + str(1+i)
139
+ if i != (int1-1):
140
+ frag_str = frag_str + ","
141
+ else:
142
+ frag_str = frag_str + "],["
143
+
144
+ int1 = max(ordersD)-min(ordersD)+1
145
+ for i in range(int1):
146
+ frag_str = frag_str + str(i+1+max(ordersA)-min(ordersA) +1)
147
+ if i != (int1-1):
148
+ frag_str = frag_str + ","
149
+ frag_str = frag_str +"]]' #"
150
+ # print(int1,max(ordersD)-min(ordersD),max(ordersA)-min(ordersA),'max(ordersA)-min(ordersA)')
151
+
152
+
153
+ elif DA_type == "DBA":
154
+ # seglist should be DBA order
155
+ # for example triad: 60+75+72 = 207, its corresponding segorder should be 60,75,72
156
+
157
+ daseg = np.array([ordersA[1]-ordersA[0]+1,ordersB[1]-ordersB[0]+1,ordersD[1]-ordersD[0]+1 ] )
158
+
159
+ accseg = 0
160
+ for ind,seg in enumerate(daseg):
161
+
162
+ for i in range(seg):
163
+ if ind == 0:
164
+ frag_str = frag_str+str(i+1)
165
+ else:
166
+ frag_str = frag_str+str(i+accseg+1)
167
+ if i!= seg-1:
168
+ frag_str = frag_str + ","
169
+ else:
170
+ if ind == 2:
171
+ frag_str = frag_str + "]]' #"
172
+ else:
173
+ frag_str = frag_str + "],["
174
+ accseg += seg
175
+ # elif DA_type == "DBA":
176
+ # # seglist should be DBA order
177
+ # # for example triad: 60+75+72 = 207, its corresponding segorder should be 60,75,72
178
+ # daseg = np.array([ordersD[1]-ordersD[0]+1,ordersB[1]-ordersB[0]+1,ordersA[1]-ordersA[0]+1 ] )
179
+ #
180
+ # for ind,seg in enumerate(daseg):
181
+ # for i in range(seg):
182
+ # if ind == 0:
183
+ # frag_str = frag_str+str(i+1)
184
+ # else:
185
+ # frag_str = frag_str+str(i+1+daseg[ind-1])
186
+ # if i!= seg-1:
187
+ # frag_str = frag_str + ","
188
+ # else:
189
+ # if ind == 2:
190
+ # frag_str = frag_str + "]]'"
191
+ # else:
192
+ # frag_str = frag_str + "],["
193
+
194
+
195
+ elif DA_type == "ADA":
196
+ # seglist should be D-A1-A2 order
197
+ # daseg = np.fromstring(daseg, dtype=int, sep=',')
198
+ daseg = np.array([ordersD[1]-ordersD[0]+1,ordersA1[1]-ordersA1[0]+1,ordersA2[1]-ordersA2[0]+1 ] )
199
+
200
+ for ind,seg in enumerate(daseg):
201
+ for i in range(seg):
202
+ if ind == 0:
203
+ frag_str = frag_str+str(i+1)
204
+ else:
205
+ frag_str = frag_str+str(i+1+daseg[ind-1])
206
+ if i!= seg-1:
207
+ frag_str = frag_str + ","
208
+ else:
209
+ if ind == 2:
210
+ frag_str = frag_str + "]]'"
211
+ else:
212
+ frag_str = frag_str + "],["
213
+
214
+ sed_inplace(submitQC_file,"fraginfo=","fraginfo="+frag_str)
215
+ os.chdir(running_dir)
216
+
217
+ jobinfo = os.popen('sh analyzeQC_flexible1.sh').read()
218
+
219
+ return jobinfo
220
+
221
+ def main_AnalyzeQC():
222
+ dict_of_simulation = parse_input()
223
+ # prepare for quantum chemistry simulation
224
+ work_dir = dict_of_simulation['work_dir']
225
+ # where we have the structure directory
226
+ structure_dir = dict_of_simulation['structure_dir']
227
+ # load the project folder
228
+ project = dict_of_simulation['project']
229
+ # get case id for the simulation
230
+ caseid = dict_of_simulation['caseid']
231
+ # get job list
232
+ case_id_list = separate_idlist(caseid)
233
+ # get list of job control token
234
+ job_control = init_job_control(case_id_list)
235
+
236
+ startime = time.time
237
+ print("SubmitQC begins at "+str(startime))
238
+ # print("Input parameters ")
239
+ # print(simulation_parameter)
240
+ for ind, ctr_ele in enumerate(job_control):
241
+ print(ind, job_control)
242
+ run_step2(ind, job_control, dict_of_simulation)
243
+
244
+ # run_submitQC(simulation_parameter)
245
+ end_time = time.time
246
+ print("SubmitQC ends at "+str(end_time))
247
+
248
+ if __name__ == "__main__":
249
+ main_AnalyzeQC()