Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for the multiplicity for cations or neutral atoms and anions #32

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions atomdb/datasets/numeric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,26 @@ def run(elem, charge, mult, nexc, dataset, datapath):
n_dn = (nelec - nspin) // 2
basis = None

# Check that the input multiplicity corresponds to the most stable electronic configuration.
# For charged species take the multiplicity from the neutral isoelectronic species.
if mult != MULTIPLICITIES[nelec]:
raise ValueError(f"Multiplicity {mult} not available for {elem} with charge = {charge}.")
if charge >= 0:
z = str(natom).zfill(3)
ne = str(nelec).zfill(3)
with h5.File(
os.path.join(os.path.dirname(__file__), "raw/database_beta_1.3.0.h5"), "r"
) as f:
mults = np.array(list(f[z][ne]["Multi"][...]), dtype=int)
energy = f[z][ne]["Energy"][...]
index_sorting = sorted(list(range(len(energy))), key=lambda k: energy[k])
mults = list(mults[index_sorting])
energy = list(energy[index_sorting])

if not mult == mults[0]:
raise ValueError(f"{elem} with {charge} and multiplicity {mult} not available.")
energy = energy[0]
else: # For anions
if mult != MULTIPLICITIES[nelec]:
raise ValueError(
f"Multiplicity {mult} not available for {elem} with charge = {charge}."
)

species_table = load_numerical_hf_data()
data = species_table[(natom, nelec)]
Expand Down
Loading