Skip to content

Commit 6831045

Browse files
Merge pull request #84 from NatLabRockies/t3co-2.0
T3co 2.0
2 parents 85017ca + fd19dee commit 6831045

278 files changed

Lines changed: 21187 additions & 316408 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# EIA Open Data API key (required for zipcode-based fuel price lookups)
2+
# Register at https://www.eia.gov/opendata/register.php
3+
# When a US zipcode is set in the Config region column, T3CO auto-discovers
4+
# the latest AEO publication year and fetches region-specific fuel prices.
5+
T3CO_EIA_API_KEY=your_api_key_here
6+
7+
# SSL verification for EIA API requests.
8+
# Set to "false" to disable (e.g. behind a corporate proxy with SSL inspection),
9+
# or set to a path to a custom CA bundle file.
10+
# T3CO_SSL_VERIFY=false

.github/workflows/python-publish.yml

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,47 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
python-version: ["3.8", "3.9", "3.10"]
24+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2525

2626
steps:
27-
- uses: actions/checkout@v1
27+
- uses: actions/checkout@v4
2828
with:
2929
fetch-depth: 9
3030
submodules: false
3131

3232
- name: Use Python ${{ matrix.python-version }}
33-
uses: actions/setup-python@v4
33+
uses: actions/setup-python@v5
3434
with:
3535
python-version: ${{ matrix.python-version }}
3636

37-
- name: Install dependencies
38-
run: |
39-
pip install -r requirements.txt
37+
- name: Install local package
38+
run: pip install .
39+
40+
- name: Install fastsim extra (Python 3.9–3.10 only)
41+
if: ${{ matrix.python-version == '3.9' || matrix.python-version == '3.10' }}
42+
run: pip install "fastsim>=2.1.1,<3"
4043

44+
- name: Install test dependencies
45+
run: pip install pytest pytest-mock
46+
47+
- name: Run tests
48+
run: pytest
49+
50+
# Build the distribution only on Python 3.10.
4151
- name: Install distribution dependencies
42-
run: |
43-
pip install build
44-
if: matrix.python-version == 3.10
52+
if: ${{ matrix.python-version == '3.10' }}
53+
run: pip install build
4554

4655
- name: Create distribution package
56+
if: ${{ matrix.python-version == '3.10' }}
4757
run: python -m build
48-
if: matrix.python-version == 3.10
4958

5059
- name: Upload distribution package
60+
if: ${{ matrix.python-version == '3.10' }}
5161
uses: actions/upload-artifact@v4
5262
with:
5363
name: dist
5464
path: dist
55-
if: matrix.python-version == 3.10
5665

5766
publish:
5867
runs-on: ubuntu-latest
@@ -66,24 +75,26 @@ jobs:
6675
path: dist
6776

6877
- name: Use Python 3.12
69-
uses: actions/setup-python@v1
78+
uses: actions/setup-python@v5
7079
with:
7180
python-version: '3.12'
7281

7382
- name: Install dependencies
74-
run: |
75-
pip install twine
83+
run: pip install twine
7684

7785
- name: Publish distribution 📦 to Test PyPI
78-
run: |
79-
twine upload -r testpypi dist/*
86+
run: twine upload -r testpypi dist/*
8087
env:
8188
TWINE_USERNAME: __token__
8289
TWINE_PASSWORD: ${{ secrets.test_pypi_password }}
8390

84-
- name: Publish distribution 📦 to PyPI
91+
- name: Install t3co from Test PyPI and run tests
8592
run: |
86-
twine upload -r pypi dist/*
93+
pip install --upgrade --no-cache-dir --index-url https://test.pypi.org/simple/ t3co[dev]
94+
pytest
95+
96+
- name: Publish distribution 📦 to PyPI
97+
run: twine upload -r pypi dist/*
8798
env:
8899
TWINE_USERNAME: __token__
89100
TWINE_PASSWORD: ${{ secrets.pypi_password }}

.gitignore

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
*.docx
77
*.pdf
88
*.svg
9+
!docs/images/*.svg
910
!docs/t3co_logo.svg
1011
*.csv
11-
!t3co/resources/inputs/**/*.csv
12-
!t3co/**/*.csv
12+
!src/t3co/resources/*.csv
13+
!src/t3co/**/*.csv
1314
*.xlsx
1415
*.json
1516
*.txt
@@ -27,6 +28,11 @@
2728
*.Rhistory
2829
*venv*
2930
*.DS_Store
31+
.env
32+
t3co/resources/T3CO_Config_Local.csv
3033
/site
31-
/t3co/resources/auxiliary/payload_pdf.csv
32-
/t3co/tco_results
34+
/tco_results
35+
/src/t3co/resources/auxiliary/payload_pdf.csv
36+
/src/results
37+
/src/t3co/resources/results
38+
!/src/t3co/resources/cost_toggles.json

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include t3co/resources *

Makefile

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 113 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,162 @@
11

22
![t3co_logo](https://github.com/user-attachments/assets/60623b62-57de-4475-b839-d7eb39405185)
33

4-
[![homepage](https://img.shields.io/badge/homepage-t3co-blue)](https://www.nrel.gov/transportation/t3co.html) [![github](https://img.shields.io/badge/github-t3co-blue.svg)](https://github.com/NREL/T3CO) [![documentation](https://img.shields.io/badge/documentation-t3co-blue.svg)](https://nrel.github.io/T3CO/) [![PyPI - Version](https://img.shields.io/pypi/v/t3co)](https://pypi.org/project/t3co/) ![GitHub License](https://img.shields.io/github/license/NREL/T3CO) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/t3co)
4+
[![homepage](https://img.shields.io/badge/homepage-t3co-blue)](https://www.nlr.gov/transportation/t3co.html) [![github](https://img.shields.io/badge/github-t3co-blue.svg)](https://github.com/NatLabRockies/T3CO) [![documentation](https://img.shields.io/badge/documentation-t3co-blue.svg)](https://NatLabRockies.github.io/T3CO/) [![PyPI - Version](https://img.shields.io/pypi/v/t3co)](https://pypi.org/project/t3co/) ![GitHub License](https://img.shields.io/github/license/NLR/T3CO) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/t3co)
55

66

77
# **T3CO** : Transportation Technology Total Cost of Ownership Tool
88
## Description
99

1010
This repo houses T3CO (Transportation Technology Total Cost of Ownership), software for modeling total cost of ownership for commercial vehicles with advanced powertrains.
1111

12-
To get started, read the [Quick Start Guide](https://github.com/NREL/T3CO/blob/main/docs/quick_start.md)
12+
**New to 2.0?** See [What's New in T3CO 2.0](./docs/whats_new.md) for a summary of EIA fuel price integration, expanded optimization algorithms, and other changes.
1313

14-
For information on the T3CO models, go to the [Overview](https://github.com/NREL/T3CO/blob/main/docs/T3CO_Overview.md)
14+
To get started, read the [Quick Start Guide](./docs/quick_start.md)
15+
16+
For detailed installation instructions, read the [Installation Guide](./docs/installation.md)
17+
18+
For information on the T3CO models, go to the [Overview](./docs/T3CO_Overview.md)
1519

1620
## Usage
1721

18-
**T3CO** is a general framework allowing a user to determine the total cost of ownership (TCO) of a FASTSim vehicle (paired with a FASTSim DriveCycle(s) for determining fuel efficiency). The user can also determine performance of gradeability, acceleration, and range. In addition to straight TCO computation there is also the option to optimize a vehicle powertrain such that it meets performance optional targets while also optionally minimizing TCO.
22+
**T3CO** is a general framework allowing a user to determine the total cost of ownership (TCO) of a vehicle (sometimes a FASTSim vehicle model paired with drivecycle(s) for determining fuel efficiency). The user can also determine performance of gradeability, acceleration, and range. In addition to straight TCO computation there is also the option to optimize a vehicle powertrain such that it meets performance optional targets while also optionally minimizing TCO.
1923

2024
## Installation
21-
T3CO is available on PyPI and as a public access GitHub repository. This gives the user two ways of installing the T3CO Python Package.
22-
### 1. Installing From [PyPI](https://pypi.org/project/t3co/)
25+
26+
T3CO is available on PyPI and as a public access GitHub repository. This gives the user **two sources** from where T3CO Python Package can be obtained and installed.
27+
28+
### Installation 'Extras'
29+
30+
The user can choose one of three installation options or 'extras' of T3CO based on their desired tool capabilities.
31+
32+
- T3CO as a pure cost estimation tool with exogenous inputs (default version `t3co` - requires Python>=3.9, <=3.13)
33+
- T3CO integrated with FASTSim for energy simulation (`t3co[fastsim]`, requires Python>=3.9,<=3.10)
34+
- T3CO for developers and quality testers that includes all capabilities (`t3co[dev]` requires Python>=3.9,<=3.10)
35+
The different 'extras' refers to different sets of dependencies that get installed along with T3CO.
36+
37+
38+
### Installation Source #1: From [PyPI](https://pypi.org/project/t3co/)
39+
40+
After creating a version-appropriate [Python environment](./docs/installation.md#setting-up-env), the latest release of T3CO can be installed from PyPI using one of the following commands.
41+
42+
For the default option/extra:
43+
2344
```bash
2445
pip install t3co
2546
```
2647

27-
### 2. Cloning the [GitHub Repo](https://github.com/NREL/T3CO)
28-
T3CO can also be installed directly from a clone of the GitHub repository which makes it easier to access input files and run the tool using a Command Line Interface.
48+
For the FASTSim-integrated 'extra':
49+
50+
```bash
51+
pip install t3co[fastsim]
52+
```
53+
54+
For the developer 'extra':
55+
56+
```bash
57+
pip install t3co[dev]
58+
```
59+
60+
### Installation Source #2: Cloning the [GitHub Repo](https://github.com/NatLabRockies/T3CO)
61+
62+
T3CO can also be installed from a clone of the GitHub repository.
63+
64+
First, [clone](https://git-scm.com/docs/git-clone) the repository from [GitHub](https://github.com/NatLabRockies/T3CO) from your desired directory (eg., /Users/Projects/):
65+
66+
```bash
67+
git clone https://github.com/NatLabRockies/T3CO.git T3CO
68+
```
69+
70+
This creates a git compliant folder 'T3CO' (i.e., a '/Users/Projects/T3CO' folder)
71+
72+
To access the `t3co-2.0` branch,
2973

30-
First, [clone](https://git-scm.com/docs/git-clone) the repository from [GitHub](https://github.com/NREL/T3CO) from your desired directory:
3174
```bash
32-
git clone https://github.com/NREL/T3CO.git T3CO
75+
git checkout t3co-2.0
3376
```
3477

35-
From within the [Python environment](./docs/installation.md#setting-up-env), navigate to the parent directory containing the T3CO repository (e.g. `cd GitHub/T3CO/`) and run:
78+
From within the [Python environment](./docs/installation.md#setting-up-env), navigate to the parent directory containing the T3CO repository (`cd T3CO`) and run one of these three installation options:
79+
80+
81+
For the default option/extra:
82+
3683
```bash
3784
pip install -e .
3885
```
39-
This installs the local version of the T3CO clone along with all its [dependencies](https://github.com/NREL/T3CO/blob/main/requirements.txt).
86+
87+
For the FASTSim-integrated 'extra':
88+
89+
```bash
90+
pip install -e .[fastsim]
91+
```
92+
93+
For the developer 'extra':
94+
95+
```bash
96+
pip install -e .[dev]
97+
```
4098

4199
### Copying the Demo Input Files
42-
The [`t3co.resources`](https://github.com/NREL/T3CO/tree/main/t3co/resources) folder contains all the necessary input files needed for running T3CO. To get an offline copy of this folder in your preferred directory, run:
100+
The [`t3co.resources`](./src/t3co/resources) module folder contains all the necessary input files needed for running T3CO. To get an offline copy of this folder in your preferred directory, run:
43101
```bash
44102
install_t3co_demo_inputs
45103
```
46104

47-
More information on the demo input files can be found in the [Installation Guide](https://github.com/NREL/T3CO/blob/main/docs/installation.md#copy-demo-inputs)
105+
More information on the demo input files can be found in the [Installation Guide](./docs/installation.md#copy-demo-inputs)
48106

49107

50108
## Running T3CO
51-
T3CO needs three main input files (*Vehicles*, *Scenarios*, and *Config*) to run an analysis. The analysis settings, file paths to main and auxiliary input files, and other parameter overrides are saved as an entry on the *Config* file. The user is provided with 500+ *Vehicle-Scenario* pairs inputs and four *Config* sample analyses to choose from to modify parameters and/or run their first T3CO analysis. The main module for T3CO,`t3co.sweep`, can be run using:
109+
T3CO needs three main input files (*Vehicles*, *Scenarios*, and *Config*) to run an analysis. The analysis settings, file paths to main and auxiliary input files, and other parameter overrides are saved as an entry on the *Config* file. The user is provided with 500+ *Vehicle-Scenario* pairs inputs and four *Config* sample analyses to choose from to modify parameters and/or run their first T3CO analysis. The main module for T3CO,`t3co.cli.sweep`, can be run using:
52110

53111
```bash
54-
python -m t3co.sweep --analysis-id=0 --config=<path/to/T3COConfig.csv>
112+
python -m t3co.cli.sweep --analysis-id=0 --config=<path/to/T3COConfig.csv>
55113
```
56114

57-
Point the `--config` argument to the `T3COConfig.csv` file path (either the t3co/resource/T3COConfig.csv file in a repo clone or the demo_inputs/T3COConfig.csv file after copying the demo input files. This parameter defaults to the T3COConfig.csv file in the t3co.resources module) and `--analysis-id` to the desired `config.analysis_id` (either an existing row or a newly added "Analysis" row in the `T3COConfig.csv` file. Default = `0`).
115+
Point the `--config` argument to the `T3COConfig.csv` file path (either the src/t3co/resource/T3COConfig.csv file in a repo clone or the demo_inputs/T3COConfig.csv file after copying the demo input files. This parameter defaults to the T3COConfig.csv file in the t3co.resources module) and `--analysis-id` to the desired `config.analysis_id` (either an existing row or a newly added "Analysis" row in the `T3COConfig.csv` file. Default = `0`).
116+
117+
Additional information on the inputs, the Batch Mode feature, other CLI arguments, and description of T3CO results are mentioned in the [Quick Start Guide](./docs/quick_start.md)
58118

59-
Additional information on the inputs, the Batch Mode feature, other CLI arguments, and description of T3CO results are mentioned in the [Quick Start Guide](https://github.com/NREL/T3CO/blob/main/docs/quick_start.md)
119+
### EIA Fuel Price Projections
120+
121+
T3CO can fetch fuel price projections directly from the [EIA Annual Energy Outlook (AEO)](https://www.eia.gov/outlooks/aeo/) API instead of relying on the static `FuelPrices.csv` file. When a US zipcode is provided in the `region` column of the Config file (or in the Scenario file), T3CO automatically:
122+
123+
1. Discovers the **latest** AEO publication year available from the EIA API (e.g. AEO 2025)
124+
2. Identifies the **reference case** scenario for that year
125+
3. Resolves the zipcode to the corresponding **US Census division** (e.g. `90210` → Pacific)
126+
4. Fetches region-specific fuel price projections for diesel, gasoline, electricity, and CNG
127+
5. Falls back to `FuelPrices.csv` for hydrogen (not available in AEO)
128+
129+
To enable this feature:
130+
131+
1. Register for a free API key at [eia.gov/opendata/register.php](https://www.eia.gov/opendata/register.php)
132+
2. Create a `.env` file in your project root (see `.env.example`):
133+
```
134+
T3CO_EIA_API_KEY=your_api_key_here
135+
```
136+
3. Set the `region` column in `T3COConfig.csv` to a US zipcode (e.g. `90210`)
137+
4. Ensure the `eia_fuel_prices` toggle is enabled in `cost_toggles.json` (default: `true`)
138+
139+
To pin a specific AEO year instead of using the latest, set `eia_aeo_year` and `eia_aeo_case` in the Config CSV or via CLI:
140+
```bash
141+
python -m t3co.cli.sweep --analysis-id=5 --eia-aeo-year=2023 --eia-aeo-case=aeo2022ref
142+
```
143+
144+
If no zipcode is provided or the toggle is disabled, T3CO uses the static `FuelPrices.csv` as before.
145+
146+
Fuel price override workflows that use `--fuel-prices-json` and `--fuel-prices-zipcode` resolve the source fuel-price region from the installed `zipcodes` dependency instead of repository-maintained ZIP range tables.
60147

61148
## Acknowledgements
149+
62150
This tool was developed with funding support from the US Department of Energy's Office of Energy Efficiency and Renewable Energy (EERE)'s Vehicle Technology Office.
63151

64-
DOE NREL Software Record: [SWR-21-54](https://doi.org/10.11578/dc.20240806.4)
152+
DOE NLR Software Record: [SWR-21-54](https://doi.org/10.11578/dc.20240806.4)
65153

66154
## To cite T3CO
67155

68-
*Lustbader, Jason, Panneer Selvam, Harish, Bennion, Kevin, Payne, Grant, Hunter, Chad, Penev, Michael, Brooker, Aaron, Baker, Chad, Birky, Alicia, Zhang, Chen, and Carow, Kyle. "T3CO (Transportation Technology Total Cost of Ownership) Open Source [SWR-21-54]." Computer software. September 16, 2024. https://github.com/NREL/T3CO. https://doi.org/10.11578/dc.20240806.4.*
156+
*Lustbader, Jason, Panneer Selvam, Harish, Bennion, Kevin, Payne, Grant, Hunter, Chad, Penev, Michael, Brooker, Aaron, Baker, Chad, Birky, Alicia, Zhang, Chen, and Carow, Kyle. "T3CO (Transportation Technology Total Cost of Ownership) Open Source [SWR-21-54]." Computer software. September 16, 2024. https://github.com/NatLabRockies/T3CO. https://doi.org/10.11578/dc.20240806.4.*
157+
158+
159+
## Contact Us
160+
To reach out to the NLR developer team with feedback, feature requests, or to explore partnership opportunities, please email at [T3CO@nlr.gov](mailto:T3CO@nlr.gov)
69161

162+
This tool is developed and maintained by the Commercial Vehicle Technologies (CVT) team in NLR's Center for Integrated Mobility Sciences.

0 commit comments

Comments
 (0)