Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelRobidas committed Jan 16, 2023
1 parent dc6133c commit 03dcfee
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
23 changes: 2 additions & 21 deletions ccinput/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
has_dispersion_parameters,
warn,
indexify,
get_charge_mult_from_name,
)
from ccinput.constants import ATOMIC_NUMBER, SYN_SOFTWARE, BASIS_SET_EXCHANGE_KEY

Expand Down Expand Up @@ -111,27 +112,7 @@ def __init__(
f"Cannot parse the charge and multiplicity from the file name: no file given"
)

if "trication" in file:
self.charge = 3
elif "dication" in file:
self.charge = 2
elif "cation" in file:
self.charge = 1
elif "trianion" in file:
self.charge = -3
elif "dianion" in file:
self.charge = -2
elif "anion" in file:
self.charge = -1
elif "neutral" in file:
self.charge = 0

if "radical" in file or "doublet" in file:
self.multiplicity = 2
elif "triplet" in file:
self.multiplicity = 3
elif "singlet" in file:
self.multiplicity = 1
self.charge, self.multiplicity = get_charge_mult_from_name(file)

self.verify_charge_mult()
self.constraints = constraints
Expand Down
29 changes: 29 additions & 0 deletions ccinput/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,32 @@ def get_coord(xyz, ids):

def warn(msg):
print(f"*** {msg} ***")


def get_charge_mult_from_name(name):
charge = 0
mult = 1

if "trication" in name:
charge = 3
elif "dication" in name:
charge = 2
elif "cation" in name:
charge = 1
elif "trianion" in name:
charge = -3
elif "dianion" in name:
charge = -2
elif "anion" in name:
charge = -1
elif "neutral" in name:
charge = 0

if "radical" in name or "doublet" in name:
mult = 2
elif "triplet" in name:
mult = 3
elif "singlet" in name:
mult = 1

return charge, mult

0 comments on commit 03dcfee

Please sign in to comment.