From: Carsten Niehaus Date: Tue, 21 Feb 2006 17:03:16 +0000 (+0000) Subject: pinotree: please review X-Git-Tag: v3.80.2~159 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=a029c27269f817bab94aa6da572dfb3f39d2a3b8;p=libqmvoc.git pinotree: please review svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=512040 --- diff --git a/libscience/isotope.cpp b/libscience/isotope.cpp index e68bb01..452eed1 100644 --- a/libscience/isotope.cpp +++ b/libscience/isotope.cpp @@ -23,7 +23,7 @@ #include Isotope::Isotope() - : m_parentElementSymbol( 0 ), m_mass( 0 ), m_identifier( 0 ), +: m_parentElementSymbol( 0 ), m_mass( 0 ), m_identifier( 0 ), m_spin( 0 ), m_magmoment( 0 ), m_halflife( 0 ), m_ecdecay( 0 ), m_betaplus( 0 ), m_betaminus( 0 ), m_alpha( 0 ) { @@ -52,7 +52,7 @@ void Isotope::addData( ChemicalDataObject* o ) m_magmoment = o; else if ( o->type() == ChemicalDataObject::halfLife ) m_halflife = o; - + //FIXME in the future there should be real CDOs. But CDO only supports one datavalue... if ( o->type() == ChemicalDataObject::betaplusDecay ) m_betaplus = o; @@ -101,10 +101,38 @@ QString Isotope::parentElementSymbol() const void Isotope::setNucleons( int number ) { - m_nucleons = number; + int protons = m_identifier->value().toInt(); + int neutrons = number - protons; + m_nucleons.protons = protons; + m_nucleons.neutrons = neutrons; } int Isotope::nucleons() const { - return m_nucleons; + return m_nucleons.neutrons + m_nucleons.protons; +} + +Isotope::Nucleons Isotope::nucleonsAfterDecay( Decay kind ) +{ + Nucleons n = m_nucleons; + + switch ( kind ) + { + case ALPHA: + n.protons-=2; + break; + case BETAMINUS: + n.protons+=1; + n.neutrons-=1; + break; + case BETAPLUS: + n.protons-=1; + break; + case EC: + n.protons-=1; + n.neutrons+=1; + break; + } + + return n; } diff --git a/libscience/isotope.h b/libscience/isotope.h index 681559a..dae6b7a 100644 --- a/libscience/isotope.h +++ b/libscience/isotope.h @@ -38,6 +38,12 @@ class Isotope Isotope(); virtual ~Isotope(); + struct Nucleons + { + int neutrons; + int protons; + }; + ChemicalDataObject* data() const; double mass() const; @@ -93,6 +99,19 @@ class Isotope ChemicalDataObject* alphadecay() const{ return m_alpha; } + + enum Decay + { + ALPHA, + BETAPLUS, + BETAMINUS, + EC + }; + + /** + * @return the number of neutrons of the Isotope after the decay + */ + Isotope::Nucleons nucleonsAfterDecay( Decay kind ); private: /** * the symbol of the element the isotope belongs to @@ -123,13 +142,14 @@ class Isotope * stores the halfLife of the Isotope */ ChemicalDataObject* m_halflife; - - int m_nucleons; ChemicalDataObject* m_ecdecay; ChemicalDataObject* m_betaplus; ChemicalDataObject* m_betaminus; ChemicalDataObject* m_alpha; + + Isotope::Nucleons m_nucleons; + }; #endif // ISOTOPE_H