Support explicit product-modelling and add examples#186
Open
TimoDiepers wants to merge 36 commits into
Open
Conversation
Extends the standalone EV example from a single vehicle to a fleet over time. A simple stock-driven dynamic MFA with a Weibull lifetime is built with flodym, and its inflow / stock / outflow time series are converted to bw_temporalis TemporalDistributions on the fleet-level production, use-phase and end-of-life exchanges. TimexLCA then produces a time-explicit inventory and dynamic LCIA score for the whole fleet.
Runs the notebook end-to-end and embeds the rendered figures (Weibull lifetime, fleet stock/flows, fleet TDs, dynamic characterized inventory) and printed scores so the results are visible without re-running.
… GWP Walks fleet_driving's exchanges to compute first-level static (2020) and prospective (2040) per-background-activity scores, then renders a stacked waterfall using bw_timex.utils.plot_characterized_inventory_as_waterfall.
Extends the fleet EV example to a cascading product system: an EV pack stock drives a stationary 2nd-life stock (Weibull lifetime, fed by alpha(t) of EV outflow) which together with the direct EV recycling stream feeds a recovered-material flow (multiplied by eta(t)). Both flows are coupled in flodym and converted to TemporalDistributions on a closed-loop foreground that includes a negative virgin-battery substitution credit. Compares a linear baseline against a cascade scenario end-to-end with TimexLCA. https://claude.ai/code/session_01WTPSHSoXjX9hU1vrRir2Rv
Moves eta(t) off the cascade-edge amount and onto the recycling_credit edge as temporal_evolution_factors, separating logistics timing (TD) from efficiency parameter. Adds the same machinery for an EV electricity efficiency improvement on the driving electricity edge of both scenarios. Adds a policy-lever sweep that reruns the cascade with eta frozen at 50% and at 95% to expose the value of foreground evolution as a one-line scenario knob, and extends the cumulative-emissions comparison plot to all four scenarios. https://claude.ai/code/session_01WTPSHSoXjX9hU1vrRir2Rv
…actors-for-ev-efficiencies
…c-ev-electricity-consumption-modelin
…c-ev-electricity-consumption-modelin-zhcnor
…c-ev-electricity-consumption-modelin-nn5y1c
Restructures the fleet-level model so the cohort year is propagated as
the consumer date of every exchange below fleet_driving, which is what
makes vintage-locked temporal_evolution_factors meaningful in an
aggregate (non-cohort-resolved) foreground.
Key changes:
- Add fleet_service intermediary node; FU is now {fleet_service: 1}.
- Move the cohort distribution onto fleet_service -> fleet_driving as
a calendar-year TD. Each cohort year now gets its own consumer-side
instance of fleet_driving.
- Replace stock-weighted use TD and outflow-weighted EOL TD with
age-relative TDs on fleet_driving's exchanges (Weibull SF for use,
Weibull PDF for retirement). The convolution with the cohort TD
reproduces the aggregate fleet stock and retirement series.
- Drop ages with zero PDF/SF weight; bw_timex's abs_td propagation
keeps zero-weight entries through the chain otherwise, which leaves
unregistered foreground instances downstream.
- Replace MILEAGE (lifetime) with ANNUAL_MILEAGE; lifetime electricity
per vehicle is built additively from survival x annual mileage.
- Consolidate the two conflicting temporal_evolution_factors cells
into one vintage-locked example with reference="consumer".
- Update waterfall scoring to apply the cohort_multiplier from the
fleet_service edge.
- Update markdown to explain the cohort + age TD layering and the
consumer/producer reference semantics it unlocks.
https://claude.ai/code/session_01U3Bvp3a9BQSDMJAXL75QQg
Inserts a new "Isolating the effect of foreground vintage learning" section after the headline waterfall plot. It re-runs the time-explicit LCA with the temporal_evolution_factors temporarily stripped from the electricity exchange and prints a clean four-line decomposition: static (2020) -> time-explicit no-evo -> time-explicit with vintage -> prospective (2040) The vintage modifier shows up as a -4.3% effect on top of the much larger background-decarbonization effect. The accompanying figure has two panels: a cumulative-emissions plot (with vs without vintage learning, with the savings shaded between) and a per-activity contribution bar chart that confirms only the electricity bar moves. The factors are restored to the exchange after the comparison so any downstream rerun of `tlca` stays consistent. https://claude.ai/code/session_01U3Bvp3a9BQSDMJAXL75QQg
Captures the analysis behind extending bw_timex to handle Brightway's explicit process/product paradigm (in addition to today's chimaera processwithreferenceproduct default). Lives under docs/content/dev/ so it's tracked alongside the codebase but not auto-rendered in user docs. Contents: - motivation (cohort TD has a natural home on a process->product output edge, removing the structural fleet_service intermediary) - empirical findings on what breaks today: bw_graph_tools np.in1d on NumPy 2, bipartite-walk failure in the traversal, KeyError in prepare_bw_timex_inputs - theoretical math for cohort TD on output edge - four-phase implementation plan with file/line specifics, ordered shallow -> deep, each phase independently testable - known footgun (silent ignore of TDs on chimaera production self-loops) and proposed fix - open design questions: multi-producer resolution, co-products, TD type constraints, backward compatibility - effort estimate: ~1-2 weeks of focused work https://claude.ai/code/session_01U3Bvp3a9BQSDMJAXL75QQg
…explicit_process_product_paradigm
…el-with-vintage-tracking-rezcrp
…-Nfpcu Refactor fleet EV notebook to cohort + age-relative TD pattern
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #186 +/- ##
==========================================
- Coverage 74.36% 74.30% -0.07%
==========================================
Files 10 10
Lines 1697 1786 +89
==========================================
+ Hits 1262 1327 +65
- Misses 435 459 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…skeleton) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
When an output-side temporal distribution produces multiple install-year cohorts of the same process, prepare_bw_timex_inputs collapsed indexed_demand to a single time-mapped producer (the last cohort, via create_demand_timing's last-write-wins). All demand then routed through that one cohort, so its temporal market shares dominated the LCA result regardless of how many vintages the timeline actually expressed. Build indexed_demand directly from the timeline's FU rows so each cohort receives its share of the user's demand. This routes each cohort's inputs to the appropriate background database (matrix_modifier already keyed temporal markets by time_mapped_producer) and lets temporal_evolution_factors apply per cohort. Adjusts a prior assertion in test_explicit_product_output_td_convolves_with_input_td that was encoding the bug (single-cohort collapse) rather than the documented behavior; the corrected expected score is the cohort-weighted COP contribution. Adds test_multi_vintage_demand_splits_across_cohorts as a regression case with two background databases at distinct dates. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
# Conflicts: # bw_timex/timex_lca.py # pyproject.toml # uv.lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.