Skip to content

Commit

Permalink
- Add default for basis set (when not mentioned)
Browse files Browse the repository at this point in the history
- Remove `None` clauses
  • Loading branch information
ndaelman committed May 28, 2024
1 parent ba6c7cb commit 7dcd3f2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions electronicparsers/gaussian/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,8 @@ def resolve_prefix(name):
name = res[2]
return prefix, name

def resolve_basis_set(parameter):
def resolve_basis_set(parameter: str) -> tuple[str, str]:
"""Standardize basis set names (`parameter`) to the format used in the metainfo."""
basis_set = self._basis_set_map.get(parameter, None)
if basis_set is not None:
return (parameter, parameter)
Expand All @@ -1320,6 +1321,9 @@ def resolve_basis_set(parameter):
)
return (basis_keys[0], parameter)

# fall back onto default basis set
return ('STO-3G', 'STO-3G')

def resolve_xc_functional(parameter):
xc_functional = self._xc_functional_map.get(parameter, None)
if xc_functional is not None:
Expand Down Expand Up @@ -1373,9 +1377,9 @@ def resolve_xc_functional(parameter):
xc_functionals.add(xc_functional)

basis_set_parameter = parameter[0] if not parameter[1:] else parameter[1]
# ! invert logic
basis_set = resolve_basis_set(basis_set_parameter.strip())
if basis_set is not None:
basis_sets.add(basis_set)
basis_sets.add(basis_set)

sec_dft = DFT()
sec_method.dft = sec_dft
Expand All @@ -1401,7 +1405,7 @@ def resolve_xc_functional(parameter):
self.logger.error(
'Found multiple or no basis set', data=dict(n_parsed=len(basis_sets))
)
bs = None

for basis_set in basis_sets:
bs = BasisSet(
type='gaussians',
Expand All @@ -1415,7 +1419,7 @@ def resolve_xc_functional(parameter):
BasisSetContainer(
type='atom-centered orbitals',
scope=['wavefunction'],
basis_set=[bs] if bs is not None else [],
basis_set=[bs],
)
]

Expand Down

0 comments on commit 7dcd3f2

Please sign in to comment.