Skip to content

Commit

Permalink
Replaced explicit custom basis sets with builtin basis sets in ORCA w…
Browse files Browse the repository at this point in the history
…hen available
  • Loading branch information
RaphaelRobidas committed Sep 11, 2022
1 parent b116647 commit 99b4ca3
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 238 deletions.
1 change: 0 additions & 1 deletion ccinput/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ class CalcType(Enum):
"hav5+dz": [],
"w1dz": [],
"w1mtsmall": [],
"w1dz": [],
"sv": [],
"svp": [],
"tzv": [],
Expand Down
75 changes: 59 additions & 16 deletions ccinput/packages/orca.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import basis_set_exchange
import basis_set_exchange as bse

from ccinput.constants import CalcType, ATOMIC_NUMBER, LOWERCASE_ATOMIC_SYMBOLS
from ccinput.utilities import get_method, get_basis_set, get_solvent, clean_xyz, warn
from ccinput.constants import (
CalcType,
ATOMIC_NUMBER,
LOWERCASE_ATOMIC_SYMBOLS,
SOFTWARE_BASIS_SETS,
)
from ccinput.utilities import (
get_method,
get_basis_set,
get_solvent,
get_abs_basis_set,
clean_xyz,
warn,
)
from ccinput.exceptions import (
InvalidParameter,
UnimplementedError,
Expand Down Expand Up @@ -276,20 +288,51 @@ def handle_custom_basis_sets(self):
except KeyError:
raise InvalidParameter("Invalid atom in custom basis set string")

bs = basis_set_exchange.get_basis(
bs_keyword, fmt="ORCA", elements=[el_num], header=False
).strip()
sbs = bs.split("\n")
if bs.find("ECP") != -1:
clean_bs = "\n".join(sbs[3:]).strip() + "\n"
clean_bs = clean_bs.replace("\n$END", "$END").replace("$END", "end")
custom_bs += f"newgto {el}\n"
custom_bs += clean_bs
abs_keyword = get_abs_basis_set(bs_keyword)
success = False
if abs_keyword in SOFTWARE_BASIS_SETS["orca"]:
_custom_bs = (
f'NewGTO {el} "{SOFTWARE_BASIS_SETS["orca"][abs_keyword]}" end\n'
)
gbs = bse.get_basis(bs_keyword, elements=[el_num])
if "ecp_potentials" in gbs["elements"][str(el_num)]:
# Search for the right ECP
hits = bse.filter_basis_sets(family=gbs["family"], role="orbital")
ecp_keyword = ""
for name, hit in hits.items():
if hit["function_types"] == ["scalar_ecp"]:
ecp_keyword = get_basis_set(name, "orca")
break
else:
warn(
"Could not find the name of the ECP linked to {SOFTWARE_BASIS_SETS['orca'][abs_keyword]}, adding manually..."
)

if ecp_keyword:
_custom_bs += f'NewECP {el} "{ecp_keyword}" end\n'
success = True
else:
success = True

# TODO: handle auxiliary basis sets

if success:
custom_bs += _custom_bs.strip()
else:
clean_bs = "\n".join(sbs[3:-1]).strip() + "\n"
custom_bs += f"newgto {el}\n"
custom_bs += clean_bs
custom_bs += "end"
bs = bse.get_basis(
bs_keyword, fmt="ORCA", elements=[el_num], header=False
).strip()
sbs = bs.split("\n")
if bs.find("ECP") != -1:
clean_bs = "\n".join(sbs[3:]).strip() + "\n"
clean_bs = clean_bs.replace("\n$END", "$END").replace("$END", "end")
custom_bs += f"newgto {el}\n"
custom_bs += clean_bs.strip()
else:
clean_bs = "\n".join(sbs[3:-1]).strip() + "\n"
custom_bs += f"newgto {el}\n"
custom_bs += clean_bs.strip()
custom_bs += "end"

if custom_bs != "":
self.blocks.append(BS_TEMPLATE.format(custom_bs))
Expand Down

0 comments on commit 99b4ca3

Please sign in to comment.