@@ -339,8 +339,6 @@ def compute(self, state: OptimizationState):
339339 state .Model_hess = copy .deepcopy (self .calculator .Model_hess )
340340 return state
341341
342-
343-
344342class ModelFunctionHandler (BasePotentialHandler ):
345343 def __init__ (self , calc1 , calc2 , mf_args , config , file_io , base_dir , force_data ):
346344 super ().__init__ (config , file_io , base_dir , force_data )
@@ -360,13 +358,11 @@ def __init__(self, calc1, calc2, mf_args, config, file_io, base_dir, force_data)
360358 self .bitss_geom2_history = []
361359 self .bitss_ref_geom = None
362360
363-
364361 self .bitss_initialized = False
365362
366363 if self .is_bitss :
367364 self ._setup_bitss_initialization ()
368365
369-
370366 def _load_mf_class (self ):
371367 if self .method_name == "opt_meci" :
372368 return OptMECI ()
@@ -396,7 +392,6 @@ def _setup_bitss_initialization(self):
396392 if len (self .params ) < 1 :
397393 raise ValueError ("BITSS requires a reference geometry file path." )
398394
399-
400395 temp_io = FileIO (self .base_dir , self .params [0 ])
401396 g_list , _ , _ = temp_io .make_geometry_list (self .config .electric_charge_and_multiplicity )
402397
@@ -414,19 +409,36 @@ def compute(self, state: OptimizationState):
414409 n_atoms = len (self .single_element_list )
415410 geom_1 , geom_2 = state .geometry [:n_atoms ], state .geometry [n_atoms :]
416411
417-
418412 if not self .bitss_initialized :
419413 self .mf_instance = BITSSModelFunction (geom_1 , geom_2 )
420414 self ._apply_config_params ()
421415 self .bitss_initialized = True
422416 else :
423417 geom_1 = geom_2 = state .geometry
424418
425-
426419 # State 1
420+ # Use config's global charge/mult as default, or parse specific params if implemented differently
421+ # Here assuming config has default, but for different states usually params are needed.
422+ # Assuming config.electric_charge_and_multiplicity is for state 1,
423+ # and params has info for state 2 if needed.
424+
425+ # NOTE: For standard cases, State 1 uses global config.
427426 e1 , g1 , ex1 = self ._run_calc (self .calc1 , geom_1 , self .single_element_list , self .config .electric_charge_and_multiplicity , "State1" , iter_idx )
427+
428428 # State 2
429- chg_mult_2 = self .config .electric_charge_and_multiplicity if self .is_bitss else [int (self .params [0 ]), int (self .params [1 ])]
429+ # Determine Charge/Multiplicity for State 2
430+ if self .is_bitss :
431+ # BITSS usually keeps same spin/charge for both images (NEB-like) unless specified
432+ chg_mult_2 = self .config .electric_charge_and_multiplicity
433+ else :
434+ # For MECI/Seam, params usually hold [charge2, mult2]
435+ # Ensure params are integers
436+ if len (self .params ) >= 2 :
437+ chg_mult_2 = [int (self .params [0 ]), int (self .params [1 ])]
438+ else :
439+ # Fallback if not provided (though params usually required for these modes)
440+ chg_mult_2 = self .config .electric_charge_and_multiplicity
441+
430442 e2 , g2 , ex2 = self ._run_calc (self .calc2 , geom_2 , self .single_element_list , chg_mult_2 , "State2" , iter_idx )
431443
432444 if ex1 or ex2 :
@@ -530,7 +542,6 @@ def compute(self, state: OptimizationState):
530542
531543 return state
532544
533-
534545 def _make_block_diag_hess (self , h1 , h2 ):
535546 d1 = h1 .shape [0 ]
536547 d2 = h2 .shape [0 ]
@@ -554,9 +565,27 @@ def _run_calc(self, calc_inst, geom, elems, chg_mult, label, iter_idx):
554565 os .makedirs (run_dir , exist_ok = True )
555566 old_dir = calc_inst .BPA_FOLDER_DIRECTORY
556567 calc_inst .BPA_FOLDER_DIRECTORY = run_dir
568+
569+
570+ calc_inst .electronic_charge = chg_mult [0 ]
571+ calc_inst .spin_multiplicity = chg_mult [1 ]
572+
557573 geom_str = self .file_io .print_geometry_list (geom * self .config .bohr2angstroms , elems , chg_mult , display_flag = True )
558574 inp_path = self .file_io .make_psi4_input_file (geom_str , iter_idx , path = run_dir )
559- e , g , _ , ex = calc_inst .single_point (inp_path , [element_number (el ) for el in elems ], iter_idx , chg_mult , method = "" )
575+
576+
577+ method_str = getattr (calc_inst , "xtb_method" , "" )
578+ if method_str is None :
579+ method_str = ""
580+
581+ e , g , _ , ex = calc_inst .single_point (
582+ inp_path ,
583+ [element_number (el ) for el in elems ],
584+ iter_idx ,
585+ chg_mult ,
586+ method = method_str
587+ )
588+
560589 calc_inst .BPA_FOLDER_DIRECTORY = old_dir
561590 return e , g , ex
562591
@@ -568,8 +597,7 @@ def finalize_bitss_trajectory(self):
568597 for s , g in enumerate (full_seq ):
569598 f .write (f"{ len (g )} \n BITSS_Step { s } \n " )
570599 for i , atom in enumerate (g ):
571- f .write (f"{ self .single_element_list [i ]:2s} { atom [0 ]:12.8f} { atom [1 ]:12.8f} { atom [2 ]:12.8f} \n " )
572-
600+ f .write (f"{ self .single_element_list [i ]:2s} { atom [0 ]:12.8f} { atom [1 ]:12.8f} { atom [2 ]:12.8f} \n " )
573601
574602class ONIOMHandler (BasePotentialHandler ):
575603 """
0 commit comments