From c87f95db81a420f37c51dd44410d77adda850b98 Mon Sep 17 00:00:00 2001 From: Dean Krueger Date: Mon, 7 Oct 2024 11:55:47 -0500 Subject: [PATCH] made changes necessary to get tricycle to build --- src/fusion_power_plant.cc | 72 ++++++++++++++++++++++---- src/fusion_power_plant.h | 104 ++++++++++++++++++++++++++++++-------- 2 files changed, 144 insertions(+), 32 deletions(-) diff --git a/src/fusion_power_plant.cc b/src/fusion_power_plant.cc index 85c9428..af37ee8 100644 --- a/src/fusion_power_plant.cc +++ b/src/fusion_power_plant.cc @@ -1,9 +1,23 @@ #include "fusion_power_plant.h" +using cyclus::Material; +using cyclus::Composition; +using cyclus::IntDistribution; +using cyclus::DoubleDistribution; +using cyclus::FixedIntDist; +using cyclus::FixedDoubleDist; +using cyclus::KeyError; + + + namespace tricycle { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FusionPowerPlant::FusionPowerPlant(cyclus::Context* ctx) : cyclus::Facility(ctx) {} +FusionPowerPlant::FusionPowerPlant(cyclus::Context* ctx) : cyclus::Facility(ctx) { + fuel_tracker.Init({&tritium_storage}, fuel_limit); + blanket_tracker.Init({&blanket_feed}, blanket_limit); + +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - std::string FusionPowerPlant::str() { @@ -17,11 +31,11 @@ void FusionPowerPlant::EnterNotify() { //fuel_usage_mass = (burn_rate * (fusion_power / MW_to_GW) / // seconds_per_year * context()->dt()); //fuel_usage_atoms = fuel_usage_mass / tritium_atomic_mass; - //blanket_turnover = blanket_size * blanket_turnover_rate; + blanket_turnover = blanket_size * blanket_turnover_quantity; //Create the blanket material for use in the core, no idea if this works... - const Composition::Ptr enriched_li = context->GetRecipe(blanket_inrecipe); - blanket = Composition::CreateFromAtom(0.0, enriched_li); + blanket = Material::Create(this, 0.0, + context()->GetRecipe(blanket_inrecipe)); fuel_startup_policy .Init(this, &tritium_storage, std::string("Tritium Storage"), @@ -66,7 +80,7 @@ void FusionPowerPlant::EnterNotify() { .Set(fuel_incommod) .Start(); - helium_sell_policy.Init(this, &helium_storage, std::string("Helium-3")) + helium_sell_policy.Init(this, &helium_excess, std::string("Helium-3")) .Set(he3_outcommod) .Start(); @@ -93,7 +107,7 @@ void FusionPowerPlant::Tick() { } else { //Some way of leaving a record of what is going wrong is helpful info I think - Record(Error); + //Record(Error); } DecayInventories(); @@ -108,7 +122,43 @@ void FusionPowerPlant::Tock() { //longer needed. Leaving a comment to remind myself about that. //Again, not sure about the recording: - RecordInventories(all_of_them.quantity()); + //RecordInventories(all_of_them.quantity()); + +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool FusionPowerPlant::CheckOperatingConditions() { + //Left empty to quickly check if code builds + return false; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FusionPowerPlant::SequesterTritium() { + //Left empty to quickly check if code builds + +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FusionPowerPlant::OperateReactor() { + //Left empty to quickly check if code builds + +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FusionPowerPlant::DecayInventories() { + //Left empty to quickly check if code builds + +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FusionPowerPlant::ExtractHelium() { + //Left empty to quickly check if code builds + +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FusionPowerPlant::MoveExcessTritiumToSellBuffer() { + //Left empty to quickly check if code builds } @@ -121,13 +171,15 @@ void FusionPowerPlant::CycleBlanket() { //guarantee blanket has enough material in CheckOperatingConditions() blanket->Absorb(blanket_feed.Pop(blanket_turnover)); - RecordOperationalInfo("Blanket Cycled"); - } else { - RecordOperationalInfo("Blanket Not Cycled"); } } } +bool FusionPowerPlant::BlanketCycleTime(){ + return (context()->time() % blanket_turnover_frequency == 0 + && !blanket_feed.empty()); +} + // WARNING! Do not change the following this function!!! This enables your // archetype to be dynamically loaded and any alterations will cause your // archetype to fail. diff --git a/src/fusion_power_plant.h b/src/fusion_power_plant.h index 27c96bb..bed2e57 100644 --- a/src/fusion_power_plant.h +++ b/src/fusion_power_plant.h @@ -4,6 +4,10 @@ #include #include "cyclus.h" +#include "boost/shared_ptr.hpp" +#include "pyne.h" + +using cyclus::Material; namespace tricycle { @@ -48,6 +52,9 @@ class FusionPowerPlant : public cyclus::Facility { #pragma cyclus note {"doc": "A stub facility is provided as a skeleton " \ "for the design of new facility agents."} + /// Set up policies and buffers: + virtual void EnterNotify(); + /// The handleTick function specific to the FusionPowerPlant. /// @param time the time of the tick virtual void Tick(); @@ -88,6 +95,17 @@ class FusionPowerPlant : public cyclus::Facility { } double buy_quantity; + #pragma cyclus var { \ + "default": 1, \ + "doc": "Frequency which reactor tries to purchase new fuel", \ + "tooltip": "Reactor is active for 1 timestep, then dormant for buy_frequency-1 timesteps", \ + "units": "Timesteps", \ + "uitype": "range", \ + "range": [0, 1e299], \ + "uilabel": "Buy frequency" \ + } + int buy_frequency; + #pragma cyclus var { \ "doc": "Helium-3 output commodity Designation", \ "tooltip": "He-3 output commodity", \ @@ -102,6 +120,13 @@ class FusionPowerPlant : public cyclus::Facility { } std::string blanket_inrecipe; + #pragma cyclus var { \ + "doc": "Blanket feed commodity designation", \ + "tooltip": "Blanket feed commodity", \ + "uilabel": "Blanket feed commodity" \ + } + std::string blanket_incommod; + #pragma cyclus var { \ "doc": "Blanket waste commodity designation", \ "tooltip": "Blanket waste commodity", \ @@ -109,6 +134,51 @@ class FusionPowerPlant : public cyclus::Facility { } std::string blanket_outcommod; + #pragma cyclus var { \ + "default": 1000.0, \ + "doc": "Initial mass of full blanket material", \ + "tooltip": "Only blanket material mass, not structural mass", \ + "units": "kg", \ + "uitype": "range", \ + "range": [0, 10000], \ + "uilabel": "Initial Mass of Blanket" \ + } + double blanket_size; + + #pragma cyclus var { \ + "default": 0.05, \ + "doc": "Percent of blanket that gets recycled every blanket turnover period", \ + "tooltip": "Defaults to 0.05 (5%), must be between 0 and 15%", \ + "units": "dimensionless", \ + "uitype": "range", \ + "range": [0, 0.15], \ + "uilabel": "Blanket Turnover Rate" \ + } + double blanket_turnover_quantity; + + #pragma cyclus var { \ + "default": 1, \ + "doc": "number of timesteps between blanket recycles", \ + "tooltip": "Defaults to 0.05 (5%), must be between 0 and 15%", \ + "units": "dimensionless", \ + "uitype": "range", \ + "range": [0, 1000], \ + "uilabel": "Blanket Turnover Rate" \ + } + int blanket_turnover_frequency; + + //Functions: + void CycleBlanket(); + bool BlanketCycleTime(); + bool CheckOperatingConditions(); + void SequesterTritium(); + void OperateReactor(); + void DecayInventories(); + void ExtractHelium(); + void MoveExcessTritiumToSellBuffer(); + + + private: //Resource Buffers and Trackers: cyclus::toolkit::ResBuf tritium_storage; cyclus::toolkit::ResBuf tritium_excess; @@ -127,32 +197,22 @@ class FusionPowerPlant : public cyclus::Facility { cyclus::toolkit::TotalInvTracker fuel_tracker; cyclus::toolkit::TotalInvTracker blanket_tracker; - //Functions: - void CycleBlanket(); - bool CheckOpeartingConditions(); - void SequesterTritium(); - void OperateReactor(); - void CycleBlanket(); - void DecayInventories(); - void ExtractHelium(); - void MoveExcessTritiumToSellBuffer(); - - private: - //This is to correctly instantiate the TotalInvTracker(s) - double fuel_limit = 1000.0; - double blanket_limit = 100000.0; - Material:Ptr blanket; + //This is to correctly instantiate the TotalInvTracker(s) + double fuel_limit = 1000.0; + double blanket_limit = 100000.0; + Material::Ptr blanket; + double blanket_turnover; - //NucIDs for Pyne - const int tritium_id = 10030000; + //NucIDs for Pyne + const int tritium_id = 10030000; - //Compositions: - const cyclus::CompMap T = {{tritium_id, 1}}; - const cyclus::Composition::Ptr tritium_comp = cyclus::Composition::CreateFromAtom(T); + //Compositions: + const cyclus::CompMap T = {{tritium_id, 1}}; + const cyclus::Composition::Ptr tritium_comp = cyclus::Composition::CreateFromAtom(T); - //Materials: - cyclus::Material::Ptr sequestered_tritium = cyclus::Material::CreateUntracked(0.0, tritium_comp); + //Materials: + cyclus::Material::Ptr sequestered_tritium = cyclus::Material::CreateUntracked(0.0, tritium_comp); // And away we go! };