-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new outputs for results related to hydrogen technologies
- Loading branch information
Showing
10 changed files
with
324 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# ********************************************************************************* | ||
# REopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, | ||
# are permitted provided that the following conditions are met: | ||
# | ||
# Redistributions of source code must retain the above copyright notice, this list | ||
# of conditions and the following disclaimer. | ||
# | ||
# Redistributions in binary form must reproduce the above copyright notice, this | ||
# list of conditions and the following disclaimer in the documentation and/or other | ||
# materials provided with the distribution. | ||
# | ||
# Neither the name of the copyright holder nor the names of its contributors may be | ||
# used to endorse or promote products derived from this software without specific | ||
# prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
# OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# ********************************************************************************* | ||
""" | ||
`Compressor` results keys: | ||
- `size_kw` Optimal compressor capacity | ||
- `lifecycle_om_cost_after_tax` Lifecycle operations and maintenance cost in present value, after tax | ||
- `year_one_hydrogen_compressed_kg` Total hydrogen compressed over the first year | ||
- `year_one_electricity_consumed_kwh` Total energy consumed by the compressor over the first year | ||
- `electricity_consumed_series_kw` Vector of power consumed by the compressor over the first year | ||
- `hydrogen_compressed_series_kg` Vector of hydrogen compressed going into the high pressure tank | ||
!!! note "'Series' and 'Annual' energy outputs are average annual" | ||
REopt performs load balances using average annual production values for technologies that include degradation. | ||
Therefore, all timeseries (`_series`) and `annual_` results should be interpretted as energy outputs averaged over the analysis period. | ||
""" | ||
function add_compressor_results(m::JuMP.AbstractModel, p::REoptInputs, d::Dict; _n="") | ||
# Adds the `Compressor` results to the dictionary passed back from `run_reopt` using the solved model `m` and the `REoptInputs` for node `_n`. | ||
# Note: the node number is an empty string if evaluating a single `Site`. | ||
print() | ||
r = Dict{String, Any}() | ||
r["size_kw"] = round(value(m[Symbol("dvSize"*_n)]["Compressor"]), digits=4) | ||
|
||
CompressorConsumption = @expression(m, [ts in p.time_steps], | ||
sum(m[Symbol("dvProductionToCompressor"*_n)][t, ts] for t in p.techs.elec) | ||
+ m[Symbol("dvGridToCompressor"*_n)][ts] | ||
+ sum(m[Symbol("dvStorageToCompressor"*_n)][b, ts] for b in p.s.storage.types.elec) | ||
) | ||
r["electricity_consumed_series_kw"] = round.(value.(CompressorConsumption), digits=3) | ||
r["year_one_electricity_consumed_kwh"] = round(sum(r["electricity_consumed_series_kw"]), digits=2) | ||
|
||
CompressorProduction = @expression(m, [ts in p.time_steps], | ||
sum(p.s.compressor.efficiency_kwh_per_kg * p.production_factor[t, ts] * p.levelization_factor[t] * | ||
m[Symbol("dvRatedProduction"*_n)][t,ts] for t in p.techs.compressor) | ||
) | ||
r["hydrogen_compressed_series_kg"] = round.(value.(CompressorProduction), digits=3) | ||
r["year_one_hydrogen_compressed_kg"] = round(sum(r["hydrogen_compressed_series_kg"]), digits=2) | ||
|
||
# PVPerUnitSizeOMCosts = p.om_cost_per_kw[t] * p.pwf_om * m[Symbol("dvSize"*_n)][t] | ||
# r["lifecycle_om_cost_after_tax"] = round(value(PVPerUnitSizeOMCosts) * (1 - p.s.financial.owner_tax_rate_fraction), digits=0) | ||
# r["lcoe_per_kwh"] = calculate_lcoe(p, r, get_pv_by_name(t, p.s.pvs)) | ||
|
||
d["Compressor"] = r | ||
|
||
end |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# ********************************************************************************* | ||
# REopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, | ||
# are permitted provided that the following conditions are met: | ||
# | ||
# Redistributions of source code must retain the above copyright notice, this list | ||
# of conditions and the following disclaimer. | ||
# | ||
# Redistributions in binary form must reproduce the above copyright notice, this | ||
# list of conditions and the following disclaimer in the documentation and/or other | ||
# materials provided with the distribution. | ||
# | ||
# Neither the name of the copyright holder nor the names of its contributors may be | ||
# used to endorse or promote products derived from this software without specific | ||
# prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
# OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# ********************************************************************************* | ||
""" | ||
`Electrolyzer` results keys: | ||
- `size_kw` Optimal electrolyzer capacity | ||
- `lifecycle_om_cost_after_tax` Lifecycle operations and maintenance cost in present value, after tax | ||
- `year_one_hydrogen_produced_kg` Total hydrogen produced over the first year | ||
- `year_one_electricity_consumed_kwh` Total energy consumed by the electrolyzer over the first year | ||
- `electricity_consumed_series_kw` Vector of power consumed by the electrolyzer to produce hydrogen over the first year | ||
- `hydrogen_produced_series_kg` Vector of hydrogen produced by the electrolyzer going into the low pressure tank | ||
!!! note "'Series' and 'Annual' energy outputs are average annual" | ||
REopt performs load balances using average annual production values for technologies that include degradation. | ||
Therefore, all timeseries (`_series`) and `annual_` results should be interpretted as energy outputs averaged over the analysis period. | ||
""" | ||
function add_electrolyzer_results(m::JuMP.AbstractModel, p::REoptInputs, d::Dict; _n="") | ||
# Adds the `Electrolyzer` results to the dictionary passed back from `run_reopt` using the solved model `m` and the `REoptInputs` for node `_n`. | ||
# Note: the node number is an empty string if evaluating a single `Site`. | ||
print() | ||
r = Dict{String, Any}() | ||
r["size_kw"] = round(value(m[Symbol("dvSize"*_n)]["Electrolyzer"]), digits=4) | ||
|
||
ElectrolyzerConsumption = @expression(m, [ts in p.time_steps], | ||
sum(m[Symbol("dvProductionToElectrolyzer"*_n)][t, ts] for t in p.techs.elec) | ||
+ m[Symbol("dvGridToElectrolyzer"*_n)][ts] | ||
+ sum(m[Symbol("dvStorageToElectrolyzer"*_n)][b, ts] for b in p.s.storage.types.elec) | ||
) | ||
r["electricity_consumed_series_kw"] = round.(value.(ElectrolyzerConsumption), digits=3) | ||
r["year_one_electricity_consumed_kwh"] = round(sum(r["electricity_consumed_series_kw"]), digits=2) | ||
|
||
ElectrolyzerProduction = @expression(m, [ts in p.time_steps], | ||
sum(p.s.electrolyzer.efficiency_kwh_per_kg * p.production_factor[t, ts] * p.levelization_factor[t] * | ||
m[Symbol("dvRatedProduction"*_n)][t,ts] for t in p.techs.electrolyzer) | ||
) | ||
r["hydrogen_produced_series_kg"] = round.(value.(ElectrolyzerProduction), digits=3) | ||
r["year_one_hydrogen_produced_kg"] = round(sum(r["hydrogen_produced_series_kg"]), digits=2) | ||
|
||
# PVPerUnitSizeOMCosts = p.om_cost_per_kw[t] * p.pwf_om * m[Symbol("dvSize"*_n)][t] | ||
# r["lifecycle_om_cost_after_tax"] = round(value(PVPerUnitSizeOMCosts) * (1 - p.s.financial.owner_tax_rate_fraction), digits=0) | ||
# r["lcoe_per_kwh"] = calculate_lcoe(p, r, get_pv_by_name(t, p.s.pvs)) | ||
|
||
d["Electrolyzer"] = r | ||
|
||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# ********************************************************************************* | ||
# REopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC. | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, | ||
# are permitted provided that the following conditions are met: | ||
# | ||
# Redistributions of source code must retain the above copyright notice, this list | ||
# of conditions and the following disclaimer. | ||
# | ||
# Redistributions in binary form must reproduce the above copyright notice, this | ||
# list of conditions and the following disclaimer in the documentation and/or other | ||
# materials provided with the distribution. | ||
# | ||
# Neither the name of the copyright holder nor the names of its contributors may be | ||
# used to endorse or promote products derived from this software without specific | ||
# prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
# OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# ********************************************************************************* | ||
""" | ||
`HydrogenStorageLP` and `HydrogenStorageHP` results keys: | ||
- `size_kg` Optimal inverter capacity | ||
- `soc_series_fraction` Vector of normalized (0-1) state of charge values over the first year | ||
- `storage_to_compressor_series_kw` Vector of power used to meet load over the first year | ||
- `initial_capital_cost` Upfront capital cost for the hydrogen storage tank | ||
""" | ||
function add_hydrogen_storage_lp_results(m::JuMP.AbstractModel, p::REoptInputs, d::Dict, b::String; _n="") | ||
# Adds the `Storage` results to the dictionary passed back from `run_reopt` using the solved model `m` and the `REoptInputs` for node `_n`. | ||
# Note: the node number is an empty string if evaluating a single `Site`. | ||
|
||
r = Dict{String, Any}() | ||
r["size_kg"] = round(value(m[Symbol("dvStorageEnergy"*_n)][b]), digits=2) | ||
|
||
if r["size_kg"] != 0 | ||
soc = (m[Symbol("dvStoredEnergy"*_n)][b, ts] for ts in p.time_steps) | ||
r["soc_series_fraction"] = round.(value.(soc) ./ r["size_kg"], digits=3) | ||
|
||
discharge = (m[Symbol("dvDischargeFromStorage"*_n)][b, ts] for ts in p.time_steps) | ||
r["storage_to_compressor_series_kg"] = round.(value.(discharge), digits=3) | ||
|
||
r["initial_capital_cost"] = r["size_kg"] * p.s.storage.attr[b].installed_cost_per_kg | ||
else | ||
r["soc_series_fraction"] = [] | ||
r["storage_to_compressor_series_kg"] = [] | ||
end | ||
|
||
d[b] = r | ||
nothing | ||
end | ||
|
||
function add_hydrogen_storage_hp_results(m::JuMP.AbstractModel, p::REoptInputs, d::Dict, b::String; _n="") | ||
# Adds the `Storage` results to the dictionary passed back from `run_reopt` using the solved model `m` and the `REoptInputs` for node `_n`. | ||
# Note: the node number is an empty string if evaluating a single `Site`. | ||
|
||
r = Dict{String, Any}() | ||
r["size_kg"] = round(value(m[Symbol("dvStorageEnergy"*_n)][b]), digits=2) | ||
|
||
if r["size_kg"] != 0 | ||
soc = (m[Symbol("dvStoredEnergy"*_n)][b, ts] for ts in p.time_steps) | ||
r["soc_series_fraction"] = round.(value.(soc) ./ r["size_kg"], digits=3) | ||
|
||
discharge = (m[Symbol("dvDischargeFromStorage"*_n)][b, ts] for ts in p.time_steps) | ||
r["storage_to_h2_load_series_kg"] = round.(value.(discharge), digits=3) | ||
|
||
r["initial_capital_cost"] = r["size_kg"] * p.s.storage.attr[b].installed_cost_per_kg | ||
else | ||
r["soc_series_fraction"] = [] | ||
r["storage_to_h2_load_series_kg"] = [] | ||
end | ||
|
||
d[b] = r | ||
nothing | ||
end | ||
|
||
# """ | ||
# MPC `ElectricStorage` results keys: | ||
# - `soc_series_fraction` Vector of normalized (0-1) state of charge values over time horizon | ||
# """ | ||
# function add_electric_storage_results(m::JuMP.AbstractModel, p::MPCInputs, d::Dict, b::String; _n="") | ||
# r = Dict{String, Any}() | ||
|
||
# soc = (m[Symbol("dvStoredEnergy"*_n)][b, ts] for ts in p.time_steps) | ||
# r["soc_series_fraction"] = round.(value.(soc) ./ p.s.storage.attr[b].size_kwh, digits=3) | ||
|
||
# discharge = (m[Symbol("dvDischargeFromStorage"*_n)][b, ts] for ts in p.time_steps) | ||
# r["to_load_series_kw"] = round.(value.(discharge), digits=3) | ||
|
||
# d[b] = r | ||
# nothing | ||
# end |
This file contains 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
Oops, something went wrong.