Skip to content

Commit

Permalink
Merge pull request #529 from abachma2/deploy-manager-inst
Browse files Browse the repository at this point in the history
New feature for DeployInst: facilities now register with the region
  • Loading branch information
opotowsky authored Feb 10, 2022
2 parents fd1623c + 43137a2 commit c7506f1
Show file tree
Hide file tree
Showing 10 changed files with 461 additions and 23 deletions.
75 changes: 75 additions & 0 deletions input/deploy_inst.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<simulation>
<control>
<duration>10</duration>
<startmonth>1</startmonth>
<startyear>2018</startyear>
<decay>never</decay>
</control>

<archetypes>
<spec> <lib>agents</lib><name>NullRegion</name> </spec>
<spec> <lib>cycamore</lib><name>DeployInst</name> </spec>
<spec> <lib>cycamore</lib><name>Source</name> </spec>
<spec> <lib>cycamore</lib><name>Sink</name> </spec>
</archetypes>

<facility>
<name>Source</name>
<config>
<Source>
<outcommod>commodity1</outcommod>
<outrecipe>commod_recipe</outrecipe>
<throughput>1</throughput>
</Source>
</config>
</facility>

<facility>
<name>Sink</name>
<config>
<Sink>
<in_commods>
<val>commodity1</val>
</in_commods>
</Sink>
</config>
</facility>

<region>
<name>Single Region</name>
<config>
<NullRegion/>
</config>

<institution>
<initialfacilitylist>
<entry>
<prototype>Sink</prototype>
<number>1</number>
</entry>
</initialfacilitylist>
<name>Single Institution</name>
<config>
<DeployInst>
<prototypes>
<val>Source</val>
</prototypes>
<build_times>
<val>1</val>
</build_times>
<n_build>
<val>1</val>
</n_build>
</DeployInst>
</config>
</institution>
</region>

<recipe>
<name>commod_recipe</name>
<basis>mass</basis>
<nuclide> <id>922350000</id> <comp>0.711</comp> </nuclide>
<nuclide> <id>922380000</id> <comp>99.289</comp> </nuclide>
</recipe>

</simulation>
118 changes: 118 additions & 0 deletions input/growth/deploy_and_manager_insts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<simulation>
<control>
<duration>10</duration>
<startmonth>1</startmonth>
<startyear>2018</startyear>
<decay>never</decay>
</control>

<archetypes>
<spec> <lib>cycamore</lib><name>GrowthRegion</name> </spec>
<spec> <lib>cycamore</lib><name>DeployInst</name> </spec>
<spec> <lib>cycamore</lib><name>ManagerInst</name> </spec>
<spec> <lib>cycamore</lib><name>Source</name> </spec>
<spec> <lib>cycamore</lib><name>Sink</name> </spec>
</archetypes>

<commodity>
<name>commodity1</name>
<solution_priority>1.0</solution_priority>
</commodity>

<facility>
<name>Source1</name>
<config>
<Source>
<outcommod>commodity1</outcommod>
<outrecipe>commod_recipe</outrecipe>
<throughput>1</throughput>
</Source>
</config>
</facility>

<facility>
<name>Source2</name>
<config>
<Source>
<outcommod>commodity1</outcommod>
<outrecipe>commod_recipe</outrecipe>
<throughput>1</throughput>
</Source>
</config>
</facility>

<facility>
<name>Sink</name>
<config>
<Sink>
<in_commods>
<val>commodity1</val>
</in_commods>
</Sink>
</config>
</facility>

<region>
<name>Single Region</name>
<config>
<GrowthRegion>
<growth>
<item>
<commod>commodity1</commod>
<piecewise_function>
<piece>
<start>5</start>
<function>
<type>linear</type>
<params>0 5</params>
</function>
</piece>
</piecewise_function>
</item>
</growth>
</GrowthRegion>
</config>

<institution>
<name>First Institution</name>
<initialfacilitylist>
<entry>
<prototype>Sink</prototype>
<number>1</number>
</entry>
</initialfacilitylist>
<config>
<ManagerInst>
<prototypes>
<val>Source2</val>
</prototypes>
</ManagerInst>
</config>
</institution>

<institution>
<name>Second Institution</name>
<config>
<DeployInst>
<prototypes>
<val>Source1</val>
</prototypes>
<build_times>
<val>1</val>
</build_times>
<n_build>
<val>1</val>
</n_build>
</DeployInst>
</config>
</institution>
</region>

<recipe>
<name>commod_recipe</name>
<basis>mass</basis>
<nuclide> <id>922350000</id> <comp>0.711</comp> </nuclide>
<nuclide> <id>922380000</id> <comp>99.289</comp> </nuclide>
</recipe>

</simulation>
1 change: 1 addition & 0 deletions src/cycamore.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "batch_reactor.h"
#include "batch_reactor_tests.h"
#include "deploy_inst.h"
#include "deploy_inst_tests.h"
#include "enrichment.h"
#include "enrichment_tests.h"
#if CYCLUS_HAS_COIN
Expand Down
51 changes: 51 additions & 0 deletions src/deploy_inst.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,57 @@ void DeployInst::EnterNotify() {
RecordPosition();
}

void DeployInst::BuildNotify(Agent* a) {
Register_(a);
}

void DeployInst::DecomNotify(Agent* a) {
Unregister_(a);
}

void DeployInst::Register_(Agent* a) {
using cyclus::toolkit::CommodityProducer;
using cyclus::toolkit::CommodityProducerManager;

CommodityProducer* cp_cast = dynamic_cast<CommodityProducer*>(a);
if (cp_cast != NULL) {
LOG(cyclus::LEV_INFO3, "mani") << "Registering agent "
<< a->prototype() << a->id()
<< " as a commodity producer.";
CommodityProducerManager::Register(cp_cast);
}
}

void DeployInst::Unregister_(Agent* a) {
using cyclus::toolkit::CommodityProducer;
using cyclus::toolkit::CommodityProducerManager;

CommodityProducer* cp_cast = dynamic_cast<CommodityProducer*>(a);
if (cp_cast != NULL)
CommodityProducerManager::Unregister(cp_cast);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DeployInst::WriteProducerInformation(
cyclus::toolkit::CommodityProducer* producer) {
using std::set;
set<cyclus::toolkit::Commodity,
cyclus::toolkit::CommodityCompare> commodities =
producer->ProducedCommodities();
set<cyclus::toolkit::Commodity, cyclus::toolkit::CommodityCompare>::
iterator it;

LOG(cyclus::LEV_DEBUG3, "maninst") << " Clone produces " << commodities.size()
<< " commodities.";
for (it = commodities.begin(); it != commodities.end(); it++) {
LOG(cyclus::LEV_DEBUG3, "maninst") << " Commodity produced: " << it->name();
LOG(cyclus::LEV_DEBUG3, "maninst") << " capacity: " <<
producer->Capacity(*it);
LOG(cyclus::LEV_DEBUG3, "maninst") << " cost: " <<
producer->Cost(*it);
}
}

void DeployInst::RecordPosition() {
std::string specification = this->spec();
context()
Expand Down
23 changes: 20 additions & 3 deletions src/deploy_inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ typedef std::map<int, std::vector<std::string> > BuildSched;
// lifetimes. The same prototype can be specified multiple times with any
// combination of the same or different build times, build number, and
// lifetimes.
class DeployInst : public cyclus::Institution,
class DeployInst :
public cyclus::Institution,
public cyclus::toolkit::CommodityProducerManager,
public cyclus::toolkit::Position {
#pragma cyclus note { \
"doc": \
"Builds and manages agents (facilities) according to a manually" \
" specified deployment schedule. Deployed agents are automatically" \
" decommissioned at the end of their lifetime. The user specifies a" \
" list of prototypes for" \
" decommissioned at the end of their lifetime. Deployed and" \
" decommissioned agents are registered and unregistered with a" \
" region. The user specifies a list of prototypes for" \
" each and corresponding build times, number to build, and (optionally)" \
" lifetimes. The same prototype can be specified multiple times with" \
" any combination of the same or different build times, build number," \
Expand All @@ -45,6 +48,20 @@ class DeployInst : public cyclus::Institution,

virtual void EnterNotify();

virtual void BuildNotify(Agent* m);
virtual void DecomNotify(Agent* m);
/// write information about a commodity producer to a stream
/// @param producer the producer
void WriteProducerInformation(cyclus::toolkit::CommodityProducer*
producer);

private:
/// register a child
void Register_(cyclus::Agent* agent);

/// unregister a child
void Unregister_(cyclus::Agent* agent);

protected:
#pragma cyclus var { \
"doc": "Ordered list of prototypes to build.", \
Expand Down
Loading

0 comments on commit c7506f1

Please sign in to comment.