Commit 90480293 authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Updating DecayDb calculate_activity to take light/actinide/fission product...

Updating DecayDb calculate_activity to take light/actinide/fission product abundances in calculation.
parent 660298bf
Pipeline #12712 passed with stages
in 9 minutes and 15 seconds
......@@ -32,9 +32,8 @@ def process_entry(dataline ):
string = string +"}}}";
return {"zaid": zaid, "z":z, "a":a,"m":m, "halflife":halflife, "fractions":fractions, "energy":energy,"abundance":abundance, "wmpc": wmpc, "ampc": ampc, "photonfraction" : photonfraction, "string": string}
decay_file = open("/opt/vendors/scale/6.2/data/origen_data/origen.rev03.decay.data", "r")
#decay_file = open("/opt/vendors/scale/6.2/data/origen_data/origen.rev03.decay.data", "r")
decay_file = open("/Users/jap/projects/scale/6.2.1/data/origen_data/origen.rev03.decay.data", "r")
hh_file = open("decaydb.hh", "w")
cc_file = open("decaydb.cc", "w")
......@@ -119,8 +118,8 @@ hh_file.write(" std::string mActinideTitle;\n")
hh_file.write(" std::string mFissionProductTitle;\n")
hh_file.write("public:\n")
hh_file.write(" DecayDb();\n")
hh_file.write(" float calculate_activity(int zaid, float abundance,\n")
hh_file.write(" bool lp=true, bool ap=true, bool fp=true) const;\n")
hh_file.write(" float calculate_activity(int zaid, float lp_abundance,\n")
hh_file.write(" float ap_abundance, float fp_abundance) const;\n")
hh_file.write(" std::string activation_title() const;")
hh_file.write(" std::string actinide_title() const;")
hh_file.write(" std::string fission_product_title() const;")
......@@ -190,7 +189,7 @@ hh_file.write("\n}; // class")
hh_file.write("\n} // namespace radix\n")
# close DecayDb constructor
cc_file.write("}\n")
cc_file.write("float DecayDb::calculate_activity(int zaid, float abundance, bool lp, bool ap, bool fp) const\n{\n")
cc_file.write("float DecayDb::calculate_activity(int zaid, float lp_abundance, float ap_abundance, float fp_abundance) const\n{\n")
cc_file.write(" static float lntwo = std::log(2.0f); // for activities\n")
cc_file.write(" static float avogadro = 6.0221367e23f; // per mole\n")
cc_file.write(" static float curie = 37.0e9f; // (dis/sec)/Ci\n\n")
......@@ -198,9 +197,9 @@ cc_file.write(" const auto& lp_it = mActivation.find(zaid);\n")
cc_file.write(" const auto& ac_it = mActinide.find(zaid);\n")
cc_file.write(" const auto& fp_it = mFissionProduct.find(zaid);\n\n")
cc_file.write(" float activity = 0.0f;\n")
cc_file.write(" if(lp && lp_it != mActivation.end() && lp_it->second.halflife > 0.f) activity += abundance / lp_it->second.halflife; \n")
cc_file.write(" if(ap && ac_it != mActinide.end() && ac_it->second.halflife > 0.f) activity += abundance / ac_it->second.halflife; \n")
cc_file.write(" if(fp && fp_it != mFissionProduct.end() && fp_it->second.halflife > 0.f) activity += abundance / fp_it->second.halflife; \n")
cc_file.write(" if(std::fabs(lp_abundance) > 1e-23 && lp_it != mActivation.end() && lp_it->second.halflife > 0.f) activity += lp_abundance / lp_it->second.halflife; \n")
cc_file.write(" if(std::fabs(ap_abundance) > 1e-23 && ac_it != mActinide.end() && ac_it->second.halflife > 0.f) activity += ap_abundance / ac_it->second.halflife; \n")
cc_file.write(" if(std::fabs(fp_abundance) > 1e-23 && fp_it != mFissionProduct.end() && fp_it->second.halflife > 0.f) activity += fp_abundance / fp_it->second.halflife; \n")
cc_file.write(" activity = activity * avogadro * lntwo / curie;\n")
cc_file.write(" return activity;\n")
cc_file.write("}\n")
......@@ -225,5 +224,7 @@ cc_file.close()
#
# Format resulting files
import os
os.system("/opt/vendors/llvm/5.0.1/bin/clang-format decaydb.hh -i -style=file")
os.system("/opt/vendors/llvm/5.0.1/bin/clang-format decaydb.cc -i -style=file")
#os.system("/opt/vendors/llvm/5.0.1/bin/clang-format decaydb.hh -i -style=file")
#os.system("/opt/vendors/llvm/5.0.1/bin/clang-format decaydb.cc -i -style=file")
os.system("/usr/local/Cellar/clang-format/2017-11-14/bin/clang-format decaydb.hh -i -style=file")
os.system("/usr/local/Cellar/clang-format/2017-11-14/bin/clang-format decaydb.cc -i -style=file")
......@@ -13458,8 +13458,8 @@ DecayDb::DecayDb()
0.0f, 0.0f,
0.0f, {{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.18434f, 0.0f}}};
}
float DecayDb::calculate_activity(int zaid, float abundance, bool lp, bool ap,
bool fp) const
float DecayDb::calculate_activity(int zaid, float lp_abundance,
float ap_abundance, float fp_abundance) const
{
static float lntwo = std::log(2.0f); // for activities
static float avogadro = 6.0221367e23f; // per mole
......@@ -13470,12 +13470,15 @@ float DecayDb::calculate_activity(int zaid, float abundance, bool lp, bool ap,
const auto& fp_it = mFissionProduct.find(zaid);
float activity = 0.0f;
if (lp && lp_it != mActivation.end() && lp_it->second.halflife > 0.f)
activity += abundance / lp_it->second.halflife;
if (ap && ac_it != mActinide.end() && ac_it->second.halflife > 0.f)
activity += abundance / ac_it->second.halflife;
if (fp && fp_it != mFissionProduct.end() && fp_it->second.halflife > 0.f)
activity += abundance / fp_it->second.halflife;
if (std::fabs(lp_abundance) > 1e-23 && lp_it != mActivation.end() &&
lp_it->second.halflife > 0.f)
activity += lp_abundance / lp_it->second.halflife;
if (std::fabs(ap_abundance) > 1e-23 && ac_it != mActinide.end() &&
ac_it->second.halflife > 0.f)
activity += ap_abundance / ac_it->second.halflife;
if (std::fabs(fp_abundance) > 1e-23 && fp_it != mFissionProduct.end() &&
fp_it->second.halflife > 0.f)
activity += fp_abundance / fp_it->second.halflife;
activity = activity * avogadro * lntwo / curie;
return activity;
}
......
......@@ -122,8 +122,8 @@ class DecayDb
public:
DecayDb();
float calculate_activity(int zaid, float abundance, bool lp = true,
bool ap = true, bool fp = true) 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;
......
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