From 4fa0ebfd4200a68ba6e971401e64d319a2fb932f Mon Sep 17 00:00:00 2001 From: Katie Mummah Date: Thu, 5 Sep 2024 13:37:24 -0500 Subject: [PATCH 1/4] move inv resource creation to Build from EnterNotify --- CHANGELOG.rst | 2 +- src/source.cc | 14 +++++++++++--- src/source.h | 4 ++++ src/source_tests.cc | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index aedb0d533..4902da3e9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,7 +7,7 @@ Since last release **Added:** * Added package parameter to storage (#603, #612, #616) -* Added package parameter to source (#613, #617, #621) +* Added package parameter to source (#613, #617, #621, #623) * Added default keep packaging to reactor (#618, #619) **Changed:** diff --git a/src/source.cc b/src/source.cc index 751aaa763..cde0d0c7a 100644 --- a/src/source.cc +++ b/src/source.cc @@ -54,20 +54,27 @@ std::string Source::str() { } void Source::EnterNotify() { + cyclus::Facility::EnterNotify(); + +} + +void Source::Build(cyclus::Agent* parent) { + Facility::Build(parent); + using cyclus::CompMap; using cyclus::Composition; using cyclus::Material; - cyclus::Facility::EnterNotify(); - RecordPosition(); // create all source inventory and place into buf cyclus::Material::Ptr all_inv; Composition::Ptr blank_comp = Composition::CreateFromMass(CompMap()); - all_inv = (outrecipe.empty() || context() == NULL) ? \ Material::Create(this, inventory_size, blank_comp) : \ Material::Create(this, inventory_size, context()->GetRecipe(outrecipe)); + std::cerr << "Source created all inv with state id " << all_inv->state_id() << std::endl; inventory.Push(all_inv); + + RecordPosition(); } std::set::Ptr> Source::GetMatlBids( @@ -153,6 +160,7 @@ void Source::GetMatlTrades( if (shippable_trades > 0) { double qty = it->amt; + std::cerr << "source trade amount " << qty << std::endl; Material::Ptr m = inventory.Pop(qty); std::vector m_pkgd = m->Package(context()->GetPackage(package)); diff --git a/src/source.h b/src/source.h index 0024f20f4..db179d93a 100644 --- a/src/source.h +++ b/src/source.h @@ -71,6 +71,10 @@ class Source : public cyclus::Facility, virtual void EnterNotify(); + /// --- Facility Members --- + /// perform module-specific tasks when entering the simulation + virtual void Build(cyclus::Agent* parent); + virtual void GetMatlTrades( const std::vector< cyclus::Trade >& trades, std::vector, diff --git a/src/source_tests.cc b/src/source_tests.cc index 10208e733..d2ea3ec2b 100644 --- a/src/source_tests.cc +++ b/src/source_tests.cc @@ -15,7 +15,7 @@ void SourceTest::SetUp() { trader = tc.trader(); InitParameters(); SetUpSource(); - src_facility->EnterNotify(); + src_facility->Build(NULL); } void SourceTest::TearDown() { From 9c1bf273f965b073fe4870920f10c399da016a71 Mon Sep 17 00:00:00 2001 From: Katie Mummah Date: Thu, 5 Sep 2024 14:14:46 -0500 Subject: [PATCH 2/4] remove extra line --- src/source.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/source.cc b/src/source.cc index cde0d0c7a..f3b0ebed0 100644 --- a/src/source.cc +++ b/src/source.cc @@ -160,7 +160,6 @@ void Source::GetMatlTrades( if (shippable_trades > 0) { double qty = it->amt; - std::cerr << "source trade amount " << qty << std::endl; Material::Ptr m = inventory.Pop(qty); std::vector m_pkgd = m->Package(context()->GetPackage(package)); From d2198c9d4fa0650c8a031257ffa0862d5f383d96 Mon Sep 17 00:00:00 2001 From: Katie Mummah Date: Mon, 9 Sep 2024 18:00:12 -0500 Subject: [PATCH 3/4] remove extra line 2 --- src/source.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/source.cc b/src/source.cc index f3b0ebed0..cacdfe64a 100644 --- a/src/source.cc +++ b/src/source.cc @@ -71,7 +71,6 @@ void Source::Build(cyclus::Agent* parent) { all_inv = (outrecipe.empty() || context() == NULL) ? \ Material::Create(this, inventory_size, blank_comp) : \ Material::Create(this, inventory_size, context()->GetRecipe(outrecipe)); - std::cerr << "Source created all inv with state id " << all_inv->state_id() << std::endl; inventory.Push(all_inv); RecordPosition(); From 517f7faefe50d9bf9024cca26d1908301831a055 Mon Sep 17 00:00:00 2001 From: Katie Mummah Date: Thu, 12 Sep 2024 22:27:49 -0500 Subject: [PATCH 4/4] move RecordPosition back to EnterNotify --- src/source.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/source.cc b/src/source.cc index cacdfe64a..4ffc3f560 100644 --- a/src/source.cc +++ b/src/source.cc @@ -55,7 +55,7 @@ std::string Source::str() { void Source::EnterNotify() { cyclus::Facility::EnterNotify(); - + RecordPosition(); } void Source::Build(cyclus::Agent* parent) { @@ -73,7 +73,6 @@ void Source::Build(cyclus::Agent* parent) { Material::Create(this, inventory_size, context()->GetRecipe(outrecipe)); inventory.Push(all_inv); - RecordPosition(); } std::set::Ptr> Source::GetMatlBids(