quinnreynolds / minplascalc

minplascalc - LTE plasma calculations
GNU General Public License v3.0
6 stars 0 forks source link

Specification of energies in special cases #37

Closed quinnreynolds closed 4 years ago

quinnreynolds commented 4 years ago

At preset there is no standardised way to specify the ionisation or dissociation energy of a species in cases where they are either physically impossible (e.g. ionisation of H+) or otherwise unavailable for some reason (e.g. they are the highest ionisation state for which reliable data is available).

A standard is required because using arbitrary "false" values such as zero or negative numbers could interfere with the partition function calculation routines. Using numpy.inf in such cases would be a simple solution - calculations will proceed as expected, and it clearly indicates to users that it's a placeholder value.

quinnreynolds commented 4 years ago

Another option is to use None, but that won't play nicely with arithmetic and logic so it would need some additional code to handle it explicitly as a special case. Not as pretty.

alchemyst commented 4 years ago

If you want the invalid values to infect all downstream calculations, why not just use numpy.nan?

quinnreynolds commented 4 years ago

It's mainly because of the if eij < (self.ionisationenergy - dE) conditional in the partition function and internal energy calculations for MonatomicSpecies. If ionisationenergy is numpy.inf that check will pass, but if it's numpy.nan it will fail all energy levels and the function will (incorrectly) return zero.

We could catch that with explicit code I suppose, but then we'd be be back to the same issue as with None.

quinnreynolds commented 4 years ago

Addressed as of d497f2c4ad9637ed8d4771c25fd988dd29abf109. Closing.