GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 18 / 0 / 18
Functions: 100.0% 2 / 0 / 2
Branches: 100.0% 36 / 0 / 36

src/energyplus/ForwardTranslator/ForwardTranslateSimulationControl.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include "../ForwardTranslator.hpp"
7
8 #include "../../model/SimulationControl.hpp"
9
10 #include "../../model/PlantLoop.hpp"
11 #include "../../model/PlantLoop_Impl.hpp"
12 #include "../../model/SizingPeriod.hpp"
13 #include "../../model/SizingPeriod_Impl.hpp"
14 #include "../../model/SizingPlant.hpp"
15
16 #include <utilities/idd/SimulationControl_FieldEnums.hxx>
17 #include <utilities/idd/IddEnums.hxx>
18
19 using namespace openstudio::model;
20
21 using namespace std;
22
23 namespace openstudio {
24
25 namespace energyplus {
26
27 870 boost::optional<IdfObject> ForwardTranslator::translateSimulationControl(SimulationControl& modelObject) {
28
29
2/2
✓ Branch 1 taken 870 times.
✓ Branch 4 taken 870 times.
870 IdfObject simCon = createAndRegisterIdfObject(openstudio::IddObjectType::SimulationControl, modelObject);
30
31
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 2560 times.
4360 auto boolToString = [](bool b) { return b ? "Yes" : "No"; };
32
33 // NOTE: the logic for these three where it's defaulted is inside the model object:
34 // it checks if you have Design Days + (Zonal equipment / AirLoopHVAC / PlantLoop)
35
3/3
✓ Branch 1 taken 870 times.
✓ Branch 5 taken 870 times.
✓ Branch 8 taken 870 times.
1740 simCon.setString(openstudio::SimulationControlFields::DoZoneSizingCalculation, boolToString(modelObject.doZoneSizingCalculation()));
36
3/3
✓ Branch 1 taken 870 times.
✓ Branch 5 taken 870 times.
✓ Branch 8 taken 870 times.
1740 simCon.setString(openstudio::SimulationControlFields::DoSystemSizingCalculation, boolToString(modelObject.doSystemSizingCalculation()));
37
3/3
✓ Branch 1 taken 870 times.
✓ Branch 5 taken 870 times.
✓ Branch 8 taken 870 times.
1740 simCon.setString(openstudio::SimulationControlFields::DoPlantSizingCalculation, boolToString(modelObject.doPlantSizingCalculation()));
38
39
3/3
✓ Branch 1 taken 870 times.
✓ Branch 5 taken 870 times.
✓ Branch 8 taken 870 times.
1740 simCon.setString(openstudio::SimulationControlFields::RunSimulationforSizingPeriods, boolToString(modelObject.runSimulationforSizingPeriods()));
40
41 // DLM: might want to check for weather file object?
42
2/2
✓ Branch 1 taken 870 times.
✓ Branch 4 taken 870 times.
870 simCon.setString(openstudio::SimulationControlFields::RunSimulationforWeatherFileRunPeriods,
43
1/1
✓ Branch 1 taken 870 times.
870 boolToString(modelObject.runSimulationforWeatherFileRunPeriods()));
44
45 // The logic when defaulted is inside the model object
46
3/3
✓ Branch 1 taken 870 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 860 times.
870 if (!modelObject.isDoHVACSizingSimulationforSizingPeriodsDefaulted()) {
47
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
20 simCon.setString(openstudio::SimulationControlFields::DoHVACSizingSimulationforSizingPeriods,
48
1/1
✓ Branch 1 taken 10 times.
10 boolToString(modelObject.doHVACSizingSimulationforSizingPeriods()));
49
3/3
✓ Branch 1 taken 860 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 858 times.
860 } else if (modelObject.doHVACSizingSimulationforSizingPeriods()) {
50 // We only write it if it's not the IDD default of "No", so we don't want to pollute the IDF with advanced fields that people aren't used to.
51
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 simCon.setString(openstudio::SimulationControlFields::DoHVACSizingSimulationforSizingPeriods, "Yes");
52 }
53
54
3/3
✓ Branch 1 taken 870 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 865 times.
870 if (!modelObject.isMaximumNumberofHVACSizingSimulationPassesDefaulted()) {
55
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 simCon.setInt(openstudio::SimulationControlFields::MaximumNumberofHVACSizingSimulationPasses,
56 modelObject.maximumNumberofHVACSizingSimulationPasses());
57 }
58
59 // other fields mapped to Building
60
61
1/1
✓ Branch 1 taken 870 times.
1740 return simCon;
62 870 }
63
64 } // namespace energyplus
65
66 } // namespace openstudio
67