virtual void SetUp() { u235 = 92235; am241 = 95241; th228 = 90228; pb208 = 82208; u235_halflife = 8445600000; // approximate, in months th228_halflife = 2 * 11; // approximate, in months vect_decay_size = 1.0; vect_decay1.setAtomCount(u235, vect_decay_size); vect_decay2.setAtomCount(u235, 1.0); vect_decay2.setAtomCount(th228, 1.0); vect_decay2.setAtomCount(vect_decay_size); }
virtual void SetUp() { try { double grams_per_kg = 1000; isotope_lower_limit = 1001; isotope_upper_limit = 1182949; isotope_not_present = 9001; oxygen = 8001; u235 = 92235; u238 = 92238; pu240 = 94240; v1_m_oxygen = 1; v1_m_u235 = 10; v1_m_u238 = 100; v2_m_oxygen = 2; v2_m_u235 = 20; v2_m_pu240 = 2000; v1_a_oxygen = v1_m_oxygen * grams_per_kg / MT->getMassInGrams(oxygen); v1_a_u235 = v1_m_u235 * grams_per_kg / MT->getMassInGrams(u235); v1_a_u238 = v1_m_u238 * grams_per_kg / MT->getMassInGrams(u238); v2_a_oxygen = v2_m_oxygen * grams_per_kg / MT->getMassInGrams(oxygen); v2_a_u235 = v2_m_u235 * grams_per_kg / MT->getMassInGrams(u235); v2_a_pu240 = v2_m_pu240 * grams_per_kg / MT->getMassInGrams(pu240); total_mass1 = v1_m_oxygen + v1_m_u235 + v1_m_u238; total_mass2 = v2_m_oxygen + v2_m_u235 + v2_m_pu240; total_moles1 = v1_a_oxygen + v1_a_u235 + v1_a_u238; total_moles2 = v2_a_oxygen + v2_a_u235 + v2_a_pu240; comp_map[oxygen] = v2_a_oxygen; comp_map[u235] = v2_a_u235; comp_map[pu240] = v2_a_pu240; vect1.setMass(oxygen, v1_m_oxygen); vect1.setMass(u235, v1_m_u235); vect1.setMass(u238, v1_m_u238); vect2 = CompMap(comp_map); } catch (std::exception err) { LOG(LEV_ERROR, "none!") << err.what(); FAIL() << "An exception was thrown in the fixture SetUp."; } }
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SourceFacility::generateMaterial(int curr_time) { int time_change = curr_time - prev_time_; prev_time_ = curr_time; // if there's room in the inventory, process material at capacity double empty_space = inventory_.space(); if (empty_space < EPS_KG) {return;} IsoVector temp = recipe_; if (capacity_ * recipe_.mass() * time_change <= empty_space) { // add a material the size of the capacity to the inventory temp.multBy(capacity_ * time_change); } else { // add a material that fills the inventory temp.setMass(empty_space); } mat_rsrc_ptr newMat = mat_rsrc_ptr(new Material(temp)); newMat->setOriginatorID( this->ID() ); inventory_.pushOne(newMat); }
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SeparationsMatrixFacility::makeOffers() { for (vector<string>::iterator iter = out_commod_.begin(); iter != out_commod_.end(); iter ++){ // decide how much to offer double offer_amt; double spotCapacity = capacity_ - outstMF_; // and offer no more than the spotCapacity allows you to produce offer_amt = spotCapacity; // there is no minimum amount a separations facility may send double min_amt = 0; // this will be an offer for free stuff // until cyclus has a working notion of default pricing for separated material double commod_price = 0; // decide what market to offer to Communicator* recipient = dynamic_cast<Communicator*>(MarketModel::marketForCommod(*iter)); // build a material IsoVector comp; comp.setMass(1001, offer_amt); Material* offer_mat = new Material(comp); // build the transaction and message Transaction trans; trans.commod = (*iter); trans.minfrac = min_amt/offer_amt; trans.is_offer = true; trans.price = commod_price; trans.resource = offer_mat; msg_ptr msg(new Message(this, recipient, trans)); msg->setNextDest(facInst()); msg->sendOn(); } }
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SourceFacility::handleTock(int time){ // if there's room in the inventory, process material at capacity double space = inventory_size_ - this->checkInventory(); if (capacity_ * recipe_.mass() <= space) { // add a material the size of the capacity to the inventory IsoVector temp = recipe_; temp.multBy(capacity_); Material* newMat = new Material(temp); LOG(LEV_DEBUG2) << facName() << ", handling the tock, has created a material:"; newMat->print(); inventory_.push_front(newMat); } else if (space < capacity_*recipe_.mass() && space > 0) { // add a material that fills the inventory IsoVector temp = recipe_; temp.setMass(space); Material* newMat = new Material(temp); LOG(LEV_DEBUG2) << facName() << ", handling the tock, has created a material:"; newMat->print(); inventory_.push_front(newMat); } // check what orders are waiting, // send material if you have it now while (!ordersWaiting_.empty()) { msg_ptr order = ordersWaiting_.front(); order->approveTransfer(); ordersWaiting_.pop_front(); } // For now, lets just print out what we have at each timestep. LOG(LEV_DEBUG2) << "SourceFacility " << this->ID() << " is holding " << this->checkInventory() << " units of material at the close of month " << time << "."; // call the facility model's handle tock last // to check for decommissioning FacilityModel::handleTock(time); }