Skip to content

Commit

Permalink
Merge pull request #337 from NREL/develop
Browse files Browse the repository at this point in the history
Add ElectricHeater Technology
  • Loading branch information
Bill-Becker authored Dec 9, 2023
2 parents 9fe47eb + 99ab3a3 commit 8c9f19b
Show file tree
Hide file tree
Showing 26 changed files with 356 additions and 158 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

16 changes: 1 addition & 15 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,4 @@ jobs:
- uses: julia-actions/julia-buildpkg@latest
# - uses: mxschmitt/action-tmate@v3 # for interactive debugging
- run: julia --project=. -e 'using Pkg; Pkg.activate("test"); Pkg.rm("Xpress"); Pkg.activate("."); using TestEnv; TestEnv.activate(); cd("test"); include("runtests.jl")'
shell: bash

xpresstests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Decrypt
env:
TRANSCRYPT_PASSWORD: ${{ secrets.TRANSCRYPT_PASSWORD }}
run: ./.github/scripts/decrypt.sh
- name: Build containers
run: docker-compose up -d
- name: Execute tests in container
run: docker exec jul julia --project=. -e 'import Pkg; Pkg.test("REopt"; test_args=["Xpress"])'
shell: bash
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Classify the change according to the following categories:
### Deprecated
### Removed

## v0.39.0
### Added
- Added new technology `ElectricHeater` which uses electricity as input and provides heating as output; load balancing constraints have been updated accordingly

## v0.38.2
### Added
- Added the following BAU outputs: lifecycle_chp_standby_cost_after_tax, lifecycle_elecbill_after_tax, lifecycle_production_incentive_after_tax, lifecycle_outage_cost, lifecycle_MG_upgrade_and_fuel_cost
Expand Down
25 changes: 0 additions & 25 deletions Dockerfile

This file was deleted.

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.38.2"
version = "0.39.0"

[deps]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
Expand Down
8 changes: 8 additions & 0 deletions data/electric_heater/electric_heater_defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"installed_cost_per_mmbtu_per_hour": 154902,
"om_cost_per_mmbtu_per_hour": 0.0,
"macrs_option_years": 0,
"macrs_bonus_fraction": 0.0,
"can_supply_steam_turbine": false,
"cop": 1.0
}
10 changes: 0 additions & 10 deletions docker-compose.yml

This file was deleted.

3 changes: 0 additions & 3 deletions docs/src/developer/organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,3 @@ System Advisor Model libraries used by this package for the Wind model.

## test
Built-in tests for several different solvers.

## transcrypt
A small executable for encrypting the xpauth.xpr license file that is used by NREL developers.
2 changes: 2 additions & 0 deletions src/REopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ include("core/electric_tariff.jl")
include("core/chp.jl")
include("core/ghp.jl")
include("core/steam_turbine.jl")
include("core/electric_heater.jl")
include("core/scenario.jl")
include("core/bau_scenario.jl")
include("core/reopt_inputs.jl")
Expand Down Expand Up @@ -178,6 +179,7 @@ include("results/chp.jl")
include("results/flexible_hvac.jl")
include("results/ghp.jl")
include("results/steam_turbine.jl")
include("results/electric_heater.jl")
include("results/heating_cooling_load.jl")

include("core/reopt.jl")
Expand Down
2 changes: 2 additions & 0 deletions src/constraints/load_balance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function add_elec_load_balance_constraints(m, p; _n="")
+ m[Symbol("dvCurtail"*_n)][t, ts] for t in p.techs.elec)
+ sum(m[Symbol("dvGridToStorage"*_n)][b, ts] for b in p.s.storage.types.elec)
+ sum(m[Symbol("dvThermalProduction"*_n)][t, ts] / p.cop[t] for t in p.techs.cooling)
+ sum(m[Symbol("dvThermalProduction"*_n)][t,ts] / p.heating_cop[t] for t in p.techs.electric_heater)
+ p.s.electric_load.loads_kw[ts]
- p.s.cooling_load.loads_kw_thermal[ts] / p.cop["ExistingChiller"]
+ sum(p.ghp_electric_consumption_kw[g,ts] * m[Symbol("binGHP"*_n)][g] for g in p.ghp_options)
Expand All @@ -28,6 +29,7 @@ function add_elec_load_balance_constraints(m, p; _n="")
+ m[Symbol("dvCurtail"*_n)][t, ts] for t in p.techs.elec)
+ sum(m[Symbol("dvGridToStorage"*_n)][b, ts] for b in p.s.storage.types.elec)
+ sum(m[Symbol("dvThermalProduction"*_n)][t, ts] / p.cop[t] for t in p.techs.cooling)
+ sum(m[Symbol("dvThermalProduction"*_n)][t,ts] / p.heating_cop[t] for t in p.techs.electric_heater)
+ p.s.electric_load.loads_kw[ts]
- p.s.cooling_load.loads_kw_thermal[ts] / p.cop["ExistingChiller"]
+ sum(p.ghp_electric_consumption_kw[g,ts] * m[Symbol("binGHP"*_n)][g] for g in p.ghp_options)
Expand Down
16 changes: 16 additions & 0 deletions src/constraints/storage_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ function add_hot_thermal_storage_dispatch_constraints(m, p, b; _n="")
end
end

if !isempty(p.techs.electric_heater)
for t in p.techs.electric_heater
if !isempty(p.techs.steam_turbine) && (t in p.techs.can_supply_steam_turbine)
@constraint(m, [b in p.s.storage.types.hot, ts in p.time_steps],
m[Symbol("dvProductionToStorage"*_n)][b,t,ts] + m[Symbol("dvThermalToSteamTurbine"*_n)][t,ts] <=
m[Symbol("dvThermalProduction"*_n)][t,ts]
)
else
@constraint(m, [b in p.s.storage.types.hot, ts in p.time_steps],
m[Symbol("dvProductionToStorage"*_n)][b,t,ts] <=
m[Symbol("dvThermalProduction"*_n)][t,ts]
)
end
end
end

# Constraint (4f)-1b: SteamTurbineTechs
if !isempty(p.techs.steam_turbine)
@constraint(m, SteamTurbineTechProductionFlowCon[b in p.s.storage.types.hot, t in p.techs.steam_turbine, ts in p.time_steps],
Expand Down
12 changes: 7 additions & 5 deletions src/constraints/thermal_tech_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ function add_boiler_tech_constraints(m, p; _n="")
)
)

# Constraint (7_heating_prod_size): Production limit based on size for boiler
@constraint(m, [t in p.techs.boiler, ts in p.time_steps],
m[Symbol("dvThermalProduction"*_n)][t,ts] <= m[Symbol("dvSize"*_n)][t]
)

m[:TotalBoilerPerUnitProdOMCosts] = 0.0
if "Boiler" in p.techs.boiler # ExistingBoiler does not have om_cost_per_kwh
m[:TotalBoilerPerUnitProdOMCosts] = @expression(m, p.third_party_factor * p.pwf_om *
Expand All @@ -28,6 +23,13 @@ function add_boiler_tech_constraints(m, p; _n="")
end
end

function add_heating_tech_constraints(m, p; _n="")
# Constraint (7_heating_prod_size): Production limit based on size for non-electricity-producing heating techs
@constraint(m, [t in setdiff(p.techs.heating, p.techs.elec), ts in p.time_steps],
m[Symbol("dvThermalProduction"*_n)][t,ts] <= m[Symbol("dvSize"*_n)][t]
)
end

function add_cooling_tech_constraints(m, p; _n="")
# Constraint (7_cooling_prod_size): Production limit based on size for boiler
@constraint(m, [t in p.techs.cooling, ts in p.time_steps_with_grid],
Expand Down
2 changes: 2 additions & 0 deletions src/core/bau_inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function BAUInputs(p::REoptInputs)
om_cost_per_kw = Dict(t => 0.0 for t in techs.all)
cop = Dict(t => 0.0 for t in techs.cooling)
thermal_cop = Dict{String, Float64}()
heating_cop = Dict{String, Float64}()
production_factor = DenseAxisArray{Float64}(undef, techs.all, p.time_steps)
tech_renewable_energy_fraction = Dict(t => 0.0 for t in techs.all)
# !!! note: tech_emissions_factors are in lb / kWh of fuel burned (gets multiplied by kWh of fuel burned, not kWh electricity consumption, ergo the use of the HHV instead of fuel slope)
Expand Down Expand Up @@ -188,6 +189,7 @@ function BAUInputs(p::REoptInputs)
tech_emissions_factors_SO2,
tech_emissions_factors_PM25,
p.techs_operating_reserve_req_fraction,
heating_cop,
unavailability
)
end
Expand Down
99 changes: 99 additions & 0 deletions src/core/electric_heater.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# REopt®, Copyright (c) Alliance for Sustainable Energy, LLC. See also https://github.com/NREL/REopt.jl/blob/master/LICENSE.

struct ElectricHeater <: AbstractThermalTech
min_kw::Real
max_kw::Real
installed_cost_per_kw::Real
om_cost_per_kw::Real
macrs_option_years::Int
macrs_bonus_fraction::Real
can_supply_steam_turbine::Bool
cop::Real
end


"""
ElectricHeater
If a user provides the `ElectricHeater` key then the optimal scenario has the option to purchase
this new `ElectricHeater` to meet the heating load in addition to using the `ExistingBoiler`
to meet the heating load.
```julia
function ElectricHeater(;
min_mmbtu_per_hour::Real = 0.0, # Minimum thermal power size
max_mmbtu_per_hour::Real = BIG_NUMBER, # Maximum thermal power size
installed_cost_per_mmbtu_per_hour::Union{Real, nothing} = nothing, # Thermal power-based cost
om_cost_per_mmbtu_per_hour::Union{Real, nothing} = nothing, # Thermal power-based fixed O&M cost
macrs_option_years::Int = 0, # MACRS schedule for financial analysis. Set to zero to disable
macrs_bonus_fraction::Real = 0.0, # Fraction of upfront project costs to depreciate under MACRS
can_supply_steam_turbine::Union{Bool, nothing} = nothing # If the boiler can supply steam to the steam turbine for electric production
cop::Union{Real, nothing} = nothing # COP of the heating (i.e., thermal produced / electricity consumed)
)
```
"""
function ElectricHeater(;
min_mmbtu_per_hour::Real = 0.0,
max_mmbtu_per_hour::Real = BIG_NUMBER,
installed_cost_per_mmbtu_per_hour::Union{Real, Nothing} = nothing,
om_cost_per_mmbtu_per_hour::Union{Real, Nothing} = nothing,
macrs_option_years::Int = 0,
macrs_bonus_fraction::Real = 0.0,
can_supply_steam_turbine::Union{Bool, Nothing} = nothing,
cop::Union{Real, Nothing} = nothing
)

defaults = get_electric_heater_defaults()

# populate defaults as needed
if isnothing(installed_cost_per_mmbtu_per_hour)
installed_cost_per_mmbtu_per_hour = defaults["installed_cost_per_mmbtu_per_hour"]
end
if isnothing(om_cost_per_mmbtu_per_hour)
om_cost_per_mmbtu_per_hour = defaults["om_cost_per_mmbtu_per_hour"]
end
if isnothing(can_supply_steam_turbine)
can_supply_steam_turbine = defaults["can_supply_steam_turbine"]
end
if isnothing(cop)
cop = defaults["cop"]
end

# Convert max sizes, cost factors from mmbtu_per_hour to kw
min_kw = min_mmbtu_per_hour * KWH_PER_MMBTU
max_kw = max_mmbtu_per_hour * KWH_PER_MMBTU


installed_cost_per_kw = installed_cost_per_mmbtu_per_hour / KWH_PER_MMBTU
om_cost_per_kw = om_cost_per_mmbtu_per_hour / KWH_PER_MMBTU


ElectricHeater(
min_kw,
max_kw,
installed_cost_per_kw,
om_cost_per_kw,
macrs_option_years,
macrs_bonus_fraction,
can_supply_steam_turbine,
cop
)
end



"""
function get_electric_heater_defaults()
Obtains defaults for the electric heater from a JSON data file.
inputs
None
returns
eh_defaults::Dict -- Dictionary containing defaults for electric heater
"""
function get_electric_heater_defaults()
eh_defaults = JSON.parsefile(joinpath(dirname(@__FILE__), "..", "..", "data", "electric_heater", "electric_heater_defaults.json"))
return eh_defaults
end
4 changes: 4 additions & 0 deletions src/core/reopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ function build_reopt!(m::JuMP.AbstractModel, p::REoptInputs)
m[:TotalTechCapCosts] += sum(p.s.chp.supplementary_firing_capital_cost_per_kw * m[:dvSupplementaryFiringSize][t] for t in p.techs.chp)
end

if !isempty(setdiff(p.techs.heating, p.techs.elec))
add_heating_tech_constraints(m, p)
end

if !isempty(p.techs.boiler)
add_boiler_tech_constraints(m, p)
m[:TotalPerUnitProdOMCosts] += m[:TotalBoilerPerUnitProdOMCosts]
Expand Down
Loading

2 comments on commit 8c9f19b

@Bill-Becker
Copy link
Collaborator Author

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/96806

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.39.0 -m "<description of version>" 8c9f19b127c6ea183f7186706c97b1ab8dbfe4ca
git push origin v0.39.0

Please sign in to comment.