Skip to content

Commit

Permalink
variable name change/improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Aug 12, 2024
1 parent 48a1fb3 commit f53a1f7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions fastsim-core/src/simdrive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl SimDrive {

vs.pwr_tractive =
vs.pwr_rr + vs.pwr_whl_inertia + vs.pwr_accel + vs.pwr_ascent + vs.pwr_drag;
vs.curr_pwr_met = vs.pwr_tractive <= vs.pwr_prop_pos_max;
vs.curr_pwr_met = vs.pwr_tractive <= vs.pwr_prop_fwd_max;
if !vs.curr_pwr_met {
// if current power demand is not met, then this becomes false for
// the rest of the cycle and should not be manipulated anywhere else
Expand Down Expand Up @@ -272,7 +272,7 @@ impl SimDrive {
let t2 = accel2 + drag2 + wheel2;
let t1 = drag1 + roll1 + ascent1;
// TODO: verify final term being subtracted. Needs to be same as `self.cur_max_trans_kw_out[i]`
let t0 = (accel0 + drag0 + roll0 + ascent0 + wheel0) - vs.pwr_prop_pos_max;
let t0 = (accel0 + drag0 + roll0 + ascent0 + wheel0) - vs.pwr_prop_fwd_max;

// initial guess
let speed_guess = (1e-3 * uc::MPS).max(cyc_speed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ pub struct ReversibleEnergyStorageState {
pub soh: f64,

// TODO: add `pwr_out_neg_electrical` and `pwr_out_pos_electrical` and corresponding energies
// powers
// powers to separately pin negative- and positive-power operation
/// total electrical power; positive is discharging
pub pwr_out_electrical: si::Power,
/// electrical power going to propulsion
Expand Down
16 changes: 8 additions & 8 deletions fastsim-core/src/vehicle/vehicle_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ impl Vehicle {
.set_cur_pwr_prop_out_max(self.pwr_aux, dt)
.with_context(|| anyhow!(format_dbg!()))?;

(self.state.pwr_prop_pos_max, self.state.pwr_prop_neg_max) = self
(self.state.pwr_prop_fwd_max, self.state.pwr_prop_bwd_max) = self
.pt_type
.get_cur_pwr_prop_out_max()
.with_context(|| anyhow!(format_dbg!()))?;
Expand Down Expand Up @@ -826,12 +826,12 @@ pub struct VehicleState {
/// time step index
pub i: usize,

// power and fields
/// maximum positive propulsive power vehicle can produce
pub pwr_prop_pos_max: si::Power,
// power and energy fields
/// maximum forward propulsive power vehicle can produce
pub pwr_prop_fwd_max: si::Power,
/// pwr exerted on wheels by powertrain
/// maximum negative propulsive power vehicle can produce
pub pwr_prop_neg_max: si::Power,
/// maximum backward propulsive power (e.g. regenerative braking) vehicle can produce
pub pwr_prop_bwd_max: si::Power,
/// Tractive power required for achieved speed
pub pwr_tractive: si::Power,
/// integral of [Self::pwr_out]
Expand Down Expand Up @@ -887,8 +887,8 @@ impl Default for VehicleState {
fn default() -> Self {
Self {
i: Default::default(),
pwr_prop_pos_max: si::Power::ZERO,
pwr_prop_neg_max: si::Power::ZERO,
pwr_prop_fwd_max: si::Power::ZERO,
pwr_prop_bwd_max: si::Power::ZERO,
pwr_tractive: si::Power::ZERO,
energy_tractive: si::Energy::ZERO,
pwr_aux: si::Power::ZERO,
Expand Down
16 changes: 8 additions & 8 deletions python/fastsim/demos/demo_variable_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@

# print out all subpaths for variables in SimDrive
print("List of variable paths for SimDrive:" + "\n".join(sd.variable_path_list()))
if ENABLE_REF_OVERRIDE:
with open(ref_dir / "variable_path_list_expected.txt", 'w') as f:
for line in sd.variable_path_list():
f.write(line + "\n")
if ENABLE_ASSERTS:
print("Checking output of `variable_path_list()`")
with open(ref_dir / "variable_path_list_expected.txt", 'r') as f:
variable_path_list_expected = [line.strip() for line in f.readlines()]
assert variable_path_list_expected == sd.variable_path_list()
if ENABLE_REF_OVERRIDE:
with open(ref_dir / "variable_path_list_expected.txt", 'w') as f:
for line in sd.variable_path_list():
f.write(line + "\n")
print("\n")

# print out all subpaths for history variables in SimDrive
Expand All @@ -48,13 +48,13 @@

# print results as dataframe
print("Results as dataframe:\n", sd.to_dataframe(), sep="")
if ENABLE_REF_OVERRIDE:
df:pl.DataFrame = sd.to_dataframe().lazy().collect()
df.write_csv(ref_dir / "to_dataframe_expected.csv")
print("Success!")
if ENABLE_ASSERTS:
print("Checking output of `to_dataframe`")
to_dataframe_expected = pl.scan_csv(ref_dir / "to_dataframe_expected.csv").collect()
assert to_dataframe_expected.equals(sd.to_dataframe())
print("Success!")
if ENABLE_REF_OVERRIDE:
df:pl.DataFrame = sd.to_dataframe().lazy().collect()
df.write_csv(ref_dir / "to_dataframe_expected.csv")
print("Success!")

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
veh.pt_type.HybridElectricVehicle.res.history.pwr_cat_max,veh.pt_type.HybridElectricVehicle.res.history.pwr_prop_max,veh.pt_type.HybridElectricVehicle.res.history.pwr_regen_max,veh.pt_type.HybridElectricVehicle.res.history.pwr_disch_max,veh.pt_type.HybridElectricVehicle.res.history.pwr_charge_max,veh.pt_type.HybridElectricVehicle.res.history.i,veh.pt_type.HybridElectricVehicle.res.history.soc,veh.pt_type.HybridElectricVehicle.res.history.eff,veh.pt_type.HybridElectricVehicle.res.history.soh,veh.pt_type.HybridElectricVehicle.res.history.pwr_out_electrical,veh.pt_type.HybridElectricVehicle.res.history.pwr_out_propulsion,veh.pt_type.HybridElectricVehicle.res.history.pwr_aux,veh.pt_type.HybridElectricVehicle.res.history.pwr_loss,veh.pt_type.HybridElectricVehicle.res.history.pwr_out_chemical,veh.pt_type.HybridElectricVehicle.res.history.energy_out_electrical,veh.pt_type.HybridElectricVehicle.res.history.energy_out_propulsion,veh.pt_type.HybridElectricVehicle.res.history.energy_aux,veh.pt_type.HybridElectricVehicle.res.history.energy_loss,veh.pt_type.HybridElectricVehicle.res.history.energy_out_chemical,veh.pt_type.HybridElectricVehicle.res.history.max_soc,veh.pt_type.HybridElectricVehicle.res.history.min_soc,veh.pt_type.HybridElectricVehicle.res.history.temperature_celsius,veh.pt_type.HybridElectricVehicle.fc.history.i,veh.pt_type.HybridElectricVehicle.fc.history.pwr_prop_max,veh.pt_type.HybridElectricVehicle.fc.history.eff,veh.pt_type.HybridElectricVehicle.fc.history.pwr_propulsion,veh.pt_type.HybridElectricVehicle.fc.history.energy_propulsion,veh.pt_type.HybridElectricVehicle.fc.history.pwr_aux,veh.pt_type.HybridElectricVehicle.fc.history.energy_aux,veh.pt_type.HybridElectricVehicle.fc.history.pwr_fuel,veh.pt_type.HybridElectricVehicle.fc.history.energy_fuel,veh.pt_type.HybridElectricVehicle.fc.history.pwr_loss,veh.pt_type.HybridElectricVehicle.fc.history.energy_loss,veh.pt_type.HybridElectricVehicle.fc.history.fc_on,veh.pt_type.HybridElectricVehicle.em.history.i,veh.pt_type.HybridElectricVehicle.em.history.eff,veh.pt_type.HybridElectricVehicle.em.history.pwr_mech_fwd_out_max,veh.pt_type.HybridElectricVehicle.em.history.pwr_mech_bwd_out_max,veh.pt_type.HybridElectricVehicle.em.history.pwr_rate_out_max,veh.pt_type.HybridElectricVehicle.em.history.pwr_out_req,veh.pt_type.HybridElectricVehicle.em.history.energy_out_req,veh.pt_type.HybridElectricVehicle.em.history.pwr_elec_prop_in,veh.pt_type.HybridElectricVehicle.em.history.energy_elec_prop_in,veh.pt_type.HybridElectricVehicle.em.history.pwr_mech_prop_out,veh.pt_type.HybridElectricVehicle.em.history.energy_mech_prop_out,veh.pt_type.HybridElectricVehicle.em.history.pwr_mech_dyn_brake,veh.pt_type.HybridElectricVehicle.em.history.energy_mech_dyn_brake,veh.pt_type.HybridElectricVehicle.em.history.pwr_elec_dyn_brake,veh.pt_type.HybridElectricVehicle.em.history.energy_elec_dyn_brake,veh.pt_type.HybridElectricVehicle.em.history.pwr_loss,veh.pt_type.HybridElectricVehicle.em.history.energy_loss,veh.history.i,veh.history.pwr_prop_pos_max,veh.history.pwr_prop_neg_max,veh.history.pwr_tractive,veh.history.energy_tractive,veh.history.pwr_aux,veh.history.energy_aux,veh.history.pwr_drag,veh.history.energy_drag,veh.history.pwr_accel,veh.history.energy_accel,veh.history.pwr_ascent,veh.history.energy_ascent,veh.history.pwr_rr,veh.history.energy_rr,veh.history.pwr_whl_inertia,veh.history.energy_whl_inertia,veh.history.pwr_brake,veh.history.energy_brake,veh.history.curr_pwr_met,veh.history.all_curr_pwr_met,veh.history.speed_ach,veh.history.dist,veh.history.grade_curr,veh.history.air_density
veh.pt_type.HybridElectricVehicle.res.history.pwr_cat_max,veh.pt_type.HybridElectricVehicle.res.history.pwr_prop_max,veh.pt_type.HybridElectricVehicle.res.history.pwr_regen_max,veh.pt_type.HybridElectricVehicle.res.history.pwr_disch_max,veh.pt_type.HybridElectricVehicle.res.history.pwr_charge_max,veh.pt_type.HybridElectricVehicle.res.history.i,veh.pt_type.HybridElectricVehicle.res.history.soc,veh.pt_type.HybridElectricVehicle.res.history.eff,veh.pt_type.HybridElectricVehicle.res.history.soh,veh.pt_type.HybridElectricVehicle.res.history.pwr_out_electrical,veh.pt_type.HybridElectricVehicle.res.history.pwr_out_propulsion,veh.pt_type.HybridElectricVehicle.res.history.pwr_aux,veh.pt_type.HybridElectricVehicle.res.history.pwr_loss,veh.pt_type.HybridElectricVehicle.res.history.pwr_out_chemical,veh.pt_type.HybridElectricVehicle.res.history.energy_out_electrical,veh.pt_type.HybridElectricVehicle.res.history.energy_out_propulsion,veh.pt_type.HybridElectricVehicle.res.history.energy_aux,veh.pt_type.HybridElectricVehicle.res.history.energy_loss,veh.pt_type.HybridElectricVehicle.res.history.energy_out_chemical,veh.pt_type.HybridElectricVehicle.res.history.max_soc,veh.pt_type.HybridElectricVehicle.res.history.min_soc,veh.pt_type.HybridElectricVehicle.res.history.temperature_celsius,veh.pt_type.HybridElectricVehicle.fc.history.i,veh.pt_type.HybridElectricVehicle.fc.history.pwr_prop_max,veh.pt_type.HybridElectricVehicle.fc.history.eff,veh.pt_type.HybridElectricVehicle.fc.history.pwr_propulsion,veh.pt_type.HybridElectricVehicle.fc.history.energy_propulsion,veh.pt_type.HybridElectricVehicle.fc.history.pwr_aux,veh.pt_type.HybridElectricVehicle.fc.history.energy_aux,veh.pt_type.HybridElectricVehicle.fc.history.pwr_fuel,veh.pt_type.HybridElectricVehicle.fc.history.energy_fuel,veh.pt_type.HybridElectricVehicle.fc.history.pwr_loss,veh.pt_type.HybridElectricVehicle.fc.history.energy_loss,veh.pt_type.HybridElectricVehicle.fc.history.fc_on,veh.pt_type.HybridElectricVehicle.em.history.i,veh.pt_type.HybridElectricVehicle.em.history.eff,veh.pt_type.HybridElectricVehicle.em.history.pwr_mech_fwd_out_max,veh.pt_type.HybridElectricVehicle.em.history.pwr_mech_bwd_out_max,veh.pt_type.HybridElectricVehicle.em.history.pwr_rate_out_max,veh.pt_type.HybridElectricVehicle.em.history.pwr_out_req,veh.pt_type.HybridElectricVehicle.em.history.energy_out_req,veh.pt_type.HybridElectricVehicle.em.history.pwr_elec_prop_in,veh.pt_type.HybridElectricVehicle.em.history.energy_elec_prop_in,veh.pt_type.HybridElectricVehicle.em.history.pwr_mech_prop_out,veh.pt_type.HybridElectricVehicle.em.history.energy_mech_prop_out,veh.pt_type.HybridElectricVehicle.em.history.pwr_mech_dyn_brake,veh.pt_type.HybridElectricVehicle.em.history.energy_mech_dyn_brake,veh.pt_type.HybridElectricVehicle.em.history.pwr_elec_dyn_brake,veh.pt_type.HybridElectricVehicle.em.history.energy_elec_dyn_brake,veh.pt_type.HybridElectricVehicle.em.history.pwr_loss,veh.pt_type.HybridElectricVehicle.em.history.energy_loss,veh.history.i,veh.history.pwr_prop_fwd_max,veh.history.pwr_prop_bwd_max,veh.history.pwr_tractive,veh.history.energy_tractive,veh.history.pwr_aux,veh.history.energy_aux,veh.history.pwr_drag,veh.history.energy_drag,veh.history.pwr_accel,veh.history.energy_accel,veh.history.pwr_ascent,veh.history.energy_ascent,veh.history.pwr_rr,veh.history.energy_rr,veh.history.pwr_whl_inertia,veh.history.energy_whl_inertia,veh.history.pwr_brake,veh.history.energy_brake,veh.history.curr_pwr_met,veh.history.all_curr_pwr_met,veh.history.speed_ach,veh.history.dist,veh.history.grade_curr,veh.history.air_density
0.0,0.0,0.0,0.0,0.0,0,0.5,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,22.0,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,false,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,true,true,0.0,0.0,0.0,1.206
0.0,98950.0,101050.0,100000.0,100000.0,1,0.4999994160827494,666.0,0.0,1050.0,0.0,1050.0,1048.4234234234234,1.5765765765765767,1050.0,0.0,1050.0,1048.4234234234234,1.5765765765765767,0.95,0.25,22.0,1,0.0,0.1,0.0,0.0,1050.0,1050.0,13125.0,13125.0,13125.0,13125.0,true,1,0.83,53000.0,53000.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,0.0,-0.0,0.0,0.0,0.0,1,53000.0,53000.0,0.0,0.0,1050.0,1050.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,true,true,0.0,0.0,0.0,1.206
0.0,98950.0,101050.0,100000.0,100000.0,2,0.4999988321654988,666.0,0.0,1050.0,0.0,1050.0,1048.4234234234234,1.5765765765765767,2100.0,0.0,2100.0,2096.846846846847,3.1531531531531534,0.95,0.25,22.0,2,0.0,0.1,0.0,0.0,1050.0,2100.0,13125.0,26250.0,13125.0,26250.0,true,2,0.83,53000.0,53000.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-0.0,0.0,-0.0,0.0,0.0,0.0,2,53000.0,53000.0,0.0,0.0,1050.0,2100.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,true,true,0.0,0.0,0.0,1.206
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@
['veh']['trans_eff']
['veh']['save_interval']
['veh']['state']['i']
['veh']['state']['pwr_prop_pos_max']
['veh']['state']['pwr_prop_neg_max']
['veh']['state']['pwr_prop_fwd_max']
['veh']['state']['pwr_prop_bwd_max']
['veh']['state']['pwr_tractive']
['veh']['state']['energy_tractive']
['veh']['state']['pwr_aux']
Expand All @@ -169,8 +169,8 @@
['veh']['state']['grade_curr']
['veh']['state']['air_density']
['veh']['history']['i']
['veh']['history']['pwr_prop_pos_max']
['veh']['history']['pwr_prop_neg_max']
['veh']['history']['pwr_prop_fwd_max']
['veh']['history']['pwr_prop_bwd_max']
['veh']['history']['pwr_tractive']
['veh']['history']['energy_tractive']
['veh']['history']['pwr_aux']
Expand Down

0 comments on commit f53a1f7

Please sign in to comment.