TIMESTAMP clotheswasher::sync(TIMESTAMP t0, TIMESTAMP t1) { // compute the seconds in this time step double dt = 0.0; TIMESTAMP t2 = residential_enduse::sync(t0, t1); if (pCircuit!=NULL) load.voltage_factor = pCircuit->pV->Mag() / 120; // update voltage factor dt = gl_toseconds(t0>0?t1-t0:0); if(t0==t1) { starttime = true; } else{ starttime = false; } // determine the delta time until the next state change dt = update_state(dt); if(dt >= 7200){ return TS_NEVER; } else{ if(t2 > (TIMESTAMP)(dt*TS_SECOND+t1)) return dt>0?-(TIMESTAMP)(dt*TS_SECOND+t1):TS_NEVER; else return t2; } }
TIMESTAMP microwave::sync(TIMESTAMP t0, TIMESTAMP t1) { TIMESTAMP ct = 0; double dt = 0; double val = 0.0; TIMESTAMP t2 = TS_NEVER; if (t0 <= 0) return TS_NEVER; if (pCircuit!=NULL) load.voltage_factor = pCircuit->pV->Mag() / 120; // update voltage factor t2 = residential_enduse::sync(t0,t1); if(shape.type == MT_UNKNOWN){ if(cycle_time > 0){ ct = update_state_cycle(t0, t1); } else { dt = update_state(gl_toseconds(t1-t0)); } load.power.SetPowerFactor( (state==ON ? shape.params.analog.power : standby_power), load.power_factor); } gl_enduse_sync(&(residential_enduse::load),t1); if(shape.type == MT_UNKNOWN){ if(cycle_time == 0) return dt>0?-(TIMESTAMP)(t1 + dt*TS_SECOND) : TS_NEVER; // negative time means soft transition else return ct == TS_NEVER ? TS_NEVER : -ct; } else { return t2; } }
TIMESTAMP refrigerator::sync(TIMESTAMP t0, TIMESTAMP t1) { double dt0 = gl_toseconds(t0>0?t1-t0:0); // if advancing from a non-init condition if (t0>TS_ZERO && t1>t0) { // compute the total energy usage in this interval load.energy += load.total * dt0/3600.0; } double dt1 = update_refrigerator_state(dt0, t1); return dt1>0?-(TIMESTAMP)(dt1*TS_SECOND+t1):TS_NEVER; }
TIMESTAMP dryer::sync(TIMESTAMP t0, TIMESTAMP t1) { double dt = 0; TIMESTAMP t3; if(((t1-start_time)%3600)==0 && start_time>0) dryer_on = true; else dryer_on = false; /* determine loadshape effects */ TIMESTAMP t2 = residential_enduse::sync(t0,t1); if ((last_t != t0) && (last_t != 0)) //Different timestamp { // compute the seconds in this time step dt = gl_toseconds(t0>0?t0-last_t:0); // if advancing from a non-init condition if (t0>TS_ZERO && dt>0) { // compute the total energy usage in this interval load.energy += load.total * dt/3600.0; //Update tracking variable last_t = t0; } dt = update_state(dt); //, t1); } else if (last_t == 0) { last_t = t0; } //Defaulted other else, do nothing t3 = (TIMESTAMP)(dt*TS_SECOND+t0); if (t3>t2) return -t3; else return t2; }
/** oven synchronization determines the time to next synchronization state and the power drawn since last synch **/ TIMESTAMP range::sync(TIMESTAMP t0, TIMESTAMP t1) { double internal_gain = 0.0; double nHours = (gl_tohours(t1) - gl_tohours(t0))/TS_SECOND; double Tamb = get_Tambient(location); double dt = gl_toseconds(t0>0?t1-t0:0); if (oven_check == true || remainon == true) time_oven_operation +=dt; if (remainon == false) time_oven_operation=0; enduse_queue_oven += enduse_demand_oven * dt/3600/24; if (t0>TS_ZERO && t1>t0) { // compute the total energy usage in this interval load.energy += load.total * dt/3600.0; } if(re_override == OV_ON){ heat_needed = TRUE; } else if(re_override == OV_OFF){ heat_needed = FALSE; } if(Tw > 212.0 - thermostat_deadband){ // if it's trying boil, turn it off! heat_needed = FALSE; is_range_on = 0; } // determine the power used if (heat_needed == TRUE){ /* power_kw */ load.total = heating_element_capacity * (heat_mode == GASHEAT ? 0.01 : 1.0); is_range_on = 1; } else { /* power_kw */ load.total = 0.0; is_range_on = 0; } TIMESTAMP t2 = residential_enduse::sync(t0,t1); set_time_to_transition(); if (location == INSIDE){ if(this->current_model == ONENODE){ internal_gain = oven_UA * (Tw - get_Tambient(location)); } } else { internal_gain = 0; } dt = update_state(dt, t1); //load.total = load.power = /* power_kw */ load.power; load.power = load.total * load.power_fraction; load.admittance = load.total * load.impedance_fraction; load.current = load.total * load.current_fraction; load.heatgain = internal_gain; range_actual_power = load.power + (load.current + load.admittance * load.voltage_factor )* load.voltage_factor; actual_load = range_actual_power.Re(); if (heat_needed == true) total_power_oven = actual_load; else total_power_oven =0; if (actual_load != 0.0) { prev_load = actual_load; power_state = PS_ON; } else power_state = PS_OFF; // gl_enduse_sync(&(residential_enduse::load),t1); if(re_override == OV_NORMAL){ if (time_to_transition < dt) { if (time_to_transition >= (1.0/3600.0)) // 0.0167 represents one second { TIMESTAMP t_to_trans = (t1+time_to_transition*3600.0/TS_SECOND); return -(t_to_trans); // negative means soft transition } // less than one second means never else return TS_NEVER; } else return (TIMESTAMP)(t1+dt); } else { return TS_NEVER; // keep running until the forced state ends } }