@@ -191,6 +191,7 @@ def pack_molecules(
191191 nmols : int = - 1 ,
192192 arch : str = "mace_mp" ,
193193 model : str = "medium-omat-0" ,
194+ dispersion : bool = False ,
194195 device : str = "cpu" ,
195196 where : str = "anywhere" ,
196197 center : tuple [float , float , float ] = None ,
@@ -226,6 +227,7 @@ def pack_molecules(
226227 nmols (int): Number of molecules to insert.
227228 arch (str): Architecture for the calculator.
228229 model (str): Path to the model file.
230+ dispersion (bool): If a dispersion correction is added to MLIP calculator.
229231 device (str): Device to run calculations on (e.g., "cpu" or "cuda").
230232 where (str): Region to insert molecules ("anywhere",
231233 "sphere", "cylinderZ", etc.).
@@ -297,7 +299,12 @@ def pack_molecules(
297299 cell , center , where , a , b , c , radius , height
298300 )
299301
300- calc = choose_calculator (arch = arch , model_path = model , device = device )
302+ calc = choose_calculator (
303+ arch = arch ,
304+ model_path = model ,
305+ device = device ,
306+ dispersion = dispersion ,
307+ )
301308 sys .calc = calc
302309
303310 e = sys .get_potential_energy () if len (sys ) > 0 else 0.0
@@ -319,7 +326,14 @@ def pack_molecules(
319326 tsys = csys .copy () + mol .copy ()
320327 if insert_strategy == "hmc" :
321328 tsys = run_md_nve (
322- tsys , md_temperature , md_steps , md_timestep , arch , model , device
329+ tsys ,
330+ md_temperature ,
331+ md_steps ,
332+ md_timestep ,
333+ arch ,
334+ model ,
335+ dispersion ,
336+ device ,
323337 )
324338
325339 if every > 0 and _itry / every == 0 :
@@ -328,6 +342,7 @@ def pack_molecules(
328342 device = device ,
329343 arch = arch ,
330344 model = model ,
345+ dispersion = dispersion ,
331346 fmax = fmax ,
332347 out_path = out_path ,
333348 md_temperature = md_temperature ,
@@ -362,6 +377,7 @@ def pack_molecules(
362377 device ,
363378 arch ,
364379 model ,
380+ dispersion ,
365381 fmax ,
366382 out_path ,
367383 md_temperature ,
@@ -382,6 +398,7 @@ def pack_molecules(
382398 fmax = fmax ,
383399 out_path = out_path ,
384400 opt_cell = True ,
401+ dispersion = dispersion ,
385402 )
386403 return (energy_final , csys )
387404
@@ -430,6 +447,7 @@ def save_the_day(
430447 device : str = "" ,
431448 arch : str = "" ,
432449 model : str = "" ,
450+ dispersion : bool = False ,
433451 fmax : float = 0.01 ,
434452 out_path : str = "." ,
435453 md_temperature : float = 100.0 ,
@@ -446,11 +464,19 @@ def save_the_day(
446464 model ,
447465 fmax ,
448466 out_path ,
467+ dispersion = dispersion ,
449468 )
450469 return a
451470 if relax_strategy == "md" :
452471 return run_md_nve (
453- struct , md_temperature , md_steps , md_timestep , arch , model , device
472+ struct ,
473+ md_temperature ,
474+ md_steps ,
475+ md_timestep ,
476+ arch ,
477+ model ,
478+ dispersion ,
479+ device ,
454480 )
455481 return None
456482
@@ -462,6 +488,7 @@ def run_md_nve(
462488 timestep : float = 1.0 ,
463489 arch : str = "" ,
464490 model : str = "" ,
491+ dispersion : bool = False ,
465492 device : str = "" ,
466493) -> Atoms :
467494 """Run nve simulation."""
@@ -470,7 +497,7 @@ def run_md_nve(
470497 temp = temp ,
471498 device = device ,
472499 arch = arch ,
473- calc_kwargs = {"model_paths" : model },
500+ calc_kwargs = {"model_paths" : model , "dispersion" : dispersion },
474501 stats_every = 1 ,
475502 steps = steps ,
476503 timestep = timestep ,
@@ -487,14 +514,15 @@ def optimize_geometry(
487514 fmax : float ,
488515 out_path : str = "." ,
489516 opt_cell : bool = False ,
517+ dispersion : bool = False ,
490518) -> tuple (float , Atoms ):
491519 """Optimize the geometry of a structure."""
492520 geo = GeomOpt (
493521 struct = struct ,
494522 device = device ,
495523 arch = arch ,
496524 fmax = fmax ,
497- calc_kwargs = {"model_paths" : model },
525+ calc_kwargs = {"model_paths" : model , "dispersion" : dispersion },
498526 filter_kwargs = {"hydrostatic_strain" : opt_cell },
499527 )
500528 geo .run ()
0 commit comments