Commit 4c7a6747 authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Merge branch 'radixio_updates' into 'master'

Radixio updates

See merge request !101
parents 4879391b 65e45d78
Pipeline #152990 passed with stages
in 17 minutes and 56 seconds
......@@ -7,6 +7,7 @@ SET(SOURCE
cfgfile.cc
eafstream.cc
endian.cc
emitdb.cc
decaydb.cc
gfsfile.cc
f71stream.cc
......@@ -21,6 +22,7 @@ SET(HEADERS
cfgfile.hh
eafstream.hh
endian.hh
emitdb.hh
decaydb.hh
gfsfile.hh
f71stream.hh
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -4,6 +4,7 @@
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
#include "radixcore/visibility.hh"
......@@ -63,7 +64,7 @@ struct DecayDBEntry
guides for continuous ingestion (from water) and inhalation (from air) in
unrestricted areas, in units of curies per cubic meter (Ci m ). -3 The RCG
values, as defined in the pre-1991 version of Part 10, Title 20, of the Code
of Federal Regulations16 (10CFR20), specify the maximum permissible
of Federal Regulations 16 (10CFR20), specify the maximum permissible
concentrations of an isotope in soluble and insoluble forms, for both
ingestion and inhalation, and for occupational and unrestricted exposure.
When the activity (in curies) of a given isotope is divided by WMPC (or
......@@ -80,7 +81,7 @@ struct DecayDBEntry
guides for continuous ingestion (from water) and inhalation (from air) in
unrestricted areas, in units of curies per cubic meter (Ci m ). -3 The RCG
values, as defined in the pre-1991 version of Part 10, Title 20, of the Code
of Federal Regulations16 (10CFR20), specify the maximum permissible
of Federal Regulations 16 (10CFR20), specify the maximum permissible
concentrations of an isotope in soluble and insoluble forms, for both
ingestion and inhalation, and for occupational and unrestricted exposure.
When the activity (in curies) of a given isotope is divided by WMPC (or
......@@ -111,10 +112,15 @@ struct DecayDBEntry
**/
std::array<float, 8> fractions;
int zaid() { return z * 10000 + a * 10 + m; }
bool operator==(const DecayDBEntry& rhs) const
{
return (z == rhs.z && a == rhs.a && m == rhs.m);
}
}; // struct
}; // struct DecayDBEntry
class RADIX_PUBLIC DecayDb
{
public:
std::unordered_map<int, DecayDBEntry> mActivation;
std::unordered_map<int, DecayDBEntry> mActinide;
std::unordered_map<int, DecayDBEntry> mFissionProduct;
......@@ -124,15 +130,28 @@ class RADIX_PUBLIC DecayDb
public:
DecayDb();
float calculate_activity(int zaid, float abundance) const;
float calculate_activity(int zaid, float lp_abundance, float ap_abundance,
float fp_abundance) const;
std::string activation_title() const;
std::string actinide_title() const;
std::string fission_product_title() const;
const std::string& activation_title() const;
const std::string& actinide_title() const;
const std::string& fission_product_title() const;
void set_activation_title(const std::string& title);
void set_actinide_title(const std::string& title);
void set_fission_product_title(const std::string& title);
std::unordered_map<int, DecayDBEntry>& activations();
const std::unordered_map<int, DecayDBEntry>& activations() const;
const DecayDBEntry& light_element(const int zaid) const;
std::unordered_map<int, DecayDBEntry>& actinides();
const std::unordered_map<int, DecayDBEntry>& actinides() const;
const DecayDBEntry& actinide(const int zaid) const;
std::unordered_map<int, DecayDBEntry>& fission_products();
const std::unordered_map<int, DecayDBEntry>& fission_products() const;
const DecayDBEntry& fission_product(const int zaid) const;
const std::unordered_map<int, DecayDBEntry>::iterator find_decayer(
const int zaid);
const DecayDBEntry& find_entry(const int zaid) const;
}; // class
} // namespace radix
#endif /** RADIX_RADIXIO_DECAYDB_HH_ */
#include <fstream>
#include "radixcore/stringfunctions.hh"
#include "radixcore/system.hh"
#include "radixio/emitdb.hh"
namespace radix
{
EmitDb::EmitDb()
{
// load_mpdkxgam(EmitDb::XGAMDATA4);
// load_mpdkxgam(EmitDb::XGAMDATA3);
// load_ensdfbeta(EmitDb::BETADATA);
}
EmitDb::EmitDb(const EmitDb& orig)
{
mIsotope = orig.mIsotope;
mIsotopeTitle = orig.mIsotopeTitle;
}
void XGamDb::load(const std::string& file, EmitDb& database)
{
std::string revStr = radix::split_string(".", file)[1];
int revNum = std::atoi(revStr.substr(revStr.size() - 1, 1).c_str());
int indexThreshold = 70, indexIterator = 20;
int linecount = 0;
if (revNum == 3)
{
indexThreshold = 70;
indexIterator = 20;
}
else if (revNum == 4)
{
indexThreshold = 77;
indexIterator = 22;
}
std::ifstream xgamFile(file);
std::string line, prev;
std::vector<float> energies, intensities;
int zaid = -1;
int totalLines = 0;
float totalEnergy = 0.f;
auto& isotopes = database.isotopes();
while (std::getline(xgamFile, line))
{
linecount += 1;
int thisZaid = std::atoi(line.substr(1, 6).c_str());
if (thisZaid != 0)
{
if (zaid != -1 && energies.size() > 0)
{
EmitDBEntry emitEntry;
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.energy = totalEnergy;
emitEntry.energies = energies;
emitEntry.intensities = intensities;
isotopes.insert(std::make_pair(zaid, emitEntry));
energies.clear();
intensities.clear();
}
zaid = thisZaid;
// totalLines = std::atoi(line.substr(9, 12).c_str());
totalEnergy = std::atof(line.substr(60, 10).c_str());
}
else
{
int index = 3;
int jumpLength = 10;
if (revNum == 3)
{
index = 10;
jumpLength = 10;
}
else
{
index = 10;
jumpLength = 11;
}
while (index < indexThreshold && index < line.size())
{
float energy = std::atof(line.substr(index, 10).c_str());
float intensity =
std::atof(line.substr(index + jumpLength, 10).c_str());
energies.push_back(energy);
intensities.push_back(intensity);
index += indexIterator;
}
}
prev = line;
}
EmitDBEntry emitEntry;
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.energy = totalEnergy;
emitEntry.energies = energies;
emitEntry.intensities = intensities;
isotopes.insert(std::make_pair(zaid, emitEntry));
energies.clear();
intensities.clear();
}
void EnsdfBetaDb::load(const std::string& file, EmitDb& database)
{
std::ifstream betaFile(file);
std::string line, prev;
int zaidCount = 0;
int zaid = -1;
int linecount = 0;
std::vector<float> energies, intensities;
auto& isotopes = database.isotopes();
while (std::getline(betaFile, line))
{
linecount += 1;
if (line.substr(0, 2) == " ")
{
if (line.size() > 10)
{
int zaidl = std::atoi(line.substr(2, 6).c_str());
if (zaid != zaidl)
{
zaid = zaidl;
}
zaidCount++;
float intensity = std::atof(line.substr(10, 8).c_str());
float energy = std::atof(line.substr(19, 9).c_str());
energies.push_back(energy);
intensities.push_back(intensity);
}
else
{
if (energies.size() > 0 && zaid != -1)
{
float totalEnergy = 0.0f;
for (size_t i = 0; i < intensities.size(); ++i)
{
totalEnergy += (intensities[i] * energies[i]);
}
EmitDBEntry emitEntry;
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.energy = totalEnergy;
emitEntry.energies = energies;
emitEntry.intensities = intensities;
const auto& isOutside =
isotopes.insert(std::make_pair(zaid, emitEntry));
if (!isOutside.second)
{
isOutside.first->second.energy = totalEnergy;
isOutside.first->second.energies = energies;
isOutside.first->second.intensities = intensities;
}
zaidCount = 0;
energies.clear();
intensities.clear();
}
}
}
prev = line;
}
if (energies.size() > 0)
{
float totalEnergy = 0.0f;
for (size_t i = 0; i < intensities.size(); ++i)
{
totalEnergy += (intensities[i] * energies[i]);
}
EmitDBEntry emitEntry;
emitEntry.z = int(zaid / 10000);
emitEntry.a = int((zaid % 10000) / 10);
emitEntry.m = int(zaid % 10);
emitEntry.energy = totalEnergy;
emitEntry.energies = energies;
emitEntry.intensities = intensities;
const auto& isOutside = isotopes.insert(std::make_pair(zaid, emitEntry));
if (!isOutside.second)
{
isOutside.first->second.energy = totalEnergy;
isOutside.first->second.energies = energies;
isOutside.first->second.intensities = intensities;
}
energies.clear();
intensities.clear();
}
}
const std::string& EmitDb::isotope_title() const { return mIsotopeTitle; }
void EmitDb::set_isotope_title(const std::string& title)
{
mIsotopeTitle = title;
}
const std::unordered_map<int, EmitDBEntry>& EmitDb::isotopes() const
{
return mIsotope;
}
std::unordered_map<int, EmitDBEntry>& EmitDb::isotopes() { return mIsotope; }
const EmitDBEntry& EmitDb::emitter(int zaid) const
{
const auto& it = mIsotope.find(zaid);
return it->second;
}
std::vector<std::vector<float>> EmitDb::energy_intensities(const int zaid) const
{
const auto& it = mIsotope.find(zaid);
const std::vector<float>& energies = it->second.energies;
const std::vector<float>& intensities = it->second.intensities;
std::vector<std::vector<float>> paired = {energies, intensities};
return paired;
}
void EmitDb::operator=(const EmitDb& orig)
{
mIsotope = orig.mIsotope;
mIsotopeTitle = orig.mIsotopeTitle;
}
} // namespace radix
#ifndef RADIX_RADIXIO_EMITDB_HH_
#define RADIX_RADIXIO_EMITDB_HH_
#include <string>
#include <unordered_map>
#include <vector>
#include "radixcore/visibility.hh"
namespace radix
{
struct RADIX_PUBLIC EmitDBEntry
{
/**
* symbol
**/
int z;
/**
* atomic number
**/
int a;
/**
* metastable state
**/
int m;
/**
* The variable energy, total energy of emission (xgam or beta) emitted by
*isotope
**/
float energy;
/**
* The energies of each xgam or beta in dataset
**/
std::vector<float> energies;
/**
* The intensities of each energy in dataset
**/
std::vector<float> intensities;
int zaid() { return z * 10000 + a * 10 + m; }
bool operator==(const EmitDBEntry& rhs) const
{
return (z == rhs.z && a == rhs.a && m == rhs.m);
}
}; // struct EmitDBEntry
class RADIX_PUBLIC EmitDb
{
// const std::string XGAMDATA3 = "origen.rev03.mpdkxgam.data";
// const std::string XGAMDATA4 = "origen.rev04.mpdkxgam.data";
// const std::string BETADATA = "origen.rev00.ensdf95beta.data";
public:
std::unordered_map<int, EmitDBEntry> mIsotope;
std::string mIsotopeTitle;
public:
EmitDb();
EmitDb(const EmitDb& orig);
void operator=(const EmitDb& orig);
const std::string& isotope_title() const;
void set_isotope_title(const std::string& title);
const std::unordered_map<int, EmitDBEntry>& isotopes() const;
std::unordered_map<int, EmitDBEntry>& isotopes();
const EmitDBEntry& emitter(int zaid) const;
std::vector<std::vector<float>> energy_intensities(int zaid) const;
}; // class EmitDb
class RADIX_PUBLIC XGamDb : public EmitDb
{
public:
static void load(const std::string& file, EmitDb& database);
};
class RADIX_PUBLIC EnsdfBetaDb : public EmitDb
{
public:
static void load(const std::string& file, EmitDb& database);
};
} // namespace radix
#endif /** RADIX_RADIXIO_EMITDB_HH_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment