15#include "tkstate_time.h"
16#include "tkn_sqlite3.h"
34vector<int> tknucleus::fmagic_number_list{2, 8, 20, 28, 50, 82, 126};
46 tkstring symbol = gmanager->get_element_symbol(_Z);
48 glog << warning <<
"Unknown nucleus. No properties loaded " << tkstring::form(
"(%d,%d)", _Z, _A) << do_endl;
52 if (!gmanager->known_nucleus(symbol)) {
53 glog << warning <<
"Unknown nucleus. No properties loaded (" << symbol <<
")" << do_endl;
56 const tknucleus &nuc = *gmanager->get_nucleus(symbol).get();
67 if (!gmanager->known_element(_Z))
68 glog <<
warning <<
"Unknown element. No properties loaded" <<
do_endl;
70 shared_ptr<tknucleus> bestnuc;
71 for (const auto &nuc : gmanager->get_nuclei_for_z(_Z)) {
72 if (bestnuc == nullptr)
74 else if (isnan(bestnuc->get_lifetime()) || (nuc->get_lifetime() > bestnuc->get_lifetime()))
76 else if (nuc->get_lifetime() == bestnuc->get_lifetime() && nuc->get_abundance() > bestnuc->get_abundance())
91 if (!gmanager->known_nucleus(
tkstring(_symbol))) {
93 if (gmanager->known_element(
tkstring(_symbol), z)) {
95 glog <<
warning <<
"Unknown nucleus. TkN will choose one for you ;)" <<
do_endl;
101 glog <<
warning <<
"Unknown nucleus. No properties loaded (" << _symbol <<
")" <<
do_endl;
104 const tknucleus &nuc = *gmanager->get_nucleus(_symbol);
108void tknucleus::set_name(
const char *_name)
117 if (std::find(fmagic_number_list.begin(), fmagic_number_list.end(), fZ) != fmagic_number_list.end())
return true;
123 if (std::find(fmagic_number_list.begin(), fmagic_number_list.end(), fN) != fmagic_number_list.end())
return true;
142 return get(
"radius")->get_value();
154 if (!
has_property(
"magnetic_dipole"))
return std::nan(
"1");
155 return get(
"magnetic_dipole")->get_value();
167 if (!
has_property(
"electric_quadrupole"))
return std::nan(
"1");
168 return get(
"electric_quadrupole")->get_value();
181 return get(
"abundance")->get_value();
195 glog <<
error << gunits->get_name(_unit) <<
" is not of 'energy' type (returns nan(1))" <<
do_endl;
196 return std::nan(
"1");
198 return get(
"mass_excess")->get_value(_unit);
210 if (!
has_property(
"binding_energy_overA"))
return std::nan(
"1");
212 glog <<
error << gunits->get_name(_unit) <<
" is not of 'energy' type (returns nan(1))" <<
do_endl;
213 return std::nan(
"1");
215 return get(
"binding_energy_overA")->get_value(_unit);
241 glog <<
error << gunits->get_name(_unit) <<
" is not of 'time' or 'energy' type (returns nan(1))" <<
do_endl;
242 return std::nan(
"1");
244 return get(
"lifetime")->get_value(_unit);
263 if (_cumulative) _parent.
prepend(
"c");
265 return get(_parent)->get_value();
278 lifetime_str =
"STABLE";
285 for (
auto &unit : units) {
317 if (!
has_property(
"binding_energy_overA"))
return false;
318 return get(
"binding_energy_overA")->get_value() > 0;
328 vector<pair<tkstring, double>> decay_list;
330 auto tokkens = decays.replace_all(
"[",
"]").tokenize(
"]");
331 for (
auto &dec : tokkens) {
332 auto tokk = dec.tokenize(
";");
333 decay_list.push_back({tokk.front(), tokk.back().atof()});
355 glog <<
info << fSymbol <<
" (Z=" << fZ <<
", N=" << fN <<
") properties:" <<
do_endl;
356 glog <<
info <<
"Ground state configuration: ";
Represents a nucleus and provides access to its properties.
double get_mass_excess(const tkunit_manager::units_keys _unit=tkunit_manager::units_keys::keV)
return the mass excess in keV by default
const tkstring & get_jpi() const
return the ground state spin and parity as a string
int get_a()
return the mass number
vector< pair< tkstring, double > > get_decay_modes()
return the decay modes as a vector of decay
double get_radius() const
returns the radius in fm
bool is_n_magic()
return true in case of n is a magic number
double get_lifetime(const tkunit_manager::units_keys _unit=tkunit_manager::units_keys::s)
double get_mean_lifetime(tkunit_manager::units_keys _unit=tkunit_manager::s)
Ground-state mean lifetime tau = T1/2 / ln(2); time units only.
bool is_stable() const
test if the nucleus is stable
double get_abundance() const
returns the natural abundance in percent
tknucleus()
default constructor
double get_fission_yield(tkstring _parent, bool _cumulative=false)
returns the fission yield of the current nucleus
tkstring get_lifetime_str()
Legacy formatting of T1/2 or Gamma (not mean lifetime).
double get_decay_width(tkunit_manager::units_keys _unit=tkunit_manager::keV)
Ground-state width Gamma = hbar/tau; energy units only. Stable: 0; absent: NaN.
shared_ptr< tklevel > get_ground_state()
return the ground state level (nullptr if no GS known)
bool is_z_magic()
return true in case of z is a magic number
int get_z()
return the proton number
shared_ptr< tklevel_scheme > get_level_scheme()
return a tklevel_scheme shared pointer to the nucleus level scheme
double get_electric_quadrupole()
return the electric quadrupole moment in barn by default
shared_ptr< tkmeasure > get_lifetime_measure() const
Legacy stored measure: half-life in time units, width in energy units.
void print() const
print the main nucleus properties
const tkstring & get_symbol()
return the nucleus symbol
double get_half_life(tkunit_manager::units_keys _unit=tkunit_manager::s)
Ground-state half-life T1/2; time units only. Stable: +inf; absent/invalid: NaN.
double get_magnetic_dipole()
return the magnetic dipole moment in mun by default
tkstring get_decay_mode_str()
return the decay modes as a string
double get_binding_energy_over_a(const tkunit_manager::units_keys _unit=tkunit_manager::units_keys::MeV)
returns the binding energy per mass unit in MeV
bool is_bound() const
test if the nucleus is bound (positive binding energy)
bool has_property(const tkstring &_property) const
to check if the property is available
shared_ptr< tkmeasure > get(const tkstring &_property) const
get the property as tkmeasure
tkproperty_list(tkstring _name)
tkstring get_property(const tkstring &_property) const
get the property value as a string
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
tkstring extract_alpha()
Returns a tkstring composed only of the alphabetic letters of the original tkstring.
static const char * form(const char *_format,...)
static tkstring Form(const char *_format,...)
int atoi() const
Converts a string to integer value.
tkstring & prepend(const tkstring &_st)
bool begins_with(const char *_s, ECaseCompare _cmp=kExact) const
units_keys
units identifiers
static const std::vector< std::tuple< tkstring, units_type, double > > funits_properties
double state_time_value(const shared_ptr< tkmeasure > &measure, bool stable, tkunit_manager::units_keys unit, bool width)
tklog & error(tklog &log)
tklog & do_endl(tklog &log)
tklog & warning(tklog &log)