Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Grid Renewable Energy Fraction #426

Open
wants to merge 107 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
0d4a787
Add API call for renewable energy fraction
pypapus Jul 30, 2024
71acc5e
Fixed cambium API call
pypapus Jul 31, 2024
eca3f12
Clean energy fraction added to scenarios
pypapus Aug 1, 2024
80d1d3e
Include profile of grid clean energy contribution in kW
pypapus Aug 1, 2024
c095d48
Updated help text and added checks for user-provided values
pypapus Aug 2, 2024
b67ff48
Corrected off-grid flag in scenario.jl
pypapus Aug 2, 2024
9a8f09f
Edited to remove cef calculation using BAU electric load
pypapus Aug 12, 2024
379eeab
Added new "cef_constraints" to calculate clean energy fraction of the…
pypapus Aug 12, 2024
26f5cec
Added cef (kWh) from the grid in accounting for renewable energy perc…
pypapus Aug 12, 2024
4cce89e
Added new function to calculate the clean_energy_fraction (kWh) grid …
pypapus Aug 12, 2024
6500b40
Added new input to include grid cef (kWh) in renewable energy percent…
pypapus Aug 12, 2024
98d22b5
Updated function adds grid clean energy kWh serving the load to results
pypapus Aug 12, 2024
c3c4d90
Merge branch 'develop' into gridRE-dev
adfarth Aug 12, 2024
e3b0300
removed "hours_per_time_step" to use model time step.
pypapus Aug 15, 2024
248481b
Added "annual_clean_grid_to_load_kwh" in results
pypapus Aug 15, 2024
1d77ec8
Merge branch 'gridRE-dev' of https://github.com/NREL/REopt.jl into gr…
pypapus Aug 15, 2024
fbf7691
Combined cambium_emissions_profile() and cambium_clean_energy_fractio…
pypapus Aug 16, 2024
29518dc
Update electric_utility.jl
adfarth Sep 10, 2024
132f982
Merge branch 'develop' into gridRE-dev
adfarth Nov 4, 2024
3a4bafd
spelling
adfarth Nov 5, 2024
8a34550
Merge branch 'develop' into gridRE-dev
adfarth Nov 12, 2024
dec6733
change cambium_metric_col to cambium_co2_metric
adfarth Nov 12, 2024
3916ba8
Change **cambium_emissions_region** to **cambium_region** and clean u…
adfarth Nov 12, 2024
37de923
Update electric_utility.jl
adfarth Nov 13, 2024
ff29a78
emissions_profile to profile_data
adfarth Nov 13, 2024
cee8176
reorganize constraints
adfarth Nov 13, 2024
8571808
minor edits
adfarth Nov 13, 2024
60cdeae
simplify constraints
adfarth Nov 14, 2024
7596768
Update renewable_energy_constraints.jl
adfarth Nov 14, 2024
434f928
Update site.jl
adfarth Nov 14, 2024
3b7a93a
update outputs
adfarth Nov 14, 2024
f2bb448
add outputs
adfarth Nov 14, 2024
a058fed
fix to align_profile_with_load_year
adfarth Nov 14, 2024
c2353fb
fixes to calcs
adfarth Nov 15, 2024
42be276
Update financial.jl
adfarth Nov 15, 2024
b9b1509
Update runtests.jl
adfarth Nov 15, 2024
82aaba4
add a test
adfarth Nov 15, 2024
394ffc8
Update CHANGELOG.md
adfarth Nov 15, 2024
bf72ef7
avoid annual grid RE if mpc
adfarth Nov 15, 2024
b57f878
Update runtests.jl
adfarth Nov 19, 2024
f333311
address failing tests
adfarth Nov 19, 2024
f2b2871
Update runtests.jl
adfarth Nov 20, 2024
c357ddf
change variable name
adfarth Nov 21, 2024
a26e268
conditionally show warning
adfarth Nov 26, 2024
b8a93c2
add soc_init_fraction
adfarth Nov 26, 2024
f09fe6e
small updates
adfarth Nov 26, 2024
9a4dd25
add a PV inputs check
adfarth Nov 26, 2024
9491bb9
fix test
adfarth Nov 26, 2024
5f6def7
fix to prod factor check
adfarth Dec 2, 2024
deeb15f
add description to outage_durations
adfarth Dec 6, 2024
b9aadb1
initial commit
adfarth Dec 6, 2024
c29810a
update help text
adfarth Dec 6, 2024
239d8f2
update runtests
adfarth Dec 11, 2024
4b27408
update cambium inputs and tests
adfarth Dec 12, 2024
20f3cff
Update chp_payback.json
adfarth Dec 12, 2024
b228777
Update EMISSIONS_DECREASE_DEFAULTS
adfarth Dec 12, 2024
a0c0b77
change output names to stay below 63 chars
adfarth Dec 12, 2024
df4e6f0
Merge branch 'develop' into gridRE-dev
adfarth Dec 12, 2024
9785939
Update CHANGELOG.md
hdunham Dec 13, 2024
92d067b
update changelog/comment
hdunham Dec 13, 2024
599e2e4
update notes about considerations when battery can export to grid in …
hdunham Dec 13, 2024
d1e9ff7
use REopt.KWH_PER_MMBTU in tests
hdunham Dec 13, 2024
52b3c0f
minor comment updates
hdunham Dec 13, 2024
f022754
clarify test "Renewable Energy from Grid"
hdunham Dec 13, 2024
c4d7871
typo
hdunham Dec 13, 2024
8ec5069
group renewable_energy_fraction_series with similar inputs in Electri…
hdunham Dec 13, 2024
08b0ecb
add to error msg
hdunham Dec 13, 2024
9c8b6a5
util function error_if_series_vals_not_0_to_1
hdunham Dec 13, 2024
bd1676e
Update runtests.jl
adfarth Dec 16, 2024
818bedd
add to dictkeys_tosymbols
adfarth Dec 16, 2024
74a3c4b
fix Degredation docstring
hdunham Dec 16, 2024
156d035
Merge branch 'gridRE-dev' of https://github.com/NREL/REopt.jl into gr…
hdunham Dec 16, 2024
5fc1160
fix make sub hr time step export rates work
hdunham Dec 17, 2024
e90f270
Update CHANGELOG.md
hdunham Dec 17, 2024
360427b
update manifest
hdunham Dec 17, 2024
55ef6fc
Merge branch 'develop' into gridRE-dev
adfarth Dec 18, 2024
c372337
Revert "Merge branch 'develop' into gridRE-dev"
adfarth Dec 18, 2024
be5695c
Merge branch 'develop' into avert-update
adfarth Dec 18, 2024
bdb9a45
Revert "update manifest"
adfarth Dec 18, 2024
699abdd
use == to test string
hdunham Dec 18, 2024
7bde370
Merge branch 'develop' into gridRE-dev
hdunham Dec 20, 2024
8d6fcc6
resolve env with 1.8.3
hdunham Dec 20, 2024
5610a11
update manifest to julia 1.11
hdunham Dec 23, 2024
a6bd8b5
simplify compat
hdunham Dec 23, 2024
f7a2d28
update authors
hdunham Dec 23, 2024
37d32e1
typo
hdunham Dec 23, 2024
cc70963
Merge branch 'develop' into gridRE-dev
adfarth Jan 6, 2025
c51e442
Merge branch 'develop' into avert-update
adfarth Jan 6, 2025
b94a25e
Update CHANGELOG.md
adfarth Jan 6, 2025
210ec72
rm inaccurate note in docstring
hdunham Jan 8, 2025
77abfc0
fix typo
hdunham Jan 13, 2025
6a922dc
clarify comment
hdunham Jan 13, 2025
4836ea3
update comment
hdunham Jan 13, 2025
5745957
Merge branch 'develop' into avert-update
adfarth Jan 13, 2025
e812def
Merge branch 'avert-update' of https://github.com/NREL/REopt.jl into …
adfarth Jan 13, 2025
c9c1aaa
Merge branch 'develop' into gridRE-dev
adfarth Jan 13, 2025
3dcbc13
Merge branch 'avert-update' into gridRE-dev
adfarth Jan 23, 2025
7b161a7
function name update
adfarth Jan 23, 2025
3c0004b
Update CHANGELOG.md
adfarth Jan 23, 2025
a399b08
Merge branch 'develop' into gridRE-dev
adfarth Jan 23, 2025
4b60d68
Update runtests.jl
adfarth Jan 23, 2025
06e4366
remove TODO
adfarth Jan 23, 2025
0653de3
fix merge issues, simplify results code
adfarth Jan 24, 2025
0f3173f
Update Project.toml
adfarth Jan 30, 2025
2ba6c06
Merge branch 'develop' into gridRE-dev
adfarth Jan 30, 2025
3458e38
update julia version in workflows
adfarth Jan 30, 2025
a30e347
Update Manifest.toml
adfarth Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reorganize constraints
adfarth committed Nov 13, 2024
commit cee81765ebcb1af3b7f539cd00f6a607cd626509
1 change: 0 additions & 1 deletion src/REopt.jl
Original file line number Diff line number Diff line change
@@ -162,7 +162,6 @@ include("constraints/ghp_constraints.jl")
include("constraints/steam_turbine_constraints.jl")
include("constraints/renewable_energy_constraints.jl")
include("constraints/emissions_constraints.jl")
include("constraints/cef_constraints.jl")

include("mpc/structs.jl")
include("mpc/scenario.jl")
59 changes: 0 additions & 59 deletions src/constraints/cef_constraints.jl

This file was deleted.

57 changes: 56 additions & 1 deletion src/constraints/renewable_energy_constraints.jl
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ function add_re_elec_calcs(m,p)
calc_clean_grid_kWh(m, p)

m[:AnnualREEleckWh] = @expression(m, p.hours_per_time_step * (
(p.s.electric_utility.include_grid_clean_energy_in_re ?
(p.s.electric_utility.include_grid_clean_energy_in_total ?
sum(m[:grid_clean_energy_series_kw][ts] for ts in p.time_steps) : 0) + # Include grid clean energy fraction conditionally
+ # Clean energy fraction of grid electricity to load and battery
sum(p.production_factor[t,ts] * p.levelization_factor[t] * m[:dvRatedProduction][t,ts] *
@@ -88,4 +88,59 @@ function add_re_elec_calcs(m,p)
)
)
nothing
end

"""
calc_clean_grid_kWh(m, p)

This function calculates the clean energy fraction of the electricity from the electric utility
by multiplying the electricity from the grid used to charge the batteries and the electricity from the grid directly serving the load
by the clean energy fraction series.

Returns:
- clean_energy_fraction: The clean energy fraction of the grid electricity.
"""
function calc_clean_grid_kWh(m, p)
# Calculate the grid electricity used to charge the batteries and directly serve the load
m[:CleanGridToLoad], m[:CleanGridToBatt] = calc_grid_to_load(m, p)

# Calculate the clean energy fraction from the electric utility
m[:grid_clean_energy_series_kw] = @expression(m, [
ts in p.time_steps], (m[:CleanGridToLoad][ts] + m[:CleanGridToBatt][ts]) * p.s.electric_utility.clean_energy_fraction_series[ts]
)
end


"""
calc_grid_to_load(m, p)

This function calculates, for each timestep:
1. The electricity from the grid used to charge the batteries, accounting for battery losses.
2. The electricity from the grid directly serving the load.

Returns:
- CleanGridToLoad: The electricity from the grid directly serving the load.
- CleanGridToBatt: The electricity from the grid used to charge the batteries, accounting for losses.
"""

function calc_grid_to_load(m, p)
if !isempty(p.s.storage.types.elec)
# Calculate the grid to load through the battery, accounting for the battery losses
m[:CleanGridToBatt] = @expression(m, [
ts in p.time_steps], sum(
m[:dvGridToStorage][b, ts] * p.s.storage.attr[b].charge_efficiency * p.s.storage.attr[b].discharge_efficiency
for b in p.s.storage.types.elec)
)
else
m[:CleanGridToBatt] = zeros(length(p.time_steps))
end

# Calculate the grid serving load not through the battery
m[:CleanGridToLoad] = @expression(m, [
ts in p.time_steps], (
sum(m[:dvGridPurchase][ts, tier] for tier in 1:p.s.electric_tariff.n_energy_tiers) -
sum(m[:dvGridToStorage][b, ts] for b in p.s.storage.types.elec)
))

return m[:CleanGridToLoad], m[:CleanGridToBatt]
end
14 changes: 7 additions & 7 deletions src/core/electric_utility.jl
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@
### Grid Clean Energy Fraction Inputs ###
cambium_cef_metric::String = "cef_load", # Options = ["cef_load", "cef_gen"] # cef_load is the fraction of generation that is clean, for the generation that is allocated to a region’s end-use load; cef_gen is the fraction of generation that is clean within a region
clean_energy_fraction_series::Union{Real,Array{<:Real,1}} = Float64[], # Utilities renewable energy fraction. Can be scalar or timeseries (aligned with time_steps_per_hour).
include_grid_clean_energy_in_re::Bool=true, # if true, the clean energy fraction of the grid electricity is included in the site's renewable electricity calculations
include_grid_clean_energy_in_total::Bool=true, # if true, the clean energy fraction of the grid electricity is included in the site's total renewable electricity calculations
```

!!! note "Outage modeling"
@@ -140,7 +140,7 @@ struct ElectricUtility
net_metering_limit_kw::Real
interconnection_limit_kw::Real
clean_energy_fraction_series::Array{<:Real,1} # Utility renewable energy fraction.
include_grid_clean_energy_in_re::Bool
include_grid_clean_energy_in_total::Bool

function ElectricUtility(;

@@ -198,7 +198,7 @@ struct ElectricUtility
### Grid Clean Energy Fraction Inputs ###
cambium_cef_metric::String = "cef_load", # Options = ["cef_load", "cef_gen"] # cef_load is the fraction of generation that is clean, for the generation that is allocated to a region’s end-use load; cef_gen is the fraction of generation that is clean within a region
clean_energy_fraction_series::Union{Real,Array{<:Real,1}} = Float64[], # Utilities renewable energy fraction. Can be scalar or timeseries (aligned with time_steps_per_hour).
include_grid_clean_energy_in_re::Bool=true # if true, the clean energy fraction of the grid electricity is included in the site's renewable electricity calculations
include_grid_clean_energy_in_total::Bool=true # if true, the clean energy fraction of the grid electricity is included in the site's renewable electricity calculations
)

is_MPC = isnothing(latitude) || isnothing(longitude)
@@ -371,7 +371,7 @@ struct ElectricUtility
net_metering_limit_kw,
interconnection_limit_kw,
is_MPC ? Float64[] : emissions_and_cef_series_dict["clean_energy_fraction_series"],
include_grid_clean_energy_in_re
include_grid_clean_energy_in_total
)
end
end
@@ -559,11 +559,11 @@ end
profile_year::Int=2017,
grid_level::String)

This function constructs an API request to the Cambium database to retrieve either emissions data or clean energy fraction data depending on the `metric_col` provided.
This function gets levelized grid CO2 or CO2e emission rate profiles (1-year time series) from the Cambium dataset.
This function constructs an API request to the Cambium database to retrieve either emissions data or clean energy fraction data depending on the `metric_col` provided.
The data will be averaged on an hourly basis over the "lifetime" provided.
The returned profiles are adjusted for day of week alignment with the provided "load_year" (Cambium profiles always start on a Sunday.)

This function is also used for the /cambium_profile endpoint in the REopt API, in particular for the webtool to display grid emissions defaults before running REopt.
This function is also used for the /cambium_profile endpoint in the REopt API, in particular for the webtool to display grid emissions data.

"""
function cambium_profile(; scenario::String,