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

MPC TLDRD #418

Draft
wants to merge 3,028 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3028 commits
Select commit Hold shift + click to select a range
3bd5135
use correct FuelCell key
hdunham Sep 6, 2023
16c1c94
use correct FuelCell key
hdunham Sep 6, 2023
e7f8a46
fix bug applying (dis)charge effic in erp (cancelled out in tests wit…
hdunham Sep 6, 2023
cc831c7
fix bug applying (dis)charge effic in erp (cancelled out in tests wit…
hdunham Sep 6, 2023
0dec629
temp comment out non-erp tests
hdunham Sep 6, 2023
365d983
temp comment out non-erp tests
hdunham Sep 6, 2023
baf450a
change erp H2 storage units from kwh to kg
hdunham Sep 7, 2023
cb5f9b8
change erp H2 storage units from kwh to kg
hdunham Sep 7, 2023
40cac50
temp revert accessing HydrogenStorageLP input model
hdunham Sep 7, 2023
8fff514
temp revert accessing HydrogenStorageLP input model
hdunham Sep 7, 2023
e77701b
round not Int to avoid inexact error
hdunham Sep 7, 2023
bc4ba26
round not Int to avoid inexact error
hdunham Sep 7, 2023
e15581b
use consistent names for H2 power capacities
hdunham Sep 7, 2023
0509813
use consistent names for H2 power capacities
hdunham Sep 7, 2023
6058313
update use of num_storage_bins_default for H2 due to units change
hdunham Sep 7, 2023
8ecc96c
update use of num_storage_bins_default for H2 due to units change
hdunham Sep 7, 2023
71679a1
reorder args for dependency
hdunham Sep 7, 2023
cd9935e
reorder args for dependency
hdunham Sep 7, 2023
44028a9
use H2 REopt models in ERP and tests
hdunham Sep 7, 2023
a143876
use H2 REopt models in ERP and tests
hdunham Sep 7, 2023
6f775b6
update test input filenames
hdunham Sep 7, 2023
2bc811f
update test input filenames
hdunham Sep 7, 2023
c2b2e34
Fix hydrogen bugs
indu-manogaran Sep 11, 2023
ca60dd5
Fix hydrogen bugs
indu-manogaran Sep 11, 2023
da421b7
ERP testing
hdunham Sep 11, 2023
fda0c53
ERP testing
hdunham Sep 11, 2023
27e0561
remove debug file
hdunham Sep 11, 2023
9bddb1c
remove debug file
hdunham Sep 11, 2023
f8bacdb
correct accessing electrolyzer/fuel cell effic inputs
hdunham Sep 11, 2023
24b6872
correct accessing electrolyzer/fuel cell effic inputs
hdunham Sep 11, 2023
397381d
make FuelCell om_cost_per_kWh lowercase
hdunham Sep 12, 2023
6bd73e4
make FuelCell om_cost_per_kWh lowercase
hdunham Sep 12, 2023
4ccbee6
get Electrolyzer size_kw from REopt results in backup_reliability_reo…
hdunham Sep 12, 2023
8913e5d
get Electrolyzer size_kw from REopt results in backup_reliability_reo…
hdunham Sep 12, 2023
e2ce9a6
erp debugging
hdunham Sep 12, 2023
452fdc7
erp debugging
hdunham Sep 12, 2023
f9d0b52
set more batt inputs in an ERP case so H2 equivalent doesn't use diff…
hdunham Sep 12, 2023
f2839dd
set more batt inputs in an ERP case so H2 equivalent doesn't use diff…
hdunham Sep 12, 2023
cd52ef8
add newlines and indentation to test input files
hdunham Sep 12, 2023
6fccb1b
add newlines and indentation to test input files
hdunham Sep 12, 2023
72e63d4
remove debug files
hdunham Sep 12, 2023
caa38e1
remove debug files
hdunham Sep 12, 2023
e9a56e3
move test jsons into scenario folder
hdunham Sep 12, 2023
743b55b
move test jsons into scenario folder
hdunham Sep 12, 2023
b00dc59
update json read/write in erp tests
hdunham Sep 12, 2023
813fecd
update json read/write in erp tests
hdunham Sep 12, 2023
2c8f298
more pre-optimization to speed up erp tests
hdunham Sep 12, 2023
daac1d3
more pre-optimization to speed up erp tests
hdunham Sep 12, 2023
8a99170
uncomment non-ERP tests
hdunham Sep 12, 2023
36d57ee
uncomment non-ERP tests
hdunham Sep 12, 2023
8eb9f12
Force hydrogen decision variables to zero when components are not added
lixiangk1 Sep 12, 2023
c1bebaf
Force hydrogen decision variables to zero when components are not added
lixiangk1 Sep 12, 2023
fe67162
Correct grid time series
indu-manogaran Sep 12, 2023
c3c6219
Correct grid time series
indu-manogaran Sep 12, 2023
1c9cebb
Revise fuel cell efficiency
indu-manogaran Sep 12, 2023
ee69dc1
Revise fuel cell efficiency
indu-manogaran Sep 12, 2023
bd4defa
Update backup_reliability.jl
hdunham Sep 14, 2023
a2d525b
fix capitalization typo in fuelcell om_cost_per_kwh
hdunham Sep 18, 2023
b473c21
fix capitalization typo in fuelcell om_cost_per_kwh
hdunham Sep 18, 2023
10d6ebe
Merge branch 'hydrogen' into h2-erp
hdunham Sep 18, 2023
91cbe1a
Merge branch 'hydrogen' into h2-erp
hdunham Sep 18, 2023
26e5b13
update getting H2 efficiencies from reopt struct for ERP
hdunham Sep 18, 2023
12b5b4b
update getting H2 efficiencies from reopt struct for ERP
hdunham Sep 18, 2023
c45a69f
update setting H2 efficiencies in ERP test
hdunham Sep 18, 2023
94d2cc3
update setting H2 efficiencies in ERP test
hdunham Sep 18, 2023
fb28c52
calc wind_kw_ac_time_series in backup_reliability_inputs
hdunham Sep 19, 2023
9549d6f
net wind_kw_ac_time_series out of critical load
hdunham Sep 19, 2023
4acf35c
add wind args to return_backup_reliability
hdunham Sep 19, 2023
4065184
update calc of probs in ERP system_characteristics dict
hdunham Sep 19, 2023
ced7804
delete old commented out code
hdunham Sep 19, 2023
499ed4e
set wind_kw_ac_time_series in backup_reliability_reopt_inputs
hdunham Sep 19, 2023
a186bee
correct _without_storage to _without_battery
hdunham Sep 19, 2023
0ff719f
fix missed var name change
hdunham Sep 19, 2023
bb403a9
change PV to wind in backup_reliability_reopt_inputs.json
hdunham Sep 19, 2023
5ee1bea
presave reopt result in erp test
hdunham Sep 19, 2023
b66a2c9
Update runtests.jl
hdunham Sep 19, 2023
320afe9
uncomment tests
hdunham Sep 19, 2023
e640eea
Update CHANGELOG.md
hdunham Sep 19, 2023
80c5acd
update backup_reliability docstrings with wind and corrections
hdunham Sep 19, 2023
bde9aef
condense some ERP tests PV and wind
hdunham Sep 19, 2023
578232c
condense syntax
hdunham Sep 19, 2023
b3c91f4
Debug fuel cell hydrogen consumption output
lixiangk1 Sep 19, 2023
c725f0f
Debug fuel cell hydrogen consumption output
lixiangk1 Sep 19, 2023
18cef5e
Zero out more variables when techs aren't included
lixiangk1 Sep 19, 2023
c1374b1
Zero out more variables when techs aren't included
lixiangk1 Sep 19, 2023
6e1143c
Add Wind to stochastic outage results
Bill-Becker Sep 19, 2023
b8c9d6c
Update LICENSE per Angela Hupp email 2023.07.21
Bill-Becker Sep 20, 2023
d368be0
Update README with REopt registered trademark
Bill-Becker Sep 20, 2023
7efe4df
Update REopt Copyright language for each file
Bill-Becker Sep 20, 2023
115e2ce
add wind_production_factor_series to dictkeys_tosymbols
hdunham Sep 20, 2023
5d65351
fix Wind series outputs being JuMP.Containers.DenseAxisArray instead …
hdunham Sep 20, 2023
7151ae9
uncomment tests
hdunham Sep 20, 2023
1d17ce0
correct batt efficiencies input names in docstrings
hdunham Sep 20, 2023
ba62b6c
Merge pull request #265 from NREL/license-update
Bill-Becker Sep 20, 2023
078b49d
Merge branch 'develop' into outages-results
Bill-Becker Sep 20, 2023
05255c8
update output name: fuel_survival_final_time_step
hdunham Sep 20, 2023
c77e268
Merge branch 'hydrogen' into h2-erp
indu-manogaran Sep 20, 2023
96f7a01
Merge branch 'hydrogen' into h2-erp
indu-manogaran Sep 20, 2023
bf8d9ed
Merge branch 'develop' into hydrogen
indu-manogaran Sep 20, 2023
8f746a6
Merge branch 'develop' into hydrogen
indu-manogaran Sep 20, 2023
fbc6710
Merge branch 'hydrogen' into h2-erp
indu-manogaran Sep 20, 2023
e3f762d
Merge branch 'hydrogen' into h2-erp
indu-manogaran Sep 20, 2023
c83a917
Add critical load and storage SOC series to outage results
Bill-Becker Sep 20, 2023
fa7de06
Make load balance for stochastic outages == instead of supply >= load
Bill-Becker Sep 20, 2023
ef29095
Add tests for outage load balance mod and results additions
Bill-Becker Sep 20, 2023
9b5111c
Fix name issue in new test
Bill-Becker Sep 20, 2023
af925d7
Merge pull request #263 from NREL/wind-erp
hdunham Sep 21, 2023
3e89032
Merge branch 'master' into develop
hdunham Sep 21, 2023
0551823
Update Project.toml
hdunham Sep 21, 2023
a098439
Update CHANGELOG.md
hdunham Sep 21, 2023
9c1baee
Merge branch 'develop' into erp-fixes
hdunham Sep 21, 2023
5f27048
update H2 default efficiencies in ERP
hdunham Sep 21, 2023
2cdeee6
update H2 default efficiencies in ERP
hdunham Sep 21, 2023
e142320
correct default in Electrolyzer docstring
hdunham Sep 21, 2023
e67fab9
correct default in Electrolyzer docstring
hdunham Sep 21, 2023
85a42fd
update H2_operational_availability default
hdunham Sep 21, 2023
e2c0fc4
update H2_operational_availability default
hdunham Sep 21, 2023
de05ef0
add electric_storage_microgrid_upgraded to Outages outputs
hdunham Sep 21, 2023
efd0a7e
replace use of non-existent storage_upgraded with electric_storage_mi…
hdunham Sep 21, 2023
47b2632
replace use of non-existent <tech>_upgraded in ERP
hdunham Sep 21, 2023
8333b2d
use production_factor_series instead of summing dispatch series
hdunham Sep 21, 2023
97a3ed9
correct calc of diesel gen size in backup_reliability_reopt_inputs
hdunham Sep 21, 2023
37898b4
use ternary operator instead of if else to avoid scope issues
hdunham Sep 21, 2023
2135a20
calc prime gen size in backup_reliability_reopt_inputs
hdunham Sep 21, 2023
bbd20a3
temp hack to handle multiple PV in results results in ERP
hdunham Sep 21, 2023
f63b922
temp hack to handle multiple PV in results results in ERP
hdunham Sep 21, 2023
1cc38b5
convert some reopt outputs from denseaxisarray to vector
hdunham Sep 22, 2023
b0a8a89
get erp generator inputs from reopt results/inputs backup_reliability…
hdunham Sep 22, 2023
54b34aa
don't production_factor_series instead of summing dispatch series
hdunham Sep 22, 2023
2ea6472
Update CHANGELOG.md
hdunham Sep 22, 2023
c6b049b
Fix Wind outage docstring naming
Bill-Becker Sep 22, 2023
d24c2e2
Remove _n for outages, not multi-node compatible
Bill-Becker Sep 22, 2023
9275b0d
Use p.storage.types.elec instead of ElectricStorage for indexing Stor…
Bill-Becker Sep 22, 2023
6e3e85a
Make "no-storage" case have empty arrays for storage outage outputs
Bill-Becker Sep 22, 2023
abdf8b6
Change outage critical load series to same shape as other outage time…
Bill-Becker Sep 22, 2023
5dbfb71
Update indexing in wind outage load test
Bill-Becker Sep 23, 2023
23b2967
Merge branch 'develop' into outages-results
Bill-Becker Sep 23, 2023
c4e5535
Merge pull request #269 from NREL/erp-fixes
hdunham Sep 23, 2023
a037851
Merge branch 'develop' into outages-results
hdunham Sep 23, 2023
9b9966e
Merge pull request #266 from NREL/outages-results
Bill-Becker Sep 23, 2023
fde4362
Update CHANGELOG.md
Bill-Becker Sep 23, 2023
36f1005
Merge branch 'develop' into h2-erp
hdunham Sep 27, 2023
a0f7682
Merge branch 'develop' into h2-erp
hdunham Sep 27, 2023
3453d8f
delete dupe tests
hdunham Sep 27, 2023
a343c40
delete dupe tests
hdunham Sep 27, 2023
1dba5f2
fix system_characteristics prob calcs
hdunham Sep 27, 2023
62166e9
fix system_characteristics prob calcs
hdunham Sep 27, 2023
2a2b8a7
fix merge mistakes
hdunham Sep 28, 2023
825c77c
fix merge mistakes
hdunham Sep 28, 2023
d6ec4ec
Debug load balance
indu-manogaran Sep 28, 2023
1e04f6b
Debug load balance
indu-manogaran Sep 28, 2023
71efc91
Add OM costs and update defaults
indu-manogaran Sep 28, 2023
6eb1a70
Add OM costs and update defaults
indu-manogaran Sep 28, 2023
a27df05
Merge branch 'h2-erp' of https://github.com/NREL/REopt.jl into h2-erp
indu-manogaran Sep 28, 2023
d30bf83
Merge branch 'h2-erp' of https://github.com/NREL/REopt.jl into h2-erp
indu-manogaran Sep 28, 2023
eb2c559
Merge branch 'h2-erp' of https://github.com/NREL/REopt.jl into h2-erp
hdunham Sep 28, 2023
bbe572d
Merge branch 'h2-erp' of https://github.com/NREL/REopt.jl into h2-erp
hdunham Sep 28, 2023
8f5e77c
Merge branch 'wind-erp' into h2-new
hdunham Sep 28, 2023
7d05b89
merge dupe tests
hdunham Sep 28, 2023
ddc0e38
fix system_characteristics dict
hdunham Sep 28, 2023
68e7a80
correct var names
hdunham Sep 28, 2023
934016e
rerun and presave reopt in erp tests
hdunham Sep 28, 2023
c3dacc5
re-presave outagesim results in erp tests
hdunham Sep 28, 2023
ede4551
update presaved results for erp tests
hdunham Sep 28, 2023
518ca96
use presaved results in erp tests
hdunham Sep 28, 2023
088a6dd
simplify system_characteristics prob calcs
hdunham Sep 28, 2023
9b47dc1
test system_characteristics simplification
hdunham Sep 28, 2023
645ae5c
fix system_characteristics_probability
hdunham Sep 28, 2023
ba82bb0
Revert "test system_characteristics simplification"
hdunham Sep 28, 2023
daf6347
Merge branch 'develop' into h2-new
hdunham Sep 29, 2023
e9e6c25
Debug load balance
indu-manogaran Sep 28, 2023
c293b50
Add OM costs and update defaults
indu-manogaran Sep 28, 2023
0da4d62
merge fix of temp hack to handle multiple PVs in ERP
hdunham Sep 29, 2023
462e75c
Merge branch 'master' into develop
Bill-Becker Oct 10, 2023
47c1da5
Merge branch 'develop' of https://github.com/NREL/REopt.jl into develop
Bill-Becker Oct 10, 2023
b7ae547
add storage leakage function to erp
hdunham Oct 13, 2023
de5caa2
test storage leakage function
hdunham Oct 13, 2023
b1658ca
move storage leakage to after all dispatch in ts
hdunham Oct 13, 2023
2b715b1
pass through args for storage leakage rates
hdunham Oct 13, 2023
f583eb9
test erp run with leakage
hdunham Oct 13, 2023
424d8d4
fix leage arg mistakes and missed docs
hdunham Oct 13, 2023
d09f463
Update runtests.jl
hdunham Oct 13, 2023
2c4fb66
uncomment tests
hdunham Oct 13, 2023
ff01dcd
trigger tests
hdunham Oct 15, 2023
6d4e09a
Update runtests.jl
hdunham Oct 15, 2023
31473a3
rm unit test of storage_leakage now that in integration tests
hdunham Oct 15, 2023
0c17bf2
update erp leakage defaults
hdunham Oct 20, 2023
7411803
add missing tech tech sets to Techs(s::MPCScenario)
hdunham Oct 20, 2023
1d55abf
restrict HiGHS version due to bug in 1.7
hdunham Oct 20, 2023
ef1b2a5
Revert "restrict HiGHS version due to bug in 1.7"
hdunham Oct 23, 2023
7ffa743
Merge branch 'develop' into h2-new
hdunham Oct 23, 2023
8115d6d
trigger tests
hdunham Oct 24, 2023
246bb8f
Merge branch 'develop' into h2-new
lixiangk1 Nov 1, 2023
add952d
Add h2 leakage and battery self discharge
lixiangk1 Nov 1, 2023
b2903bf
Update hydrogen storage tank min soc
lixiangk1 Nov 1, 2023
c62c58f
Update LP storage results variable name
lixiangk1 Nov 1, 2023
52c9a9b
Merge branch 'develop' into h2-new
indu-manogaran Nov 29, 2023
c3faecc
Merge branch 'develop' into h2-tldrd-mpc
lixiangk1 Feb 29, 2024
6e0c7c6
Merge branch 'add-process-heat-load' into h2-tldrd-mpc
lixiangk1 Mar 6, 2024
4861d45
Hydrogen storage model
indu-manogaran Mar 21, 2024
64af7ba
Initial implementation of electric heater and process heating load in…
lixiangk1 Mar 22, 2024
16de677
Hydrogen storage MPC model
indu-manogaran Mar 26, 2024
7e2c07e
Distinguish between all techs and elec techs in mpc runs
lixiangk1 Mar 26, 2024
7555100
Add MPC fuel cell to elec techs
indu-manogaran Mar 27, 2024
b5f18ad
Add initial solid-state TES implementation
lixiangk1 Mar 27, 2024
900af9f
MPC results keys renaming
indu-manogaran Mar 27, 2024
a989188
Add separate charge vs discharge limits on HighTempThermalStorage in mpc
lixiangk1 Mar 28, 2024
38a33ae
Merge branch 'develop' into h2-tldrd-mpc
lixiangk1 Mar 28, 2024
53cd29e
Add Wind to MPC
lixiangk1 Apr 30, 2024
d26ba78
Merge branch 'h2-erp' of https://github.com/NREL/REopt.jl into h2-erp
indu-manogaran Apr 30, 2024
eca4526
Merge branch 'develop' into h2-erp
indu-manogaran May 6, 2024
e08044c
Syntax error correction
indu-manogaran May 9, 2024
97b8eb8
Add hydrogen to multiple outages
lixiangk1 May 23, 2024
1fe4d5e
Initial off-grid implementation for mpc (no h2)
lixiangk1 Jun 12, 2024
15b2c50
Hydrogen model updates
indu-manogaran Jun 22, 2024
b78be8a
Merge branch 'develop' into h2-erp
indu-manogaran Jun 22, 2024
1b01a63
Add heuristics BESS dispatch, correct mpc battery efficiency defaults
lixiangk1 Jul 7, 2024
0757902
Merge branch 'develop' into h2-erp
hdunham Jul 15, 2024
7366b59
remove xpress docker files
hdunham Jul 15, 2024
54c8eb1
small code simplification
hdunham Jul 15, 2024
c67aae1
Hydrogen model updates multiple updates
indu-manogaran Jul 18, 2024
0877cdc
Merge branch 'develop' into h2-tldrd-mpc
hdunham Jul 22, 2024
a6f7f9e
syntax consistency
hdunham Jul 24, 2024
4b68fdb
confirm techs not nothing before accessing fields
hdunham Jul 24, 2024
689c861
correct Tech struct docstring
hdunham Jul 24, 2024
0fd049b
eliminate unnecessary steps
hdunham Jul 24, 2024
31b027a
conciseness
hdunham Jul 26, 2024
408275b
add override warning
hdunham Jul 26, 2024
be75a33
if else clarity
hdunham Jul 30, 2024
a457e34
uodate add_electric_load_results docstring
hdunham Jul 30, 2024
f0d9491
add critical_load_series_kw to MPC outputs
hdunham Jul 30, 2024
6c2a13a
MPC: add emissions accounting and CO2 cost to objective function
lixiangk1 Jul 30, 2024
31a0ee2
Merge branch 'h2-tldrd-mpc' of https://github.com/NREL/REopt.jl into …
lixiangk1 Jul 30, 2024
bdbc423
rm dupe if condition
hdunham Jul 31, 2024
bec41fe
add clarity to emissions warning msg
hdunham Jul 31, 2024
228b2ed
tie grid_charge_efficiency default to charge_efficiency
hdunham Jul 31, 2024
c4c5f0d
add docstrings
hdunham Jul 31, 2024
82eccb8
add to add_hot_storage_results docstring
hdunham Aug 1, 2024
e63a83d
Hydrogen model debug
indu-manogaran Aug 5, 2024
d1eaaad
Merge branch 'h2-erp' into h2-tldrd-mpc
indu-manogaran Aug 5, 2024
6174dfd
Bug fix
indu-manogaran Aug 6, 2024
14fd1f0
Allow init soc to be read for MPCElectricStorage
lixiangk1 Aug 8, 2024
65dcdd6
Add time series intermediary emissions variables for MPC
lixiangk1 Aug 8, 2024
48424e1
Hydrogen model update
indu-manogaran Aug 8, 2024
cec4cca
Merge branch 'h2-erp' into h2-tldrd-mpc
indu-manogaran Aug 8, 2024
3e4f8b1
Change sum operator to expression emissions
indu-manogaran Aug 11, 2024
cde2917
Change sum operator to expression emissions
indu-manogaran Aug 12, 2024
13ede1e
RE accounting hydrogen
indu-manogaran Aug 13, 2024
04ed96e
Merge branch 'develop' into h2-tldrd-mpc
lixiangk1 Aug 14, 2024
036d516
Hydrogen bug fixes
lixiangk1 Sep 11, 2024
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
15 changes: 15 additions & 0 deletions src/REopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export
run_mpc,
build_mpc!,
backup_reliability,
shift_gen_storage_prob_matrix!,
backup_reliability_reopt_inputs,
get_maximum_generation,
storage_leakage!,
get_chp_defaults_prime_mover_size_class,
get_steam_turbine_defaults_size_class,
simulated_load,
Expand Down Expand Up @@ -118,9 +122,14 @@ include("core/wind.jl")
include("core/energy_storage/storage.jl")
include("core/energy_storage/electric_storage.jl")
include("core/energy_storage/thermal_storage.jl")
include("core/energy_storage/hydrogen_storage.jl")
include("core/electrolyzer.jl")
include("core/compressor.jl")
include("core/fuel_cell.jl")
include("core/generator.jl")
include("core/doe_commercial_reference_building_loads.jl")
include("core/electric_load.jl")
include("core/hydrogen_load.jl")
include("core/existing_boiler.jl")
include("core/boiler.jl")
include("core/existing_chiller.jl")
Expand Down Expand Up @@ -159,6 +168,7 @@ include("constraints/ghp_constraints.jl")
include("constraints/steam_turbine_constraints.jl")
include("constraints/renewable_energy_constraints.jl")
include("constraints/emissions_constraints.jl")
include("constraints/hydrogen_constraints.jl")

include("mpc/structs.jl")
include("mpc/scenario.jl")
Expand Down Expand Up @@ -189,6 +199,11 @@ include("results/ghp.jl")
include("results/steam_turbine.jl")
include("results/electric_heater.jl")
include("results/heating_cooling_load.jl")
include("results/hydrogen_load.jl")
include("results/hydrogen_storage.jl")
include("results/electrolyzer.jl")
include("results/compressor.jl")
include("results/fuel_cell.jl")

include("core/reopt.jl")
include("core/reopt_multinode.jl")
Expand Down
8 changes: 6 additions & 2 deletions src/constraints/electric_utility_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ function add_simultaneous_export_import_constraint(m, p; _n="")
@constraint(m, NoGridPurchasesBinary[ts in p.time_steps],
m[Symbol("binNoGridPurchases"*_n)][ts] => {
sum(m[Symbol("dvGridPurchase"*_n)][ts, tier] for tier in 1:p.s.electric_tariff.n_energy_tiers) +
sum(m[Symbol("dvGridToStorage"*_n)][b, ts] for b in p.s.storage.types.elec) <= 0
sum(m[Symbol("dvGridToStorage"*_n)][b, ts] for b in p.s.storage.types.elec) +
m[Symbol("dvGridToElectrolyzer"*_n)][ts] +
m[Symbol("dvGridToCompressor"*_n)][ts] <= 0
}
)
@constraint(m, ExportOnlyAfterSiteLoadMetCon[ts in p.time_steps],
Expand All @@ -276,7 +278,9 @@ function add_simultaneous_export_import_constraint(m, p; _n="")
bigM_hourly_load = maximum(p.s.electric_load.loads_kw)+maximum(p.s.space_heating_load.loads_kw)+maximum(p.s.process_heat_load.loads_kw)+maximum(p.s.dhw_load.loads_kw)+maximum(p.s.cooling_load.loads_kw_thermal)
@constraint(m, NoGridPurchasesBinary[ts in p.time_steps],
sum(m[Symbol("dvGridPurchase"*_n)][ts, tier] for tier in 1:p.s.electric_tariff.n_energy_tiers) +
sum(m[Symbol("dvGridToStorage"*_n)][b, ts] for b in p.s.storage.types.elec) <= bigM_hourly_load*(1-m[Symbol("binNoGridPurchases"*_n)][ts])
sum(m[Symbol("dvGridToStorage"*_n)][b, ts] for b in p.s.storage.types.elec) +
m[Symbol("dvGridToElectrolyzer"*_n)][ts] +
m[Symbol("dvGridToCompressor"*_n)][ts] <= bigM_hourly_load*(1-m[Symbol("binNoGridPurchases"*_n)][ts])
)
@constraint(m, ExportOnlyAfterSiteLoadMetCon[ts in p.time_steps],
sum(m[Symbol("dvProductionToGrid"*_n)][t,u,ts] for t in p.techs.elec, u in p.export_bins_by_tech[t]) <= bigM_hourly_load * m[Symbol("binNoGridPurchases"*_n)][ts]
Expand Down
115 changes: 63 additions & 52 deletions src/constraints/emissions_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,39 @@ end

function add_yr1_emissions_calcs(m,p)
# Components:
m[:yr1_emissions_onsite_fuel_lbs_CO2], m[:yr1_emissions_onsite_fuel_lbs_NOx],
m[:yr1_emissions_onsite_fuel_lbs_SO2], m[:yr1_emissions_onsite_fuel_lbs_PM25] =
yr1_emissions_onsite_fuel_series_lbs_CO2, yr1_emissions_onsite_fuel_series_lbs_NOx,
yr1_emissions_onsite_fuel_series_lbs_SO2, yr1_emissions_onsite_fuel_series_lbs_PM25 =
calc_yr1_emissions_from_onsite_fuel(m,p; tech_array=p.techs.fuel_burning)

m[:yr1_emissions_from_elec_grid_lbs_CO2], m[:yr1_emissions_from_elec_grid_lbs_NOx],
m[:yr1_emissions_from_elec_grid_lbs_SO2], m[:yr1_emissions_from_elec_grid_lbs_PM25] =
yr1_emissions_from_elec_grid_series_lbs_CO2, yr1_emissions_from_elec_grid_series_lbs_NOx,
yr1_emissions_from_elec_grid_series_lbs_SO2, yr1_emissions_from_elec_grid_series_lbs_PM25 =
calc_yr1_emissions_from_elec_grid_purchase(m, p)

yr1_emissions_offset_from_elec_exports_lbs_CO2,
yr1_emissions_offset_from_elec_exports_lbs_NOx,
yr1_emissions_offset_from_elec_exports_lbs_SO2,
yr1_emissions_offset_from_elec_exports_lbs_PM25 =
yr1_emissions_offset_from_elec_exports_series_lbs_CO2,
yr1_emissions_offset_from_elec_exports_series_lbs_NOx,
yr1_emissions_offset_from_elec_exports_series_lbs_SO2,
yr1_emissions_offset_from_elec_exports_series_lbs_PM25 =
calc_yr1_emissions_offset_from_elec_exports(m, p)

m[:yr1_emissions_from_elec_grid_net_if_selected_lbs_CO2] = (m[:yr1_emissions_from_elec_grid_lbs_CO2] -
yr1_emissions_offset_from_elec_exports_lbs_CO2)
m[:yr1_emissions_from_elec_grid_net_if_selected_lbs_NOx] = (m[:yr1_emissions_from_elec_grid_lbs_NOx] -
yr1_emissions_offset_from_elec_exports_lbs_NOx)
m[:yr1_emissions_from_elec_grid_net_if_selected_lbs_SO2] = (m[:yr1_emissions_from_elec_grid_lbs_SO2] -
yr1_emissions_offset_from_elec_exports_lbs_SO2)
m[:yr1_emissions_from_elec_grid_net_if_selected_lbs_PM25] = (m[:yr1_emissions_from_elec_grid_lbs_PM25] -
yr1_emissions_offset_from_elec_exports_lbs_PM25)
m[:yr1_emissions_from_elec_grid_net_if_selected_series_lbs_CO2] = @expression(m, [ts in p.time_steps],
yr1_emissions_from_elec_grid_series_lbs_CO2[ts] - yr1_emissions_offset_from_elec_exports_series_lbs_CO2[ts])
m[:yr1_emissions_from_elec_grid_net_if_selected_series_lbs_NOx] = @expression(m, [ts in p.time_steps],
yr1_emissions_from_elec_grid_series_lbs_NOx[ts] - yr1_emissions_offset_from_elec_exports_series_lbs_NOx[ts])
m[:yr1_emissions_from_elec_grid_net_if_selected_series_lbs_SO2] = @expression(m, [ts in p.time_steps],
yr1_emissions_from_elec_grid_series_lbs_SO2[ts] - yr1_emissions_offset_from_elec_exports_series_lbs_SO2[ts])
m[:yr1_emissions_from_elec_grid_net_if_selected_series_lbs_PM25] = @expression(m, [ts in p.time_steps],
yr1_emissions_from_elec_grid_series_lbs_PM25[ts] - yr1_emissions_offset_from_elec_exports_series_lbs_PM25[ts])

# Summed variables
m[:yr1_emissions_onsite_fuel_lbs_CO2] = @expression(m, sum(yr1_emissions_onsite_fuel_series_lbs_CO2[ts] for ts in p.time_steps))
m[:yr1_emissions_onsite_fuel_lbs_NOx] = @expression(m, sum(yr1_emissions_onsite_fuel_series_lbs_NOx[ts] for ts in p.time_steps))
m[:yr1_emissions_onsite_fuel_lbs_SO2] = @expression(m, sum(yr1_emissions_onsite_fuel_series_lbs_SO2[ts] for ts in p.time_steps))
m[:yr1_emissions_onsite_fuel_lbs_PM25] = @expression(m, sum(yr1_emissions_onsite_fuel_series_lbs_PM25[ts] for ts in p.time_steps))

m[:yr1_emissions_from_elec_grid_net_if_selected_lbs_CO2] = @expression(m, sum(m[:yr1_emissions_from_elec_grid_net_if_selected_series_lbs_CO2][ts] for ts in p.time_steps))
m[:yr1_emissions_from_elec_grid_net_if_selected_lbs_NOx] = @expression(m, sum(m[:yr1_emissions_from_elec_grid_net_if_selected_series_lbs_NOx][ts] for ts in p.time_steps))
m[:yr1_emissions_from_elec_grid_net_if_selected_lbs_SO2] = @expression(m, sum(m[:yr1_emissions_from_elec_grid_net_if_selected_series_lbs_SO2][ts] for ts in p.time_steps))
m[:yr1_emissions_from_elec_grid_net_if_selected_lbs_PM25] = @expression(m, sum(m[:yr1_emissions_from_elec_grid_net_if_selected_series_lbs_PM25][ts] for ts in p.time_steps))

m[:EmissionsYr1_Total_LbsCO2] = m[:yr1_emissions_onsite_fuel_lbs_CO2] + m[:yr1_emissions_from_elec_grid_net_if_selected_lbs_CO2]
m[:EmissionsYr1_Total_LbsNOx] = m[:yr1_emissions_onsite_fuel_lbs_NOx] + m[:yr1_emissions_from_elec_grid_net_if_selected_lbs_NOx]
Expand All @@ -65,22 +76,22 @@ Function to calculate annual emissions from onsite fuel consumption.
account for expected operations during modeled outages (time_steps_without_grid is empty)
"""
function calc_yr1_emissions_from_onsite_fuel(m,p; tech_array=p.techs.fuel_burning) # also run this with p.techs.boiler
yr1_emissions_onsite_fuel_lbs_CO2 = @expression(m,p.hours_per_time_step*
sum(m[:dvFuelUsage][t,ts]*p.tech_emissions_factors_CO2[t] for t in tech_array, ts in p.time_steps))
yr1_emissions_onsite_fuel_series_lbs_CO2 = @expression(m, [ts in p.time_steps], p.hours_per_time_step*
sum(m[:dvFuelUsage][t,ts]*p.tech_emissions_factors_CO2[t] for t in tech_array))

yr1_emissions_onsite_fuel_lbs_NOx = @expression(m,p.hours_per_time_step*
sum(m[:dvFuelUsage][t,ts]*p.tech_emissions_factors_NOx[t] for t in tech_array, ts in p.time_steps))
yr1_emissions_onsite_fuel_series_lbs_NOx = @expression(m, [ts in p.time_steps], p.hours_per_time_step*
sum(m[:dvFuelUsage][t,ts]*p.tech_emissions_factors_NOx[t] for t in tech_array))

yr1_emissions_onsite_fuel_lbs_SO2 = @expression(m,p.hours_per_time_step*
sum(m[:dvFuelUsage][t,ts]*p.tech_emissions_factors_SO2[t] for t in tech_array, ts in p.time_steps))
yr1_emissions_onsite_fuel_series_lbs_SO2 = @expression(m, [ts in p.time_steps], p.hours_per_time_step*
sum(m[:dvFuelUsage][t,ts]*p.tech_emissions_factors_SO2[t] for t in tech_array))

yr1_emissions_onsite_fuel_lbs_PM25 = @expression(m,p.hours_per_time_step*
sum(m[:dvFuelUsage][t,ts]*p.tech_emissions_factors_PM25[t] for t in tech_array, ts in p.time_steps))
yr1_emissions_onsite_fuel_series_lbs_PM25 = @expression(m, [ts in p.time_steps], p.hours_per_time_step*
sum(m[:dvFuelUsage][t,ts]*p.tech_emissions_factors_PM25[t] for t in tech_array))

return yr1_emissions_onsite_fuel_lbs_CO2,
yr1_emissions_onsite_fuel_lbs_NOx,
yr1_emissions_onsite_fuel_lbs_SO2,
yr1_emissions_onsite_fuel_lbs_PM25
return yr1_emissions_onsite_fuel_series_lbs_CO2,
yr1_emissions_onsite_fuel_series_lbs_NOx,
yr1_emissions_onsite_fuel_series_lbs_SO2,
yr1_emissions_onsite_fuel_series_lbs_PM25
end

"""
Expand All @@ -96,54 +107,54 @@ Function to calculate annual emissions from grid electricity consumption.
account for expected operations during modeled outages (time_steps_without_grid is empty)
"""
function calc_yr1_emissions_from_elec_grid_purchase(m,p)
yr1_emissions_from_elec_grid_lbs_CO2 = @expression(m,p.hours_per_time_step*
sum(m[:dvGridPurchase][ts, tier]*p.s.electric_utility.emissions_factor_series_lb_CO2_per_kwh[ts] for ts in p.time_steps, tier in 1:p.s.electric_tariff.n_energy_tiers))
yr1_emissions_from_elec_grid_series_lbs_CO2 = @expression(m, [ts in p.time_steps], p.hours_per_time_step*
sum(m[:dvGridPurchase][ts, tier]*p.s.electric_utility.emissions_factor_series_lb_CO2_per_kwh[ts] for tier in 1:p.s.electric_tariff.n_energy_tiers))

yr1_emissions_from_elec_grid_lbs_NOx = @expression(m,p.hours_per_time_step*
sum(m[:dvGridPurchase][ts, tier]*p.s.electric_utility.emissions_factor_series_lb_NOx_per_kwh[ts] for ts in p.time_steps, tier in 1:p.s.electric_tariff.n_energy_tiers))
yr1_emissions_from_elec_grid_series_lbs_NOx = @expression(m, [ts in p.time_steps], p.hours_per_time_step*
sum(m[:dvGridPurchase][ts, tier]*p.s.electric_utility.emissions_factor_series_lb_NOx_per_kwh[ts] for tier in 1:p.s.electric_tariff.n_energy_tiers))

yr1_emissions_from_elec_grid_lbs_SO2 = @expression(m,p.hours_per_time_step*
sum(m[:dvGridPurchase][ts, tier]*p.s.electric_utility.emissions_factor_series_lb_SO2_per_kwh[ts] for ts in p.time_steps, tier in 1:p.s.electric_tariff.n_energy_tiers))
yr1_emissions_from_elec_grid_series_lbs_SO2 = @expression(m, [ts in p.time_steps], p.hours_per_time_step*
sum(m[:dvGridPurchase][ts, tier]*p.s.electric_utility.emissions_factor_series_lb_SO2_per_kwh[ts] for tier in 1:p.s.electric_tariff.n_energy_tiers))

yr1_emissions_from_elec_grid_lbs_PM25 = @expression(m,p.hours_per_time_step*
sum(m[:dvGridPurchase][ts, tier]*p.s.electric_utility.emissions_factor_series_lb_PM25_per_kwh[ts] for ts in p.time_steps, tier in 1:p.s.electric_tariff.n_energy_tiers))
yr1_emissions_from_elec_grid_series_lbs_PM25 = @expression(m, [ts in p.time_steps], p.hours_per_time_step*
sum(m[:dvGridPurchase][ts, tier]*p.s.electric_utility.emissions_factor_series_lb_PM25_per_kwh[ts] for tier in 1:p.s.electric_tariff.n_energy_tiers))

return yr1_emissions_from_elec_grid_lbs_CO2,
yr1_emissions_from_elec_grid_lbs_NOx,
yr1_emissions_from_elec_grid_lbs_SO2,
yr1_emissions_from_elec_grid_lbs_PM25
return yr1_emissions_from_elec_grid_series_lbs_CO2,
yr1_emissions_from_elec_grid_series_lbs_NOx,
yr1_emissions_from_elec_grid_series_lbs_SO2,
yr1_emissions_from_elec_grid_series_lbs_PM25
end


function calc_yr1_emissions_offset_from_elec_exports(m, p)
if !(p.s.site.include_exported_elec_emissions_in_total)
return 0.0, 0.0, 0.0, 0.0
end
yr1_emissions_offset_from_elec_exports_lbs_CO2 = @expression(m, p.hours_per_time_step *
yr1_emissions_offset_from_elec_exports_series_lbs_CO2 = @expression(m, [ts in p.time_steps], p.hours_per_time_step *
sum(m[:dvProductionToGrid][t,u,ts] * (p.s.electric_utility.emissions_factor_series_lb_CO2_per_kwh[ts])
for t in p.techs.elec, ts in p.time_steps, u in p.export_bins_by_tech[t])
for t in p.techs.elec, u in p.export_bins_by_tech[t])
)
# if battery ends up being able to discharge to grid, need to incorporate here- might require complex tracking of what's charging battery

yr1_emissions_offset_from_elec_exports_lbs_NOx = @expression(m, p.hours_per_time_step *
yr1_emissions_offset_from_elec_exports_series_lbs_NOx = @expression(m, [ts in p.time_steps], p.hours_per_time_step *
sum(m[:dvProductionToGrid][t,u,ts] * (p.s.electric_utility.emissions_factor_series_lb_NOx_per_kwh[ts])
for t in p.techs.elec, ts in p.time_steps, u in p.export_bins_by_tech[t])
for t in p.techs.elec, u in p.export_bins_by_tech[t])
)

yr1_emissions_offset_from_elec_exports_lbs_SO2 = @expression(m, p.hours_per_time_step *
yr1_emissions_offset_from_elec_exports_series_lbs_SO2 = @expression(m, [ts in p.time_steps], p.hours_per_time_step *
sum(m[:dvProductionToGrid][t,u,ts] * (p.s.electric_utility.emissions_factor_series_lb_SO2_per_kwh[ts])
for t in p.techs.elec, ts in p.time_steps, u in p.export_bins_by_tech[t])
for t in p.techs.elec, u in p.export_bins_by_tech[t])
)

yr1_emissions_offset_from_elec_exports_lbs_PM25 = @expression(m, p.hours_per_time_step *
yr1_emissions_offset_from_elec_exports_series_lbs_PM25 = @expression(m, [ts in p.time_steps], p.hours_per_time_step *
sum(m[:dvProductionToGrid][t,u,ts] * (p.s.electric_utility.emissions_factor_series_lb_PM25_per_kwh[ts])
for t in p.techs.elec, ts in p.time_steps, u in p.export_bins_by_tech[t])
for t in p.techs.elec, u in p.export_bins_by_tech[t])
)

return yr1_emissions_offset_from_elec_exports_lbs_CO2,
yr1_emissions_offset_from_elec_exports_lbs_NOx,
yr1_emissions_offset_from_elec_exports_lbs_SO2,
yr1_emissions_offset_from_elec_exports_lbs_PM25
return yr1_emissions_offset_from_elec_exports_series_lbs_CO2,
yr1_emissions_offset_from_elec_exports_series_lbs_NOx,
yr1_emissions_offset_from_elec_exports_series_lbs_SO2,
yr1_emissions_offset_from_elec_exports_series_lbs_PM25
end


Expand Down
Loading
Loading