diff --git a/src/sink.cc b/src/sink.cc index 5fde24893..710162cfb 100644 --- a/src/sink.cc +++ b/src/sink.cc @@ -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) { @@ -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, + amt * random_size_stddev, 0, amt); + } + else if (random_size == "NormalInt") { + requestAmt = context()->random_normal_int(amt * random_size_mean, + amt * random_size_stddev, 0, amt); + } + else { + requestAmt = amt; + } + LOG(cyclus::LEV_INFO4, "SnkFac") << prototype() + << " has request amount " << requestAmt + << " kg of " << in_commods[0] << "."; for (vector::iterator commod = in_commods.begin(); commod != in_commods.end(); commod++) { diff --git a/src/sink.h b/src/sink.h index f5fabedd5..852497e43 100644 --- a/src/sink.h +++ b/src/sink.h @@ -154,6 +154,44 @@ class Sink #pragma cyclus var {'capacity': 'max_inv_size'} cyclus::toolkit::ResBuf 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; + + // 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", \