@@ -315,6 +315,7 @@ def system(command, log_file="", force_local=False, software="xtb", calc_id=-1):
315315 return ErrorCodes .UNKNOWN_TERMINATION
316316
317317 if calc_id != - 1 and res .is_aborted () == True :
318+ logger .info (f"Stopping calculation { calc_id } " )
318319 signal_to_send = signal .SIGTERM
319320
320321 parent = psutil .Process (t .pid )
@@ -349,7 +350,7 @@ def get_cache_index(calc, cache_path):
349350 inputs = glob .glob (cache_path + '/*.input' )
350351 for f in inputs :
351352 if files_are_equal (f , calc .input_file ):
352- ind = f .split ('/' )[- 1 ].split ('.' )[0 ]
353+ ind = '.' . join ( f .split ('/' )[- 1 ].split ('.' )[: - 1 ])
353354 return ind
354355 else :
355356 return - 1
@@ -1031,6 +1032,7 @@ def orca_opt(in_file, calc):
10311032 calc .structure = s
10321033 calc .step = BasicStep .objects .get (name = "Single-Point Energy" )
10331034 calc .save ()
1035+ add_input_to_calc (calc )
10341036 return orca_sp (in_file , calc )
10351037
10361038 local_folder = os .path .join (CALCUS_SCR_HOME , str (calc .id ))
@@ -1168,9 +1170,10 @@ def orca_freq(in_file, calc):
11681170
11691171 with open (os .path .join (CALCUS_RESULTS_HOME , str (calc .id ), "IR.csv" ), 'w' ) as out :
11701172 out .write ("Wavenumber,Intensity\n " )
1171- intensities = 1000 * np .array (intensities )/ max (intensities )
1172- for _x , i in sorted ((zip (list (x ), spectrum )), reverse = True ):
1173- out .write ("-{:.1f},{:.5f}\n " .format (_x , i ))
1173+ if len (intensities ) > 0 :
1174+ intensities = 1000 * np .array (intensities )/ max (intensities )
1175+ for _x , i in sorted ((zip (list (x ), spectrum )), reverse = True ):
1176+ out .write ("-{:.1f},{:.5f}\n " .format (_x , i ))
11741177
11751178 prop = get_or_create (calc .parameters , calc .structure )
11761179 prop .energy = E
@@ -1193,6 +1196,11 @@ def orca_freq(in_file, calc):
11931196 a , x , y , z = line .strip ().split ()
11941197 struct .append ([a , float (x ), float (y ), float (z )])
11951198
1199+ parse_orca_charges (calc , calc .structure )
1200+
1201+ if num_atoms == 1 :
1202+ return ErrorCodes .SUCCESS
1203+
11961204 while lines [ind ].find ("VIBRATIONAL FREQUENCIES" ) == - 1 and ind > 0 :
11971205 ind -= 1
11981206
@@ -1256,8 +1264,6 @@ def is_all_null(arr):
12561264 for ind2 , (a , x , y , z ) in enumerate (struct ):
12571265 out .write ("{} {:.4f} {:.4f} {:.4f} {} {} {}\n " .format (a , x , y , z , * vibs [ind ][3 * ind2 :3 * ind2 + 3 ]))
12581266
1259- parse_orca_charges (calc , calc .structure )
1260-
12611267 return ErrorCodes .SUCCESS
12621268
12631269def orca_scan (in_file , calc ):
@@ -1663,8 +1669,7 @@ def parse_default_orca_charges(calc, s):
16631669
16641670def parse_gaussian_charges (calc , s ):
16651671 parse_default_gaussian_charges (calc , s )
1666-
1667- for spec in calc .parameters .specifications .split (' ' ):#The specifications have been cleaned/formatted already
1672+ for spec in calc .parameters .specifications .replace (', ' , ',' ).split (' ' ):#The specifications have been cleaned/formatted already
16681673 if spec .strip () == '' :
16691674 continue
16701675 if spec .find ('(' ) != - 1 :
@@ -2796,6 +2801,24 @@ def dispatcher(drawing, order_id):
27962801 c .task_id = res
27972802 c .save ()
27982803
2804+ def add_input_to_calc (calc ):
2805+ inp = calc_to_ccinput (calc )
2806+ if isinstance (inp , CCInputException ):
2807+ msg = f"CCInput error: { str (inp )} "
2808+ if is_test :
2809+ print (msg )
2810+ calc .error_message = msg
2811+ calc .status = 3
2812+ calc .save ()
2813+ return ErrorCodes .FAILED_TO_CREATE_INPUT
2814+
2815+ calc .input_file = inp .input_file
2816+
2817+ calc .parameters .specifications = inp .confirmed_specifications
2818+
2819+ calc .save ()
2820+ calc .parameters .save ()
2821+
27992822@app .task (base = AbortableTask )
28002823def run_calc (calc_id ):
28012824 if not is_test :
@@ -2829,25 +2852,6 @@ def get_calc(calc_id):
28292852 logger .info (f"Calc { calc_id } already revoked" )
28302853 return ErrorCodes .JOB_CANCELLED
28312854
2832- def add_input_to_calc (calc ):
2833- inp = calc_to_ccinput (calc )
2834- if isinstance (inp , CCInputException ):
2835- msg = f"CCInput error: { str (inp )} "
2836- if is_test :
2837- print (msg )
2838- calc .error_message = msg
2839- calc .status = 3
2840- calc .save ()
2841- return ErrorCodes .FAILED_TO_CREATE_INPUT
2842-
2843- calc .input_file = inp .input_file
2844-
2845- if inp .confirmed_specifications != '' :
2846- calc .parameters .specifications = inp .confirmed_specifications
2847-
2848- calc .save ()
2849- calc .parameters .save ()
2850-
28512855 if calc .parameters .software != "xtb" : # xtb currently not directly supported by ccinput
28522856 ret = add_input_to_calc (calc )
28532857 if isinstance (ret , ErrorCodes ):
@@ -2946,9 +2950,9 @@ def add_input_to_calc(calc):
29462950 analyse_opt (calc .id )
29472951
29482952 if is_test and os .getenv ("CAN_USE_CACHED_LOGS" ) == "true" and os .getenv ("USE_CACHED_LOGS" ) == "true" and not calc_is_cached (calc ):
2949- index = str ( time ()). replace ( '.' , '_' )
2950- shutil .copytree (os .path .join (tests_dir , "scr" , str (calc .id )), os .path .join (tests_dir , "cache" , index ) )
2951- with open (os .path .join (tests_dir , "cache" , index + '.input' ), 'w' ) as out :
2953+ test_name = os . environ [ 'TEST_NAME' ]
2954+ shutil .copytree (os .path .join (tests_dir , "scr" , str (calc .id )), os .path .join (tests_dir , "cache" , test_name ), dirs_exist_ok = True )
2955+ with open (os .path .join (tests_dir , "cache" , test_name + '.input' ), 'w' ) as out :
29522956 out .write (calc .input_file )
29532957
29542958 return ret
0 commit comments