Skip to content
This repository was archived by the owner on May 5, 2026. It is now read-only.

Commit ce3ebc9

Browse files
authored
Add files via upload
1 parent 5ac02c7 commit ce3ebc9

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

multioptpy/Calculator/ase_calculation_tools.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from multioptpy.Calculator.ase_tools.mace import ASE_MACE
2323
from multioptpy.Calculator.ase_tools.mopac import ASE_MOPAC
2424
from multioptpy.Calculator.ase_tools.pygfn0 import ASE_GFN0
25+
from multioptpy.Calculator.ase_tools.pygfnff import ASE_GFNFF
2526
from multioptpy.Calculator.ase_tools.gxtb_dev import ASE_gxTB_Dev
2627

2728

@@ -432,6 +433,15 @@ def setup_calculator(atom_obj, software_type, electric_charge_and_multiplicity,
432433
software_type=software_type)
433434

434435
return calc_obj
436+
437+
if software_type == "GFN-FF":
438+
calc_obj = ASE_GFNFF(atom_obj=atom_obj,
439+
electric_charge_and_multiplicity=electric_charge_and_multiplicity,
440+
software_type=software_type)
441+
442+
return calc_obj
443+
444+
435445
if software_type == "mopac":
436446
calc_obj = ASE_MOPAC(atom_obj=atom_obj,
437447
electric_charge_and_multiplicity=electric_charge_and_multiplicity,
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
class ASE_GFNFF:
2+
"""
3+
Wrapper class to set up and run GFN-FF calculations via ASE.
4+
ref.:
5+
- S.Spicher, S.Grimme. Robust Atomistic Modeling of Materials, Organometallic, and Biochemical Systems (2020), DOI: https://doi.org/10.1002/anie.202004239
6+
- A standalone library of the GFN-FF method. https://github.com/pprcht/gfnff/
7+
- https://github.com/LiuGaoyong/PyGFNFF
8+
"""
9+
def __init__(self, **kwargs):
10+
11+
self.atom_obj = kwargs.get('atom_obj', None)
12+
self.electric_charge_and_multiplicity = kwargs.get('electric_charge_and_multiplicity', None)
13+
self.software_path = kwargs.get('software_path', None)
14+
self.software_type = kwargs.get('software_type', None)
15+
16+
def set_calculator(self):
17+
"""
18+
Sets the ASE calculator object utilizing pygfnff.
19+
"""
20+
import pygfnff
21+
22+
# While GFN-FF is a force field and topology generation is often automated,
23+
# we retain the logic to parse charge to maintain consistency with the
24+
# wrapper design pattern.
25+
# Note: Specific support for explicit charge setting depends on the
26+
# underlying PyGFNFF implementation details.
27+
charge = 0
28+
if self.electric_charge_and_multiplicity is not None:
29+
try:
30+
# Get charge from [charge, multiplicity] list
31+
charge = int(self.electric_charge_and_multiplicity[0])
32+
except (IndexError, TypeError, ValueError):
33+
print(f"Warning: Could not parse charge from {self.electric_charge_and_multiplicity}. Defaulting to 0.")
34+
pass
35+
36+
# Instantiate GFNFF calculator.
37+
# Based on the provided reference snippet: calculator=GFNFF()
38+
# If the specific version of PyGFNFF supports charge argument, it can be passed here.
39+
# Assuming standard initialization for now.
40+
gfnff_calc = pygfnff.GFNFF()
41+
42+
return gfnff_calc
43+
44+
def run(self):
45+
"""
46+
Attaches the calculator to the atoms object and returns it.
47+
"""
48+
calc_obj = self.set_calculator()
49+
self.atom_obj.calc = calc_obj
50+
return self.atom_obj

0 commit comments

Comments
 (0)