Skip to content

Commit

Permalink
- Move default out of function
Browse files Browse the repository at this point in the history
- Remove double check with `basis_set_mappings`
  • Loading branch information
Nathan Daelman committed May 29, 2024
1 parent c8fb6e1 commit 684c1f3
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions electronicparsers/gaussian/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ def __init__(self):

self._basis_set_pattern = re.compile(
r'(6\-311G)|(6\-31G)|(LANL2)|(LANL1)|(CBSB7)|(UGBS)|AUG\-(.*)|(D95)'
)
) # match additional specifications

self._energy_methods = {
'mp': (
Expand Down Expand Up @@ -1307,11 +1307,14 @@ def resolve_prefix(name):
return prefix, name

def resolve_basis_set(parameter: str) -> tuple[str, str]:
"""Standardize basis set names (`parameter`) to the format used in the metainfo."""
"""This function has 2 responsibilities:
1. discern `parameter` from other input settings.
2. verify that `parameter` is a valid basis set name."""
basis_set = self._basis_set_map.get(parameter, None)
if basis_set is not None:
return (parameter, parameter)

# handle modular extensions
res = self._basis_set_pattern.match(parameter)
if res is not None:
basis_keys = [key for key in res.groups() if key is not None]
Expand All @@ -1321,9 +1324,6 @@ def resolve_basis_set(parameter: str) -> tuple[str, str]:
)
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 @@ -1406,10 +1406,8 @@ def resolve_xc_functional(parameter):
type='gaussians',
scope=['full-electron'],
)
for _ in self._basis_set_map.get(basis_set[0], []):
# TODO need to adjust basis_set atom centered to take multiple entries
# old parser writes the full name of basis set here not the name on map
bs.atom_centered.append(BasisSetAtomCentered(name=basis_set[1]))
basis_set_name = basis_set[1] if basis_set else 'STO-3G'
bs.atom_centered.append(BasisSetAtomCentered(name=basis_set_name))
sec_method.electrons_representation = [
BasisSetContainer(
type='atom-centered orbitals',
Expand Down

0 comments on commit 684c1f3

Please sign in to comment.