@@ -29,6 +29,10 @@ def __init__(self, respectdir=None, filename='respect', printlevel=2, label="ReS
29
29
self .scf_inputkeywords = scf_inputkeywords
30
30
self .jobtype_inputkeywords = jobtype_inputkeywords
31
31
self .parallelization = parallelization
32
+
33
+ # Store optional properties of ReSpect run job in a dict
34
+ self .properties = {}
35
+
32
36
#
33
37
if scf_inputkeywords is None :
34
38
print ("Error: You must pass a dictionary to scf_inputkeywords option" )
@@ -111,7 +115,13 @@ def run(self, current_coords=None, current_MM_coords=None, MMcharges=None, qm_el
111
115
print ("SCF calculation done" )
112
116
#Grab energy. Note: no analytic gradient in ReSpect yet
113
117
self .energy = grab_energy (f"{ self .filename } .out_scf" , Grad = Grad )
114
- #Grab properties
118
+
119
+ if self .energy is None :
120
+ print (f"No energy was found in ReSpect SCF outputfile: { self .filename } .out_scf" )
121
+ print (f"Something went wrong in calculation. Inspect { self .filename } .out_scf for reason" )
122
+ ashexit ()
123
+
124
+ print (f"Single-point { self .theorynamelabel } energy:" , self .energy )
115
125
116
126
# if jobtype has been set
117
127
if self .jobtype is not None :
@@ -121,10 +131,23 @@ def run(self, current_coords=None, current_MM_coords=None, MMcharges=None, qm_el
121
131
for job in self .jobtype :
122
132
print ("Running job:" , job )
123
133
run_respect (respectdir = self .respectdir , jobtype = self .jobtype , inputfile = self .filename , numcores = self .numcores , scratchdir = f'{ os .getcwd ()} /respect_calc_scratch' )
134
+ # Grab properties
135
+ if job == "gt" :
136
+ gvalues = grab_gtensor (f"{ self .filename } .out_gt" )
137
+ self .properties = {'g_values' :gvalues }
124
138
else :
125
139
run_respect (respectdir = self .respectdir , jobtype = self .jobtype , inputfile = self .filename , numcores = self .numcores , scratchdir = f'{ os .getcwd ()} /respect_calc_scratch' )
140
+ # Grab properties
141
+ if self .jobtype == "gt" :
142
+ gvalues = grab_gtensor (f"{ self .filename } .out_gt" )
143
+ self .properties = {'g_values' :gvalues }
126
144
127
- print (f"Single-point { self .theorynamelabel } energy:" , self .energy )
145
+
146
+ print ("Calculated and stored ReSpect properties:" )
147
+ for p_k ,p_v in self .properties .items ():
148
+ print (f"{ p_k } : { p_v } " )
149
+
150
+ print ()
128
151
print (BC .OKBLUE , BC .BOLD , f"------------ENDING { self .theorynamelabel } INTERFACE-------------" , BC .END )
129
152
130
153
print_time_rel (module_init_time , modulename = f'{ self .theorynamelabel } run' , moduleindex = 2 )
@@ -183,3 +206,16 @@ def create_respect_inputfile(filename,elems, coords, charge,mult, scf_inputkeywo
183
206
f .write (f"{ indent } { subj_k } : { subj_val } \n " )
184
207
185
208
f .close ()
209
+
210
+ def grab_gtensor (filename ):
211
+ grab = False
212
+ g_values = []
213
+ with open (filename ) as f :
214
+ for line in f :
215
+ if grab is True :
216
+ if 'g_11' in line or 'g_22' in line or 'g_33' in line :
217
+ g_values .append (float (line .split ()[1 ]))
218
+ if ' Principal values of the g-tensor' in line :
219
+ grab = True
220
+ if ' Determinant of the g-tensor' in line :
221
+ grab = False
0 commit comments