diff --git a/src/enrichment_tests.cc b/src/enrichment_tests.cc index 287d52699..b92032462 100644 --- a/src/enrichment_tests.cc +++ b/src/enrichment_tests.cc @@ -81,7 +81,7 @@ TEST_F(EnrichmentTest, RequestQty) { // Should be only one transaction into the EF, // and it should be exactly 1kg of natu EXPECT_EQ(1.0, qr.rows.size()); - EXPECT_NEAR(1.0, m->quantity(), 1e-10) << + EXPECT_NEAR(1.0, m->quantity(), cyclus::CY_NEAR_ZERO) << "matched trade provides the wrong quantity of material"; } @@ -572,6 +572,9 @@ TEST_F(EnrichmentTest, ValidReq) { TEST_F(EnrichmentTest, ConstraintConverters) { // Tests the SWU and NatU converters to make sure that amount of // feed and SWU required are correct to fulfill the enrichment request. + using cyclus::toolkit::MatQuery; + using cyclus::Composition; + cyclus::Env::SetNucDataPath(); double qty = 5; // 5 kg @@ -605,6 +608,12 @@ TEST_F(EnrichmentTest, Enrich) { // of natural uranium required that is exactly its inventory level. that // inventory will be comprised of two materials to test the manifest/absorb // strategy employed in Enrich_. + using cyclus::toolkit::MatQuery; + using cyclus::Composition; + using cyclus::toolkit::Assays; + using cyclus::toolkit::UraniumAssayMass; + using cyclus::toolkit::SwuRequired; + using cyclus::toolkit::FeedQty; double qty = 5; // kg double product_assay = 0.05; // of 5 w/o enriched U diff --git a/src/fuel_fab.cc b/src/fuel_fab.cc index 9ed6c4a84..cc1d1dc4c 100644 --- a/src/fuel_fab.cc +++ b/src/fuel_fab.cc @@ -38,7 +38,7 @@ class FissConverter : public cyclus::Converter { return AtomToMassFrac(frac, c_fiss_, c_topup_) * m->quantity(); } else { // don't bid at all - return 1e200; + return cyclus::CY_LARGE_DOUBLE; } } @@ -77,7 +77,7 @@ class FillConverter : public cyclus::Converter { return 0; } else { // don't bid at all - return 1e200; + return cyclus::CY_LARGE_DOUBLE; } } @@ -116,7 +116,7 @@ class TopupConverter : public cyclus::Converter { return AtomToMassFrac(frac, c_topup_, c_fiss_) * m->quantity(); } else { // don't bid at all - return 1e200; + return cyclus::CY_LARGE_DOUBLE; } } @@ -375,11 +375,11 @@ std::set::Ptr> FuelFab::GetMatlBids( new TopupConverter(c_fill, c_fiss, c_topup, spectrum)); // important! - the std::max calls prevent CapacityConstraint throwing a zero // cap exception - cyclus::CapacityConstraint fissc(std::max(fiss.quantity(), 1e-10), + cyclus::CapacityConstraint fissc(std::max(fiss.quantity(), cyclus::CY_NEAR_ZERO), fissconv); - cyclus::CapacityConstraint fillc(std::max(fill.quantity(), 1e-10), + cyclus::CapacityConstraint fillc(std::max(fill.quantity(), cyclus::CY_NEAR_ZERO), fillconv); - cyclus::CapacityConstraint topupc(std::max(topup.quantity(), 1e-10), + cyclus::CapacityConstraint topupc(std::max(topup.quantity(), cyclus::CY_NEAR_ZERO), topupconv); port->AddConstraint(fillc); port->AddConstraint(fissc); diff --git a/src/fuel_fab.h b/src/fuel_fab.h index a36ff3456..b7b88cf43 100644 --- a/src/fuel_fab.h +++ b/src/fuel_fab.h @@ -279,8 +279,8 @@ class FuelFab double CosiWeight(cyclus::Composition::Ptr c, const std::string& spectrum); bool ValidWeights(double w_low, double w_tgt, double w_high); -double LowFrac(double w_low, double w_tgt, double w_high, double eps = 1e-6); -double HighFrac(double w_low, double w_tgt, double w_high, double eps = 1e-6); +double LowFrac(double w_low, double w_tgt, double w_high, double eps = cyclus::CY_NEAR_ZERO); +double HighFrac(double w_low, double w_tgt, double w_high, double eps = cyclus::CY_NEAR_ZERO); double AtomToMassFrac(double atomfrac, cyclus::Composition::Ptr c1, cyclus::Composition::Ptr c2); } // namespace cycamore diff --git a/src/fuel_fab_tests.cc b/src/fuel_fab_tests.cc index a56d36a28..ca893ec19 100644 --- a/src/fuel_fab_tests.cc +++ b/src/fuel_fab_tests.cc @@ -531,12 +531,12 @@ TEST(FuelFabTests, CorrectMixing) { conds[0] = Cond("Commodity", "==", std::string("natu")); qr = sim.db().Query("Transactions", &conds); m = sim.GetMaterial(qr.GetVal("ResourceId")); - EXPECT_NEAR(9.7463873197, m->quantity(), 1e-6) << "mixed wrong amount of Nat. U stream"; + EXPECT_NEAR(9.7463873197, m->quantity(), cyclus::CY_NEAR_ZERO) << "mixed wrong amount of Nat. U stream"; conds[0] = Cond("Commodity", "==", std::string("pustream")); qr = sim.db().Query("Transactions", &conds); m = sim.GetMaterial(qr.GetVal("ResourceId")); - EXPECT_NEAR(0.25361268029, m->quantity(), 1e-6) << "mixed wrong amount of Pu stream"; + EXPECT_NEAR(0.25361268029, m->quantity(), cyclus::CY_NEAR_ZERO) << "mixed wrong amount of Pu stream"; } // fuel is requested requiring more filler than is available with plenty of @@ -582,7 +582,7 @@ TEST(FuelFabTests, FillConstrained) { QueryResult qr = sim.db().Query("Transactions", &conds); Material::Ptr m = sim.GetMaterial(qr.GetVal("ResourceId")); - EXPECT_NEAR(max_provide, m->quantity(), 1e-10) << "matched trade uses more fill than available"; + EXPECT_NEAR(max_provide, m->quantity(), cyclus::CY_NEAR_ZERO) << "matched trade uses more fill than available"; } // fuel is requested requiring more fissile material than is available with @@ -628,7 +628,7 @@ TEST(FuelFabTests, FissConstrained) { QueryResult qr = sim.db().Query("Transactions", &conds); Material::Ptr m = sim.GetMaterial(qr.GetVal("ResourceId")); - EXPECT_NEAR(max_provide, m->quantity(), 1e-10) << "matched trade uses more fill than available"; + EXPECT_NEAR(max_provide, m->quantity(), cyclus::CY_NEAR_ZERO) << "matched trade uses more fill than available"; } // swap to topup inventory because fissile has too low reactivity. @@ -669,7 +669,7 @@ TEST(FuelFabTests, SwapTopup) { QueryResult qr = sim.db().Query("Transactions", &conds); ASSERT_EQ(1, qr.rows.size()) << "failed to meet fuel request"; Material::Ptr m = sim.GetMaterial(qr.GetVal("ResourceId")); - EXPECT_NEAR(sink_cap, m->quantity(), 1e-10) << "supplied fuel was constrained too much"; + EXPECT_NEAR(sink_cap, m->quantity(), cyclus::CY_NEAR_ZERO) << "supplied fuel was constrained too much"; conds[0] = Cond("Commodity", "==", std::string("natu")); conds.push_back(Cond("Time", "==", 2)); @@ -719,7 +719,7 @@ TEST(FuelFabTests, SwapTopup_ZeroFill) { QueryResult qr = sim.db().Query("Transactions", &conds); ASSERT_EQ(1, qr.rows.size()) << "failed to meet fuel request"; Material::Ptr m = sim.GetMaterial(qr.GetVal("ResourceId")); - EXPECT_NEAR(sink_cap, m->quantity(), 1e-10) << "supplied fuel was constrained too much"; + EXPECT_NEAR(sink_cap, m->quantity(), cyclus::CY_NEAR_ZERO) << "supplied fuel was constrained too much"; conds[0] = Cond("Commodity", "==", std::string("pustream")); conds.push_back(Cond("Time", "==", 2)); @@ -786,7 +786,7 @@ TEST(FuelFabTests, SwapTopup_TopupConstrained) { ASSERT_EQ(1, qr.rows.size()) << "failed to meet fuel request"; Material::Ptr m = sim.GetMaterial(qr.GetVal("ResourceId")); - EXPECT_NEAR(max_provide, m->quantity(), 1e-10) << "matched trade uses more fiss than available"; + EXPECT_NEAR(max_provide, m->quantity(), cyclus::CY_NEAR_ZERO) << "matched trade uses more fiss than available"; } // swap to topup inventory but are limited by fiss inventory quantity. This @@ -841,7 +841,7 @@ TEST(FuelFabTests, SwapTopup_FissConstrained) { ASSERT_EQ(1, qr.rows.size()) << "failed to meet fuel request"; Material::Ptr m = sim.GetMaterial(qr.GetVal("ResourceId")); - EXPECT_NEAR(max_provide, m->quantity(), 1e-10) << "matched trade uses more fiss than available"; + EXPECT_NEAR(max_provide, m->quantity(), cyclus::CY_NEAR_ZERO) << "matched trade uses more fiss than available"; } // Before this test and a fix, the fuel fab (partially) assumed each entire material @@ -987,5 +987,3 @@ TEST(FuelFabTests, PositionInitialize2) { } // namespace fuelfabtests } // namespace cycamore - - diff --git a/src/mixer_tests.cc b/src/mixer_tests.cc index c5251f4fc..b8e23eec2 100644 --- a/src/mixer_tests.cc +++ b/src/mixer_tests.cc @@ -176,7 +176,7 @@ class MixerTest : public ::testing::Test { // Checking that ratios correctly default to 1/N. TEST_F(MixerTest, StreamDefaultRatio) { SetOutStream_capacity(50); - SetThroughput(1e200); + SetThroughput(cyclus::CY_LARGE_DOUBLE); mf_facility_->EnterNotify(); double ext_val = 1.0 / 3.0; @@ -198,7 +198,7 @@ TEST_F(MixerTest, StreamRatio) { SetStream_ratio(in_frac_); SetStream_capacity(in_cap_); SetOutStream_capacity(50); - SetThroughput(1e200); + SetThroughput(cyclus::CY_LARGE_DOUBLE); mf_facility_->EnterNotify(); std::vector strm_ratio_ = GetStream_ratio(); @@ -213,7 +213,7 @@ TEST_F(MixerTest, StreamRatio) { // Checking renormalisation when sum of ratio is smaller tham 1. in_frac_ = {0.1, 0.2, 0.5}; SetOutStream_capacity(50); - SetThroughput(1e200); + SetThroughput(cyclus::CY_LARGE_DOUBLE); SetStream_ratio(in_frac_); mf_facility_->EnterNotify(); @@ -237,7 +237,7 @@ TEST_F(MixerTest, MixingComposition) { SetOutStream_capacity(50); - SetThroughput(1e200); + SetThroughput(cyclus::CY_LARGE_DOUBLE); std::vector mat; mat.push_back(Material::CreateUntracked(in_cap[0], c_natu())); diff --git a/src/storage.cc b/src/storage.cc index 038a19203..244464dc7 100644 --- a/src/storage.cc +++ b/src/storage.cc @@ -75,7 +75,7 @@ void Storage::InitBuyPolicyParameters() { if (active_buying_max == -1) { active_buying_max = std::numeric_limits::max();} - active_dist_ = cyclus::NormalIntDist::Ptr (new cyclus::NormalIntDist(active_buying_mean, active_buying_stddev, + active_dist_ = cyclus::NormalIntDist::Ptr (new cyclus::NormalIntDist(active_buying_mean, active_buying_stddev, active_buying_min, active_buying_max)); } else { @@ -184,7 +184,7 @@ void Storage::EnterNotify() { std::string package_name_ = context()->GetPackage(package)->name(); if (out_commods.size() == 1) { - sell_policy.Init(this, &stocks, std::string("stocks"), 1e+299, false, + sell_policy.Init(this, &stocks, std::string("stocks"), cyclus::CY_LARGE_DOUBLE, false, sell_quantity, package_name_) .Set(out_commods.front()) .Start(); @@ -225,7 +225,7 @@ std::string Storage::str() { //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Storage::Tick() { - + LOG(cyclus::LEV_INFO3, "ComCnv") << prototype() << " is ticking {"; @@ -265,9 +265,9 @@ void Storage::Tock() { int maxindx = std::distance(in_commod_prefs.begin(), result); double demand = 0; demand = current_capacity(); - + cyclus::toolkit::RecordTimeSeries("demand"+in_commods[maxindx], this, demand); - + // Multiple commodity tracking is not supported, user can only // provide one value for out_commods, despite it being a vector of strings. cyclus::toolkit::RecordTimeSeries("supply"+out_commods[0], this, diff --git a/tests/test_regression.py b/tests/test_regression.py index 9fded61ee..1d323ab14 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -9,6 +9,7 @@ from numpy.testing import assert_array_almost_equal from numpy.testing import assert_almost_equal from cyclus.lib import Env +from cyclus.system import CY_NEAR_ZERO from pytest import skip @@ -273,7 +274,7 @@ class TestDynamicCapacitated(TestRegression): facilities being the constraint. At time step 3, after decommissioning 2 older sink facilities, the remaining number of sink facilities becomes the constraint, resulting in the same transaction amount as in time step 1. - """ + """ @classmethod def setup_class(cls): skip_if_dont_allow_milps() @@ -365,7 +366,7 @@ def test_xaction_specific(self): class TestGrowth1(TestRegression): """This class tests the growth.xml - + Tests GrowthRegion, ManagerInst, and Source over a 4-time step simulation. @@ -411,7 +412,7 @@ def test_deployment(self): class TestGrowth2(TestRegression): """This class tests the ./input/deploy_and_manager_insts.xml - + Tests GrowthRegion, ManagerInst, DeployInst, and Source over a 10-time step simulation. @@ -449,17 +450,17 @@ def test_deployment(self): class TestDeployInst(TestRegression): """This class tests the ../input/deploy_inst.xml - + Tests DeployInst, and NullRegion over a 10-time step simulation. - A DeployInst is used to define that a Source agent is to be deployed at + A DeployInst is used to define that a Source agent is to be deployed at time t=1 within a Null Region. A Sink agent is also deployed as - an initial facility. This input is used to test that the Source and - Sink agents are deployed at their respecitve times and that the correct + an initial facility. This input is used to test that the Source and + Sink agents are deployed at their respecitve times and that the correct number of these agents are deployed. - """ + """ @classmethod def setup_class(cls): skip_if_dont_allow_milps() @@ -487,7 +488,7 @@ def test_deployment(self): class _Recycle(TestRegression): """This class tests the input/recycle.xml file. - """ + """ @classmethod def setup_class(cls, inf): super(_Recycle, cls).setup_class(inf) @@ -506,7 +507,7 @@ def setup_class(cls, inf): def do_compare(self, fromfac, tofac, nuclide, exp_invs): conn = sqlite3.connect(self.outf) c = conn.cursor() - eps = 1e-10 + eps = CY_NEAR_ZERO simdur = len(exp_invs) invs = [0.0] * simdur @@ -583,7 +584,7 @@ def setup_class(cls): class TestCBCRecycle(_Recycle): """This class tests the input/recycle.xml file. - """ + """ @classmethod def setup_class(cls): skip_if_dont_allow_milps()