Skip to content

Commit

Permalink
- Add checkpoint basis set names to basis_set_map (#226)
Browse files Browse the repository at this point in the history
- Correct `GEN` and co to `user-generated` in `basis_set_map`
- Standardize output `resolve_basis_set`

Co-authored-by: Nathan Daelman <ndaelman.physik.hu-berlin.de>
  • Loading branch information
ndaelman-hu authored May 29, 2024
1 parent 1adcdff commit e7d1ffe
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions electronicparsers/gaussian/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import numpy as np
import logging
import ase
from typing import Optional

from .metainfo import m_env

Expand Down Expand Up @@ -836,6 +835,8 @@ def __init__(self):
'W1RO': [{'name': 'W1RO'}],
}

user = 'User-defined'
checkpoint = 'See previous calculation'
self._basis_set_map = {
'STO-3G': [{'name': 'STO-3G'}],
'3-21G': [{'name': '3-21G'}],
Expand Down Expand Up @@ -884,8 +885,8 @@ def __init__(self):
'SDD': [{'name': 'SDD'}],
'OLDSDD': [{'name': 'OldSDD'}],
'SDDALL': [{'name': 'SDDAll'}],
'GEN': [{'name': 'General'}],
'GENECP': [{'name': 'General ECP'}],
'GEN': [{'name': user}],
'GENECP': [{'name': user + ' ' + 'ECP'}],
'CHKBAS': [{'name': 'CHKBAS'}],
'EXTRABASIS': [{'name': 'ExtraBasis'}],
'DGA1': [{'name': 'DGA1'}],
Expand All @@ -896,6 +897,12 @@ def __init__(self):
'CHF': [{'name': 'CHF'}],
'FIT': [{'name': 'FIT'}],
'AUTO': [{'name': 'AUTO'}],
'READ': [{'name': checkpoint}],
'READBASIS': [{'name': checkpoint}],
'RDBASIS': [{'name': checkpoint}],
'CHCKBASIS': [{'name': checkpoint}],
'CHECKBASIS': [{'name': checkpoint}],
'CHECKPOINTBASIS': [{'name': checkpoint}],
}

self._xc_functional_pattern = re.compile(
Expand Down Expand Up @@ -1307,13 +1314,13 @@ def resolve_prefix(name):
name = res[2]
return prefix, name

def resolve_basis_set(parameter: str) -> Optional[tuple[str, str]]:
def resolve_basis_set(parameter: str) -> tuple[str, str]:
"""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)
basis_set = self._basis_set_map.get(parameter.upper(), None)
if basis_set is not None:
return (parameter, parameter)
return (parameter, basis_set[0]['name'])

# handle modular extensions
res = self._basis_set_pattern.match(parameter)
Expand All @@ -1324,9 +1331,10 @@ def resolve_basis_set(parameter: str) -> Optional[tuple[str, str]]:
'Cannot resolve basis set', data=dict(key=parameter)
)
return (basis_keys[0], parameter)
# TODO: make this piggy-bank off basis_set_map

# in case the setting was not recognized
return None
return ('', '')

def resolve_xc_functional(parameter):
xc_functional = self._xc_functional_map.get(parameter, None)
Expand Down Expand Up @@ -1383,7 +1391,7 @@ def resolve_xc_functional(parameter):
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:
if basis_set[1]: # only index 1 is later on used
basis_sets.add(basis_set)
if len(basis_sets) == 0:
basis_sets.add(resolve_basis_set('STO-3G'))
Expand Down

0 comments on commit e7d1ffe

Please sign in to comment.