int stub_bidder::init(OBJECT *parent) { new_bid_id = -1; next_t = 0; change = 1; lastbid_id = -1; lastmkt_id = -1; if (market==NULL) throw "market is not defined"; thismkt_id = (int64*)gl_get_addr(market,"market_id"); if (thismkt_id==NULL) throw "market does not define market_id"; return SUCCESS; }
int refrigerator::init(OBJECT *parent) { OBJECT *hdr = OBJECTHDR(this); hdr->flags |= OF_SKIPSAFE; // defaults for unset values */ if (size==0) size = gl_random_uniform(RNGSTATE,20,40); // cf if (thermostat_deadband==0) thermostat_deadband = gl_random_uniform(RNGSTATE,2,3); if (Tset==0) Tset = gl_random_uniform(RNGSTATE,35,39); if (UA == 0) UA = 0.6; if (UAr==0) UAr = UA+size/40*gl_random_uniform(RNGSTATE,0.9,1.1); if (UAf==0) UAf = gl_random_uniform(RNGSTATE,0.9,1.1); if (COPcoef==0) COPcoef = gl_random_uniform(RNGSTATE,0.9,1.1); if (Tout==0) Tout = 59.0; if (load.power_factor==0) load.power_factor = 0.95; pTout = (double*)gl_get_addr(parent, "air_temperature"); if (pTout==NULL) { static double default_air_temperature = 72; gl_warning("%s (%s:%d) parent object lacks air temperature, using %0f degF instead", hdr->name, hdr->oclass->name, hdr->id, default_air_temperature); pTout = &default_air_temperature; } /* derived values */ Tair = gl_random_uniform(RNGSTATE,Tset-thermostat_deadband/2, Tset+thermostat_deadband/2); // size is used to couple Cw and Qrated Cf = size/10.0 * RHOWATER * CWATER; // cf * lb/cf * BTU/lb/degF = BTU / degF rated_capacity = BTUPHPW * size*10; // BTU/h ... 10 BTU.h / cf (34W/cf, so ~700 for a full-sized refrigerator) // duty cycle estimate for initial condition if (gl_random_bernoulli(RNGSTATE,0.1)){ Qr = rated_capacity; } else { Qr = 0; } // initial demand load.total = Qr * KWPBTUPH; return residential_enduse::init(parent); }
int refrigerator::init(OBJECT *parent) { if(parent != NULL){ if((parent->flags & OF_INIT) != OF_INIT){ char objname[256]; gl_verbose("refrigerator::init(): deferring initialization on %s", gl_name(parent, objname, 255)); return 2; // defer } } OBJECT *hdr = OBJECTHDR(this); hdr->flags |= OF_SKIPSAFE; // defaults for unset values */ if (size==0) size = gl_random_uniform(&hdr->rng_state,20,40); // cf if (thermostat_deadband==0) thermostat_deadband = gl_random_uniform(&hdr->rng_state,2,3); if (Tset==0) Tset = gl_random_uniform(&hdr->rng_state,35,39); if (UA == 0) UA = 0.6; if (UAr==0) UAr = UA+size/40*gl_random_uniform(&hdr->rng_state,0.9,1.1); if (UAf==0) UAf = gl_random_uniform(&hdr->rng_state,0.9,1.1); if (COPcoef==0) COPcoef = gl_random_uniform(&hdr->rng_state,0.9,1.1); if (Tout==0) Tout = 59.0; if (load.power_factor==0) load.power_factor = 0.95; pTout = (double*)gl_get_addr(parent, "air_temperature"); if (pTout==NULL) { static double default_air_temperature = 72; gl_warning("%s (%s:%d) parent object lacks air temperature, using %0f degF instead", hdr->name, hdr->oclass->name, hdr->id, default_air_temperature); pTout = &default_air_temperature; } /* derived values */ Tair = gl_random_uniform(&hdr->rng_state,Tset-thermostat_deadband/2, Tset+thermostat_deadband/2); // size is used to couple Cw and Qrated Cf = size/10.0 * RHOWATER * CWATER; // cf * lb/cf * BTU/lb/degF = BTU / degF rated_capacity = BTUPHPW * size*10; // BTU/h ... 10 BTU.h / cf (34W/cf, so ~700 for a full-sized refrigerator) start_time = 0; if(compressor_off_normal_energy==0) compressor_off_normal_energy=15*45*60; //watt-secs if(compressor_off_normal_power==0) compressor_off_normal_power=15; //watt if(long_compressor_cycle_energy==0) long_compressor_cycle_energy=120*100*60; //watt-secs if(long_compressor_cycle_power==0) long_compressor_cycle_power=120; //watt if(compressor_on_normal_energy==0) compressor_on_normal_energy=120*35*60; //watt-secs if(compressor_on_normal_power==0) compressor_on_normal_power=120; //watt if(defrost_energy==0) defrost_energy=40*550*60; //watt-secs if(defrost_power==0) defrost_power=550; //watt if(icemaking_energy==0) icemaking_energy=300*60; //watt-secs if(icemaking_power==0) icemaking_power=300; //watt if(ice_making_probability==0) ice_making_probability=0.02; //watt if(DO_Thershold==0) DO_Thershold=24; if(long_compressor_cycle_threshold==0) long_compressor_cycle_threshold=0.05; if(FF_Door_Openings==0) FF_Door_Openings=0; if(door_opening_power==0) door_opening_power=16; if(delay_defrost_time==0) delay_defrost_time=28800; if(defrost_criterion==0) defrost_criterion=DC_TIMED; refrigerator_power = 0; return_time = 0; no_of_defrost = 0; total_compressor_time = 0; if(door_open_time==0) door_open_time=7; long_compressor_cycle_due=false; door_energy_calc = false; ice_making_time = new double[1,2,3]; icemaker_running = false; check_defrost = false; switch(state){ case RS_DEFROST: if(energy_needed==0) energy_needed = defrost_energy; cycle_time = ceil((energy_needed - energy_used)/defrost_power); break; case RS_COMPRESSSOR_OFF_NORMAL: if(energy_needed==0) energy_needed = compressor_off_normal_energy; cycle_time = ceil((energy_needed - energy_used)/compressor_off_normal_power); break; case RS_COMPRESSSOR_ON_NORMAL: if(energy_needed==0) energy_needed = compressor_on_normal_energy; cycle_time = ceil((energy_needed - energy_used)/compressor_on_normal_power); break; } run_defrost = false; if (is_240) { load.config = EUC_IS220; } load.total = Qr * KWPBTUPH; return residential_enduse::init(parent); }