Skip to content

fastsim-3 style api #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 91 commits into
base: main
Choose a base branch
from
Open

fastsim-3 style api #133

wants to merge 91 commits into from

Conversation

calbaker
Copy link
Collaborator

@calbaker calbaker commented May 22, 2025

  • removes direct nested variable access because to_pydict and from_pydict work much better
  • adds TrackedState guarantees

TODOs

  • have Matt check over sim_manager_demo and rollout_demo (@mbbruch )
  • check discrepancies in data associated with failing tests in demos (@FDsteven) -- see f0f103e
  • get everything ready to hand off to Steven (@calbaker )
  • implement all the tracked state methods (@FDsteven )

solves https://github.com/NREL/altrios-private/issues/567

FDsteven and others added 26 commits March 17, 2025 10:09
…te is somehow not working, need to take deeper look.
@calbaker calbaker marked this pull request as draft May 22, 2025 16:52
calbaker and others added 3 commits June 12, 2025 14:09
test meet_pass::dispatch::test_dispatch::test_simple_dispatch ... FAILED

failures:

---- meet_pass::dispatch::test_dispatch::test_simple_dispatch stdout ----

thread 'meet_pass::dispatch::test_dispatch::test_simple_dispatch' panicked at altrios-core/src/meet_pass/dispatch.rs:333:70:
called `Result::unwrap()` on an `Err` value: [altrios-core/src/meet_pass/est_times/mod.rs:688]

Caused by:
    0: [altrios-core/src/meet_pass/est_times/est_time_structs.rs:79]
       time step: 10
    1: [altrios-core/src/train/speed_limit_train_sim.rs:538]
    2: [altrios-core/src/consist/consist_model.rs:448]
       loco idx: 2, loco type: HybridLoco
    3: [altrios-core/src/consist/locomotive/locomotive_model.rs:1211] "HybridLoco": "HybridLoco"
    4: [altrios-core/src/consist/locomotive/hybrid_loco.rs:279] fc_on: true

       [altrios-core/src/consist/locomotive/hybrid_loco.rs:280] pwr_out_req.get::<si::kilowatt>(): 2861.03699599694 kW

       [altrios-core/src/consist/locomotive/hybrid_loco.rs:281] self.edrv.state.pwr_elec_prop_in: TrackedState(2892497.3446029206 m^2 kg^1 s^-3, Fresh) kW

       [altrios-core/src/consist/locomotive/hybrid_loco.rs:282] gen_pwr_out_req.get::<si::kilowatt>(): 1808.8410260843998 kW
       [altrios-core/src/consist/locomotive/hybrid_loco.rs:283] self.gen.state.pwr_elec_aux: TrackedState(0.0 m^2 kg^1 s^-3, Fresh) kW
       [altrios-core/src/consist/locomotive/hybrid_loco.rs:284] self.gen.state.pwr_elec_out_max: TrackedState(1808841.0260843998 m^2 kg^1 s^-3, Fresh) kW
       [altrios-core/src/consist/locomotive/hybrid_loco.rs:285] self.gen.state.pwr_mech_in: TrackedState(1845799.9999999998 m^2 kg^1 s^-3, Fresh) kW

       [altrios-core/src/consist/locomotive/hybrid_loco.rs:286] res_pwr_out_req.get::<si::kilowatt>(): 1083.6563185185207 kW

       [altrios-core/src/consist/locomotive/hybrid_loco.rs:287] self.res.state.pwr_prop_max: TrackedState(1083656.3185185208 m^2 kg^1 s^-3, Fresh) kW
       [altrios-core/src/consist/locomotive/hybrid_loco.rs:288] self.res.state.pwr_disch_max: TrackedState(1093666.6666666667 m^2 kg^1 s^-3, Fresh) kW
       [altrios-core/src/consist/locomotive/hybrid_loco.rs:289] self.res.state.pwr_regen_max: TrackedState(1103677.0148148127 m^2 kg^1 s^-3, Fresh) kW
       [altrios-core/src/consist/locomotive/hybrid_loco.rs:290] self.res.state.pwr_charge_max: TrackedState(1093666.6666666667 m^2 kg^1 s^-3, Fresh) kW
    5: [altrios-core/src/consist/locomotive/powertrain/fuel_converter.rs:245] utils::almost_le_uom(&pwr_out_req, &self.pwr_out_max, Some(TOL)): false
       fc pwr_out_req (1.845800 MW) must be less than or equal to static pwr_out_max (1.678000 MW)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    meet_pass::dispatch::test_dispatch::test_simple_dispatch

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 103 filtered out; finished in 0.66s
.force
.update(fric_brake_force, || format_dbg!())?;

let pwr_whl_out_unclipped = f_consist * *self.state.speed.get_fresh(|| format_dbg!())?;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@garrettlanderson , this might have introduced a problem

calbaker and others added 23 commits June 13, 2025 13:35
…Stopping for now to go do a couple other things.

There's probably some optimization that needs to occur once I get this working.
Black did a whole lot of formatting on this.  That is most of the changes.
To duplicate verificiation:
- run python/altrios/demos/speed_limit_train_sim_demo_with_derating.py
- run
```python
to_dataframe = train_sim.to_dataframe()[-1]
common_cols = set(train_sim.to_dataframe()[-1].columns) & set(to_dataframe_expected.columns)
[col for col in common_cols if not to_dataframe_expected[col].equals(to_dataframe[col])]
```
rollout_demo.py runs but plots need attention
…data that needs to be checked and updated if no errors are found
This was referenced Jun 25, 2025
@calbaker calbaker marked this pull request as ready for review July 11, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants