Skip to content

Commit

Permalink
made changes necessary to get tricycle to build
Browse files Browse the repository at this point in the history
  • Loading branch information
dean-krueger committed Oct 7, 2024
1 parent fc90dc3 commit c87f95d
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 32 deletions.
72 changes: 62 additions & 10 deletions src/fusion_power_plant.cc
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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"),
Expand Down Expand Up @@ -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();

Expand All @@ -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();
Expand All @@ -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

}

Expand All @@ -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.
Expand Down
104 changes: 82 additions & 22 deletions src/fusion_power_plant.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <string>

#include "cyclus.h"
#include "boost/shared_ptr.hpp"
#include "pyne.h"

using cyclus::Material;

namespace tricycle {

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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", \
Expand All @@ -102,13 +120,65 @@ 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", \
"uilabel": "Blanket waste commodity" \
}
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<cyclus::Material> tritium_storage;
cyclus::toolkit::ResBuf<cyclus::Material> tritium_excess;
Expand All @@ -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!
};
Expand Down

0 comments on commit c87f95d

Please sign in to comment.