|
The Isotope class models an isotope. More...
Header: | #include <Isotope.hpp> |
Isotope(int id, QString element, QString symbol, int atomicNo, double mass, int massNo, int extraNeutrons, double probability, double lnProbability, bool radioactive) | |
Isotope(const QString &text) | |
Isotope(const Isotope &other) | |
virtual | ~Isotope() |
int | getAtomicNo() const |
QString | getElement() const |
int | getExtraNeutrons() const |
int | getId() const |
double | getLnProbability() const |
double | getMass() const |
int | getMassNo() const |
double | getProbability() const |
bool | getRadioactive() const |
QString | getSymbol() const |
bool | initialize(const QString &text) |
void | setAtomicNo(int atomic_number) |
void | setElement(const QString &element) |
void | setExtraNeutrons(int extra_neutrons) |
void | setId(int id) |
void | setLnProbability(double ln_probability) |
void | setMass(double mass) |
void | setMassNo(int mass_number) |
void | setProbability(double probability) |
void | setRadioactive(bool is_radioactive) |
void | setSymbol(const QString &symbol) |
QString | toString() const |
int | validate(QString *errors_p = nullptr) const |
bool | operator!=(const Isotope &other) const |
virtual Isotope & | operator=(const Isotope &other) |
bool | operator==(const Isotope &other) const |
int | m_atomicNo |
QString | m_element |
int | m_extraNeutrons |
int | m_id |
double | m_lnProbability |
double | m_mass |
int | m_massNo |
double | m_probability |
bool | m_radioactive |
QString | m_symbol |
The Isotope class models an Isotope by featuring all the methods and member data required to fully characterize an isotope. The member data in this class have been inspired by the element tables from the IsoSpec library. Please, see https://github.com/MatteoLacki/IsoSpec/.
Constructs the Isotope with all the required arguments.
The isotope is created as a fully documented instance if all the following parameters a correctly set:
id MsXpS::libXpertMass::Isotope::m_id
element MsXpS::libXpertMass::Isotope::m_element
symbol MsXpS::libXpertMass::Isotope::m_symbol
atomicNo MsXpS::libXpertMass::Isotope::m_atomicNo
mass MsXpS::libXpertMass::Isotope::m_mass
massNo MsXpS::libXpertMass::Isotope::m_massNo
extraNeutrons MsXpS::libXpertMass::Isotope::m_extraNeutrons
probability MsXpS::libXpertMass::Isotope::m_probability
lnProbability MsXpS::libXpertMass::Isotope::m_lnProbability
radioactive MsXpS::libXpertMass::Isotope::m_radioactive
Constructs the Isotope using all the data in the text string.
The strings contains all the Isotope data, separated by a comma ',' exactly with the same format as that implemented by Isotope::toString().
See also Isotope::initialize() and Isotope::toString().
Constructs the Isotope as a copy of other.
[virtual noexcept]
Isotope::~Isotope()Destructs the Isotope.
Returns the atomic number of the isotope.
See also setAtomicNo().
Returns the element of the isotope.
See also setElement().
Returns the extra neutrons of the isotope.
See also setExtraNeutrons().
Returns the id of the isotope.
See also setId().
Returns the ln(probability) of the isotope.
See also setLnProbability().
Returns the mass of the isotope.
See also setMass().
Returns the mass number of the isotope.
See also setMassNo().
Returns the probability (the abundance) of the isotope.
See also setProbability().
Returns true if the isotope is radioactive, false otherwise.
See also setRadioactive().
Returns the symbol of the isotope.
See also setSymbol().
Initializes the Isotope using all the data in the text string.
The string passed as argument is QString::simplified() and QString::split() with ',' as the delimiter.
The obtained strings are converted to the corresponding numerical or textual values to initalize all the member data. The code is similar to:
m_radioactive = string_list[static_cast<int>(IsotopeFields::RADIOACTIVE)].toInt(&ok); if(!ok) { qDebug() << "Failed to extract the isotope radioactive."; return false; }
Returns true if the string contained valid substrings that successfully initialized the Isotope, false otherwise.
See also Isotope::Isotope(const QString &text).
Sets the the atomic number of the isotope to atomic_number.
See also getAtomicNo().
Sets the element of the isotope to element.
See also getElement().
Sets the extra neutrons of the isotope to extra_neutrons.
See also getExtraNeutrons().
Sets the id of the isotope to id.
See also getId().
Sets the ln(probability) of the isotope to ln_probability.
See also getLnProbability().
Sets the the mass of the isotope to mass.
See also getMass().
Sets the the mass number of the isotope to mass_number.
See also getMassNo().
Sets the probability (the abundance) of the isotope to probability.
See also getProbability().
Sets if the isotope is radioactive to is_radioactive.
See also getRadioactive().
Sets the symbol of the isotope to symbol.
See also getSymbol().
Returns a string containing a comma-separated textual representation of all the member data values.
All the member data values are separated using commas ','. Only the values are stored in the string, without naming the variables:
return QString("%1,%2,%3,%4,%5,%6,%7,%8,%9,%10") .arg(m_id) .arg(m_element) .arg(m_symbol) .arg(m_atomicNo) .arg(m_mass, 0, 'f', 60) .arg(m_massNo) .arg(m_extraNeutrons) .arg(m_probability, 0, 'f', 60) .arg(m_lnProbability, 0, 'f', 60) .arg(m_radioactive ? 1 : 0);
Returns a string.
Validates the isotope.
The symbol, mass and probability member data are scrutinized and if errors are detected an error counter is incremented.
errors_p Pointer to a string where the detected errors (if any) are stored as meaningful strings. If errors_p is nullptr, the errors are not stored.
if(m_symbol.isEmpty()) { ++error_count; errors += "The symbol is not set."; }
Returns the error count. If no error occurred, the returned value is 0.
Tests the inequality between this isotope and other.
Computes the negation of the result obtained by calling operator==().
Returns true if at lease one difference has been encountered and false otherwise.
See also operator==().
[virtual]
Isotope &Isotope::operator=(const Isotope &other)Assigns to this isotope the other isotope's member data.
Each member datum in other is copied to this isotope.
Returns a reference to this isotope.
Tests the equality between this isotope and other.
Each member datum in other is compared to this isotope's member datum. If a difference is detected, a counter is incremented.
Returns true if no difference has been encountered (the counter is 0) and false otherwise.
See also operator!=().
This variable holds the atomic number (Z), like 6 for "C", number of protons.
This variable holds the element, like "carbon" or "nitrogen" (lowercase).
This variable holds the extra neutrons in the isotope's nucleus.
This variable holds the unambiguous id for the chemical element (Hydrogen: 1, Helium, 2, Carbon 6, for example). The id is repeated for each isotope of each chemical element.
This variable holds the ln (natural logarithm) of the probability p
(eln(p)=p).
This variable holds the mass.
This variable holds the mass number, (A) like 12 for "C", number of (protons + neutrons).
This variable holds the probability of this isotope, that is, its abundance.
This variable holds the true if the isotope is unstable (disintegrates), false otherwise.
This variable holds the symbol, like "C" or "N".