diff --git a/atomdb/promolecule.py b/atomdb/promolecule.py index 9b829558..54162258 100644 --- a/atomdb/promolecule.py +++ b/atomdb/promolecule.py @@ -584,8 +584,12 @@ def make_promolecule( # Handle default multiplicity parameters if mults is None: - # Force non-int charge to be integer here; will be overwritten below. - mults = [MULTIPLICITIES[(atnum, charge)] for (atnum, charge) in zip(atnums, charges)] + # if all charges are integers, get corresponding multiplicities + if all(isinstance(charge, Integral) for charge in charges): + mults = [MULTIPLICITIES[(atnum, charge)] for (atnum, charge) in zip(atnums, charges)] + else: + # set each multiplicity to None + mults = [None for _ in atnums] # Construct linear combination of species promol = Promolecule() @@ -615,6 +619,41 @@ def make_promolecule( "of other species", stacklevel=1, ) + # Non-integer charge, default multiplicity + if mult is None: + # get floor and ceiling charges + f_charge, c_charge = int(np.floor(charge)), int(np.ceil(charge)) + fmult, cmult = MULTIPLICITIES[(atnum, f_charge)], MULTIPLICITIES[(atnum, c_charge)] + # get coefficients for linear combination + f_coeff = np.ceil(charge) - charge + c_coeff = charge - np.floor(charge) + # get corresponding species + try: + specie_f = load( + atom, + f_charge, + fmult, + dataset=dataset, + datapath=datapath, + remotepath=remotepath, + ) + specie_c = load( + atom, + c_charge, + cmult, + dataset=dataset, + datapath=datapath, + remotepath=remotepath, + ) + promol._extend((specie_f, specie_c), (coord, coord), (f_coeff, c_coeff)) + continue + except FileNotFoundError: + warn( + "Unable to load species corresponding to `charge, mult`; " + "generating species via linear combination " + "of other species", + stacklevel=1, + ) # Non-integer charge and multiplicity #