Skip to main content

eflips-impact

eflips-impact is part of the eFLIPS tool family for electric bus fleet simulation. It provides two impact analysis modules operating on eFLIPS simulation results:

  • TCO — Total Cost of Ownership, including capital expenditure (vehicles, batteries, charging infrastructure) and operational expenditure (energy, staff, maintenance, insurance, taxes).
  • LCA — Life Cycle Assessment of greenhouse gas emissions (GWP, kg CO₂-eq), following ISO 14040/14044. Functional unit: revenue-kilometre (Nutzwagenkilometer).

Both modules read simulation data from an eFLIPS database and accept scenario parameters from JSON configuration files.


Installation

From PyPI

pip install eflips-impact

From source

git clone https://github.com/mpm-tu-berlin/eflips-impact.git
cd eflips-impact
pip install .

For development (includes linting, type checking, and docs tools):

pip install -e ".[dev]"

Python version: 3.10 – 3.13.


Quick start

Two example scripts under bin/ demonstrate the full pipeline end-to-end.

TCO example

python bin/example_tco.py

Runs the following steps:

  1. Initialises fleet topology (battery types, charging point types) from fleet.json.
  2. Writes TCO parameters to the database from tco.json.
  3. Calculates TCO and prints a per-category cost table (EUR / revenue-km).
  4. Saves a stacked bar chart to tco_by_type.png.

LCA example

python bin/example_lca.py

Runs the following steps:

  1. Initialises fleet topology from fleet.json.
  2. Writes LCA parameters to the database from lca.json and lca_overrides.json.
  3. Calculates LCA and prints GWP results by lifecycle scope and component type.
  4. Saves charts to lca_by_scope.png and lca_by_type.png.

Before running, set the DATABASE_URL variable at the top of each script (or via the DATABASE_URL environment variable) to point to a populated eFLIPS simulation database.


Input data

eflips-impact requires two types of input:

1. eFLIPS simulation data

A PostgreSQL database produced by an eFLIPS simulation run, containing VehicleType, Trip, Route, Event, Area, Station, and related tables. The database URL is passed to all entry-point functions via database_url or the DATABASE_URL environment variable.

2. JSON parameter files

Scenario-specific parameters are supplied through four JSON files. Example files for all four are provided under eflips/impact/defaults/example/:

File Purpose
fleet.json Defines battery types (chemistry, specific mass) and charging point types; assigns them to vehicle types, depot areas, and opportunity charging stations. Read by complete_fleet(), which must be called before init_tco_params() and init_lca_params().
tco.json Provides TCO parameters: procurement costs, useful life, energy prices, staff costs, maintenance rates, financial assumptions, and fleet availability factor (eta_avail). See TCO.md for a full field description.
lca.json Raw openLCA matrix export used as the LCA background data source. See LCA.md for a full field description.
lca_overrides.json Per-vehicle-type overrides for LCA inputs (motor power, energy consumption) and the analysis year. See LCA.md for a full field description.

Copy and adapt the example files to your scenario. The matching between JSON entries and database rows uses string keys (name_short for vehicle types, type for charging infrastructure) — never database-assigned integer IDs.


Calculation workflow

eFLIPS simulation DB
        │
        ▼
  complete_fleet()                        ← fleet.json
  (creates BatteryType /
   ChargingPointType rows)
        │
        ├─────────────────────────────────────────┐
        │                                         │
        ▼                                         ▼
  init_tco_params()  ← tco.json     init_lca_params()  ← lca.json
  (writes tco_parameters                (writes lca_parameters          + lca_overrides.json
   to DB entities)                       to DB entities)
        │                                         │
        ▼                                         ▼
  calculate_tco()                       calculate_lca()
        │                                         │
        ▼                                         ▼
   TCOResult                              LCAResult

complete_fleet() must be called once before the parameter-init functions. The two parameter-init steps (init_tco_params, init_lca_params) and the two calculation steps are independent and can be run separately.

Public API

from eflips.impact.utils import complete_fleet
from eflips.impact.tco import init_tco_params, calculate_tco
from eflips.impact.lca import init_lca_params, calculate_lca

# 1. Fleet topology
complete_fleet(scenario=1, json_path="fleet.json", delete_existing_data=True, database_url=DATABASE_URL)

# 2a. TCO parameters
init_tco_params(scenario=1, json_path="tco.json", database_url=DATABASE_URL)

# 2b. LCA parameters
init_lca_params(scenario=1, lca_json_path="lca.json", overrides_json_path="lca_overrides.json",
                database_url=DATABASE_URL)

# 3. Calculate
tco_result = calculate_tco(scenario=1, database_url=DATABASE_URL)
lca_result = calculate_lca(scenario=1, database_url=DATABASE_URL)

# 4. Results
print(tco_result.tco_per_revenue_km)  # EUR / revenue-km
print(lca_result.total_per_revenue_km.gwp)  # kg CO₂-eq / revenue-km

# 5. Plots
tco_result.plot(use_revenue_km=True, save_path="tco.png")
lca_result.plot_by_scope(save_path="lca_scope.png")
lca_result.plot_by_type(save_path="lca_type.png")

Development

# Format
black eflips/

# Type check
mypy eflips --explicit-package-bases --strict

# Tests
pytest

License

See LICENSE.

Metadata

Release files for eflips-impact 2.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eflips-impact 2.1.1
File Size Uploaded Provenance Actions
eflips_impact-2.1.1.tar.gz 60.4 kB With provenance Details for eflips_impact-2.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for eflips-impact 2.1.1
File Interpreter ABI Platform Actions
eflips_impact-2.1.1-py3-none-any.whl Python 3 none any Details for eflips_impact-2.1.1-py3-none-any.whl

Total release size: 128.3 kB

Release files / eflips_impact-2.1.1.tar.gz

Download URL eflips_impact-2.1.1.tar.gz
Size 60.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6dbdfa86a29a26083ecae281a60d5272aeed578c113c00f85728762916f1bca2
BLAKE2b-256 checksum
How to use checksums
6f4f6f713b2940ce03f4eb7c6900f962866c8f61ccfb7fc7333d7fc4849585ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / eflips_impact-2.1.1-py3-none-any.whl

Download URL eflips_impact-2.1.1-py3-none-any.whl
Size 67.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc0e0d1fefcbb7cce331306130d668914d89c6dc19363c6b35892d966928bdb6
BLAKE2b-256 checksum
How to use checksums
9aa184a71391ef521c684723c095c9edd7940e2fb48aabebb6b7a8b5e8bdb523
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for eflips-impact 2.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for eflips_impact-2.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page