@@ -383,85 +383,80 @@ def write_input_file(self) -> None:
383383        with  open (os .path .join (self .local_path , input_filenames [self .job_adapter ]), 'w' ) as  f :
384384            f .write (Template (input_template ).render (** input_dict ))
385385    def  generate_qchem_scan_angles (self ,start_angle : int , step : int ) ->  (int , int , int , int ):
386-             """ 
387-             Generates the angles for a Q-Chem scan. The scan is split into two parts, one from start_angle to 180, and one from -180 to end_angle. 
388- 
389-             Parameters 
390-             ---------- 
391-             start_angle : int 
392-                 The starting angle for the scan 
393-             step : int 
394-                 The step size for the scan 
395- 
396-             Returns 
397-             ------- 
398-             scan1_start : int 
399-                 The starting angle for the first part of the scan 
400-             scan1_end : int 
401-                 The ending angle for the first part of the scan 
402-             scan2_start : int 
403-                 The starting angle for the second part of the scan 
404-             scan2_end : int 
405-                 The ending angle for the second part of the scan 
406-             """ 
407- 
408-             # First, we need to check that the start_angle is within the range of -180 to 180, and if not, convert it to be within that range 
409-             if  start_angle  >  180 :
410-                 start_angle  =  start_angle  -  360 
411- 
412- 
413-             # This sets the end angle but does not take into account the limit of -180 to 180 
414-             end_angle  =  start_angle  -  step 
415- 
416-             # This function wraps the scan2_start within the range of -180 to 180 
417-             wrap_within_range  =  lambda  number , addition : (number  +  addition ) %  360  -  360  if  (number  +  addition ) %  360  >  180  else  (number  +  addition ) %  360 
418- 
419-             # This function converts the angles to be within the range of -180 to 180 
420-             convert_angle  =  lambda  angle : angle  %  360  if  angle  >=  0  else  ( angle  %  360  if  angle  <=  - 180  else  (angle  %  360 ) -  360 )
421- 
422-             # This converts the angles to be within the range of -180 to 180 
423-             start_angle  =  convert_angle (start_angle )
424-             end_angle  =  convert_angle (end_angle )
386+         """Generates angles for a Q-Chem dihedral scan, split into two segments. 
387+ 
388+         This function computes the angles for a Q-Chem dihedral scan. The scan is 
389+         divided into two parts: one spanning from the start_angle to 180 degrees, 
390+         and the other from -180 degrees to the calculated end_angle based on the 
391+         step size. 
392+ 
393+         Args: 
394+             start_angle (int): The initial angle for the scan. 
395+             step (int): The incremental step size for the scan. 
396+ 
397+         Returns: 
398+             tuple of int: A tuple containing the start and end angles for both 
399+                         scan segments. It includes scan1_start, scan1_end, 
400+                         scan2_start, and scan2_end. 
401+         """ 
402+ 
403+         # First, we need to check that the start_angle is within the range of -180 to 180, and if not, convert it to be within that range 
404+         if  start_angle  >  180 :
405+             start_angle  =  start_angle  -  360 
406+ 
407+ 
408+         # This sets the end angle but does not take into account the limit of -180 to 180 
409+         end_angle  =  start_angle  -  step 
410+ 
411+         # This function wraps the scan2_start within the range of -180 to 180 
412+         wrap_within_range  =  lambda  number , addition : (number  +  addition ) %  360  -  360  if  (number  +  addition ) %  360  >  180  else  (number  +  addition ) %  360 
413+ 
414+         # This function converts the angles to be within the range of -180 to 180 
415+         convert_angle  =  lambda  angle : angle  %  360  if  angle  >=  0  else  ( angle  %  360  if  angle  <=  - 180  else  (angle  %  360 ) -  360 )
416+ 
417+         # This converts the angles to be within the range of -180 to 180 
418+         start_angle  =  convert_angle (start_angle )
419+         end_angle  =  convert_angle (end_angle )
420+ 
421+         if  start_angle  ==  0  and  end_angle  ==  0 :
422+             scan1_start  =  start_angle 
423+             scan1_end  =  180 
424+             scan2_start  =  - 180 
425+             scan2_end  =  end_angle 
426+         elif  start_angle  ==  180 :
427+             # This is a special case because the scan will be from 180 to 180 
428+             # This is not allowed in Q-Chem so we split it into two scans 
429+             # Arguably this could be done in one scan but it is easier to do it this way 
430+             # We will need to find the starting angle that when added by the step size will be 180 
431+             target_sum  =  180 
432+             quotient  =  target_sum  //  step 
433+             starting_number  =  target_sum  -  (quotient  *  step )
434+             scan1_start  =  starting_number 
435+             scan1_end  =  180 
436+             scan2_start  =  - 180 
437+             scan2_end  =  scan1_start  -  step 
438+         elif  start_angle  <=  end_angle :
439+             scan1_start  =  start_angle 
440+             scan1_end  =   start_angle  +  (step  *  ((180  -  start_angle )// step ))
441+             scan2_start  =  convert_angle (scan1_end )
442+             scan2_end  =  end_angle 
443+         elif  (start_angle  +  step ) >  180 :
444+             # This is a special case because the scan will be from, for example, 178 to 178 for the first scan. Therefore, we should make it a single scan from end angle, 178, step size 
445+             scan1_end  =  start_angle 
446+             scan1_start  =  wrap_within_range (scan1_end , step )
447+             scan2_start  =  0 
448+             scan2_end  =  0 
449+         else :
450+             scan1_start  =  start_angle 
451+             scan1_end  =  start_angle  +  (step  *  ((180  -  start_angle )// step ))
452+             scan2_start  =  wrap_within_range (scan1_end , step )
453+             scan2_end  =  end_angle 
425454
426-             if  start_angle  ==  0  and  end_angle  ==  0 :
427-                 scan1_start  =  start_angle 
428-                 scan1_end  =  180 
429-                 scan2_start  =  - 180 
430-                 scan2_end  =  end_angle 
431-             elif  start_angle  ==  180 :
432-                 # This is a special case because the scan will be from 180 to 180 
433-                 # This is not allowed in Q-Chem so we split it into two scans 
434-                 # Arguably this could be done in one scan but it is easier to do it this way 
435-                 # We will need to find the starting angle that when added by the step size will be 180 
436-                 target_sum  =  180 
437-                 quotient  =  target_sum  //  step 
438-                 starting_number  =  target_sum  -  (quotient  *  step )
439-                 scan1_start  =  starting_number 
440-                 scan1_end  =  180 
441-                 scan2_start  =  - 180 
442-                 scan2_end  =  scan1_start  -  step 
443-             elif  start_angle  <=  end_angle :
444-                 scan1_start  =  start_angle 
445-                 scan1_end  =   start_angle  +  (step  *  ((180  -  start_angle )// step ))
446-                 scan2_start  =  convert_angle (scan1_end )
447-                 scan2_end  =  end_angle 
448-             elif  (start_angle  +  step ) >  180 :
449-                 # This is a special case because the scan will be from, for example, 178 to 178 for the first scan. Therefore, we should make it a single scan from end angle, 178, step size  
450-                 scan1_end  =  start_angle 
451-                 scan1_start  =  wrap_within_range (scan1_end , step )
452-                 scan2_start  =  0 
453-                 scan2_end  =  0 
454-             else :
455-                 scan1_start  =  start_angle 
456-                 scan1_end  =  start_angle  +  (step  *  ((180  -  start_angle )// step ))
457-                 scan2_start  =  wrap_within_range (scan1_end , step )
458-                 scan2_end  =  end_angle 
459-                 
460-             if  scan2_start  ==  scan2_end :
461-                 scan2_start  =  0 
462-                 scan2_end  =  0 
463- 
464-             return  int (scan1_start ), int (scan1_end ), int (scan2_start ), int (scan2_end )
455+         if  scan2_start  ==  scan2_end :
456+             scan2_start  =  0 
457+             scan2_end  =  0 
458+ 
459+         return  int (scan1_start ), int (scan1_end ), int (scan2_start ), int (scan2_end )
465460
466461    def  generate_scan_angles (self , req_angle : int , step : int ) ->  (int , int ):
467462
0 commit comments