Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add random behavior for size of sink request #550

Merged
merged 6 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Sink::~Sink() {}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sink::EnterNotify() {
cyclus::Facility::EnterNotify();
LOG(cyclus::LEV_INFO4, "SnkFac") << " using random behavior " << random_size;

if (in_commod_prefs.size() == 0) {
for (int i = 0; i < in_commods.size(); ++i) {
Expand Down Expand Up @@ -164,9 +165,36 @@ void Sink::Tick() {
using std::vector;
LOG(cyclus::LEV_INFO3, "SnkFac") << prototype() << " is ticking {";

double requestAmt = RequestAmt();
double amt = RequestAmt();
double requestAmt = 0;

LOG(cyclus::LEV_INFO3, "SnkFac") << prototype() << " has default request amount " << amt;

// inform the simulation about what the sink facility will be requesting
if (requestAmt > cyclus::eps()) {
if (amt > cyclus::eps()) {
if (random_size == "None") {
requestAmt = amt;
}
else if (random_size == "UniformInt") {
requestAmt = context()->random_uniform_int(0, amt);
}
else if (random_size == "UniformReal") {
requestAmt = context()->random_uniform_real(0, amt);
}
else if (random_size == "NormalReal") {
requestAmt = context()->random_normal_real(amt * random_size_mean,
gonuke marked this conversation as resolved.
Show resolved Hide resolved
amt * random_size_stddev, 0, amt);
nuclearkatie marked this conversation as resolved.
Show resolved Hide resolved
}
else if (random_size == "NormalInt") {
requestAmt = context()->random_normal_int(amt * random_size_mean,
amt * random_size_stddev, 0, amt);
nuclearkatie marked this conversation as resolved.
Show resolved Hide resolved
}
else {
requestAmt = amt;
gonuke marked this conversation as resolved.
Show resolved Hide resolved
}
LOG(cyclus::LEV_INFO4, "SnkFac") << prototype()
<< " has request amount " << requestAmt
<< " kg of " << in_commods[0] << ".";
for (vector<string>::iterator commod = in_commods.begin();
commod != in_commods.end();
commod++) {
Expand Down
38 changes: 38 additions & 0 deletions src/sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,44 @@ class Sink
#pragma cyclus var {'capacity': 'max_inv_size'}
cyclus::toolkit::ResBuf<cyclus::Resource> inventory;

/// random status (size of request)
#pragma cyclus var {"default": "None", \
"tooltip": "type of random behavior when setting the " \
"size of the request", \
"uitype": "combobox", \
"uilabel": "Random Size", \
"categorical": ["None", "UniformReal", "UniformInt", "NormalReal", "NormalInt"], \
"doc": "type of random behavior to use. Default None, " \
"other options are 'UniformReal', 'UniformInt', " \
"'NormalReal', and 'NormalInt'"}
std::string random_size;
nuclearkatie marked this conversation as resolved.
Show resolved Hide resolved

// random size mean (as a fraction of available space)
#pragma cyclus var {"default": 1.0, \
"tooltip": "fraction of available space to determine the mean", \
"uilabel": "Random Size Mean", \
"uitype": "range", \
"range": [0.0, 1.0], \
"doc": "When a normal distribution is used to determine the " \
"size of the request, this is the fraction of available " \
"space to use as the mean. Default 1.0, must be between " \
"0.0 and 1.0"}
double random_size_mean;

// random size std dev (as a fraction of available space)
#pragma cyclus var {"default": 0.1, \
"tooltip": "fraction of available space to determine the std dev", \
"uilabel": "Random Size Std Dev", \
"uitype": "range", \
"range": [0.0, 1e299], \
"doc": "When a normal distribution is used to determine the " \
"size of the request, this is the fraction of available " \
"space to use as the standard deviation. Default 0.1"}
double random_size_stddev;


// random status (frequencing/timing of request)

#pragma cyclus var { \
"default": 0.0, \
"uilabel": "Geographical latitude in degrees as a double", \
Expand Down
Loading