Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Removed mass in favor of pyne data #764

Merged
merged 1 commit into from

2 participants

@scopatz
Owner

That is all.

@scopatz scopatz referenced this pull request in cyclus/cycamore
Merged

Removed masses #199

@gidden
Owner

looks great, tests great. waiting for ubuntu to finish on batlab.

@scopatz scopatz added this to the v0.5 milestone
@gidden gidden merged commit cd311dc into cyclus:develop

1 check passed

Details default build and test completed successfully
@scopatz scopatz deleted the scopatz:rm-mass branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  cli/cyclus.cc
@@ -168,7 +168,7 @@ int main(int argc, char* argv[]) {
Env::SetCyclusRelPath(path);
// tell pyne about the path to nuc data
- pyne::NUC_DATA_PATH = Env::GetBuildPath() + "/share/cyclus_nuc_data.h5";
+ Env::SetNucDataPath();
// read input file and setup simulation
std::string inputFile = vm["input-file"].as<std::string>();
View
9 src/CMakeLists.txt
@@ -19,12 +19,6 @@ else()
endif()
CONFIGURE_FILE(
- "${CMAKE_CURRENT_SOURCE_DIR}/mass.sqlite"
- "${CYCLUS_BINARY_DIR}/share/mass.sqlite"
- COPYONLY
- )
-
-CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cyclus_nuc_data.h5"
"${CYCLUS_BINARY_DIR}/share/cyclus_nuc_data.h5"
COPYONLY
@@ -39,7 +33,6 @@ CONFIGURE_FILE(
)
INSTALL(FILES
- "${CMAKE_CURRENT_SOURCE_DIR}/mass.sqlite"
"${CMAKE_CURRENT_SOURCE_DIR}/cyclus.rng.in"
"${CMAKE_CURRENT_SOURCE_DIR}/cyclus-flat.rng.in"
"${CMAKE_CURRENT_SOURCE_DIR}/cyclus_nuc_data.h5"
@@ -95,7 +88,6 @@ SET(CYCLUS_CORE_SRC ${CYCLUS_CORE_SRC}
"${CMAKE_CURRENT_SOURCE_DIR}/inst_model.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/l_matrix.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/logger.cc"
- "${CMAKE_CURRENT_SOURCE_DIR}/mass_table.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/mat_query.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/material.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/model.cc"
@@ -171,7 +163,6 @@ INSTALL(FILES
intrusive_base.h
l_matrix.h
logger.h
- mass_table.h
mat_query.h
material.h
model.h
View
21 src/composition.cc
@@ -4,7 +4,6 @@
#include "context.h"
#include "decayer.h"
#include "error.h"
-#include "mass_table.h"
#include "recorder.h"
namespace cyclus {
@@ -12,9 +11,11 @@ namespace cyclus {
int Composition::next_id_ = 0;
Composition::Ptr Composition::CreateFromAtom(CompMap v) {
- if (!compmath::ValidNucs(v) || !compmath::AllPositive(v)) {
- throw ValueError("invalid nuclide or negative quantity in CompMap");
- }
+ if (!compmath::ValidNucs(v))
+ throw ValueError("invalid nuclide in CompMap");
+
+ if (!compmath::AllPositive(v))
+ throw ValueError("negative quantity in CompMap");
Composition::Ptr c(new Composition());
c->atom_ = v;
@@ -22,9 +23,11 @@ Composition::Ptr Composition::CreateFromAtom(CompMap v) {
}
Composition::Ptr Composition::CreateFromMass(CompMap v) {
- if (!compmath::ValidNucs(v) || !compmath::AllPositive(v)) {
- throw ValueError("invalid nuclide or negative quantity in CompMap");
- }
+ if (!compmath::ValidNucs(v))
+ throw ValueError("invalid nuclide in CompMap");
+
+ if (!compmath::AllPositive(v))
+ throw ValueError("negative quantity in CompMap");
Composition::Ptr c(new Composition());
c->mass_ = v;
@@ -40,7 +43,7 @@ const CompMap& Composition::atom() {
CompMap::iterator it;
for (it = mass_.begin(); it != mass_.end(); ++it) {
Nuc nuc = it->first;
- atom_[nuc] = mass_[nuc] / MT->GramsPerMol(nuc);
+ atom_[nuc] = mass_[nuc] / pyne::atomic_mass(nuc);
}
}
return atom_;
@@ -51,7 +54,7 @@ const CompMap& Composition::mass() {
CompMap::iterator it;
for (it = atom_.begin(); it != atom_.end(); ++it) {
Nuc nuc = it->first;
- mass_[nuc] = atom_[nuc] * MT->GramsPerMol(nuc);
+ mass_[nuc] = atom_[nuc] * pyne::atomic_mass(nuc);
}
}
return mass_;
View
1  src/cyclus.h
@@ -29,7 +29,6 @@
#include "generic_resource.h"
#include "inst_model.h"
#include "logger.h"
-#include "mass_table.h"
#include "mat_query.h"
#include "material.h"
#include "model.h"
View
1  src/enrichment.cc
@@ -6,7 +6,6 @@
#include "error.h"
#include "cyc_limits.h"
#include "logger.h"
-#include "mass_table.h"
#include "mat_query.h"
namespace cyclus {
View
12 src/env.h
@@ -5,6 +5,8 @@
#include <string>
#include "boost/filesystem.hpp"
+#include "pyne.h"
+
namespace cyclus {
/// @class Env
@@ -88,6 +90,16 @@ class Env {
static bool FindModuleLib(std::string name,
boost::filesystem::path& path_found);
+ /// Initializes the path to the nuclear data library to a default location
+ inline static const void SetNucDataPath() {
+ pyne::NUC_DATA_PATH = Env::GetBuildPath() + "/share/cyclus_nuc_data.h5";
+ }
+
+ /// Initializes the path to the nuclear data library to p
+ inline static const void SetNucDataPath(std::string p) {
+ pyne::NUC_DATA_PATH = p;
+ }
+
private:
/// the relative path from cwd to cyclus
static boost::filesystem::path path_from_cwd_to_cyclus_;
View
BIN  src/mass.sqlite
Binary file not shown
View
74 src/mass_table.cc
@@ -1,74 +0,0 @@
-// MassTable class
-
-#include <iostream>
-#include <stdlib.h>
-
-#include "mass_table.h"
-#include "sqlite_db.h"
-
-#include "env.h"
-#include "error.h"
-
-namespace cyclus {
-
-MassTable* MassTable::instance_ = 0;
-
-//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-MassTable* MassTable::Instance() {
- // If we haven't created a MassTable yet, create it, and then and return it
- // either way.
- if (0 == instance_) {
- instance_ = new MassTable();
- }
- return instance_;
-}
-
-//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-MassTable::MassTable() {
- InitializeSQL();
-}
-
-//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-MassTable::~MassTable() {
- //Should close the 'mass.h5' file
-}
-
-//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-double MassTable::GramsPerMol(int nuc) {
- double toRet = nuclide_vec_[nucIndex_[nuc]].mass;
- return toRet;
-}
-
-//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-void MassTable::InitializeSQL() {
- // get the file location
- std::string file_path = Env::GetBuildPath() + "/share/mass.sqlite";
- bool readonly = true;
- SqliteDb* db = new SqliteDb(file_path, readonly);
-
- std::vector<StrList> znums = db->Query("SELECT Z FROM isotopemasses");
- std::vector<StrList> anums = db->Query("SELECT A FROM isotopemasses");
- std::vector<StrList> mnums = db->Query("SELECT Mass FROM isotopemasses");
-
- for (int i = 0; i < znums.size(); i++) {
- // // obtain the database row and declare the appropriate members
- std::string aStr = anums.at(i).at(0);
- std::string zStr = znums.at(i).at(0);
- std::string mStr = mnums.at(i).at(0);
- int z = atoi(zStr.c_str());
- int a = atoi(aStr.c_str());
- double mass = atof(mStr.c_str());
- // create a nuclide member and add it to the nuclide vector
- Nuclide n = {z, a, 0, mass};
- nuclide_vec_.push_back(n);
- // create an index and log it accordingly
- int nuc = (z * 10000000) + (a * 10000);
- nucIndex_.insert(std::make_pair(nuc, i));
- }
- // set the total number of nuclides
- nuclide_len_ = nuclide_vec_.size();
-
- delete db;
-}
-
-} // namespace cyclus
View
101 src/mass_table.h
@@ -1,101 +0,0 @@
-// mass_table.h
-#ifndef CYCLUS_SRC_MASS_TABLE_H_
-#define CYCLUS_SRC_MASS_TABLE_H_
-
-#include <string>
-#include <vector>
-#include <map>
-
-#define MT MassTable::Instance()
-
-namespace cyclus {
-
-/**
- @class MassTable
- The MassTable class provides an interface to the mass.sqlite
- database, providing a robust and correct mass lookup by nuclide
- */
-class MassTable {
- private:
- /**
- A pointer to this MassTable once it has been initialized.
- */
- static MassTable* instance_;
-
- public:
- /**
- Gives all simulation objects global access to the Env by
- returning a pointer to it.
-
- @return a pointer to the MassTable
- */
- static MassTable* Instance();
-
- /**
- Default constructor for the MassTable class.
- Initializes the data from the provided mass.h5 file.
- */
- MassTable();
-
- /**
- Destructor for the NullFacility class.
- Makes certain to delete all appropriate data on the stack.
- */
- ~MassTable();
-
- /**
- get the Atomic Number of an nuclide according to its
- identifier.
-
- @param tope is the nuclide identifier of type Nuc, which is an int
- typedef
- @return int the atomic number of the tope nuclide.
- */
- int GetAtomicNum(int tope);
-
- /**
- get the Mass, a double, of an nuclide according to its
- identifier.
-
- @param tope is the nuclide identifier of type Nuc, which is an int
- typedef
- @return the mass, a double, of the tope nuclide.
- */
- double GramsPerMol(int tope);
-
- protected:
- /**
- Defines the structure of data associated with each row entry in the
- mass database. Right now, strings are a little funky, so the names
- */
- typedef struct Nuclide {
- int Z; /**< an integer indicating the atomic (proton) number of an atom >**/
- int A; /**< an integer indicating the A (mass A=N+Z) number of an atom. >**/
- int S; /**< an integer indicating the S (state) number of an atom. >**/
- double mass; /**< a double indicating the mass of an atom >**/
- } Nuclide;
-
- /**
- The integer length (number of rows) of the mass.h5/ame03/nuclide/
- */
- int nuclide_len_;
-
- /**
- The vector of nuclide structs that holds the data in the mass table
- */
- std::vector<Nuclide> nuclide_vec_;
-
- /**
- a map for index lookup in the nuclide vector.
- */
- std::map<int, int> nucIndex_;
-
- /**
- a function to initialize a large array of Nuclide structs via the
- SQLite/C++ API
- */
- void InitializeSQL();
-
-};
-} // namespace cyclus
-#endif // ifndef CYCLUS_MASS_TABLE_H_
View
2  src/mat_query.cc
@@ -15,7 +15,7 @@ double MatQuery::mass(Nuc nuc) {
};
double MatQuery::moles(Nuc nuc) {
- return mass(nuc) / (MT->GramsPerMol(nuc) * units::g);
+ return mass(nuc) / (pyne::atomic_mass(nuc) * units::g);
};
double MatQuery::mass_frac(Nuc nuc) {
View
2  src/mat_query.h
@@ -3,8 +3,8 @@
#include "comp_math.h"
#include "cyc_limits.h"
-#include "mass_table.h"
#include "material.h"
+#include "pyne.h"
namespace cyclus {
View
1  tests/CMakeLists.txt
@@ -102,7 +102,6 @@ set ( CYCLUS_CORE_TEST_SOURCE ${CYCLUS_CORE_TEST_SOURCE}
"${CMAKE_CURRENT_SOURCE_DIR}/hdf5_back_tests.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/header_impl.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/inst_model_class_tests.cc"
- "${CMAKE_CURRENT_SOURCE_DIR}/mass_table_tests.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/mat_query_tests.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/material_tests.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/model_tests.cc"
View
12 tests/composition_tests.cc
@@ -4,7 +4,6 @@
#include "composition.h"
#include "env.h"
-#include "mass_table.h"
#include "pyne.h"
class TestComp : public cyclus::Composition {
@@ -18,6 +17,7 @@ class TestComp : public cyclus::Composition {
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TEST(CompositionTests, create_atom) {
using cyclus::Composition;
+ cyclus::Env::SetNucDataPath();
cyclus::CompMap v;
v[922350000] = 2;
@@ -27,12 +27,14 @@ TEST(CompositionTests, create_atom) {
v = c->atom();
EXPECT_DOUBLE_EQ(v[922350000] / v[922330000], 2 / 1);
v = c->mass();
- EXPECT_DOUBLE_EQ(v[922350000] / v[922330000], 2 * cyclus::MT->GramsPerMol(922350000) / cyclus::MT->GramsPerMol(922330000));
+ EXPECT_DOUBLE_EQ(v[922350000] / v[922330000],
+ 2 * pyne::atomic_mass(922350000) / pyne::atomic_mass(922330000));
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TEST(CompositionTests, create_mass) {
using cyclus::Composition;
+ cyclus::Env::SetNucDataPath();
cyclus::CompMap v;
v[922350000] = 2;
@@ -42,14 +44,14 @@ TEST(CompositionTests, create_mass) {
v = c->mass();
EXPECT_DOUBLE_EQ(v[922350000] / v[922330000], 2 / 1);
v = c->atom();
- EXPECT_DOUBLE_EQ(v[922350000] / v[922330000], 2 / cyclus::MT->GramsPerMol(922350000) * cyclus::MT->GramsPerMol(922330000));
+ EXPECT_DOUBLE_EQ(v[922350000] / v[922330000],
+ 2 / pyne::atomic_mass(922350000) * pyne::atomic_mass(922330000));
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TEST(CompositionTests, lineage) {
using cyclus::Composition;
- // tell pyne about the path to nuc data
- pyne::NUC_DATA_PATH = cyclus::Env::GetBuildPath() + "/share/cyclus_nuc_data.h5";
+ cyclus::Env::SetNucDataPath();
TestComp c;
View
12 tests/mass_table_tests.cc
@@ -1,12 +0,0 @@
-// mass_table_tests.cc
-#include <gtest/gtest.h>
-#include "mass_table_tests.h"
-
-//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-TEST_F(MassTableTest, gramsPerMol){
- EXPECT_NEAR(235, cyclus::MT->GramsPerMol(u235_), 0.5);
- EXPECT_NEAR(241, cyclus::MT->GramsPerMol(am241_), 0.5);
- EXPECT_NEAR(228, cyclus::MT->GramsPerMol(th228_), 0.5);
- EXPECT_NEAR(208, cyclus::MT->GramsPerMol(pb208_), 0.5);
-}
-
View
28 tests/mass_table_tests.h
@@ -1,28 +0,0 @@
-// mass_table_tests.cc
-#ifndef CYCLUS_TESTS_MASS_TABLE_TESTS_H_
-#define CYCLUS_TESTS_MASS_TABLE_TESTS_H_
-
-#include <gtest/gtest.h>
-#include "mass_table.h"
-
-//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-class MassTableTest : public ::testing::Test {
- protected:
- int u235_, am241_, th228_, pb208_;
- double one_g_;
-
- virtual void SetUp(){
- // composition set up
- u235_ = 922350000;
- am241_ = 952410000;
- th228_ = 902280000;
- pb208_ = 822080000;
- one_g_ = 1.0;
-
- }
-
- virtual void TearDown(){
- }
-};
-
-#endif // CYCLUS_TESTS_MASS_TABLE_TESTS_H_
View
39 tests/mat_query_tests.cc
@@ -3,10 +3,11 @@
#include "composition.h"
#include "context.h"
-#include "recorder.h"
-#include "mass_table.h"
+#include "env.h"
#include "mat_query.h"
#include "material.h"
+#include "pyne.h"
+#include "recorder.h"
#include "timer.h"
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -14,25 +15,25 @@ TEST(MatQueryTests, MassAndMoles) {
cyclus::Recorder rec;
cyclus::Timer ti;
cyclus::Context ctx(&ti, &rec);
- cyclus::MassTable* mt = cyclus::MT;
-
cyclus::CompMap v;
- v[92235] = 1.5;
- v[1008] = 2.5;
+ cyclus::Env::SetNucDataPath();
+
+ v[922350000] = 1.5;
+ v[10070000] = 2.5;
cyclus::Composition::Ptr c = cyclus::Composition::CreateFromMass(v);
cyclus::Material::Ptr m = cyclus::Material::CreateUntracked(4.0, c);
cyclus::MatQuery mq(m);
- EXPECT_DOUBLE_EQ(mq.mass(92235), 1.5);
- EXPECT_DOUBLE_EQ(mq.mass(1008), 2.5);
- EXPECT_DOUBLE_EQ(mq.moles(92235), 1500 / mt->GramsPerMol(92235));
- EXPECT_DOUBLE_EQ(mq.moles(1008), 2500 / mt->GramsPerMol(1008));
- EXPECT_DOUBLE_EQ(mq.mass_frac(92235), 1.5 / 4.0);
- EXPECT_DOUBLE_EQ(mq.mass_frac(1008), 2.5 / 4.0);
- double nmoles = mq.moles(92235) + mq.moles(1008);
- EXPECT_DOUBLE_EQ(mq.atom_frac(92235), 1500 / mt->GramsPerMol(92235) / nmoles);
- EXPECT_DOUBLE_EQ(mq.atom_frac(1008), 2500 / mt->GramsPerMol(1008) / nmoles);
+ EXPECT_DOUBLE_EQ(mq.mass(922350000), 1.5);
+ EXPECT_DOUBLE_EQ(mq.mass(10070000), 2.5);
+ EXPECT_DOUBLE_EQ(mq.moles(922350000), 1500 / pyne::atomic_mass(922350000));
+ EXPECT_DOUBLE_EQ(mq.moles(10070000), 2500 / pyne::atomic_mass(10070000));
+ EXPECT_DOUBLE_EQ(mq.mass_frac(922350000), 1.5 / 4.0);
+ EXPECT_DOUBLE_EQ(mq.mass_frac(10070000), 2.5 / 4.0);
+ double nmoles = mq.moles(922350000) + mq.moles(10070000);
+ EXPECT_DOUBLE_EQ(mq.atom_frac(922350000), 1500 / pyne::atomic_mass(922350000) / nmoles);
+ EXPECT_DOUBLE_EQ(mq.atom_frac(10070000), 2500 / pyne::atomic_mass(10070000) / nmoles);
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -43,8 +44,8 @@ TEST(MatQueryTests, AlmostEq) {
cyclus::CompMap v;
cyclus::Composition::Ptr c;
- v[92235] = 1.5;
- v[1008] = 2.5;
+ v[922350000] = 1.5;
+ v[10070000] = 2.5;
c = cyclus::Composition::CreateFromMass(v);
cyclus::Material::Ptr m1 = cyclus::Material::CreateUntracked(4.0, c);
cyclus::MatQuery mq(m1);
@@ -56,13 +57,13 @@ TEST(MatQueryTests, AlmostEq) {
cyclus::Material::Ptr m3 = cyclus::Material::CreateUntracked(4.0, c);
EXPECT_TRUE(mq.AlmostEq(m3, 0));
- v[1008] += 0.99 * cyclus::eps_rsrc();
+ v[10070000] += 0.99 * cyclus::eps_rsrc();
c = cyclus::Composition::CreateFromMass(v);
cyclus::Material::Ptr m4 = cyclus::Material::CreateUntracked(4.0, c);
EXPECT_FALSE(mq.AlmostEq(m4, 0));
EXPECT_TRUE(mq.AlmostEq(m4, cyclus::eps_rsrc()));
- v[1008] += 4.0 * cyclus::eps_rsrc();
+ v[10070000] += 4.0 * cyclus::eps_rsrc();
c = cyclus::Composition::CreateFromMass(v);
cyclus::Material::Ptr m5 = cyclus::Material::CreateUntracked(4.0, c);
EXPECT_FALSE(mq.AlmostEq(m5, cyclus::eps_rsrc()));
Something went wrong with that request. Please try again.