src/isomodel/SimModel.hpp
| 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 | #ifndef ISOMODEL_SIMMODEL_HPP | ||
| 7 | #define ISOMODEL_SIMMODEL_HPP | ||
| 8 | |||
| 9 | #include "ISOModelAPI.hpp" | ||
| 10 | |||
| 11 | #include "../utilities/core/Logger.hpp" | ||
| 12 | #include "../utilities/data/Vector.hpp" | ||
| 13 | #include "../utilities/data/Matrix.hpp" | ||
| 14 | #include "../utilities/data/EndUses.hpp" | ||
| 15 | #include "Population.hpp" | ||
| 16 | #include "Location.hpp" | ||
| 17 | #include "Lighting.hpp" | ||
| 18 | #include "Building.hpp" | ||
| 19 | #include "Cooling.hpp" | ||
| 20 | #include "Heating.hpp" | ||
| 21 | #include "Structure.hpp" | ||
| 22 | #include "Ventilation.hpp" | ||
| 23 | |||
| 24 | namespace openstudio { | ||
| 25 | |||
| 26 | class EndUses; | ||
| 27 | |||
| 28 | namespace isomodel { | ||
| 29 | |||
| 30 | ISOMODEL_API Vector mult(const double* v1, const double s1, int size); | ||
| 31 | ISOMODEL_API Vector mult(const Vector& v1, const double s1); | ||
| 32 | ISOMODEL_API Vector mult(const Vector& v1, const double* v2); | ||
| 33 | ISOMODEL_API Vector mult(const Vector& v1, const Vector& v2); | ||
| 34 | ISOMODEL_API Vector div(const Vector& v1, const double s1); | ||
| 35 | ISOMODEL_API Vector div(const double s1, const Vector& v1); | ||
| 36 | ISOMODEL_API Vector div(const Vector& v1, const Vector& v2); | ||
| 37 | ISOMODEL_API Vector sum(const Vector& v1, const Vector& v2); | ||
| 38 | ISOMODEL_API Vector sum(const Vector& v1, const double v2); | ||
| 39 | ISOMODEL_API Vector dif(const Vector& v1, const Vector& v2); | ||
| 40 | ISOMODEL_API Vector dif(const Vector& v1, const double v2); | ||
| 41 | ISOMODEL_API Vector dif(const double v1, const Vector& v2); | ||
| 42 | |||
| 43 | ISOMODEL_API Vector maximum(const Vector& v1, const Vector& v2); | ||
| 44 | ISOMODEL_API Vector maximum(const Vector& v1, double val); | ||
| 45 | ISOMODEL_API double maximum(const Vector& v1); | ||
| 46 | |||
| 47 | ISOMODEL_API Vector minimum(const Vector& v1, double val); | ||
| 48 | ISOMODEL_API double minimum(const Vector& v1); | ||
| 49 | |||
| 50 | ISOMODEL_API Vector abs(const Vector& v1); | ||
| 51 | ISOMODEL_API Vector pow(const Vector& v1, const double xp); | ||
| 52 | |||
| 53 | struct ISOMODEL_API ISOResults | ||
| 54 | { | ||
| 55 | std::vector<EndUses> monthlyResults; | ||
| 56 | double totalEnergyUse() const; | ||
| 57 | }; | ||
| 58 | |||
| 59 | class ISOMODEL_API SimModel | ||
| 60 | { | ||
| 61 | public: | ||
| 62 | 1 | void setPop(std::shared_ptr<Population> value) { | |
| 63 | 1 | pop = value; | |
| 64 | 1 | } | |
| 65 | 1 | void setLocation(std::shared_ptr<Location> value) { | |
| 66 | 1 | location = value; | |
| 67 | 1 | } | |
| 68 | 1 | void setLights(std::shared_ptr<Lighting> value) { | |
| 69 | 1 | lights = value; | |
| 70 | 1 | } | |
| 71 | 1 | void setBuilding(std::shared_ptr<Building> value) { | |
| 72 | 1 | building = value; | |
| 73 | 1 | } | |
| 74 | 1 | void setStructure(std::shared_ptr<Structure> value) { | |
| 75 | 1 | structure = value; | |
| 76 | 1 | } | |
| 77 | 1 | void setHeating(std::shared_ptr<Heating> value) { | |
| 78 | 1 | heating = value; | |
| 79 | 1 | } | |
| 80 | 1 | void setCooling(std::shared_ptr<Cooling> value) { | |
| 81 | 1 | cooling = value; | |
| 82 | 1 | } | |
| 83 | 1 | void setVentilation(std::shared_ptr<Ventilation> value) { | |
| 84 | 1 | ventilation = value; | |
| 85 | 1 | } | |
| 86 | |||
| 87 | /* | ||
| 88 | * Runs the ISO Model cacluations for the given set of input parameters. | ||
| 89 | * returns ISOResults which is a vector of EndUses, one EndUses per month of the year | ||
| 90 | */ | ||
| 91 | ISOResults simulate() const; | ||
| 92 | − | REGISTER_LOGGER("openstudio.isomodel.SimModel"); | |
| 93 | |||
| 94 | private: | ||
| 95 | std::shared_ptr<Population> pop; | ||
| 96 | std::shared_ptr<Location> location; | ||
| 97 | std::shared_ptr<Lighting> lights; | ||
| 98 | std::shared_ptr<Building> building; | ||
| 99 | std::shared_ptr<Structure> structure; | ||
| 100 | std::shared_ptr<Heating> heating; | ||
| 101 | std::shared_ptr<Cooling> cooling; | ||
| 102 | std::shared_ptr<Ventilation> ventilation; | ||
| 103 | |||
| 104 | void scheduleAndOccupancy(Vector& weekdayOccupiedMegaseconds, Vector& weekdayUnoccupiedMegaseconds, Vector& weekendOccupiedMegaseconds, | ||
| 105 | Vector& weekendUnoccupiedMegaseconds, Vector& clockHourOccupied, Vector& clockHourUnoccupied, double& frac_hrs_wk_day, | ||
| 106 | double& hoursUnoccupiedPerDay, double& hoursOccupiedPerDay, double& frac_hrs_wk_nt, double& frac_hrs_wke_tot) const; | ||
| 107 | void solarRadiationBreakdown(const Vector& weekdayOccupiedMegaseconds, const Vector& weekdayUnoccupiedMegaseconds, | ||
| 108 | const Vector& weekendOccupiedMegaseconds, const Vector& weekendUnoccupiedMegaseconds, | ||
| 109 | const Vector& clockHourOccupied, const Vector& clockHourUnoccupied, Vector& v_hrs_sun_down_mo, | ||
| 110 | Vector& frac_Pgh_wk_nt, Vector& frac_Pgh_wke_day, Vector& frac_Pgh_wke_nt, Vector& v_Tdbt_nt) const; | ||
| 111 | void lightingEnergyUse(const Vector& v_hrs_sun_down_mo, double& Q_illum_occ, double& Q_illum_unocc, double& Q_illum_tot_yr, Vector& v_Q_illum_tot, | ||
| 112 | Vector& v_Q_illum_ext_tot) const; | ||
| 113 | void envelopCalculations(Vector& v_win_A, Vector& v_wall_emiss, Vector& v_wall_alpha_sc, Vector& v_wall_U, Vector& v_wall_A, double& H_tr) const; | ||
| 114 | void windowSolarGain(const Vector& v_win_A, const Vector& v_wall_emiss, const Vector& v_wall_alpha_sc, const Vector& v_wall_U, | ||
| 115 | const Vector& v_wall_A, Vector& v_wall_A_sol, Vector& v_win_hr, Vector& v_wall_R_sc, Vector& v_win_A_sol) const; | ||
| 116 | void solarHeatGain(const Vector& v_win_A_sol, const Vector& v_wall_R_sc, const Vector& v_wall_U, const Vector& v_wall_A, const Vector& v_win_hr, | ||
| 117 | const Vector& v_wall_A_sol, Vector& v_E_sol) const; | ||
| 118 | void heatGainsAndLosses(double frac_hrs_wk_day, double Q_illum_occ, double Q_illum_unocc, double Q_illum_tot_yr, double& phi_int_avg, | ||
| 119 | double& phi_plug_avg, double& phi_illum_avg, double& phi_int_wke_nt, double& phi_int_wke_day, | ||
| 120 | double& phi_int_wk_nt) const; | ||
| 121 | void internalHeatGain(double phi_int_avg, double phi_plug_avg, double phi_illum_avg, double& phi_I_tot) const; | ||
| 122 | void unoccupiedHeatGain(double phi_int_wk_nt, double phi_int_wke_day, double phi_int_wke_nt, const Vector& weekdayUnoccupiedMegaseconds, | ||
| 123 | const Vector& weekendOccupiedMegaseconds, const Vector& weekendUnoccupiedMegaseconds, const Vector& frac_Pgh_wk_nt, | ||
| 124 | const Vector& frac_Pgh_wke_day, const Vector& frac_Pgh_wke_nt, const Vector& v_E_sol, Vector& v_P_tot_wke_day, | ||
| 125 | Vector& v_P_tot_wk_nt, Vector& v_P_tot_wke_nt) const; | ||
| 126 | void interiorTemp(const Vector& v_wall_A, const Vector& v_P_tot_wke_day, const Vector& v_P_tot_wk_nt, const Vector& v_P_tot_wke_nt, | ||
| 127 | const Vector& v_Tdbt_nt, double H_tr, double hoursUnoccupiedPerDay, double hoursOccupiedPerDay, double frac_hrs_wk_day, | ||
| 128 | double frac_hrs_wk_nt, double frac_hrs_wke_tot, Vector& v_Th_avg, Vector& v_Tc_avg, double& tau) const; | ||
| 129 | void ventilationCalc(const Vector& v_Th_avg, const Vector& v_Tc_avg, double frac_hrs_wk_day, Vector& v_Hve_ht, Vector& v_Hve_cl) const; | ||
| 130 | void heatingAndCooling(const Vector& v_E_sol, const Vector& v_Th_avg, const Vector& v_Hve_ht, const Vector& v_Tc_avg, const Vector& v_Hve_cl, | ||
| 131 | double tau, double H_tr, double phi_I_tot, double frac_hrs_wk_day, Vector& v_Qfan_tot, Vector& v_Qneed_ht, | ||
| 132 | Vector& v_Qneed_cl, double& Qneed_ht_yr, double& Qneed_cl_yr) const; | ||
| 133 | void hvac(const Vector& v_Qneed_ht, const Vector& v_Qneed_cl, double Qneed_ht_yr, double Qneed_cl_yr, Vector& v_Qelec_ht, Vector& v_Qgas_ht, | ||
| 134 | Vector& v_Qcl_elec_tot, Vector& v_Qcl_gas_tot) const; | ||
| 135 | void pump(const Vector& v_Qneed_ht, const Vector& v_Qneed_cl, double Qneed_ht_yr, double Qneed_cl_yr, Vector& v_Q_pump_tot) const; | ||
| 136 | |||
| 137 | // TODO: Not implemented yet | ||
| 138 | // cppcheck-suppress functionStatic | ||
| 139 | void energyGeneration() const; | ||
| 140 | |||
| 141 | void heatedWater(Vector& v_Q_dhw_elec, Vector& v_Q_dhw_gas) const; | ||
| 142 | |||
| 143 | ISOResults outputGeneration(const Vector& v_Qelec_ht, const Vector& v_Qcl_elec_tot, const Vector& v_Q_illum_tot, const Vector& v_Q_illum_ext_tot, | ||
| 144 | const Vector& v_Qfan_tot, const Vector& v_Q_pump_tot, const Vector& v_Q_dhw_elec, const Vector& v_Qgas_ht, | ||
| 145 | const Vector& v_Qcl_gas_tot, const Vector& v_Q_dhw_gas, double frac_hrs_wk_day) const; | ||
| 146 | |||
| 147 | static void printVector(const char* vecName, const Vector& vec); | ||
| 148 | static void printMatrix(const char* matName, const Matrix& mat); | ||
| 149 | }; | ||
| 150 | } // namespace isomodel | ||
| 151 | } // namespace openstudio | ||
| 152 | |||
| 153 | #endif // ISOMODEL_SIMMODEL_HPP | ||
| 154 |