Skip to content

Commit

Permalink
Merge pull request #48 from NREL/f2-simdrivevec
Browse files Browse the repository at this point in the history
parallelization in rust is working and demonstrates speedup
  • Loading branch information
calbaker authored Aug 23, 2023
2 parents c4b8f60 + 7417998 commit cb969a1
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 363 deletions.
24 changes: 24 additions & 0 deletions python/fastsim/demos/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,30 @@

print(f'Time to simulate: {time.perf_counter() - t0:.2e} s')


# %% [markdown]
# # Simulating multiple instances of RustSimDrive

# Note that this cell (demarcated by the `# %%`)

def get_sim_drive_vec(
parallelize: bool=True,
) -> fsim.fastsimrust.SimDriveVec:
cyc = fsim.cycle.Cycle.from_file('udds').to_rust()
veh = fsim.vehicle.Vehicle.from_vehdb(1).to_rust()
sim_drive = fsim.simdrive.RustSimDrive(cyc, veh)
sim_drive_vec = fsim.fastsimrust.SimDriveVec([sim_drive] * 20)
t0 = time.perf_counter()
sim_drive_vec.sim_drive(parallelize)
par_str = "with parallelization" if parallelize else "without parallelization"
print(f'Time to simulate {par_str}: {time.perf_counter() - t0:.2e} s')
return sim_drive_vec

if __name__ == "__main__":
sdv = get_sim_drive_vec(False)
sdv_par = get_sim_drive_vec(True)


# %% [markdown]
# ## Batch Drive Cycles - TSDC Drive Cycles
#
Expand Down
Loading

0 comments on commit cb969a1

Please sign in to comment.