Skip to content

Commit

Permalink
Merge branch 'fastsim-2' into feature/vehicle_import
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecarow authored Dec 1, 2023
2 parents f57e88b + 05d46c1 commit e60a5fa
Show file tree
Hide file tree
Showing 42 changed files with 1,250 additions and 1,045 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/deploy-book.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Deploy mdBook site to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["fastsim-2"]
paths:
- "docs/**"
- ".github/workflows/deploy-book.yaml"
pull_request:
branches: ["fastsim-2"]
paths:
- "docs/**"
- ".github/workflows/deploy-book.yaml"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: [ self-hosted ]
env:
MDBOOK_VERSION: 0.4.21
steps:
- uses: actions/checkout@v3
- name: Install mdBook
run: |
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
rustup update
cargo install --version ${MDBOOK_VERSION} mdbook
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Build with mdBook
working-directory: ${{runner.workspace}}/mbap-computing/docs/
run: mdbook build
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./docs/book

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: [ self-hosted ]
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
![FASTSim Logo](https://www.nrel.gov/transportation/assets/images/icon-fastsim.jpg)

[![Tests](https://github.com/NREL/fastsim/actions/workflows/tests.yaml/badge.svg)](https://github.com/NREL/fastsim/actions/workflows/tests.yaml) [![wheels](https://github.com/NREL/fastsim/actions/workflows/wheels.yaml/badge.svg)](https://github.com/NREL/fastsim/actions/workflows/wheels.yaml?event=release) ![Python](https://img.shields.io/badge/python-3.9%20%7C%203.10-blue) [![Documentation](https://img.shields.io/badge/documentation-custom-blue.svg)](https://nrel.github.io/fastsim/) [![GitHub](https://img.shields.io/badge/GitHub-fastsim-blue.svg)](https://github.com/NREL/fastsim)

# Description
This is the python/rust flavor of [NREL's FASTSim<sup>TM</sup>](https://www.nrel.gov/transportation/fastsim.html), which is based on the original Excel implementation. Effort will be made to keep the core methodology between this software and the Excel flavor in line with one another.

Expand Down
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
book/
10 changes: 10 additions & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[book]
authors = ["Chad Baker"]
language = "en"
multilingual = false
src = "src"
title = "FASTSim Documentation"

[output.html.fold]
enable = true
level = 0
4 changes: 4 additions & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Summary

- [Introduction](./intro.md)
- [How to Update This Book](./how-to-update.md)
15 changes: 15 additions & 0 deletions docs/src/how-to-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# How to Update This Markdown Book

[mdBook Documentation](https://rust-lang.github.io/mdBook/)

## Setup

1. If not already done, [install mdbook](https://rust-lang.github.io/mdBook/guide/installation.html)

## Publishing

1. Update `book.toml` or files in `docs/src/`
1. Make sure the docs look good locally: `mdbook build docs/ --open`
1. Commit files and push to `main` branch

After that, a GitHub action will build the book and publish it [here](https://pages.github.nrel.gov/MBAP/mbap-computing/)
3 changes: 3 additions & 0 deletions docs/src/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introduction

This is the overall FASTSim documentation. We're working toward making this a fully integrated document that includes both the Python API and Rust core documentation for the `fastsim-2` branch and eventually also for the `fastsim-3` branch.
19 changes: 9 additions & 10 deletions python/fastsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
import logging
import traceback

from . import fastsimrust
from . import fastsimrust as fsr
from . import parameters as params
from . import utilities as utils
from . import simdrive, vehicle, cycle, calibration, tests
from . import calibration as cal
from .resample import resample
from . import auxiliaries


def package_root() -> Path:
"""Returns the package root directory."""
Expand All @@ -19,16 +28,6 @@ def package_root() -> Path:
)
logger = logging.getLogger(__name__)


from . import fastsimrust
from . import fastsimrust as fsr
from . import parameters as params
from . import utilities as utils
from . import simdrive, vehicle, cycle, calibration, tests
from . import calibration as cal
from .resample import resample
from . import auxiliaries

from pkg_resources import get_distribution

__version__ = get_distribution("fastsim").version
Expand Down
7 changes: 7 additions & 0 deletions python/fastsim/demos/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import logging

logger = logging.getLogger(__name__)
logger.warning(
"Module `fastsim.demos` has been imported. This should only "
+ "happen during testing, so you might be doing something wrong."
)
5 changes: 1 addition & 4 deletions python/fastsim/fastsimrust.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ class RustSimDrive(SerdeAPI):
cur_max_fs_kw_out: Pyo3ArrayF64
cur_max_mc_elec_kw_in: Pyo3ArrayF64
cur_max_mc_kw_out: Pyo3ArrayF64
cur_max_mech_mc_kw_in: Pyo3ArrayF64
cur_max_roadway_chg_kw: Pyo3ArrayF64
cur_max_trac_kw: Pyo3ArrayF64
cur_max_trans_kw_out: Pyo3ArrayF64
Expand Down Expand Up @@ -445,20 +444,18 @@ class RustSimDrive(SerdeAPI):
ess_eff_kj: float
ess_kw_if_fc_req: Pyo3ArrayF64
ess_kw_out_ach: Pyo3ArrayF64
ess_lim_mc_regen_kw: Pyo3ArrayF64
cur_max_mech_mc_kw_in: Pyo3ArrayF64
ess_lim_mc_regen_perc_kw: Pyo3ArrayF64
ess_loss_kw: Pyo3ArrayF64
ess_perc_dead: Pyo3ArrayF64
ess_regen_buff_dischg_kw: Pyo3ArrayF64
fc_forced_on: Pyo3ArrayBool
fc_forced_state: Pyo3ArrayU32
fc_fs_lim_kw: Pyo3ArrayF64
fc_kj: float
fc_kw_gap_fr_eff: Pyo3ArrayF64
fc_kw_in_ach: Pyo3ArrayF64
fc_kw_out_ach: Pyo3ArrayF64
fc_kw_out_ach_pct: Pyo3ArrayF64
fc_max_kw_in: Pyo3ArrayF64
fc_time_on: Pyo3ArrayF64
fc_trans_lim_kw: Pyo3ArrayF64
fs_cumu_mj_out_ach: Pyo3ArrayF64
Expand Down
16 changes: 4 additions & 12 deletions python/fastsim/simdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ def init_arrays(self):
# Component Limits -- calculated dynamically
self.cur_max_fs_kw_out = np.zeros(cyc_len, dtype=np.float64)
self.fc_trans_lim_kw = np.zeros(cyc_len, dtype=np.float64)
self.fc_fs_lim_kw = np.zeros(cyc_len, dtype=np.float64)
self.fc_max_kw_in = np.zeros(cyc_len, dtype=np.float64)
self.cur_max_fc_kw_out = np.zeros(cyc_len, dtype=np.float64)
self.ess_cap_lim_dischg_kw = np.zeros(cyc_len, dtype=np.float64)
self.cur_ess_max_kw_out = np.zeros(cyc_len, dtype=np.float64)
Expand All @@ -228,7 +226,6 @@ def init_arrays(self):
self.cur_max_mc_kw_out = np.zeros(cyc_len, dtype=np.float64)
self.ess_lim_mc_regen_perc_kw = np.zeros(
cyc_len, dtype=np.float64)
self.ess_lim_mc_regen_kw = np.zeros(cyc_len, dtype=np.float64)
self.cur_max_mech_mc_kw_in = np.zeros(cyc_len, dtype=np.float64)
self.cur_max_trans_kw_out = np.zeros(cyc_len, dtype=np.float64)

Expand Down Expand Up @@ -720,11 +717,8 @@ def set_comp_lims(self, i):
self.veh.fc_max_kw / self.veh.fc_sec_to_peak_pwr * self.cyc.dt_s_at_i(i)
)

self.fc_max_kw_in[i] = min(
self.cur_max_fs_kw_out[i], self.veh.fs_max_kw)
self.fc_fs_lim_kw[i] = self.veh.fc_max_kw
self.cur_max_fc_kw_out[i] = min(
self.veh.fc_max_kw, self.fc_fs_lim_kw[i], self.fc_trans_lim_kw[i])
self.veh.fc_max_kw, self.fc_trans_lim_kw[i])

if self.veh.ess_max_kwh == 0 or self.soc[i-1] < self.veh.min_soc:
self.ess_cap_lim_dischg_kw[i] = 0.0
Expand Down Expand Up @@ -813,14 +807,14 @@ def set_comp_lims(self, i):
self.ess_lim_mc_regen_perc_kw[i] = min(
(self.cur_max_ess_chg_kw[i] + self.aux_in_kw[i]) / self.veh.mc_max_kw, 1)
if self.cur_max_ess_chg_kw[i] == 0:
self.ess_lim_mc_regen_kw[i] = 0.0
self.cur_max_mech_mc_kw_in[i] = 0.0

else:
if self.veh.mc_max_kw == self.cur_max_ess_chg_kw[i] - self.cur_max_roadway_chg_kw[i]:
self.ess_lim_mc_regen_kw[i] = min(
self.cur_max_mech_mc_kw_in[i] = min(
self.veh.mc_max_kw, self.cur_max_ess_chg_kw[i] / self.veh.mc_full_eff_array[-1])
else:
self.ess_lim_mc_regen_kw[i] = min(
self.cur_max_mech_mc_kw_in[i] = min(
self.veh.mc_max_kw,
self.cur_max_ess_chg_kw[i] / self.veh.mc_full_eff_array[
max(1,
Expand All @@ -835,8 +829,6 @@ def set_comp_lims(self, i):
]
)

self.cur_max_mech_mc_kw_in[i] = min(
self.ess_lim_mc_regen_kw[i], self.veh.mc_max_kw)
self.cur_max_trac_kw[i] = (
self.veh.wheel_coef_of_fric * self.veh.drive_axle_weight_frac *
self.veh.veh_kg * self.props.a_grav_mps2
Expand Down
6 changes: 1 addition & 5 deletions python/fastsim/tests/test_simdrive_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ def test_post_diagnostics(self):
"cur_ess_max_kw_out",
"cur_max_fs_kw_out",
"cur_max_mc_elec_kw_in",
"cur_max_mech_mc_kw_in",
"cur_max_trac_kw",
"cur_max_trans_kw_out",
"cyc_fric_brake_kw",
Expand All @@ -224,11 +223,8 @@ def test_post_diagnostics(self):
"er_ae_kw_out",
"ess_cap_lim_chg_kw",
"ess_cap_lim_dischg_kw",
"ess_lim_mc_regen_kw",
"cur_max_mech_mc_kw_in",
"ess_lim_mc_regen_perc_kw",
"fc_fs_lim_kw",
"fc_max_kw_in",
"fc_max_kw_in",
"fc_trans_lim_kw",
"high_acc_fc_on_tag",
"max_trac_mps",
Expand Down
1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"

members = [
"fastsim-cli", # command line app
Expand Down
2 changes: 2 additions & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Crate Architecture
[![Tests](https://github.com/NREL/fastsim/actions/workflows/tests.yaml/badge.svg)](https://github.com/NREL/fastsim/actions/workflows/tests.yaml) [![wheels](https://github.com/NREL/fastsim/actions/workflows/wheels.yaml/badge.svg)](https://github.com/NREL/fastsim/actions/workflows/wheels.yaml?event=release) ![Python](https://img.shields.io/badge/python-3.9%20%7C%203.10-blue) [![Documentation](https://img.shields.io/badge/documentation-custom-blue.svg)](https://nrel.github.io/fastsim/) [![GitHub](https://img.shields.io/badge/GitHub-fastsim-blue.svg)](https://github.com/NREL/fastsim)

FASTSim Rust crates are organized as a cargo [workspace](Cargo.toml) as follows:
1. `fastsim-core`: a pure rust lib crate with optional `pyo3` feature. This crate is intended to be used by other crates and is not in itself an app.
1. `fastsim-cli`: a wrapper around `fastsim-core` to enable a standalone CLI app for running fastsim and getting results out.
Expand Down
1 change: 1 addition & 0 deletions rust/fastsim-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repository = "https://github.com/NREL/fastsim"

[dependencies]
fastsim-core = { path = "../fastsim-core", version = "~0" }
anyhow = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
project-root = "0.2.2"
Expand Down
Loading

0 comments on commit e60a5fa

Please sign in to comment.