00001
00010 #ifndef _HOUSE_E_H
00011 #define _HOUSE_E_H
00012
00013 #include "residential.h"
00014 #include "complex.h"
00015 #include "enduse.h"
00016 #include "loadshape.h"
00017 #include "residential_enduse.h"
00018
00019 typedef struct s_implicit_enduse {
00020 enduse load;
00021 double amps;
00022 int is220;
00023 struct s_implicit_enduse *next;
00024 } IMPLICITENDUSE;
00025
00026 typedef enum {
00027
00028 IEU_LIGHTS = 0x00000001,
00029 IEU_PLUGS = 0x00000002,
00030 IEU_OCCUPANCY = 0x00000004,
00031
00032
00033 IEU_DISHWASHER = 0x00000100,
00034 IEU_MICROWAVE = 0x00000200,
00035
00036
00037 IEU_FREEZER = 0x00010000,
00038 IEU_REFRIGERATOR = 0x00020000,
00039 IEU_RANGE = 0x00040000,
00040 IEU_EVCHARGER = 0x00080000,
00041 IEU_WATERHEATER = 0x00100000,
00042
00043
00044 IEU_CLOTHESWASHER = 0x01000000,
00045 IEU_DRYER = 0x02000000,
00046
00048 IEU_ALL = 0x03170303,
00049 } IMPLICITENDUSEFLAGS;
00050
00051 class house_e : public residential_enduse {
00052 public:
00053 object weather;
00054 PANEL panel;
00055
00056
00057 inline complex V(CIRCUIT *c)
00058 { return c->status==BRK_CLOSED ? *(c->pV) : complex(0,0);};
00059 complex *pCircuit_V;
00060 complex *pLine_I;
00061 complex *pShunt;
00062 complex *pPower;
00063 bool *pHouseConn;
00064 IMPLICITENDUSE *implicit_enduse_list;
00065 static set implicit_enduses_active;
00066 public:
00067
00068 double floor_area;
00069 double envelope_UA;
00070 double number_of_doors;
00071 double area_per_door;
00072 double total_door_area;
00073 double total_wall_area;
00074 double gross_wall_area;
00075 double ceiling_height;
00076 double interior_exterior_wall_ratio;
00077 double exterior_wall_fraction;
00078 double exterior_ceiling_fraction;
00079 double exterior_floor_fraction;
00080 double aspect_ratio;
00081 double solar_aperture[N_SOLAR_SURFACES];
00082 double house_content_heat_transfer_coeff;
00083 double air_density;
00084 double air_heat_capacity;
00085 double house_content_thermal_mass;
00086 double total_thermal_mass_per_floor_area;
00087 double interior_surface_heat_transfer_coeff;
00088 double air_heat_fraction;
00089 double mass_solar_gain_fraction;
00090 double mass_internal_gain_fraction;
00091 double number_of_stories;
00092
00093
00094 double glazing_shgc;
00095 double window_wall_ratio;
00096 double window_roof_ratio;
00097 double total_window_area;
00098 double window_exterior_transmission_coefficient;
00099 double solar_heatgain_factor;
00100
00101
00102
00103 double thermostat_deadband;
00104 int16 thermostat_cycle_time;
00105 TIMESTAMP thermostat_last_cycle_time;
00106 double heating_setpoint;
00107 double cooling_setpoint;
00108
00109
00110 enum {TC_FULL=0, TC_BAND=1, TC_NONE=2} thermostat_control;
00111 double TcoolOn;
00112 double TcoolOff;
00113 double TheatOn;
00114 double TheatOff;
00115 double TauxOn;
00116
00117
00118 double design_heating_setpoint;
00119 double design_cooling_setpoint;
00120 double design_heating_capacity;
00121 double design_cooling_capacity;
00122 double heating_COP;
00123 double cooling_COP;
00124
00125 double over_sizing_factor;
00126 double rated_heating_capacity;
00127 double rated_cooling_capacity;
00128 double hvac_breaker_rating;
00129 double hvac_power_factor;
00130
00131 double aux_heat_capacity;
00132 double aux_heat_deadband;
00133 double aux_heat_temp_lockout;
00134 double aux_heat_time_delay;
00135
00136 double fan_design_power;
00137 double fan_low_power_fraction;
00138 double fan_power;
00139 double fan_design_airflow;
00140
00142 double fan_impedance_fraction;
00143 double fan_current_fraction;
00144 double fan_power_fraction;
00145 double fan_power_factor;
00146
00147 double duct_pressure_drop;
00148 double cooling_supply_air_temp;
00149 double heating_supply_air_temp;
00150
00151 double airchange_per_hour;
00152 double airchange_UA;
00153 double latent_load_fraction;
00154
00155
00156 double system_rated_power;
00157 double system_rated_capacity;
00158
00159
00160 double hvac_load;
00161 double total_load;
00162 enduse total;
00163 double heating_demand;
00164 double cooling_demand;
00165
00166
00167 typedef enum {
00168 ST_GAS = 0x00000001,
00169 ST_AC = 0x00000002,
00170 ST_AIR = 0x00000004,
00171 ST_VAR = 0x00000008,
00172 ST_RST = 0x00000010,
00173 } SYSTEMTYPE;
00174 set system_type;
00175
00176
00177 typedef enum {
00178 AX_NONE = 0x0,
00179 AX_DEADBAND = 0x1,
00180 AX_TIMER = 0x2,
00181 AX_LOCKOUT = 0x4,
00182 } AUXSTRATEGY;
00183 set auxiliary_strategy;
00184
00185 typedef enum{
00186 AT_UNKNOWN = 0,
00187 AT_NONE = 1,
00188 AT_ELECTRIC = 2,
00189 } AUXILIARYSYSTEMTYPE;
00190 AUXILIARYSYSTEMTYPE auxiliary_system_type;
00191
00192 typedef enum{
00193 HT_UNKNOWN = 0,
00194 HT_NONE = 1,
00195 HT_GAS = 2,
00196 HT_HEAT_PUMP = 3,
00197 HT_RESISTANCE = 4,
00198 } HEATSYSTEMTYPE;
00199 HEATSYSTEMTYPE heating_system_type;
00200
00201 typedef enum {
00202 CT_UNKNOWN = 0,
00203 CT_NONE = 1,
00204 CT_ELECTRIC = 2,
00205 } COOLSYSTEMTYPE;
00206 COOLSYSTEMTYPE cooling_system_type;
00207
00208 typedef enum {
00209 FT_UNKNOWN = 0,
00210 FT_NONE = 1,
00211 FT_ONE_SPEED = 2,
00212 FT_TWO_SPEED = 3,
00213 } FANTYPE;
00214 FANTYPE fan_type;
00215
00216 typedef enum {
00217 GM_OTHER = 0,
00218 GM_GLASS = 1,
00219 GM_LOW_E_GLASS = 2,
00220 } GLASSTYPE;
00221 GLASSTYPE glass_type;
00222
00223 typedef enum {
00224 WF_NONE = 0,
00225 WF_ALUMINUM = 1,
00226 WF_THERMAL_BREAK = 2,
00227 WF_WOOD = 3,
00228 WF_INSULATED = 4,
00229 } WINDOWFRAME;
00230 WINDOWFRAME window_frame;
00231
00232 typedef enum {
00233 GT_OTHER = 0,
00234 GT_CLEAR = 1,
00235 GT_ABS = 2,
00236 GT_REFL = 3,
00237 GT_LOW_S = 4,
00238 GT_HIGH_S = 5,
00239 } GLAZINGTREATMENT;
00240 GLAZINGTREATMENT glazing_treatment;
00241
00242 typedef enum {
00243 GL_ONE=1,
00244 GL_TWO=2,
00245 GL_THREE=3,
00246 GL_OTHER,
00247 } GLAZINGLAYERS;
00248 GLAZINGLAYERS glazing_layers;
00249
00250 typedef enum {
00251 TI_VERY_LITTLE =0,
00252 TI_LITTLE =1,
00253 TI_BELOW_NORMAL =2,
00254 TI_NORMAL =3,
00255 TI_ABOVE_NORMAL =4,
00256 TI_GOOD =5,
00257 TI_VERY_GOOD =6,
00258 TI_UNKNOWN =7
00259 } THERMAL_INTEGRITY;
00260 THERMAL_INTEGRITY thermal_integrity_level;
00261
00262 typedef enum {
00263 MM_NONE = 0,
00264 MM_BASIC = 1,
00265 MM_FULL = 2
00266 } MOTORMODEL;
00267 MOTORMODEL motor_model;
00268
00269
00270 double hvac_motor_efficiency;
00271 double hvac_motor_loss_power_factor;
00272 double hvac_motor_real_loss;
00273 double hvac_motor_reactive_loss;
00274 typedef enum {
00275 ME_VERY_POOR = 0,
00276 ME_POOR = 1,
00277 ME_AVERAGE = 2,
00278 ME_GOOD = 3,
00279 ME_VERY_GOOD = 4,
00280 } MOTOREFFICIENCY;
00281 MOTOREFFICIENCY motor_efficiency;
00282
00283 typedef enum {
00284 SM_UNKNOWN =0,
00285 SM_OFF =1,
00286 SM_HEAT =2,
00287 SM_AUX =3,
00288 SM_COOL =4,
00289 } SYSTEMMODE;
00290 SYSTEMMODE system_mode,
00291 last_system_mode;
00292 int64 last_mode_timer;
00293
00294
00295 double volume;
00296 double air_mass;
00297 double air_thermal_mass;
00298 double solar_load;
00299
00300
00301
00302
00303
00304 double cooling_design_temperature;
00305 double heating_design_temperature;
00306 double design_peak_solar;
00307 double design_internal_gains;
00308 double design_internal_gain_density;
00309
00310 double Rroof;
00311 double Rwall;
00312 double Rfloor;
00313 double Rwindows;
00314 double Rdoors;
00315
00316 double *pTout;
00317 double *pRhout;
00318 double *pSolar;
00319 double incident_solar_radiation;
00320
00321 double Tair;
00322 double Tmaterials;
00323 double outside_temperature;
00324 double outdoor_rh;
00325
00326 private:
00327 void set_thermal_integrity();
00328 void set_window_shgc();
00329 void set_window_Rvalue();
00330
00331 double dTair;
00332 double a,b,c,c1,c2,A3,A4,k1,k2,r1,r2,Teq,Tevent,Qi,Qa,Qm,adj_cooling_cap,adj_heating_cap,adj_cooling_cop,adj_heating_cop;
00333 #ifdef _DEBUG
00334 double d;
00335 #endif
00336 static bool warn_control;
00337 static double warn_low_temp;
00338 static double warn_high_temp;
00339 static double system_dwell_time;
00340 bool check_start;
00341 bool heat_start;
00342 bool *NR_mode;
00343 TIMESTAMP Off_Return;
00344
00345 complex load_values[3][3];
00346
00347 public:
00348 static CLASS *oclass, *pclass;
00349 house_e( MODULE *module);
00350 ~house_e();
00351
00352 int create();
00353 TIMESTAMP presync(TIMESTAMP t0, TIMESTAMP t1);
00354 TIMESTAMP sync(TIMESTAMP t0, TIMESTAMP t1);
00355 TIMESTAMP postsync(TIMESTAMP t0, TIMESTAMP t1);
00356 TIMESTAMP sync_billing(TIMESTAMP t0, TIMESTAMP t1);
00357 TIMESTAMP sync_thermostat(TIMESTAMP t0, TIMESTAMP t1);
00358 TIMESTAMP sync_panel(TIMESTAMP t0, TIMESTAMP t1);
00359 TIMESTAMP sync_enduses(TIMESTAMP t0, TIMESTAMP t1);
00360 void update_system(double dt=0);
00361 void update_model(double dt=0);
00362 void check_controls(void);
00363 void update_Tevent(void);
00364
00365 int init(OBJECT *parent);
00366 int init_climate(void);
00367 int isa(char *classname);
00368
00369 CIRCUIT *attach(OBJECT *obj, double limit, int is220=false, enduse *pEnduse=NULL);
00370 void attach_implicit_enduses(void);
00371
00372
00373 public:
00374 inline double get_floor_area () { return floor_area; };
00375 inline double get_Tout () { return *pTout; };
00376 inline double get_Tair () { return Tair; };
00377
00378 complex *get_complex(OBJECT *obj, char *name);
00379 bool *get_bool(OBJECT *obj, char *name);
00380 };
00381
00382 inline double sgn(double x)
00383 {
00384 if (x<0) return -1;
00385 if (x>0) return 1;
00386 return 0;
00387 }
00388
00389 #endif
00390