File indexing completed on 2024-04-21 03:41:36
0001 /* 0002 SPDX-FileCopyrightText: 2005 Carsten Niehaus <cniehaus@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "isotope.h" 0008 0009 0010 #include "kalzium_libscience_debug.h" 0011 0012 Isotope::Isotope() = default; 0013 0014 Isotope::~Isotope() = default; 0015 0016 void Isotope::addData(const ChemicalDataObject &o) 0017 { 0018 if (o.type() == ChemicalDataObject::exactMass) { 0019 m_mass = o; 0020 } else if (o.type() == ChemicalDataObject::atomicNumber) { 0021 m_identifier = o; 0022 } else if (o.type() == ChemicalDataObject::symbol) { 0023 m_parentElementSymbol = o; 0024 } else if (o.type() == ChemicalDataObject::spin) { 0025 m_spin = o; 0026 } else if (o.type() == ChemicalDataObject::magneticMoment) { 0027 m_magmoment = o; 0028 } else if (o.type() == ChemicalDataObject::relativeAbundance) { 0029 m_abundance = o; 0030 } else if (o.type() == ChemicalDataObject::halfLife) { 0031 m_halflife = o; 0032 } else if (o.type() == ChemicalDataObject::betaminusfissionDecay) { 0033 m_betaminusfissiondecay = o; 0034 } else if (o.type() == ChemicalDataObject::betaminusfissionDecayLikeliness) { 0035 m_betaminusfissionlikeliness = o; 0036 } else if (o.type() == ChemicalDataObject::alphaDecay) { 0037 m_alphadecay = o; 0038 } else if (o.type() == ChemicalDataObject::alphaDecayLikeliness) { 0039 m_alphalikeliness = o; 0040 } else if (o.type() == ChemicalDataObject::protonDecay) { 0041 m_protondecay = o; 0042 } else if (o.type() == ChemicalDataObject::protonDecayLikeliness) { 0043 m_protonlikeliness = o; 0044 } else if (o.type() == ChemicalDataObject::twoprotonDecay) { 0045 m_twoprotondecay = o; 0046 } else if (o.type() == ChemicalDataObject::twoprotonDecayLikeliness) { 0047 m_twoprotonlikeliness = o; 0048 } else if (o.type() == ChemicalDataObject::neutronDecay) { 0049 m_neutrondecay = o; 0050 } else if (o.type() == ChemicalDataObject::neutronDecayLikeliness) { 0051 m_neutronlikeliness = o; 0052 } else if (o.type() == ChemicalDataObject::twoneutronDecay) { 0053 m_twoneutrondecay = o; 0054 } else if (o.type() == ChemicalDataObject::twoneutronDecayLikeliness) { 0055 m_twoneutronlikeliness = o; 0056 } else if (o.type() == ChemicalDataObject::ecDecay) { 0057 m_ecdecay = o; 0058 } else if (o.type() == ChemicalDataObject::ecDecayLikeliness) { 0059 m_eclikeliness = o; 0060 } else if (o.type() == ChemicalDataObject::twoecDecay) { 0061 m_twoecdecay = o; 0062 } else if (o.type() == ChemicalDataObject::twoecDecayLikeliness) { 0063 m_twoeclikeliness = o; 0064 } else if (o.type() == ChemicalDataObject::betaminusDecay) { 0065 m_betaminusdecay = o; 0066 } else if (o.type() == ChemicalDataObject::betaminusDecayLikeliness) { 0067 m_betaminuslikeliness = o; 0068 } else if (o.type() == ChemicalDataObject::twobetaminusDecay) { 0069 m_twobetaminusdecay = o; 0070 } else if (o.type() == ChemicalDataObject::twobetaminusDecayLikeliness) { 0071 m_twobetaminuslikeliness = o; 0072 } else if (o.type() == ChemicalDataObject::betaplusDecay) { 0073 m_betaplusdecay = o; 0074 } else if (o.type() == ChemicalDataObject::betaplusDecayLikeliness) { 0075 m_betapluslikeliness = o; 0076 } else if (o.type() == ChemicalDataObject::twobetaplusDecay) { 0077 m_twobetaplusdecay = o; 0078 } else if (o.type() == ChemicalDataObject::twobetaplusDecayLikeliness) { 0079 m_twobetapluslikeliness = o; 0080 } else if (o.type() == ChemicalDataObject::betaminusneutronDecay) { 0081 m_betaminusneutrondecay = o; 0082 } else if (o.type() == ChemicalDataObject::betaminusneutronDecayLikeliness) { 0083 m_betaminusneutronlikeliness = o; 0084 } else if (o.type() == ChemicalDataObject::betaminustwoneutronDecay) { 0085 m_betaminustwoneutrondecay = o; 0086 } else if (o.type() == ChemicalDataObject::betaminustwoneutronDecayLikeliness) { 0087 m_betaminustwoneutronlikeliness = o; 0088 } else if (o.type() == ChemicalDataObject::betaminusthreeneutronDecay) { 0089 m_betaminusthreeneutrondecay = o; 0090 } else if (o.type() == ChemicalDataObject::betaminusthreeneutronDecayLikeliness) { 0091 m_betaminusthreeneutronlikeliness = o; 0092 } else if (o.type() == ChemicalDataObject::betaminusfourneutronDecay) { 0093 m_betaminusfourneutrondecay = o; 0094 } else if (o.type() == ChemicalDataObject::betaminusfourneutronDecayLikeliness) { 0095 m_betaminusfourneutronlikeliness = o; 0096 } else if (o.type() == ChemicalDataObject::betaminusalphaneutronDecay) { 0097 m_betaminusalphaneutrondecay = o; 0098 } else if (o.type() == ChemicalDataObject::betaminusalphaneutronDecayLikeliness) { 0099 m_betaminusalphaneutronlikeliness = o; 0100 } else if (o.type() == ChemicalDataObject::betaminusalphaDecay) { 0101 m_betaminusalphadecay = o; 0102 } else if (o.type() == ChemicalDataObject::betaminusalphaDecayLikeliness) { 0103 m_betaminusalphalikeliness = o; 0104 } else if (o.type() == ChemicalDataObject::betaminustwoalphaDecay) { 0105 m_betaminustwoalphadecay = o; 0106 } else if (o.type() == ChemicalDataObject::betaminustwoalphaDecayLikeliness) { 0107 m_betaminustwoalphalikeliness = o; 0108 } else if (o.type() == ChemicalDataObject::betaminusthreealphaDecay) { 0109 m_betaminusthreealphadecay = o; 0110 } else if (o.type() == ChemicalDataObject::betaminusthreealphaDecayLikeliness) { 0111 m_betaminusthreealphalikeliness = o; 0112 } else if (o.type() == ChemicalDataObject::betaplusprotonDecay) { 0113 m_betaplusprotondecay = o; 0114 } else if (o.type() == ChemicalDataObject::betaplusprotonDecayLikeliness) { 0115 m_betaplusprotonlikeliness = o; 0116 } else if (o.type() == ChemicalDataObject::betaplustwoprotonDecay) { 0117 m_betaplustwoprotondecay = o; 0118 } else if (o.type() == ChemicalDataObject::betaplustwoprotonDecayLikeliness) { 0119 m_betaplustwoprotonlikeliness = o; 0120 } else if (o.type() == ChemicalDataObject::betaplusalphaDecay) { 0121 m_betaplusalphadecay = o; 0122 } else if (o.type() == ChemicalDataObject::betaplusalphaDecayLikeliness) { 0123 m_betaplusalphalikeliness = o; 0124 } else if (o.type() == ChemicalDataObject::betaplustwoalphaDecay) { 0125 m_betaplustwoalphadecay = o; 0126 } else if (o.type() == ChemicalDataObject::betaplustwoalphaDecayLikeliness) { 0127 m_betaplustwoalphalikeliness = o; 0128 } else if (o.type() == ChemicalDataObject::betaplusthreealphaDecay) { 0129 m_betaplusthreealphadecay = o; 0130 } else if (o.type() == ChemicalDataObject::betaplusthreealphaDecayLikeliness) { 0131 m_betaplusthreealphalikeliness = o; 0132 } else if (o.type() == ChemicalDataObject::alphabetaminusDecay) { 0133 m_alphabetaminusdecay = o; 0134 } else if (o.type() == ChemicalDataObject::alphabetaminusDecayLikeliness) { 0135 m_alphabetaminuslikeliness = o; 0136 } else if (o.type() == ChemicalDataObject::protonalphaDecay) { 0137 m_protonalphadecay = o; 0138 } else if (o.type() == ChemicalDataObject::protonalphaDecayLikeliness) { 0139 m_protonalphalikeliness = o; 0140 } else if (o.type() == ChemicalDataObject::ecprotonDecay) { 0141 m_ecprotondecay = o; 0142 } else if (o.type() == ChemicalDataObject::ecprotonDecayLikeliness) { 0143 m_ecprotonlikeliness = o; 0144 } else if (o.type() == ChemicalDataObject::ectwoprotonDecay) { 0145 m_ectwoprotondecay = o; 0146 } else if (o.type() == ChemicalDataObject::ectwoprotonDecayLikeliness) { 0147 m_ectwoprotonlikeliness = o; 0148 } else if (o.type() == ChemicalDataObject::ecthreeprotonDecay) { 0149 m_ecthreeprotondecay = o; 0150 } else if (o.type() == ChemicalDataObject::ecthreeprotonDecayLikeliness) { 0151 m_ecthreeprotonlikeliness = o; 0152 } else if (o.type() == ChemicalDataObject::ecalphaDecay) { 0153 m_ecalphadecay = o; 0154 } else if (o.type() == ChemicalDataObject::ecalphaDecayLikeliness) { 0155 m_ecalphalikeliness = o; 0156 } else if (o.type() == ChemicalDataObject::ecalphaprotonDecay) { 0157 m_ecalphaprotondecay = o; 0158 } else if (o.type() == ChemicalDataObject::ecalphaprotonDecayLikeliness) { 0159 m_ecalphaprotonlikeliness = o; 0160 } else if (o.type() == ChemicalDataObject::spontfissionDecay) { 0161 m_spontfissiondecay = o; 0162 } else if (o.type() == ChemicalDataObject::spontfissionDecayLikeliness) { 0163 m_spontfissionlikeliness = o; 0164 } 0165 } 0166 0167 double Isotope::mass() const 0168 { 0169 return m_mass.value().toDouble(); 0170 } 0171 0172 QString Isotope::errorMargin() const 0173 { 0174 return m_mass.errorValue().toString(); 0175 } 0176 0177 int Isotope::parentElementNumber() const 0178 { 0179 return m_identifier.value().toInt(); 0180 } 0181 0182 QString Isotope::spin() const 0183 { 0184 return m_spin.value().toString(); 0185 } 0186 0187 QString Isotope::magmoment() const 0188 { 0189 return m_magmoment.value().toString(); 0190 } 0191 0192 QString Isotope::abundance() const 0193 { 0194 return m_abundance.value().toString(); 0195 } 0196 0197 double Isotope::halflife() const 0198 { 0199 return m_halflife.value().toDouble(); 0200 } 0201 0202 QString Isotope::halflifeUnit() const 0203 { 0204 return m_halflife.unitAsString(); 0205 } 0206 0207 double Isotope::betaminusfissiondecay() const 0208 { 0209 return m_betaminusfissiondecay.value().toDouble(); 0210 } 0211 0212 double Isotope::betaminusfissionlikeliness() const 0213 { 0214 return m_betaminusfissionlikeliness.value().toDouble(); 0215 } 0216 0217 double Isotope::alphadecay() const 0218 { 0219 return m_alphadecay.value().toDouble(); 0220 } 0221 double Isotope::alphalikeliness() const 0222 { 0223 return m_alphalikeliness.value().toDouble(); 0224 } 0225 double Isotope::protondecay() const 0226 { 0227 return m_protondecay.value().toDouble(); 0228 } 0229 double Isotope::protonlikeliness() const 0230 { 0231 return m_protonlikeliness.value().toDouble(); 0232 } 0233 double Isotope::twoprotondecay() const 0234 { 0235 return m_twoprotondecay.value().toDouble(); 0236 } 0237 double Isotope::twoprotonlikeliness() const 0238 { 0239 return m_twoprotonlikeliness.value().toDouble(); 0240 } 0241 double Isotope::neutrondecay() const 0242 { 0243 return m_neutrondecay.value().toDouble(); 0244 } 0245 double Isotope::neutronlikeliness() const 0246 { 0247 return m_neutronlikeliness.value().toDouble(); 0248 } 0249 double Isotope::twoneutrondecay() const 0250 { 0251 return m_twoneutrondecay.value().toDouble(); 0252 } 0253 double Isotope::twoneutronlikeliness() const 0254 { 0255 return m_twoneutronlikeliness.value().toDouble(); 0256 } 0257 double Isotope::ecdecay() const 0258 { 0259 return m_ecdecay.value().toDouble(); 0260 } 0261 double Isotope::eclikeliness() const 0262 { 0263 return m_eclikeliness.value().toDouble(); 0264 } 0265 double Isotope::twoecdecay() const 0266 { 0267 return m_twoecdecay.value().toDouble(); 0268 } 0269 double Isotope::twoeclikeliness() const 0270 { 0271 return m_twoeclikeliness.value().toDouble(); 0272 } 0273 double Isotope::betaminusdecay() const 0274 { 0275 return m_betaminusdecay.value().toDouble(); 0276 } 0277 double Isotope::betaminuslikeliness() const 0278 { 0279 return m_betaminuslikeliness.value().toDouble(); 0280 } 0281 double Isotope::twobetaminusdecay() const 0282 { 0283 return m_twobetaminusdecay.value().toDouble(); 0284 } 0285 double Isotope::twobetaminuslikeliness() const 0286 { 0287 return m_twobetaminuslikeliness.value().toDouble(); 0288 } 0289 double Isotope::betaplusdecay() const 0290 { 0291 return m_betaplusdecay.value().toDouble(); 0292 } 0293 double Isotope::betapluslikeliness() const 0294 { 0295 return m_betapluslikeliness.value().toDouble(); 0296 } 0297 double Isotope::twobetaplusdecay() const 0298 { 0299 return m_twobetaplusdecay.value().toDouble(); 0300 } 0301 double Isotope::twobetapluslikeliness() const 0302 { 0303 return m_twobetapluslikeliness.value().toDouble(); 0304 } 0305 double Isotope::betaminusneutrondecay() const 0306 { 0307 return m_betaminusneutrondecay.value().toDouble(); 0308 } 0309 double Isotope::betaminusneutronlikeliness() const 0310 { 0311 return m_betaminusneutronlikeliness.value().toDouble(); 0312 } 0313 double Isotope::betaminustwoneutrondecay() const 0314 { 0315 return m_betaminustwoneutrondecay.value().toDouble(); 0316 } 0317 double Isotope::betaminustwoneutronlikeliness() const 0318 { 0319 return m_betaminustwoneutronlikeliness.value().toDouble(); 0320 } 0321 double Isotope::betaminusthreeneutrondecay() const 0322 { 0323 return m_betaminusthreeneutrondecay.value().toDouble(); 0324 } 0325 double Isotope::betaminusthreeneutronlikeliness() const 0326 { 0327 return m_betaminusthreeneutronlikeliness.value().toDouble(); 0328 } 0329 double Isotope::betaminusfourneutrondecay() const 0330 { 0331 return m_betaminusfourneutrondecay.value().toDouble(); 0332 } 0333 double Isotope::betaminusfourneutronlikeliness() const 0334 { 0335 return m_betaminusfourneutronlikeliness.value().toDouble(); 0336 } 0337 double Isotope::betaminusalphaneutrondecay() const 0338 { 0339 return m_betaminusalphaneutrondecay.value().toDouble(); 0340 } 0341 double Isotope::betaminusalphaneutronlikeliness() const 0342 { 0343 return m_betaminusalphaneutronlikeliness.value().toDouble(); 0344 } 0345 double Isotope::betaminusalphadecay() const 0346 { 0347 return m_betaminusalphadecay.value().toDouble(); 0348 } 0349 double Isotope::betaminusalphalikeliness() const 0350 { 0351 return m_betaminusalphalikeliness.value().toDouble(); 0352 } 0353 double Isotope::betaminustwoalphadecay() const 0354 { 0355 return m_betaminustwoalphadecay.value().toDouble(); 0356 } 0357 double Isotope::betaminustwoalphalikeliness() const 0358 { 0359 return m_betaminustwoalphalikeliness.value().toDouble(); 0360 } 0361 double Isotope::betaminusthreealphadecay() const 0362 { 0363 return m_betaminusthreealphadecay.value().toDouble(); 0364 } 0365 double Isotope::betaminusthreealphalikeliness() const 0366 { 0367 return m_betaminusthreealphalikeliness.value().toDouble(); 0368 } 0369 double Isotope::betaplusprotondecay() const 0370 { 0371 return m_betaplusprotondecay.value().toDouble(); 0372 } 0373 double Isotope::betaplusprotonlikeliness() const 0374 { 0375 return m_betaplusprotonlikeliness.value().toDouble(); 0376 } 0377 double Isotope::betaplustwoprotondecay() const 0378 { 0379 return m_betaplustwoprotondecay.value().toDouble(); 0380 } 0381 double Isotope::betaplustwoprotonlikeliness() const 0382 { 0383 return m_betaplustwoprotonlikeliness.value().toDouble(); 0384 } 0385 double Isotope::betaplusalphadecay() const 0386 { 0387 return m_betaplusalphadecay.value().toDouble(); 0388 } 0389 double Isotope::betaplusalphalikeliness() const 0390 { 0391 return m_betaplusalphalikeliness.value().toDouble(); 0392 } 0393 double Isotope::betaplustwoalphadecay() const 0394 { 0395 return m_betaplustwoalphadecay.value().toDouble(); 0396 } 0397 double Isotope::betaplustwoalphalikeliness() const 0398 { 0399 return m_betaplustwoalphalikeliness.value().toDouble(); 0400 } 0401 double Isotope::betaplusthreealphadecay() const 0402 { 0403 return m_betaplusthreealphadecay.value().toDouble(); 0404 } 0405 double Isotope::betaplusthreealphalikeliness() const 0406 { 0407 return m_betaplusthreealphalikeliness.value().toDouble(); 0408 } 0409 double Isotope::alphabetaminusdecay() const 0410 { 0411 return m_alphabetaminusdecay.value().toDouble(); 0412 } 0413 double Isotope::alphabetaminuslikeliness() const 0414 { 0415 return m_alphabetaminuslikeliness.value().toDouble(); 0416 } 0417 double Isotope::protonalphadecay() const 0418 { 0419 return m_protonalphadecay.value().toDouble(); 0420 } 0421 double Isotope::protonalphalikeliness() const 0422 { 0423 return m_protonalphalikeliness.value().toDouble(); 0424 } 0425 double Isotope::ecprotondecay() const 0426 { 0427 return m_ecprotondecay.value().toDouble(); 0428 } 0429 double Isotope::ecprotonlikeliness() const 0430 { 0431 return m_ecprotonlikeliness.value().toDouble(); 0432 } 0433 double Isotope::ectwoprotondecay() const 0434 { 0435 return m_ectwoprotondecay.value().toDouble(); 0436 } 0437 double Isotope::ectwoprotonlikeliness() const 0438 { 0439 return m_ectwoprotonlikeliness.value().toDouble(); 0440 } 0441 double Isotope::ecthreeprotondecay() const 0442 { 0443 return m_ecthreeprotondecay.value().toDouble(); 0444 } 0445 double Isotope::ecthreeprotonlikeliness() const 0446 { 0447 return m_ecthreeprotonlikeliness.value().toDouble(); 0448 } 0449 double Isotope::ecalphadecay() const 0450 { 0451 return m_ecalphadecay.value().toDouble(); 0452 } 0453 double Isotope::ecalphalikeliness() const 0454 { 0455 return m_ecalphalikeliness.value().toDouble(); 0456 } 0457 double Isotope::ecalphaprotondecay() const 0458 { 0459 return m_ecalphaprotondecay.value().toDouble(); 0460 } 0461 double Isotope::ecalphaprotonlikeliness() const 0462 { 0463 return m_ecalphaprotonlikeliness.value().toDouble(); 0464 } 0465 double Isotope::spontfissiondecay() const 0466 { 0467 return m_spontfissiondecay.value().toDouble(); 0468 } 0469 double Isotope::spontfissionlikeliness() const 0470 { 0471 return m_spontfissionlikeliness.value().toDouble(); 0472 } 0473 0474 QString Isotope::parentElementSymbol() const 0475 { 0476 return m_parentElementSymbol.value().toString(); 0477 } 0478 0479 void Isotope::setNucleons(int number) 0480 { 0481 m_numberOfNucleons = number; 0482 } 0483 0484 int Isotope::nucleons() const 0485 { 0486 return m_numberOfNucleons; 0487 } 0488 0489 Isotope::Nucleons Isotope::nucleonsAfterDecay(Decay kind) 0490 { 0491 Isotope::Nucleons n; 0492 int protons = m_identifier.value().toInt(); 0493 int neutrons = m_numberOfNucleons - protons; 0494 n.protons = protons; 0495 n.neutrons = neutrons; 0496 0497 switch (kind) { 0498 case ALPHA: 0499 n.protons -= 2; 0500 break; 0501 case ALPHABETAMINUS: 0502 n.protons -= 1; 0503 n.neutrons -= 1; 0504 break; 0505 case BETAMINUS: 0506 n.protons += 1; 0507 n.neutrons -= 1; 0508 break; 0509 case BETAPLUS: 0510 n.protons -= 1; 0511 break; 0512 case EC: 0513 n.protons -= 1; 0514 n.neutrons += 1; 0515 break; 0516 case NEUTRON: 0517 n.neutrons -= 1; 0518 break; 0519 case PROTON: 0520 n.protons -= 1; 0521 break; 0522 } 0523 0524 return n; 0525 }