- added
data
property toSubstance
to store additional information or to calculate mean values of mixtures- updated
copy()
function and documentation of all constructors
- updated
- added
rule_of_mixtures()
method toMixture
class- used to calculate mean values of keys in
data
dictionary- all constituents of a mixture must have this key-value pair
- fraction mode for weighting must be chosen: either atomic/mole, weight or volume fractions
- can use general or inverse rule of mixtures, cf. https://en.wikipedia.org/wiki/Rule_of_mixtures
- used to calculate mean values of keys in
- changed calculation of density in
_calc_rho()
of classMixture
:- calls new
rule_of_mixtures()
method with special "density" keyword - now uses volume fractions and general rule of mixtures (instead of old direct implementation with weight fractions and inverse rule)
- calls new
- added
copy()
function toSubstance
- deep-copy of the substance
- keyword arguments to change properties are:
name
for the descriptive namesymbol
for the symbolrho
for densityM
for molar mass
- fixed typos in "README.md"
This update features a major overhaul of the routines to fetch isotopic (and elemental) compositions.
Atomic fractions of Molecule
s in Mixture
s cannot be passed down directly.
This would underestimate the atomic fraction of the Element
s of that Molecule
.
Instead, all Element
s have to be collected according to their actual atomic abundance and subsequently be normalised.
When the composition input mode was weight
and the isotopic composition was fetched in weight
as well, values were correct (because of back and forth conversion).
Update 1.1.1 was ment to adress the faulty isotopic composition, when fetched in ´atomic´ mode, but introduced other errors and is thus discouraged to be used.
The respective releases on PyPI therefore have been yanked.
This new approach also required changes to the tree-printing routine.
print_tree()
has been replaced by print_tree_input()
, that acts like the old print_tree(scale=False)
.
To show the actual (scaled) elemental and isotopic composition, print_tree_composition()
has to be used.
- added
get_elements()
method toSubstance
for elemental composition of thatSubstance
- keyword
mode
for either "atomic" or "weight" fractions
- keyword
- added option for
get_isotopes()
to supply explicit collection of (natural) elements to be considered- removed the internal method
_append_isotopes()
- instead uses
_isotopic_composition()
,_elemental_composition()
and_append_elements()
to get correct (atomic) composition_isotopic_composition()
,_elemental_composition()
return a dictionary, matching the position in the tree hierarchy to theIsotope
orElement
and their fraction respectively
- removed the internal method
- added
surrogate_isotope()
method toElement
to get a surrogateIsotope
object in case of a natural element (used foruse_natural
algorithm) - removed
print_overview()
fromMixture
,Molecule
andElement
, because it doesn't comply with the new approach and has been superseded by tree-printing Node
s in the tree use their position in the tree-hierarchy as their id- replaced
print_tree()
withprint_tree_input()
- shows input composition in selected fraction modes (
atomic
,weight
andvolume
) - similar to old
print_tree(scale=False)
- shows input composition in selected fraction modes (
print_tree_composition()
- shows scaled composition of
Element
s andIsotopes
s of aSubstance
- possible fraction modes:
atomic
andweight
- uses
Node
id to fetch the correct composition value from_isotopic_composition()
or_elemental_composition()
dictionary
- shows scaled composition of
- added more sophisticated right alignment options for tree-plotting
- added
_print_depth()
method forNode
class, to get desired level of printing thatNode
object - new prefix generation in
print_node()
ofNode
class - right-alignment-preference class variable for
Substance
Element
s andIsotope
s are respectively right aligned inprint_tree_composition()
- added
- added internal conversion consistency case to "validation.py"
- added detailed air case to "validation.py"
- fixed problem with tree plotting of molecules, that lead to wrong atomic isotope vectors
- changed molar mass of molecule to average molar mass (as other substances)
- added molar mass of molecule (is calculated as before)
- added
_get_data_dict()
toSubstance
(andMolecule
) for more flexibility in tree plotting
- added option for
get_isotopes()
to supply explicit collection of (natural) elements to be considered
- fixed problem with molar mass of molecules, that lead to wrong atomic isotope vectors
- changed molar mass of molecule to average molar mass (as other substances)
- added molar mass of molecule (is calculated as before)
- added
_get_data_dict()
toSubstance
(andMolecule
) for more flexibility in tree plotting
- added option for
get_isotopes()
to supply explicit collection of (natural) elements to be considered
This updates marks a big overhaul of the code structure.
Element
, Molecule
and Mixture
now inherit from the abstract base class Substance
.
This will help in terms of future maintainability.
Volume fractions are introduced as a possible input for Mixture
s.
All modules, classes, methods and constants received docstrings for documentation and a more helpful API.
Now, all isotopes from the NIST database are implemented, increasing the available Isotope
object count from 357 to 3355.
Added Node
class for easier access to hierarchical tree structure of substances.
Furthermore, this class allows a tree structure print, that should be clearer than previous print methods.
Isotope
, Substance
and all subclasses received various additional attributes and methods for enhanced functionality.
- changes to
Isotope
:- added attribute relative atomic mass
A_r
- molar mass
M
is calculated viaA_r
and molar mass constantM_u
(according to 2019 redefinitions)
- molar mass
- added isomeric state
I
- added property
ZA
(notation) - added property
ZAI
(notation) - name is not longer a positional argument in constructor and is generated automatically, but can be overriden with
name
keyword - added
element_symbol()
method to get symbol of associated element
- added attribute relative atomic mass
- added all isotopes from NIST database
- total amount: 3355 isotopes
Substance
base class for maintainability- unified attributes and methods where possible
- renaming of internal variables to consent with physical quantities
- attribute
constituents
is now called more appropriatelycomposition
- attribute
- added attribute for density
rho
(necessary for volume fraction conversions)- can generally not be calculated and must be given explicitly during construction (as keyword argument)
- added attribute
symbol
for shorter names - added constructor argument
mode
for "atomic", "weight" and "volume" fractions as input- added dedicated constructor wrappers:
from_atomic()
,from_weight()
andfrom_volume()
- added dedicated constructor wrappers:
- constructor checks, if given constituents are allowed
- added methods to return compositions in weight fractions (
get_composition_in_wt()
) and volume fractions (get_composition_in_vol()
) - added properties for molar volume
V_m
and number densityn
- added methods to compute those values
- added methods
make_node()
andprint_tree()
for querrying and printing (see classNode
below) - changes to
get_isotopes()
method- keyword
mode
for either "atomic" or "weight" fractions - keyword
use_natural
to return elemental composition (only for natural elements)
- keyword
- changes to
Element
:- constituents in composition limited to
Isotope
objects - added attribute
is_natural
to mark implemented natural elements, that can alter the behaviour inget_isotopes()
method - added attribute
Z
as atomic number (similar toIsotope
) - added attribute relative atomic mass
A_r
- is calculated as weighted mean from its composition
- added
element_symbol()
method to getsymbol
- is used to generate
symbol
automatically
- is used to generate
- constituents in composition limited to
- changes to
Molecule
:- constituents in composition limited to
Element
objects - added attribute
atoms
to track number of atoms - added property
constituent_atoms
that returns composition dictionary not with fractions, but with number of eachElement
symbol
is automatically generated by its elements and their count (rough estimate of chemical symbol)
- constituents in composition limited to
- changes to
Mixture
:- constituents in composition limited to
Element
,Molecule
andMixture
objects - tries to calculate attribute
rho
by itself- only possible if all constituents have a density given
- only use case for new volume fractions
- constituents in composition limited to
- added
Node
class for easier access to hierarchical tree structure of substances- access
Substance
orIsotope
via the attributecontent
- additional information, like calculated (scaled) fractions, is stored in dictionary attribute
data
- keys: atomic fraction (
"x"
), weight fraction ("w"
), volume fraction ("phi"
), molar mass ("M"
) and density ("rho"
),
- keys: atomic fraction (
- querry tree structure via:
get_nodes_by_label()
: search for name ofNode
get_nodes_by_content()
: search forSubstance
orIsotope
object- returns a list of
Node
s that match criterion
print_tree()
method to print tree structure as such- additional
data
is printed as well - successor to
print_overview()
method
- additional
- access
- added docstrings (in accordance to Google Python Style Guide)
- better documentation
- improvements for API
- added all possible conversion methods for atomic and weight fractions, as well as newly introduced volume fractions
- changed official required Python version to 3.10 (might not be necessary)
- updated README and its tutorial to reflect changes and improvements
- removed custom exceptions (using default ones instead) and "exceptions.py"
- removed "printer.py"; separator strings are in "node.py"
- created "constants.py" for physical constants and mapping dictionaries for symbol and names of elements
- added volume fraction case to "validation.py"
- added comparison tables (package tabular) to "validation.py"
- ... probably lots of other stuff I've missed
The whole source code was adjusted to the PEP 8 Style Guide for Python Code.
This was no easy choice, as it would obviously break parts of the API.
However, isoVec is still a fairly new package and the user base therefore is most likely slim to none.
In favour of more consistency with standard and other popular Python packages, as well as future maintainability, the style of this package was changed.
Presumably, changes for users will be limited to the PrintOverview
method (now print_overview
) and the GetIsotopes
method (now get_isotopes
).
- adjusted naming convections to PEP 8 style guide (Docstrings will follow in the near future, presumably
- fixed a bug, when
get_isotopes
is called sequentially- the dictionary would unintentionally clutter up with isotopes from former calls
- since dictionaries are mutable objects and Python compiles functions (and thus their default values) at the beginning, the very same dictionary is used every call, even though an empty one should be created
- this beahviour is described nicely in an article by Don Cross
- added conversion functions:
- percent (per hundred):
percent
,perc
,pc
- per mille (per thousand):
permille
,pm
- per myriad (per ten thousand):
permyriad
,bp
- per cent mille (per hundred thousand):
percentmille
,pcm
- parts-per-million:
ppm
- parts-per-billion:
ppb
- parts-per-trillion:
ppt
- parts-per-quadrillion:
ppq
- percent (per hundred):
- initial release