2424veh = fsim .Vehicle .from_file (
2525 Path (__file__ ).parent / "f3-vehicles/2021_Hyundai_Sonata_Hybrid_Blue.yaml"
2626)
27- veh_dict = veh .to_pydict ()
27+ veh_dict = veh .to_dict ()
2828
29- sim_params_dict = fsim .SimParams .default ().to_pydict ()
29+ sim_params_dict = fsim .SimParams .default ().to_dict ()
3030sim_params_dict ["trace_miss_opts" ] = "AllowChecked"
31- sim_params = fsim .SimParams .from_pydict (sim_params_dict , skip_init = False )
31+ sim_params = fsim .SimParams .from_dict (sim_params_dict , skip_init = False )
3232
3333# Obtain the data from
3434# https://www.anl.gov/taps/d3-2021-hyundai-sonata-hybrid
@@ -130,7 +130,7 @@ def df_to_cyc(df: pd.DataFrame) -> fsim.Cycle:
130130 # TODO: pipe solar load from `Cycle` into cabin thermal model
131131 # "pwr_solar_load_watts": df[],
132132 }
133- return fsim .Cycle .from_pydict (cyc_dict , skip_init = False )
133+ return fsim .Cycle .from_dict (cyc_dict , skip_init = False )
134134
135135
136136pt_type_var = "HybridElectricVehicle"
@@ -177,7 +177,7 @@ def veh_init(cyc_file_stem: str, dfs: Dict[str, pd.DataFrame]) -> fsim.Vehicle:
177177 te_set + celsius_to_kelvin_offset if te_set is not None else None
178178 )
179179
180- return fsim .Vehicle .from_pydict (vd , skip_init = False )
180+ return fsim .Vehicle .from_dict (vd , skip_init = False )
181181
182182
183183def resample_df (df : pd .DataFrame ) -> pd .DataFrame :
@@ -220,7 +220,7 @@ def resample_df(df: pd.DataFrame) -> pd.DataFrame:
220220 cyc : fsim .Cycle
221221 # NOTE: maybe change `save_interval` to 5
222222 veh = veh_init (cyc_file_stem , dfs_for_cal )
223- sds_for_cal [cyc_file_stem ] = fsim .SimDrive (veh , cyc , sim_params ).to_pydict ()
223+ sds_for_cal [cyc_file_stem ] = fsim .SimDrive (veh , cyc , sim_params ).to_dict ()
224224
225225cyc_files_for_val : List [Path ] = list (set (cyc_files ) - set (cyc_files_for_cal ))
226226assert len (cyc_files_for_val ) > 0
@@ -245,7 +245,7 @@ def resample_df(df: pd.DataFrame) -> pd.DataFrame:
245245 cyc_file_stem : str
246246 cyc : fsim .Cycle
247247 veh = veh_init (cyc_file_stem , dfs_for_val )
248- sds_for_val [cyc_file_stem ] = fsim .SimDrive (veh , cyc , sim_params ).to_pydict ()
248+ sds_for_val [cyc_file_stem ] = fsim .SimDrive (veh , cyc , sim_params ).to_dict ()
249249
250250
251251# Setup model parameters and objectives
@@ -254,41 +254,41 @@ def new_em_eff_max(sd_dict, new_eff_max) -> Dict:
254254 """
255255 Set `new_eff_max` in `ElectricMachine`
256256 """
257- em = fsim .ElectricMachine .from_pydict (sd_dict ["veh" ]["pt_type" ][pt_type_var ]["em" ])
257+ em = fsim .ElectricMachine .from_dict (sd_dict ["veh" ]["pt_type" ][pt_type_var ]["em" ])
258258 em .__eff_fwd_max = new_eff_max
259- sd_dict ["veh" ]["pt_type" ][pt_type_var ]["em" ] = em .to_pydict ()
259+ sd_dict ["veh" ]["pt_type" ][pt_type_var ]["em" ] = em .to_dict ()
260260 return sd_dict
261261
262262
263263def new_em_eff_range (sd_dict , new_eff_range ) -> Dict :
264264 """
265265 Set `new_eff_range` in `ElectricMachine`
266266 """
267- em = fsim .ElectricMachine .from_pydict (sd_dict ["veh" ]["pt_type" ][pt_type_var ]["em" ])
267+ em = fsim .ElectricMachine .from_dict (sd_dict ["veh" ]["pt_type" ][pt_type_var ]["em" ])
268268 em .__eff_fwd_range = new_eff_range
269- sd_dict ["veh" ]["pt_type" ][pt_type_var ]["em" ] = em .to_pydict ()
269+ sd_dict ["veh" ]["pt_type" ][pt_type_var ]["em" ] = em .to_dict ()
270270 return sd_dict
271271
272272
273273def new_fc_eff_max (sd_dict , new_eff_max ) -> Dict :
274274 """
275275 Set `new_eff_max` in `FuelConverter`
276276 """
277- fc = fsim .FuelConverter .from_pydict (sd_dict ["veh" ]["pt_type" ][pt_type_var ]["fc" ])
277+ fc = fsim .FuelConverter .from_dict (sd_dict ["veh" ]["pt_type" ][pt_type_var ]["fc" ])
278278 fc .__eff_max = new_eff_max
279- sd_dict ["veh" ]["pt_type" ][pt_type_var ]["fc" ] = fc .to_pydict ()
279+ sd_dict ["veh" ]["pt_type" ][pt_type_var ]["fc" ] = fc .to_dict ()
280280 return sd_dict
281281
282282
283283def new_fc_eff_range (sd_dict , new_eff_range ) -> Dict :
284284 """
285285 Set `new_eff_range` in `FuelConverter`
286286 """
287- fc = fsim .FuelConverter .from_pydict (sd_dict ["veh" ]["pt_type" ][pt_type_var ]["fc" ])
287+ fc = fsim .FuelConverter .from_dict (sd_dict ["veh" ]["pt_type" ][pt_type_var ]["fc" ])
288288 fc_eff_max = fc .eff_max
289289 # TODO: this is a quick and dirty apprach, change to using constraints in PyMOO
290290 fc .__eff_range = min (new_eff_range , fc_eff_max * 0.95 )
291- sd_dict ["veh" ]["pt_type" ][pt_type_var ]["fc" ] = fc .to_pydict ()
291+ sd_dict ["veh" ]["pt_type" ][pt_type_var ]["fc" ] = fc .to_dict ()
292292 return sd_dict
293293
294294
@@ -654,8 +654,8 @@ def perturb_params(pos_perturb_dec: float = 0.05, neg_perturb_dec: float = 0.1):
654654 # - `pos_perturb_doc`: perturbation percentage added to all params. Can be overridden invididually
655655 # - `neg_perturb_doc`: perturbation percentage subtracted from all params. Can be overridden invididually
656656 """
657- em = fsim .ElectricMachine .from_pydict (veh_dict ["pt_type" ][pt_type_var ]["em" ], skip_init = False )
658- fc = fsim .FuelConverter .from_pydict (veh_dict ["pt_type" ][pt_type_var ]["fc" ], skip_init = False )
657+ em = fsim .ElectricMachine .from_dict (veh_dict ["pt_type" ][pt_type_var ]["em" ], skip_init = False )
658+ fc = fsim .FuelConverter .from_dict (veh_dict ["pt_type" ][pt_type_var ]["fc" ], skip_init = False )
659659 baseline_params_and_bounds = [
660660 (em .eff_fwd_max , None ),
661661 (em .eff_fwd_range , None ),
0 commit comments