@@ -36,6 +36,7 @@ def __init__(self, parameter, inter_param=None):
3636 self .reprod = parameter ["reproduce" ]
3737 if not self .reprod :
3838 if not ("init_from_suffix" in parameter and "output_suffix" in parameter ):
39+ parameter ["cal_type" ] = parameter .get ("cal_type" , "relaxation" )
3940 parameter ["plane_miller" ] = parameter .get ("plane_miller" , None )
4041 self .plane_miller = parameter ["plane_miller" ]
4142 parameter ["slip_direction" ] = parameter .get ("slip_direction" , None )
@@ -48,14 +49,18 @@ def __init__(self, parameter, inter_param=None):
4849 self .supercell_size = parameter ["supercell_size" ]
4950 parameter ["vacuum_size" ] = parameter .get ("vacuum_size" , 0 )
5051 self .vacuum_size = parameter ["vacuum_size" ]
51- parameter ["add_fix" ] = parameter .get (
52- "add_fix" , ["true" , "true" , "false" ]
53- ) # standard method
52+ if parameter ["cal_type" ] == "static" and "add_fix" not in parameter :
53+ parameter ["add_fix" ] = None
54+ else :
55+ parameter ["add_fix" ] = parameter .get (
56+ "add_fix" , ["true" , "true" , "false" ]
57+ ) # standard method
5458 self .add_fix = parameter ["add_fix" ]
5559 parameter ["n_steps" ] = parameter .get ("n_steps" , 10 )
5660 self .n_steps = parameter ["n_steps" ]
5761 self .atom_num = None
58- parameter ["cal_type" ] = parameter .get ("cal_type" , "relaxation" )
62+ else :
63+ parameter ["cal_type" ] = parameter .get ("cal_type" , "relaxation" )
5964 default_cal_setting = {
6065 "relax_pos" : True ,
6166 "relax_shape" : False ,
@@ -157,7 +162,18 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
157162
158163 equi_contcar = os .path .join (path_to_equi , CONTCAR )
159164 if not os .path .exists (equi_contcar ):
160- raise RuntimeError ("please do relaxation first" )
165+ raise RuntimeError (
166+ "Gamma requires a baseline relaxation before PropsMake. "
167+ "For static gamma scans, run a static baseline relaxation "
168+ "with relax_pos=false, relax_shape=false, and relax_vol=false."
169+ )
170+ equi_result = os .path .join (path_to_equi , "result.json" )
171+ if not os .path .exists (equi_result ):
172+ raise RuntimeError (
173+ "Gamma post-processing requires relaxation/relax_task/result.json. "
174+ "Please provide a static baseline relaxation result before "
175+ "running gamma PropsMake."
176+ )
161177 # print("we now only support gamma line calculation for BCC FCC and HCP metals")
162178 # print(
163179 # f"supported slip systems are:\n{SlabSlipSystem.hint_string()}"
@@ -451,6 +467,8 @@ def __inLammpes_fix(self, inLammps) -> None:
451467 )
452468 with open (inLammps , "r" ) as fin1 :
453469 contents = fin1 .readlines ()
470+ lower_id = None
471+ upper_id = None
454472 for ii in range (len (contents )):
455473 upper = contents [ii ].split ()[:3 ] == ["variable" , "N" , "equal" ]
456474 lower = re .search ("min_style cg" , contents [ii ])
@@ -460,6 +478,13 @@ def __inLammpes_fix(self, inLammps) -> None:
460478 elif upper :
461479 upper_id = ii
462480 # print(upper_id)
481+ if lower_id is None or upper_id is None or lower_id >= upper_id :
482+ raise RuntimeError (
483+ "Gamma add_fix was requested, but in.lammps does not contain "
484+ "a compatible minimization block to patch. For static gamma "
485+ "calculations set add_fix to null, or use a relaxation-style "
486+ "LAMMPS input with min_style cg and variable N equal markers."
487+ )
463488 del contents [lower_id + 1 :upper_id - 1 ]
464489 contents .insert (lower_id + 1 , add_fix_str )
465490 with open (inLammps , "w" ) as fin2 :
0 commit comments