Skip to content

Commit

Permalink
Merge pull request #419 from NREL/develop
Browse files Browse the repository at this point in the history
v0.47.2
  • Loading branch information
zolanaj authored Jul 5, 2024
2 parents 4bd24d5 + 4ba2d47 commit ac70848
Show file tree
Hide file tree
Showing 8 changed files with 1,410 additions and 120 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ Classify the change according to the following categories:
### Deprecated
### Removed

## v0.47.2
### Fixed
- Increased the big-M bound on maximum net metering benefit to prevent artificially low export benefits.
- Fixed a bug in which tier limits did not load correctly when the number of tiers vary by period in the inputs.
- Set a limit for demand and energy tier maxes to avoid errors returned by HiGHS due to numerical limits.
- Index utility rate demand and energy tier limits on month and/or ratchet in addition to tier. This allows for the inclusion of multi-tiered energy and demand rates in which the rates may vary by month or ratchet, whereas previously only the maximum tier limit was used.
### Added
- Added thermal efficiency as input to chp defaults function.

## v0.47.1
### Fixed
- Type issue with `CoolingLoad` monthly energy input
Expand Down Expand Up @@ -178,7 +187,7 @@ Classify the change according to the following categories:
## v0.37.5
### Fixed
- Fixed AVERT emissions profiles for NOx. Were previously the same as the SO2 profiles. AVERT emissions profiles are currently generated from AVERT v3.2 https://www.epa.gov/avert/download-avert. See REopt User Manual for more information.
- Fix setting of equal demand tiers in scrub_urdb_demand_tiers!, which was previously causing an error.
- Fix setting of equal demand tiers in `scrub_urdb_demand_tiers`, now renamed `scrub_urdb_tiers`.
- When calling REopt.jl from a python environment using PyJulia and PyCall, some urdb_response fields get converted from a list-of-lists to a matrix type, when REopt.jl expects an array type. This fix adds checks on the type for two urdb_response fields and converts them to an array if needed.
- Update the outages dispatch results to align with CHP availability during outages

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "REopt"
uuid = "d36ad4e8-d74a-4f7a-ace1-eaea049febf6"
authors = ["Nick Laws", "Hallie Dunham <[email protected]>", "Bill Becker <[email protected]>", "Bhavesh Rathod <[email protected]>", "Alex Zolan <[email protected]>", "Amanda Farthing <[email protected]>"]
version = "0.47.1"
version = "0.47.2"

[deps]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
Expand Down
16 changes: 8 additions & 8 deletions src/constraints/electric_utility_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function add_export_constraints(m, p; _n="")
@warn "Adding binary variable for net metering choice. Some solvers are slow with binaries."

# Good to bound the benefit - we use max_bene as a lower bound because the benefit is treated as a negative cost
max_bene = sum([ld*rate for (ld,rate) in zip(p.s.electric_load.loads_kw, p.s.electric_tariff.export_rates[:NEM])])*10
max_bene = sum([ld*rate for (ld,rate) in zip(p.s.electric_load.loads_kw, p.s.electric_tariff.export_rates[:NEM])])*p.pwf_e*p.hours_per_time_step*10
NEM_benefit = @variable(m, lower_bound = max_bene)


Expand Down Expand Up @@ -135,7 +135,7 @@ function add_export_constraints(m, p; _n="")
else
binWHL = @variable(m, binary = true)
@warn "Adding binary variable for wholesale export choice. Some solvers are slow with binaries."
max_bene = sum([ld*rate for (ld,rate) in zip(p.s.electric_load.loads_kw, p.s.electric_tariff.export_rates[:WHL])])*10
max_bene = sum([ld*rate for (ld,rate) in zip(p.s.electric_load.loads_kw, p.s.electric_tariff.export_rates[:WHL])])*p.pwf_e*p.hours_per_time_step*100
WHL_benefit = @variable(m, lower_bound = max_bene)

@constraint(m, binNEM + binWHL == 1) # can either NEM or WHL export, not both
Expand Down Expand Up @@ -200,7 +200,7 @@ function add_monthly_peak_constraint(m, p; _n="")
b = m[Symbol(dv)]
# Upper bound on peak electrical power demand by month, tier; if tier is selected (0 o.w.)
@constraint(m, [mth in p.months, tier in 1:ntiers],
m[Symbol("dvPeakDemandMonth"*_n)][mth, tier] <= p.s.electric_tariff.monthly_demand_tier_limits[tier] *
m[Symbol("dvPeakDemandMonth"*_n)][mth, tier] <= p.s.electric_tariff.monthly_demand_tier_limits[mth, tier] *
b[mth, tier]
)

Expand All @@ -209,7 +209,7 @@ function add_monthly_peak_constraint(m, p; _n="")

# One monthly peak electrical power demand tier must be full before next one is active
@constraint(m, [mth in p.months, tier in 2:ntiers],
b[mth, tier] * p.s.electric_tariff.monthly_demand_tier_limits[tier-1] <=
b[mth, tier] * p.s.electric_tariff.monthly_demand_tier_limits[mth, tier-1] <=
m[Symbol("dvPeakDemandMonth"*_n)][mth, tier-1]
)
# TODO implement NewMaxDemandMonthsInTier, which adds mth index to monthly_demand_tier_limits
Expand All @@ -233,7 +233,7 @@ function add_tou_peak_constraint(m, p; _n="")

# Upper bound on peak electrical power demand by tier, by ratchet, if tier is selected (0 o.w.)
@constraint(m, [r in p.ratchets, tier in 1:ntiers],
m[Symbol("dvPeakDemandTOU"*_n)][r, tier] <= p.s.electric_tariff.tou_demand_tier_limits[tier] * b[r, tier]
m[Symbol("dvPeakDemandTOU"*_n)][r, tier] <= p.s.electric_tariff.tou_demand_tier_limits[r, tier] * b[r, tier]
)

# Ratchet peak electrical power ratchet tier ordering
Expand All @@ -243,7 +243,7 @@ function add_tou_peak_constraint(m, p; _n="")

# One ratchet peak electrical power demand tier must be full before next one is active
@constraint(m, [r in p.ratchets, tier in 2:ntiers],
b[r, tier] * p.s.electric_tariff.tou_demand_tier_limits[tier-1]
b[r, tier] * p.s.electric_tariff.tou_demand_tier_limits[r, tier-1]
<= m[Symbol("dvPeakDemandTOU"*_n)][r, tier-1]
)
end
Expand Down Expand Up @@ -299,15 +299,15 @@ function add_energy_tier_constraints(m, p; _n="")
##Constraint (10a): Usage limits by pricing tier, by month
@constraint(m, [mth in p.months, tier in 1:p.s.electric_tariff.n_energy_tiers],
p.hours_per_time_step * sum( m[Symbol("dvGridPurchase"*_n)][ts, tier] for ts in p.s.electric_tariff.time_steps_monthly[mth] )
<= b[mth, tier] * p.s.electric_tariff.energy_tier_limits[tier]
<= b[mth, tier] * p.s.electric_tariff.energy_tier_limits[mth, tier]
)
##Constraint (10b): Ordering of pricing tiers
@constraint(m, [mth in p.months, tier in 2:p.s.electric_tariff.n_energy_tiers],
b[mth, tier] - b[mth, tier-1] <= 0
)
## Constraint (10c): One tier must be full before any usage in next tier
@constraint(m, [mth in p.months, tier in 2:p.s.electric_tariff.n_energy_tiers],
b[mth, tier] * p.s.electric_tariff.energy_tier_limits[tier-1] -
b[mth, tier] * p.s.electric_tariff.energy_tier_limits[mth, tier-1] -
sum( m[Symbol("dvGridPurchase"*_n)][ts, tier-1] for ts in p.s.electric_tariff.time_steps_monthly[mth])
<= 0
)
Expand Down
26 changes: 18 additions & 8 deletions src/core/chp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ function CHP(d::Dict;
boiler_efficiency=eff,
avg_electric_load_kw=avg_electric_load_kw,
max_electric_load_kw=max_electric_load_kw,
is_electric_only=chp.is_electric_only)
is_electric_only=chp.is_electric_only,
thermal_efficiency=chp.thermal_efficiency_full_load)
defaults = chp_defaults_response["default_inputs"]
for (k, v) in custom_chp_inputs
if k in [:installed_cost_per_kw, :tech_sizes_for_cost_curve]
Expand Down Expand Up @@ -336,7 +337,8 @@ end
boiler_efficiency::Union{Float64, Nothing}=nothing,
avg_electric_load_kw::Union{Float64, Nothing}=nothing,
max_electric_load_kw::Union{Float64, Nothing}=nothing,
is_electric_only::Bool=false)
is_electric_only::Bool=false,
thermal_efficiency::Float64=NaN)
Depending on the set of inputs, different sets of outputs are determine in addition to all CHP cost and performance parameter defaults:
1. Inputs: hot_water_or_steam and avg_boiler_fuel_load_mmbtu_per_hour
Expand Down Expand Up @@ -371,7 +373,8 @@ function get_chp_defaults_prime_mover_size_class(;hot_water_or_steam::Union{Stri
boiler_efficiency::Union{Float64, Nothing}=nothing,
avg_electric_load_kw::Union{Float64, Nothing}=nothing,
max_electric_load_kw::Union{Float64, Nothing}=nothing,
is_electric_only::Union{Bool, Nothing}=nothing)
is_electric_only::Union{Bool, Nothing}=nothing,
thermal_efficiency::Float64=NaN)

prime_mover_defaults_all = JSON.parsefile(joinpath(@__DIR__, "..", "..", "data", "chp", "chp_defaults.json"))
avg_boiler_fuel_load_under_recip_over_ct = Dict([("hot_water", 27.0), ("steam", 7.0)]) # [MMBtu/hr] Based on external calcs for size versus production by prime_mover type
Expand Down Expand Up @@ -434,7 +437,7 @@ function get_chp_defaults_prime_mover_size_class(;hot_water_or_steam::Union{Stri
boiler_effic = boiler_efficiency
end
chp_elec_size_heuristic_kw = get_heuristic_chp_size_kw(prime_mover_defaults_all, avg_boiler_fuel_load_mmbtu_per_hour,
prime_mover, size_class_calc, hot_water_or_steam, boiler_effic)
prime_mover, size_class_calc, hot_water_or_steam, boiler_effic, thermal_efficiency)
chp_max_size_kw = 2 * chp_elec_size_heuristic_kw
# If available, calculate heuristic CHP size based on average electric load, and max size based on peak electric load
elseif !isnothing(avg_electric_load_kw) && !isnothing(max_electric_load_kw)
Expand Down Expand Up @@ -482,7 +485,7 @@ function get_chp_defaults_prime_mover_size_class(;hot_water_or_steam::Union{Stri
while !(size_class in size_class_last)
append!(size_class_last, size_class)
chp_elec_size_heuristic_kw = get_heuristic_chp_size_kw(prime_mover_defaults_all, avg_boiler_fuel_load_mmbtu_per_hour,
prime_mover, size_class, hot_water_or_steam, boiler_effic)
prime_mover, size_class, hot_water_or_steam, boiler_effic, thermal_efficiency)
chp_max_size_kw = 2 * chp_elec_size_heuristic_kw
size_class = get_size_class_from_size(chp_elec_size_heuristic_kw, class_bounds, n_classes)
end
Expand Down Expand Up @@ -515,11 +518,18 @@ function get_chp_defaults_prime_mover_size_class(;hot_water_or_steam::Union{Stri
end

function get_heuristic_chp_size_kw(prime_mover_defaults_all, avg_boiler_fuel_load_mmbtu_per_hour,
prime_mover, size_class, hot_water_or_steam, boiler_effic)
therm_effic = prime_mover_defaults_all[prime_mover]["thermal_efficiency_full_load"][hot_water_or_steam][size_class+1]
prime_mover, size_class, hot_water_or_steam, boiler_effic, thermal_efficiency=NaN)
if isnan(thermal_efficiency)
therm_effic = prime_mover_defaults_all[prime_mover]["thermal_efficiency_full_load"][hot_water_or_steam][size_class+1]
else
therm_effic = thermal_efficiency
end
if therm_effic == 0.0
if prime_mover == "micro_turbine" && isnothing(size_class)
size_class = "any"
end
throw(@error("Error trying to calculate heuristic CHP size based on average thermal load because the
thermal efficiency of prime mover $prime_mover for generating $hot_water_or_steam is 0.0"))
thermal efficiency of prime_mover $prime_mover (size_class $size_class) for generating $hot_water_or_steam is 0.0"))
end
elec_effic = prime_mover_defaults_all[prime_mover]["electric_efficiency_full_load"][size_class+1]
avg_heating_thermal_load_mmbtu_per_hr = avg_boiler_fuel_load_mmbtu_per_hour * boiler_effic
Expand Down
16 changes: 8 additions & 8 deletions src/core/electric_tariff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
"""
struct ElectricTariff
energy_rates::AbstractArray{Float64, 2} # gets a second dim with tiers
energy_tier_limits::AbstractArray{Float64,1}
energy_tier_limits::AbstractArray{Float64,2} # month X tier
n_energy_tiers::Int

monthly_demand_rates::AbstractArray{Float64, 2} # gets a second dim with tiers
time_steps_monthly::AbstractArray{AbstractArray{Int64,1},1} # length = 0 or 12
monthly_demand_tier_limits::AbstractArray{Float64,1}
monthly_demand_tier_limits::AbstractArray{Float64,2} # month X tier
n_monthly_demand_tiers::Int

tou_demand_rates::AbstractArray{Float64, 2} # gets a second dim with tiers
tou_demand_ratchet_time_steps::AbstractArray{AbstractArray{Int64,1},1} # length = n_tou_demand_ratchets
tou_demand_tier_limits::AbstractArray{Float64,1}
tou_demand_tier_limits::AbstractArray{Float64,2} # ratchet X tier
n_tou_demand_tiers::Int

demand_lookback_months::AbstractArray{Int,1}
Expand All @@ -42,7 +42,7 @@ end
`ElectricTariff` is a required REopt input for on-grid scenarios only (it cannot be supplied when `Settings.off_grid_flag` is true) with the following keys and default values:
```julia
urdb_label::String="",
urdb_response::Dict=Dict(),
urdb_response::Dict=Dict(), # Response JSON for URDB rates. Note: if creating your own urdb_response, ensure periods are zero-indexed.
urdb_utility_name::String="",
urdb_rate_name::String="",
wholesale_rate::T1=nothing, # Price of electricity sold back to the grid in absence of net metering. Can be a scalar value, which applies for all-time, or an array with time-sensitive values. If an array is input then it must have a length of 8760, 17520, or 35040. The inputed array values are up/down-sampled using mean values to match the Settings.time_steps_per_hour.
Expand Down Expand Up @@ -120,11 +120,11 @@ function ElectricTariff(;
# TODO remove_tiers for multinode models
nem_rate = Float64[]

energy_tier_limits = Float64[]
energy_tier_limits = Array{Float64,2}(undef, 0, 0)
n_energy_tiers = 1
monthly_demand_tier_limits = Float64[]
monthly_demand_tier_limits = Array{Float64,2}(undef, 0, 0)
n_monthly_demand_tiers = 1
tou_demand_tier_limits = Float64[]
tou_demand_tier_limits = Array{Float64,2}(undef, 0, 0)
n_tou_demand_tiers = 1
time_steps_monthly = get_monthly_time_steps(year, time_steps_per_hour=time_steps_per_hour)

Expand Down Expand Up @@ -241,7 +241,7 @@ function ElectricTariff(;
if remove_tiers
energy_rates, monthly_demand_rates, tou_demand_rates = remove_tiers_from_urdb_rate(u)
energy_tier_limits, monthly_demand_tier_limits, tou_demand_tier_limits =
Float64[], Float64[], Float64[]
Array{Float64,2}(undef, 0, 0), Array{Float64,2}(undef, 0, 0), Array{Float64,2}(undef, 0, 0)
n_energy_tiers, n_monthly_demand_tiers, n_tou_demand_tiers = 1, 1, 1
end

Expand Down
Loading

2 comments on commit ac70848

@zolanaj
Copy link
Collaborator Author

@zolanaj zolanaj commented on ac70848 Jul 5, 2024

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/110534

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.47.2 -m "<description of version>" ac70848afca324c1e8c03f3c4a9f22482aa7e2a1
git push origin v0.47.2

Please sign in to comment.