6#include "../Branch/BranchRecord.h"
7#include "../Global/SimulationContext.h"
44 string comp_type, comp_name, comp_unit;
48 file_name +=
"RELAP5_channels.txt";
49 ifstream fin(file_name.c_str(), ios::in);
53 cout <<
"FATAL: File: " << file_name <<
" could not be found" << endl;
54 ofstream fout(
"err messages.txt", ios::app);
55 fout <<
r5pars_.timesno <<
" FATAL: File: " << file_name <<
" could not be found\n";
60 fin >> comp_type >> n_comp;
61 for(i = 0; i < n_comp; i++){
62 auto p = make_unique<HydraulicVolume>();
63 p->readInfoFromFile(fin);
67 fin >> comp_type >> n_comp;
68 for(i = 0; i < n_comp; i++){
69 auto p = make_unique<HydraulicJunction>();
70 p->readInfoFromFile(fin);
74 fin >> comp_type >> n_comp;
75 for(i = 0; i < n_comp; i++){
76 auto p = make_unique<VariableTrip>();
77 p->readInfoFromFile(fin);
81 fin >> comp_type >> n_comp;
82 for(i = 0; i < n_comp; i++){
83 auto p = make_unique<LogicalTrip>();
84 p->readInfoFromFile(fin);
88 fin >> comp_type >> n_comp;
89 for(i = 0; i < n_comp; i++){
90 auto p = make_unique<InteractiveVariable>();
91 p->readInfoFromFile(fin);
92 p->setSequenceInTheArray(i);
96 fin >> comp_type >> n_comp;
97 for(i = 0; i < n_comp; i++){
98 auto p = make_unique<HeatStructure>();
99 p->readInfoFromFile(fin);
103 fin >> comp_type >> n_comp;
104 for(i = 0; i < n_comp; i++){
105 auto p = make_unique<ControlVariable>();
106 p->readInfoFromFile(fin);
139 int i, max_channel, max_ht, max_mesh, n_return,
n_mesh;
152 if (
r5pars_.n_hydrov > max_channel){
153 ofstream fout(
"err messages.txt", ios_base::out | ios_base::app);
154 fout <<
r5pars_.timesno <<
" SystemModule::setConnectionToRELAP5: r5pars_.n_hydrov value " <<
r5pars_.n_hydrov
155 <<
" exceeds the maximum allowance value " << max_channel <<
'\n';
159 if (
r5pars_.n_hydroj > max_channel){
160 ofstream fout(
"err messages.txt", ios_base::out | ios_base::app);
161 fout <<
r5pars_.timesno <<
" SystemModule::setConnectionToRELAP5: r5pars_.n_hydroj value " <<
r5pars_.n_hydroj
162 <<
" exceeds the maximum allowance value " << max_channel <<
'\n';
166 if (
r5pars_.n_vartrip > max_channel){
167 ofstream fout(
"err messages.txt", ios_base::out | ios_base::app);
168 fout <<
r5pars_.timesno <<
" SystemModule::setConnectionToRELAP5: r5pars_.n_vartrip value " <<
r5pars_.n_vartrip
169 <<
" exceeds the maximum allowance value " << max_channel <<
'\n';
173 if (
r5pars_.n_logtrip > max_channel){
174 ofstream fout(
"err messages.txt", ios_base::out | ios_base::app);
175 fout <<
r5pars_.timesno <<
" SystemModule::setConnectionToRELAP5: r5pars_.n_logtrip value " <<
r5pars_.n_logtrip
176 <<
" exceeds the maximum allowance value " << max_channel <<
'\n';
180 if (
r5pars_.n_interact > max_channel){
181 ofstream fout(
"err messages.txt", ios_base::out | ios_base::app);
182 fout <<
r5pars_.timesno <<
" SystemModule::setConnectionToRELAP5: r5pars_.n_interact value " <<
r5pars_.n_interact
183 <<
" exceeds the maximum allowance value " << max_channel <<
'\n';
187 if (
r5pars_.n_ctrl_var > max_channel){
188 ofstream fout(
"err messages.txt", ios_base::out | ios_base::app);
189 fout <<
r5pars_.timesno <<
" SystemModule::setConnectionToRELAP5: r5pars_.n_ctrl_var value " <<
r5pars_.n_ctrl_var
190 <<
" exceeds the maximum allowance value " << max_channel <<
'\n';
197 if (
r5pars_.n_heatstr > max_ht){
198 ofstream fout(
"err messages.txt", ios_base::out | ios_base::app);
199 fout <<
r5pars_.timesno <<
" SystemModule::setConnectionToRELAP5: r5pars_.n_heatstr value " <<
r5pars_.n_heatstr
200 <<
" exceeds the maximum allowance value " << max_ht <<
'\n';
209 for(i = 0; i <
r5pars_.n_heatstr; i++){
213 ofstream fout(
"err messages.txt", ios_base::out | ios_base::app);
214 fout <<
r5pars_.timesno <<
" SystemModule::setConnectionToRELAP5: total mesh points" <<
n_mesh
215 <<
" exceeds the maximum allowance value " << max_mesh <<
'\n';
221 for(i = 0; i <
r5pars_.n_hydrov; i++){
223 for(i = 0; i <
r5pars_.n_hydroj; i++){
225 for(i = 0; i <
r5pars_.n_vartrip; i++){
227 for(i = 0; i <
r5pars_.n_logtrip; i++){
229 for(i = 0; i <
r5pars_.n_interact; i++){
231 for(i = 0; i <
r5pars_.n_ctrl_var; i++){
233 for(i = 0; i <
r5pars_.n_heatstr; i++){
254 (*hv_itr)->setLiquidTemperature(
r5pars_.liq_t[i]);
255 (*hv_itr)->setVaporTemperature(
r5pars_.vap_t[i]);
256 (*hv_itr)->setSaturationTemperature(
r5pars_.sat_t[i]);
257 (*hv_itr)->setPressure(
r5pars_.sys_pressure[i]);
258 (*hv_itr)->setBoronDensity(
r5pars_.boron_d[i]);
259 (*hv_itr)->setEquilibriumQuality(
r5pars_.quality[i]);
260 (*hv_itr)->setFlowRegimeNumber(
r5pars_.flow_reg[i]);
266 (*hj_itr)->setLiquidVelocity(
r5pars_.liq_vel[i]);
267 (*hj_itr)->setMassFlowRate(
r5pars_.mass_fr[i]);
268 (*hj_itr)->setVaporVelocity(
r5pars_.vap_vel[i]);
274 (*vt_itr)->setTripTime(
r5pars_.vartrip_t[i]);
280 (*lt_itr)->setTripTime(
r5pars_.logtrip_t[i]);
286 (*iv_itr)->setDisplayValue(
r5pars_.inter_val[i]);
292 (*ctrl_itr)->setControlValue(
r5pars_.ctrl_var_val[i]);
298 for(i = 0; i < (*ht_itr)->getNumberOfMeshPoints(); i++){
299 (*ht_itr)->setMeshPointTemperature(i,
r5pars_.mesh_t[j]);
308 string name, str1, str2, str3, str4, str5, str6, str7;
319 name = (*hv_itr)->getName();
320 for(i = 0; i < 7; i++){
321 fout << name <<
'\t';
326 name = (*hj_itr)->getName();
327 for(i = 0; i < 3; i++){
328 fout << name <<
'\t';
333 fout << (*vt_itr)->getName() <<
'\t';
337 fout << (*lt_itr)->getName() <<
'\t';
341 fout << (*iv_itr)->getName() <<
'\t';
345 fout << (*ctrl_itr)->getName() <<
'\t';
349 name = (*ht_itr)->getName();
350 for(i = 0; i < (*ht_itr)->getNumberOfMeshPoints(); i++){
351 fout << name <<
'\t';
372 (*hv_itr)->setUnitOfLiquidTemperature(
r5pars_.si_unit);
373 (*hv_itr)->setUnitOfVaporTemperature(
r5pars_.si_unit);
374 (*hv_itr)->setUnitOfSaturationTemperature(
r5pars_.si_unit);
375 (*hv_itr)->setUnitOfPressure(
r5pars_.si_unit);
376 (*hv_itr)->setUnitOfBoronDensity(
r5pars_.si_unit);
377 str1 =
"Liquid_T("; str1 += (*hv_itr)->getUnitOfLiquidTemperature(); str1 +=
")";
378 str2 =
"Vapor_T("; str2 += (*hv_itr)->getUnitOfVaporTemperature(); str2 +=
")";
379 str3 =
"Sat_T("; str3 += (*hv_itr)->getUnitOfSaturationTemperature(); str3 +=
")";
380 str4 =
"Pressure("; str4 += (*hv_itr)->getUnitOfPressure(); str4 +=
")";
381 str5 =
"Boron_density("; str5 += (*hv_itr)->getUnitOfBoronDensity(); str5 +=
")";
382 str6 =
"Equilibrium";
383 str7 =
"Flow_regime";
384 fout << str1 <<
'\t' << str2 <<
'\t' << str3 <<
'\t' << str4 <<
'\t' << str5 <<
'\t' << str6 <<
'\t' << str7 <<
'\t';
388 (*hj_itr)->setUnitOfLiquidVelocity(
r5pars_.si_unit);
389 (*hj_itr)->setUnitOfMassFlowRate(
r5pars_.si_unit);
390 (*hj_itr)->setUnitOfVaporVelocity(
r5pars_.si_unit);
391 str1 =
"Liquid_vel("; str1 += (*hj_itr)->getUnitOfLiquidVelocity(); str1 +=
")";
392 str2 =
"Mass_flow("; str2 += (*hj_itr)->getUnitOfMassFlowRate(); str2 +=
")";
393 str3 =
"Vapor_vel("; str3 += (*hj_itr)->getUnitOfVaporVelocity(); str3 +=
")";
394 fout << str1 <<
'\t' << str2 <<
'\t' << str3 <<
'\t';
398 fout <<
"Trip_time(s)\t";
402 fout <<
"Trip_time(s)\t";
410 fout << (*ctrl_itr)->getUnitOfControlValue() <<
'\t';
415 (*ht_itr)->setUnitOfMeshPointTemperature(
r5pars_.si_unit);
416 for(i = 0; i < (*ht_itr)->getNumberOfMeshPoints(); i++){
418 str1 += to_string(i);
420 str1 += (*ht_itr)->getUnitOfMeshPointTemperature();
422 fout << str1 <<
'\t';
433 (*hv_itr)->setUnitOfLiquidTemperature(
r5pars_.si_unit);
434 (*hv_itr)->setUnitOfVaporTemperature(
r5pars_.si_unit);
435 (*hv_itr)->setUnitOfSaturationTemperature(
r5pars_.si_unit);
436 (*hv_itr)->setUnitOfPressure(
r5pars_.si_unit);
437 (*hv_itr)->setUnitOfBoronDensity(
r5pars_.si_unit);
441 (*hj_itr)->setUnitOfLiquidVelocity(
r5pars_.si_unit);
442 (*hj_itr)->setUnitOfMassFlowRate(
r5pars_.si_unit);
443 (*hj_itr)->setUnitOfVaporVelocity(
r5pars_.si_unit);
447 (*ht_itr)->setUnitOfMeshPointTemperature(
r5pars_.si_unit);
462 fout << (*hv_itr)->getLiquidTemperature() <<
'\t'
463 << (*hv_itr)->getVaporTemperature() <<
'\t'
464 << (*hv_itr)->getSaturationTemperature() <<
'\t'
465 << (*hv_itr)->getPressure() <<
'\t'
466 << (*hv_itr)->getBoronDensity() <<
'\t'
467 << (*hv_itr)->getEquilibriumQuality() <<
'\t'
468 << (*hv_itr)->getFlowRegimeNumber() <<
'\t';
472 fout << (*hj_itr)->getLiquidVelocity() <<
'\t'
473 << (*hj_itr)->getMassFlowRate() <<
'\t'
474 << (*hj_itr)->getVaporVelocity() <<
'\t';
478 fout << (*vt_itr)->getTripTime() <<
'\t';
482 fout << (*lt_itr)->getTripTime() <<
'\t';
486 fout << (*iv_itr)->getDisplayValue() <<
'\t';
490 fout << (*ctrl_itr)->getControlValue() <<
'\t';
494 for(i = 0; i < (*ht_itr)->getNumberOfMeshPoints(); i++){
495 fout << (*ht_itr)->getMeshPointTemperature(i) <<
'\t';
504 map<string, THElement *>::iterator itr;
510 ofstream fout(
"err messages.txt", ios::app);
511 cout <<
"SystemModule::getComponentFromSystemMap indicator " << _str <<
" could not be found in plant." << endl;
512 fout <<
r5pars_.timesno <<
" SystemModule::getComponentFromSystemMap indicator " << _str <<
" could not be found in plant.\n";
524 cout <<
"FATAL: SystemModule::setConnectionToRELAP5 failed — channel counts exceed "
525 <<
"the r5pars_ bridge capacity (see err messages.txt)." << endl;
532 cout <<
"FATAL: SystemModule::setConnectionToRELAP5 failed — channel counts exceed "
533 <<
"the r5pars_ bridge capacity (see err messages.txt)." << endl;
541 (*itr)->executeInteractiveAction();
559 (*hv_itr)->saveHydraulicVolumeToFile(fout);
563 (*hj_itr)->saveHydraulicJunctionToFile(fout);
567 (*vt_itr)->saveVariableTripToFile(fout);;
571 (*lt_itr)->saveLogicalTripToFile(fout);
575 (*iv_itr)->saveInteractiveVariableToFile(fout);
579 (*hs_itr)->saveHeatStructureToFile(fout);
583 (*cv_itr)->saveControlVariableToFile(fout);
594 fin >> str >> n_comp;
595 if(str !=
"SystemModule"){
596 ofstream fout(
"err messages.txt", ios::app);
597 cout <<
"SystemModule::retrieveSystemModuleFromFile File retrieval error in previous function" << endl;
598 fout <<
r5pars_.timesno <<
" SystemModule::retrieveSystemModuleFromFile File retrieval error in previous function\n";
605 for(i = 0; i < n_comp; i++){
606 auto ptr = make_unique<HydraulicVolume>();
607 ptr->retrieveHydraulicVolumeFromFile(fin);
612 for(i = 0; i < n_comp; i++){
613 auto ptr = make_unique<HydraulicJunction>();
614 ptr->retrieveHydraulicJunctionFromFile(fin);
619 for(i = 0; i < n_comp; i++){
620 auto ptr = make_unique<VariableTrip>();
621 ptr->retrieveVariableTripFromFile(fin);
626 for(i = 0; i < n_comp; i++){
627 auto ptr = make_unique<LogicalTrip>();
628 ptr->retrieveLogicalTripFromFile(fin);
633 for(i = 0; i < n_comp; i++){
634 auto ptr = make_unique<InteractiveVariable>();
635 ptr->retrieveInteractiveVariableFromFile(fin);
636 ptr->setSequenceInTheArray(i);
641 for(i = 0; i < n_comp; i++){
642 auto ptr = make_unique<HeatStructure>();
643 ptr->retrieveHeatStructureFromFile(fin);
648 for(i = 0; i < n_comp; i++){
649 auto ptr = make_unique<ControlVariable>();
650 ptr->retrieveControlVariableFromFile(fin);
687 auto ptr = make_unique<ControlVariable>();
688 ptr->copyControlVariable(*src);
692 auto ptr = make_unique<HeatStructure>();
693 ptr->copyHeatStructure(*src);
697 auto ptr = make_unique<HydraulicJunction>();
698 ptr->copyHydraulicJunction(*src);
702 auto ptr = make_unique<HydraulicVolume>();
703 ptr->copyHydraulicVolume(*src);
707 auto ptr = make_unique<InteractiveVariable>();
708 ptr->copyInteractiveVariable(*src);
712 auto ptr = make_unique<LogicalTrip>();
713 ptr->copyLogicalTrip(*src);
717 auto ptr = make_unique<VariableTrip>();
718 ptr->copyVariableTrip(*src);
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
map< string, THElement * > sm_type
Maps RELAP5 input deck components to C++ objects for T-H parameter access.
void setTempTypeOfConsequence(Consequence)
Stores the consequence of the end state the running sequence will get.
void setTempESMessage(std::string)
Stores the description of the end state the running sequence will get if it is terminated (set by mod...
std::string getSystemDirectory()
std::map< std::string, THElement * > system_map
std::vector< std::unique_ptr< HeatStructure > > heat_structure_array
THElement * getComponentFromSystemMap(std::string)
void outputParametersValuesToFile(std::ofstream &)
void initiationForSimulation()
std::vector< std::unique_ptr< VariableTrip > > variable_trip_array
std::vector< std::unique_ptr< HydraulicVolume > > hydraulic_volume_array
void retrieveSystemModuleFromFile(std::ifstream &)
void executeActionsToInteractWithSystem()
std::vector< std::unique_ptr< HydraulicJunction > > hydraulic_junction_array
std::vector< std::unique_ptr< LogicalTrip > > logical_trip_array
void copySystemModule(SystemModule &)
void initiationForSimulationClient()
void updateParametersValues()
std::vector< std::unique_ptr< InteractiveVariable > > interactive_variable_array
void outputParametersLabelsToFile(std::ofstream &)
void clearSystemModiule()
std::vector< std::unique_ptr< ControlVariable > > control_variable_array
int setConnectionToRELAP5()
void saveSystemModuleToFile(std::ofstream &)
int n_mesh[10]
Number of mesh points per heat structure.
Scheduler SScheduler
Simulation scheduling, parses CLI options.
BranchRecord Branch_center
Dynamic event tree state.