Skip to content

Commit

Permalink
fc range works
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Jan 31, 2025
1 parent eea7f96 commit c3b46af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
7 changes: 2 additions & 5 deletions cal_and_val/thermal/cal_hev.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,12 @@ def get_exp_pwr_hvac(df):
get_mod_pwr_hvac,
get_exp_pwr_hvac
),
# TODO: add objectives for:
# - battery temperature -- BEV only, if available
# - HVAC power for cabin, if available
),
param_fns=(
new_em_eff_max,
new_em_eff_range,
new_fc_eff_max,
# new_fc_eff_range,
new_fc_eff_range,
# TODO: make sure this has functions for modifying
# - cabin thermal
# - thermal mass
Expand Down Expand Up @@ -337,7 +334,7 @@ def get_exp_pwr_hvac(df):
(0.80, 0.99),
(0.1, 0.6),
(0.32, 0.45),
# (0.0, 0.45),
(0.2, 0.45),
),
verbose=False,
)
Expand Down
16 changes: 11 additions & 5 deletions python/fastsim/pymoo_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,23 @@ def update_params(self, xs: List[Any]):

t0 = time.perf_counter()

# Instantiate SimDrive objects
sim_drives = {}

# Update all model parameters
for key, pydict in self.models.items():
for (param_fn, new_val) in zip(self.param_fns, xs):
pydict = param_fn(pydict, new_val)
try:
for (param_fn, new_val) in zip(self.param_fns, xs):
pydict = param_fn(pydict, new_val)
except Exception as err:
sim_drives[key] = err
# this assignement may be redundant, but `pydict` is probably **not** mutably modified.
# If this is correct, then this assignment is necessary
self.models[key] = pydict

# Instantiate SimDrive objects
sim_drives = {}
for key, pydict in self.models.items():
if key in list(sim_drives.keys()):
continue
try:
sim_drives[key] = fsim.SimDrive.from_pydict(pydict, skip_init=False)
except Exception as err:
Expand Down Expand Up @@ -188,7 +194,7 @@ def get_errors(

if not isinstance(sd, fsim.SimDrive):
solved_mods[key] = sd
objectives[key] = [1e12] * len(self.obj_fns) * len(self.dfs)
objectives[key] = [1e12] * len(self.obj_fns)
continue

try:
Expand Down

0 comments on commit c3b46af

Please sign in to comment.