theochem / AtomDB

An Extended Periodic Table of Neutral and Charged Atomic Species
http://atomdb.qcdevs.org/
GNU General Public License v3.0
16 stars 14 forks source link

Promolecule: add default multiplicities for non-int charge (#82) #84

Closed msricher closed 6 months ago

msricher commented 6 months ago

Fixes #82.

The code example,

from atomdb import make_promolecule
import numpy as np

atnums = [7]
charges = [0.1]
atcoords = np.array([[0.0, 0.0, 0.0]])

# Build a promolecule
promol = make_promolecule(
    atnums,
    atcoords,
    charges=charges,
    units="bohr",
    dataset="gaussian",
)

now runs, but it isn't able to construct a Promolecule instance:

ValueError: Unable to construct species with non-integer charge/spin from database entries

This is a valid error to get, but it's not ideal. This is why, when making a Promolecule with non-integer charges, I suggested that the user should also specify the multiplicities.

Open to suggestions.

marco-2023 commented 6 months ago

Hi @msricher I added the logic handling the case where charges are fractional and no multiplicity is given. It works now for the example.