Skip to content

Commit

Permalink
runs with hvac params
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Jan 31, 2025
1 parent b5c0ad7 commit f43db23
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions cal_and_val/thermal/cal_hev.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def veh_init(cyc_file_stem: str, dfs: Dict[str, pd.DataFrame]) -> fsim.Vehicle:
sds_for_val[cyc_file_stem] = fsim.SimDrive(veh, cyc, sim_params).to_pydict()

# Setup model parameters and objectives
## Parameter Functions
## Parameter Functions `param_fns`
def new_em_eff_max(sd_dict, new_eff_max) -> Dict:
"""
Set `new_eff_max` in `ElectricMachine`
Expand Down Expand Up @@ -285,14 +285,42 @@ def new_frac_pwr_demand_fc_forced_on(sd_dict, new_val) -> Dict:
def new_frac_of_most_eff_pwr_to_run_fc(sd_dict, new_val) -> Dict:
sd_dict["veh"]["pt_type"]["HybridElectricVehicle"]["pt_cntrl"]["RGWDB"]["frac_of_most_eff_pwr_to_run_fc"] = new_val
return sd_dict

def new_hvac_p_watts_per_kelvin(sd_dict, new_val) -> Dict:
sd_dict['veh']['hvac']['LumpedCabin']['p_watts_per_kelvin'] = new_val
return sd_dict

def new_hvac_i(sd_dict, new_val) -> Dict:
sd_dict['veh']['hvac']['LumpedCabin']['i'] = new_val
return sd_dict

# def new_hvac_pwr_i_max_watts(sd_dict, new_val) -> Dict:
# sd_dict['veh']['hvac']['LumpedCabin']['pwr_i_max_watts'] = new_val
# return sd_dict

# def new_hvac_d(sd_dict, new_val) -> Dict:
# sd_dict['veh']['hvac']['LumpedCabin']['d'] = new_val
# return sd_dict

# def new_hvac_pwr_thrml_max_watts(sd_dict, new_val) -> Dict:
# sd_dict['veh']['hvac']['LumpedCabin']['pwr_thrml_max_watts'] = new_val
# return sd_dict

def new_hvac_frac_of_ideal_cop(sd_dict, new_val) -> Dict:
sd_dict['veh']['hvac']['LumpedCabin']['frac_of_ideal_cop'] = new_val
return sd_dict

# def new_hvac_pwr_aux_for_hvac_max_watt(sd_dict, new_val) -> Dict:
# sd_dict['veh']['hvac']['LumpedCabin']['pwr_aux_for_hvac_max_watts'] = new_val
# return sd_dict

# veh.pt_type.HybridElectricVehicle.pt_cntrl.RGWDB.speed_soc_regen_buffer_meters_per_second
# veh.pt_type.HybridElectricVehicle.pt_cntrl.RGWDB.speed_soc_regen_buffer_coeff
# veh.pt_type.HybridElectricVehicle.pt_cntrl.RGWDB.speed_fc_forced_on_meters_per_second
# veh.pt_type.HybridElectricVehicle.pt_cntrl.RGWDB.temp_fc_forced_on_kelvin
# veh.pt_type.HybridElectricVehicle.pt_cntrl.RGWDB.temp_fc_allowed_off_kelvin

# Objective Functions
# Objective Functions -- `obj_fns`
def get_mod_soc(sd_dict):
return np.array(sd_dict['veh']['pt_type']['HybridElectricVehicle']['res']['history']['soc'])

Expand Down Expand Up @@ -382,6 +410,9 @@ def get_exp_pwr_hvac(df):
new_fc_min_time_on_seconds,
new_frac_pwr_demand_fc_forced_on,
new_frac_of_most_eff_pwr_to_run_fc,
new_hvac_p_watts_per_kelvin,
new_hvac_i,
new_hvac_frac_of_ideal_cop,
# TODO: make sure this has functions for modifying
# - battery thermal -- not necessary for HEV because battery temperature has no real effect
# - thermal mass
Expand Down Expand Up @@ -416,6 +447,9 @@ def get_exp_pwr_hvac(df):
(5, 30),
(0.3, 0.8),
(0.1, 1.0),
(5, 100),
(1, 20),
(0.05, 0.25),
),
verbose=False,
)
Expand Down Expand Up @@ -447,6 +481,9 @@ def perturb_params(pct: float = 0.05):
veh_dict_flat['pt_type.HybridElectricVehicle.pt_cntrl.RGWDB.fc_min_time_on_seconds'],
veh_dict_flat['pt_type.HybridElectricVehicle.pt_cntrl.RGWDB.frac_pwr_demand_fc_forced_on'],
veh_dict_flat['pt_type.HybridElectricVehicle.pt_cntrl.RGWDB.frac_of_most_eff_pwr_to_run_fc'],
veh_dict_flat['hvac.LumpedCabin.p_watts_per_kelvin'],
veh_dict_flat['hvac.LumpedCabin.i'],
veh_dict_flat['hvac.LumpedCabin.frac_of_ideal_cop'],
]

print("Verifying that model responds to input parameter changes by individually perturbing parameters")
Expand Down

0 comments on commit f43db23

Please sign in to comment.