Skip to content

Reorganize emissions info #121 - #136

Open
urwahah wants to merge 3 commits into
developmentfrom
reorganize-emissions-info-#121
Open

Reorganize emissions info #121#136
urwahah wants to merge 3 commits into
developmentfrom
reorganize-emissions-info-#121

Conversation

@urwahah

@urwahah urwahah commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Fuel switching (and maybe load shifting later on) requires the grid emissions data to be available for loads to site energy calculations. This is a fairly significant revision to the architecture of energy.py so it would be better to review and implement this before I start changing the calculations :-)

To summarize the changes:
Currently:

  1. run_loads_to_site calls loads_to_site_energy, which iterates through the equipment scenarios, and saves the site energy results as a temporary file
  2. run_site_to_source passes those results to site_to_source, which iterates through the emissions scenarios for final source emissions

Proposed:

  1. run_loads_to_site calls loads_to_site_energy
    a. loads_to_site_energy calls grid_emissions, which iterates through the emissions scenarios to return a dataframe containing grid emissions data
    b. loads_to_site_energy iterates over both emissions and equipment scenarios (nested) to calculate site energy
  2. run_site_to_source passes the site energy results file (same as before) to site_to_source, which iterates through the emissions scenarios for final source emissions

@urwahah
urwahah requested a review from t-kramer July 10, 2026 05:20
Comment thread src/energy.py
results.append(df)

total_emissions_kg = sum(r[Col.TOTAL_EMISSIONS_KG_CO2E.value].sum() for r in results)
total_emissions_kg = df[Col.TOTAL_EMISSIONS_KG_CO2E.value].sum()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated but i changed this because it was doing a cumulative sum of all emissions scenarios which didn't seem helpful to me. now it outputs the total emissions for each scenario - still summed up for all equipment scenarios, but better for a high level check i suppose

@urwahah urwahah added the CALNext In scope of CALNext project label Jul 24, 2026
@urwahah urwahah added this to the 02 | Capability expansion milestone Jul 24, 2026
@t-kramer

t-kramer commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

@urwahah Thanks for putting in all this work.

One thing I wanted to flag before this gets built on: the nested loop means site_energy.pkl grows from N_equipment × 8760 rows to N_equipment × N_emissions × 8760. So with 3 equipment × 3 emission scenarios that's already 9× more data and 9× more simulation runs, right? And it would be more with additional scenarios.

So please remind me: What was the reason we need the emissions data in the loop? Since sizing in the current code is driven purely by peak thermal loads (e.g. df["hhw_W"].max()), is the plan for fuel switching to affect sizing at all, or will it be a purely operational decision (i.e. which fuel to use at each hour)? If it's the latter, the fuel-switching logic could potentially stay in site_to_source() and avoid the data explosion entirely. We could just add some extra input columns (e.g. "potential gas" and "potential electric" per hour). Equipment simulation stays at N_equipment runs.

I might not be thinking this through properly here, so feel to explain again. Maybe even if we need the loop, there's an alternative way to reduce the "data explosion".

@urwahah

urwahah commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

the nested loop is definitely the issue with this change. i like the idea that we could avoid the extra runs by passing new 'potential' gas and electricity input columns to site_to_source. i don't think fuel switching should affect the AWHP sizing? but it might affect the boiler sizing, which is currently irrelevant to the calculations but i think in the future we want to report total area and peak electric demand. to solve that we could move the boiler sizing to site_to_source as well, since it's not needed for any further calculations in loads_to_site.

however, thinking ahead to load shifting, this will come up again if we want to include AWHP sizing strategies that are dependent on peak day emissions. we should discuss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CALNext In scope of CALNext project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants