Skip to content

Removed decay data, now with pyne! #762

Merged
merged 10 commits into from Mar 5, 2014

3 participants

@scopatz
Cyclus member
scopatz commented Mar 5, 2014

This PR replaces the decayInfo.dat file with nuclear data coming from pyne. A custom cyclus_nuc_data.h5 has been created and uploaded to our webspace. The install process will automatically download and install this file. This data file may be generated by the following command:

scopatz@ares ~/pyne staging $ nuc_data_make -o cyclus_nuc_data.h5 
    -m atomic_mass,scattering_lengths,decay,simple_xs,materials,eaf,wimsd_fpy,nds_fpy

This PR also exposed what I would consider some fundamental problems with how the current methodology works. These will be addressed in separate issues as the purpose here is only to integrate with pyne data. As much as I wanted to throw my machine out of the 4th floor window of ERB during this process, the unite tests now pass :).

@scopatz scopatz added this to the v0.5 milestone Mar 5, 2014
@gidden gidden commented on the diff Mar 5, 2014
cli/cyclus.cc
@@ -167,6 +167,9 @@ int main(int argc, char* argv[]) {
std::string path = Env::PathBase(argv[0]);
Env::SetCyclusRelPath(path);
+ // tell pyne about the path to nuc data
+ pyne::NUC_DATA_PATH = Env::GetBuildPath() + "/share/cyclus_nuc_data.h5";
@gidden
Cyclus member
gidden added a note Mar 5, 2014

should likely use a boost file system path for os robustness

@scopatz
Cyclus member
scopatz added a note Mar 5, 2014

There is a lot of this kind of code in cyclus right now. Maybe we could make an issue and tackle it later.

@gidden
Cyclus member
gidden added a note Mar 5, 2014

I see thats the case with finding mass.sqlite as well. Would you like to make the issue? We could also make an issue about using pyne nuclide masses as well and get rid of mass.sqlite.

@scopatz
Cyclus member
scopatz added a note Mar 5, 2014

I see thats the case with finding mass.sqlite as well. Would you like to make the issue?

I'd rather if you did. Thanks!

We could also make an issue about using pyne nuclide masses as well and get rid of mass.sqlite.

I am going to do this tomorrow :)

@gidden
Cyclus member
gidden added a note Mar 5, 2014

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@gidden gidden commented on the diff Mar 5, 2014
src/CMakeLists.txt
@@ -8,6 +8,16 @@ CONFIGURE_FILE(suffix.h.in "${CMAKE_CURRENT_SOURCE_DIR}/suffix.h" @ONLY)
EXECUTE_PROCESS(COMMAND git describe --tags OUTPUT_VARIABLE core_version OUTPUT_STRIP_TRAILING_WHITESPACE)
CONFIGURE_FILE(version.h.in "${CMAKE_CURRENT_SOURCE_DIR}/version.h" @ONLY)
+if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cyclus_nuc_data.h5")
+ message("-- Found '${CMAKE_CURRENT_SOURCE_DIR}/cyclus_nuc_data.h5'")
+else()
+ message("-- Downloading http://regtests.fuelcycle.org/cyclus_nuc_data.h5 to "
+ "'${CMAKE_CURRENT_SOURCE_DIR}/cyclus_nuc_data.h5'...")
+ file(DOWNLOAD "http://regtests.fuelcycle.org/cyclus_nuc_data.h5"
@gidden
Cyclus member
gidden added a note Mar 5, 2014

TIL. Neat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@gidden gidden and 2 others commented on an outdated diff Mar 5, 2014
src/composition.cc
@@ -105,11 +105,13 @@ void Composition::Record(Context* ctx) {
Composition::Ptr Composition::NewDecay(int delta) {
int tot_decay = prev_decay_ + delta;
- double months_per_year = 12;
- double years = double(delta) / months_per_year;
+
+ if (atom_.size() == 0)
+ // FIXME this is only here for testing
+ return (Composition::Ptr) new Composition(tot_decay, decay_line_);
@gidden
Cyclus member
gidden added a note Mar 5, 2014
@rwcarlsen
Cyclus member
rwcarlsen added a note Mar 5, 2014

Also - need curlies on multi-line if. Also - the casting syntax is strange and non-obvious. You should use the constructor syntax - which is what is really going on:

return Composition::Ptr(new Composition(tot_decay, decay_line_));
@rwcarlsen
Cyclus member
rwcarlsen added a note Mar 5, 2014

@scopatz I just noticed a bug here - could you throw in this line at the top of the NewDecay function:

  atom(); // force evaluation of atom-composition if not calculated already
@scopatz
Cyclus member
scopatz added a note Mar 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@gidden gidden commented on the diff Mar 5, 2014
src/decayer.cc
- nuc));
- }
- }
- temp[i] = std::make_pair(nuc, branchRatio);
- }
-
- daughters_[jcol] = temp;
- ++jcol; // set next column
- decayInfo >> nuc; // get next parent
- nuc *= 10000; // put in id form
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+void Decayer::AddNucToMaps(int nuc) {
+ int i;
+ int col;
+ int daughter;
+ std::set<int> daughters;
@gidden
Cyclus member
gidden added a note Mar 5, 2014

I believe in a PyNE PR, someone suggested either from_nuc/to_nuc, parent/child, or mother/daughter, in that preference order =)

@scopatz
Cyclus member
scopatz added a note Mar 5, 2014

I feel it safe to call this legacy code that matches the names around it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@gidden gidden commented on an outdated diff Mar 5, 2014
src/decayer.cc
@@ -162,7 +110,7 @@ void Decayer::GetResult(CompMap& comp) {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Decayer::BuildDecayMatrix() {
- double decayConst = 0; // decay constant, in inverse years
+ double decayConst = 0; // decay constant, in inverse secs
@gidden
Cyclus member
gidden added a note Mar 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@gidden gidden commented on an outdated diff Mar 5, 2014
src/decayer.cc
@@ -173,6 +121,9 @@ void Decayer::BuildDecayMatrix() {
while (parent_iter != parent_.end()) {
jcol = parent_iter->second.first; // determines column index
decayConst = parent_iter->second.second;
+ // Gross heuristic for mostly stable nuclides 2903040000 sec / 100 years
+ if ((long double) exp(-2903040000 * decayConst) == 0.0)
@gidden
Cyclus member
gidden added a note Mar 5, 2014

c++ style casts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@gidden gidden commented on the diff Mar 5, 2014
src/material.cc
@@ -128,7 +127,8 @@ void Material::Decay(int curr_time) {
CompMap::const_iterator it;
for (it = c.end(); it != c.begin(); --it) {
int nuc = it->first;
- double lambda_months = Decayer::DecayConstant(nuc) / 12;
+ // 2419200 == secs / month
+ double lambda_months = pyne::decay_const(nuc) * 2419200;
@gidden
Cyclus member
gidden added a note Mar 5, 2014

shouldn't [months] = [secs] / [secs / month]?

@gidden
Cyclus member
gidden added a note Mar 5, 2014

errr, [months] = 1 / ([secs / month] * [1 / secs])

@scopatz
Cyclus member
scopatz added a note Mar 5, 2014

lambda: [1/months] = [1/sec] * [sec/month]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@gidden
Cyclus member
gidden commented Mar 5, 2014

we definitely need decayer unit tests..

@rwcarlsen
Cyclus member

+1 for tests. I also would like to award anthony a code destroyer medal. Code is the enemy.

@gidden - who is in your new profile pic?

@gidden
Cyclus member
gidden commented Mar 5, 2014
@scopatz
Cyclus member
scopatz commented Mar 5, 2014

+1 for tests.

I completely agree, but I think that is a separate issue.

I also would like to award anthony a code destroyer medal. Code is the enemy.

Thanks! Hopefully I'll get rid of even more tomorrow.

I think this is ready for another look.

@scopatz scopatz @rwcarlsen 'force evaluation of atom-composition if not calculated al…
…ready'
f0cf104
@rwcarlsen rwcarlsen commented on an outdated diff Mar 5, 2014
src/composition.cc
@@ -105,11 +105,14 @@ void Composition::Record(Context* ctx) {
Composition::Ptr Composition::NewDecay(int delta) {
int tot_decay = prev_decay_ + delta;
- double months_per_year = 12;
- double years = double(delta) / months_per_year;
+ atom(); // force evaluation of atom-composition if not calculated already
+
+ // FIXME this is only here for testing
+ if (atom_.size() == 0)
+ return static_cast<Composition::Ptr>(new Composition(tot_decay, decay_line_));
@rwcarlsen
Cyclus member
rwcarlsen added a note Mar 5, 2014

This should be:

return Composition::Ptr(new Composition(tot_decay, decay_line_));

Composition::Ptr is a smart pointer - so we want to call its constructor. A static cast is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@scopatz
Cyclus member
scopatz commented Mar 5, 2014

ping.

@gidden
Cyclus member
gidden commented Mar 5, 2014

Looks good. Thanks, @scopatz!

@gidden gidden merged commit 825f02b into cyclus:develop Mar 5, 2014

1 check passed

Details default build and test completed successfully
@scopatz scopatz deleted the scopatz:rm-decay branch Mar 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.