Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
3931a81
set up testing
hdunham Jan 14, 2025
41af908
add results to compare to
hdunham Jan 14, 2025
f6afbd0
Update debugging_tests.jl
hdunham Jan 14, 2025
94192fe
add dc_coupled_with_battery option to PV model
hdunham Oct 18, 2023
001a6ee
rename result file
hdunham Jan 14, 2025
9e8f5e4
update testing
hdunham Jan 14, 2025
f79e4a6
warn that PV inv_eff ignored if dc_coupled_with_electric_storage
hdunham Oct 18, 2023
584bc3f
create dc and ac coupled tech sets
hdunham Oct 19, 2023
1d655ce
store dc_(dis)charge_efficiency in ElectricStorage
hdunham Oct 19, 2023
195bd5e
test checkpoint
hdunham Jan 14, 2025
1be7e8c
return dc prod if dc_coupled_with_battery in call_pvwatts_api
hdunham Oct 18, 2023
8b4ad0b
correct call_pvwatts_api arg issues
hdunham Oct 19, 2023
5bdd53d
REVERT LATER temp return ac prod for dc coupled
hdunham Jan 14, 2025
a741853
create dvDCCoupledTechStorageInverterSize
hdunham Oct 19, 2023
caa574c
create DV for dc coupled inverter size
hdunham Nov 9, 2023
8ee32a6
add dc_couple_inverter_size_kw to ElectricStorage results
hdunham Nov 10, 2023
42b00b3
rename to dc_coupled_with_storage
hdunham Nov 10, 2023
28f36a7
make dc coupled constraints compatible with multinode
hdunham Nov 14, 2023
a61629e
call dc coupled constraints if dc coupled tech not not empty
hdunham Nov 14, 2023
ee0e7d0
update consrtaint on dvDCCoupledTechStorageInverterSize
hdunham Nov 14, 2023
a5072f5
don't let AC coupled techs charge dc coupled bess
hdunham Jan 14, 2025
adc276d
update test scenarios
hdunham Jan 14, 2025
7b6c0fe
update testing
hdunham Jan 14, 2025
ce59f4f
update testing
hdunham Jan 14, 2025
78dab57
Revert "don't let AC coupled techs charge dc coupled bess"
hdunham Jan 14, 2025
68cda37
Update debugging_tests.jl
hdunham Jan 14, 2025
266f472
testing checkpoint
hdunham Jan 14, 2025
3f25088
Reapply "don't let AC coupled techs charge dc coupled bess"
hdunham Jan 14, 2025
878f864
update testing
hdunham Jan 14, 2025
5eab825
Revert "don't let AC coupled techs charge dc coupled bess"
hdunham Jan 14, 2025
06a4c7f
testing checkpoint
hdunham Jan 14, 2025
c0580a5
Reapply "don't let AC coupled techs charge dc coupled bess"
hdunham Jan 14, 2025
99197a3
testing checkpoint after disallowing ac tech to charge dc coupled stor
hdunham Jan 15, 2025
9600ade
separate ac and dc in dvProductionToGrid constraint
hdunham Jan 15, 2025
aea4903
collect DVs that can be DC on one side of load balance
hdunham Nov 21, 2023
aa33cf3
combine loops thru techs.elec in load bal
hdunham Nov 21, 2023
d77b683
separate dc and ac coupled techs in load bal
hdunham Nov 21, 2023
2c0afb0
rearrange load balance without grid
hdunham Nov 22, 2023
d45d82b
separate ac and dc tech terms in unservedload const
hdunham Jan 15, 2025
20e0bd8
testing checkpoint
hdunham Jan 15, 2025
b650cac
add ac dc tech constraints to outage_constraints
hdunham Jan 15, 2025
c1ab4cb
fix and call ac dc tech constraints in outage_constraints
hdunham Nov 23, 2023
636efde
correct add_dc_coupled_tech_elec_storage_constraints
hdunham Nov 23, 2023
61c4762
testing checkpoint
hdunham Jan 15, 2025
d075a4a
separate ac and dc coupled techs in add_elec_storage_dispatch_constra…
hdunham Jan 15, 2025
489c358
note PV size_kw is DC capacity
hdunham Jan 10, 2024
5786602
delete commented out code
hdunham Jan 12, 2024
0c18be6
rm sum for b in storage.types.elec b/c b passed in
hdunham Jan 12, 2024
4ebe22d
Add rectifier direction to dc couple inv min size constraint
hdunham Jan 15, 2025
e96b1fc
readability
hdunham Jan 12, 2024
3be4f2c
testing checkpoint
hdunham Jan 15, 2025
9706854
combine terms that can be DC in AnnualREEleckWh calc
hdunham Jan 12, 2024
b3f926e
separate dc coupled techs in AnnualREEleckWh calc and mult by inv effic
hdunham Jan 15, 2025
c006452
handle ElectricStorage not existing in AnnualREEleckWh calc
hdunham Jan 13, 2024
3422724
rm dupe constraint on dvDCCoupledTechStorageInverterSize
hdunham Jan 15, 2025
42708f9
clarifying comment
hdunham Jan 15, 2025
43d9bfc
test checkpoint (done cherry picking)
hdunham Jan 15, 2025
b7c188c
rm dupe constraints
hdunham Jan 15, 2025
3b65bfb
separate ac and dc techs in add_production_constraints
hdunham Jan 15, 2025
b813c1d
separate ac and dc techs in MG SOC equation
hdunham Jan 15, 2025
5d39b2b
include prod to dc stor from ac techs even tho 0 for future dev ease
hdunham Jan 15, 2025
c4b03ed
test checkpoint (separated ac dc terms)
hdunham Jan 15, 2025
9124b1d
fix misnamed tech sets
hdunham Jan 15, 2025
7459cac
new testing set up to compare effect of incremental changes
hdunham Jan 15, 2025
e5510c9
REVERT "temp return ac prod for dc coupled"
hdunham Jan 15, 2025
c4b2926
correct filename in new test
hdunham Jan 15, 2025
79de826
correct new test
hdunham Jan 15, 2025
6dd3656
test changes (pv size down, pv prod up, lcc down)
hdunham Jan 15, 2025
fd59515
use inv effic in add_production_constraints
hdunham Jan 15, 2025
ca5ea25
use dc_charge_efficiency in SOC constraint
hdunham Jan 15, 2025
74d2f9d
use dc_charge_efficiency in MG SOC constraint
hdunham Jan 15, 2025
13f2459
test changes (pv size down, pv prod down, stor up, lcc down)
hdunham Jan 15, 2025
bf9b05c
in prevent simul (dis)charge consts: separate ac/dc techs, use dc_cha…
hdunham Jan 15, 2025
db3c38c
test changes (only pv to stor down)
hdunham Jan 15, 2025
fa4d844
use inv effic in AnnualREEleckWh calc
hdunham Jan 15, 2025
12c980d
test changes (annual_renewable_electricity_kwhn down)
hdunham Jan 15, 2025
b71c0aa
use inv effic in add_elec_load_balance_constraints
hdunham Feb 4, 2025
565ee28
test changes (stor kwh down, to stor down, inv up, pv up, lcc up)
hdunham Feb 4, 2025
7936131
use inv effic in add_dv_UnservedLoad_constraints
hdunham Feb 4, 2025
a6084d4
test (Outages pv_to_load_series_kw up b/c still DC)
hdunham Feb 4, 2025
bc583b5
use inv effic in results PVtoLoad calc
hdunham Feb 10, 2025
1e6db68
test (no solution change, only output series vals)
hdunham Feb 10, 2025
37b2d7f
rm isempty(p.s.storage.types.elec) ?
hdunham Feb 10, 2025
d5ff54c
condense 3 stor power const into 1
hdunham Feb 11, 2025
2849f31
(MG) condense 3 stor power const into 1
hdunham Feb 11, 2025
d88f903
separate ac and dc coupled techs in elec stor power constraints
hdunham Feb 11, 2025
e87936d
correct separate ac and dc coupled techs in elec stor power constraints
hdunham Feb 11, 2025
6ab6617
test no change
hdunham Feb 11, 2025
14d281f
add dc_coupled input to ElectricStorage
hdunham Feb 11, 2025
638f3c9
create dc_coupled storage set
hdunham Feb 11, 2025
231547c
add dc_coupled input to dc test posts
hdunham Feb 11, 2025
0885aa8
apply efficiencies in stor power constraints
hdunham Feb 11, 2025
0bac613
test (size_kw, size_kwh, pv, lcc all up)
hdunham Feb 11, 2025
9601ec4
use dc_coupled stor set to call add_dc_coupled_tech_elec_storage_cons…
hdunham Feb 11, 2025
0cbe847
add DC to DV name to clarify
hdunham Feb 11, 2025
6f9c860
apply inv and rect effic in dvDCCoupledTechStorageInverterSizeDC cons…
hdunham Feb 11, 2025
059a087
apply inv and rect effic in outages dvDCCoupledTechStorageInverterSiz…
hdunham Feb 11, 2025
defa5cd
merge DC coupled inverter constraints charge/discharge directions
hdunham Feb 11, 2025
4ef6429
test (no change)
hdunham Feb 11, 2025
24ddaa3
check p.s.storage.types.dc_coupled empty not p.techs.dc_couple_with_stor
hdunham Feb 13, 2025
b9e557c
add ac_coupled storage set
hdunham Feb 13, 2025
2483373
always use !isempty(p.s.storage.types.dc_coupled) as condition
hdunham Feb 13, 2025
45e1f0b
update storage cap cost objective term
hdunham Feb 13, 2025
618d21e
update big M calc in outage_constraints
hdunham Feb 13, 2025
57932b1
dvDCCoupledTechStorageInverterSizeDC >= dvStoragePower
hdunham Feb 13, 2025
032527a
test no changes
hdunham Feb 13, 2025
0108a99
rm debuging infos
hdunham Feb 13, 2025
a3d774b
rm commented old line
hdunham Feb 13, 2025
ccca421
index dvDCCoupledTechStorageInverterSizeDC on only dc coupled stors
hdunham Feb 13, 2025
940a86b
update check before getting result
hdunham Feb 13, 2025
3cd3ea1
test no changes
hdunham Feb 13, 2025
4ee31a7
rename dc_couple_with_stor to dc_coupled_with_storage
hdunham Feb 13, 2025
338a640
formatting
hdunham Feb 25, 2025
7312563
Don’t allow existing PV that is DC coupled
hdunham Feb 25, 2025
30eccac
Enforce storage dc coupled input to be true if PV one is
hdunham Feb 26, 2025
b7b4976
add missed end
hdunham Feb 26, 2025
500bf01
test no changes
hdunham Feb 26, 2025
7112d00
test error if PV dc coupled but not stor
hdunham Feb 26, 2025
87914c7
Revert "test error if PV dc coupled but not stor"
hdunham Feb 26, 2025
eeed005
error if stor dc coupled but pv not
hdunham Feb 26, 2025
7b1b445
Merge branch 'develop' into new-dc-couple
hdunham Mar 10, 2025
3a43c08
Merge branch 'develop' into new-dc-couple
hdunham Mar 10, 2025
72dd5d8
use dc coupled inverter size in battery capex result
hdunham Mar 10, 2025
2160481
use dc coupled inverter size in initial_capex function
hdunham Mar 10, 2025
a20d835
rename p.techs.ac_couple_with_stor to ac_coupled_with_storage
hdunham Mar 11, 2025
20221a3
test only emissions changes
hdunham Mar 11, 2025
52d5414
use dc coupled inverter size in proforma
hdunham Mar 11, 2025
53dc3f1
fix batt size and inverter size switched
hdunham Mar 12, 2025
48f447b
default can_grid_charge to false if dc_coupled
hdunham Mar 12, 2025
01f5a01
error if off grid and dc coupling
hdunham Mar 12, 2025
c8dd58e
handle MPCElectricStorage not having dc_coupled field
hdunham Mar 13, 2025
862803d
update no ac to dc and visa versa charging
hdunham Mar 13, 2025
fc26f3b
rm dc tech to ac stor term causing attr error
hdunham Mar 13, 2025
744005a
use dc_coupled set not attr for MPC compat
hdunham Mar 13, 2025
42ee652
in proforma only get dc_couple_inverter_size_kw if dc_coupled
hdunham Mar 13, 2025
5b0160e
rename to dc_coupled_inverter_size_kw
hdunham Mar 13, 2025
938a7e7
test no changes
hdunham Mar 13, 2025
9d8ea4b
debugging
hdunham Mar 13, 2025
a7d49e5
rm debugging files
hdunham Mar 13, 2025
dabc419
(MG) update no ac to dc and visa versa charging
hdunham Mar 13, 2025
97492e7
apply inv effic to dvProdIncent const
hdunham Mar 13, 2025
1d9faa8
use ac and dc coupled storage sets to reduce # of constr
hdunham Mar 14, 2025
4c14340
warn in ERP if elec stor is dc coupled
hdunham Mar 14, 2025
64aa393
don't expose <>charge_efficiency fields
hdunham Mar 14, 2025
12ef848
debug offgrid
hdunham Mar 14, 2025
95186d4
Revert "debug offgrid"
hdunham Mar 14, 2025
cdef19e
intersect not union oops
hdunham Mar 14, 2025
e2226ae
Update CHANGELOG.md
hdunham Mar 14, 2025
1fa603a
delete unused testing files
hdunham Mar 14, 2025
ff4e893
Merge branch 'develop' into new-dc-couple
hdunham Mar 17, 2025
1a3d949
Update CHANGELOG.md
adfarth Mar 26, 2025
0082851
rm dc_discharge_efficiency from ElectricStorage
hdunham Mar 28, 2025
722122c
Merge branch 'new-dc-couple' of https://github.com/NREL/REopt.jl into…
hdunham Mar 28, 2025
63c998a
test no changes
hdunham Mar 28, 2025
6214f80
change dc coupled inv size to AC
hdunham Mar 28, 2025
1b95021
test no meaningful changes
hdunham Mar 28, 2025
57c5ffa
use set storage.types.dc_coupled in Scenario()
hdunham Mar 28, 2025
c63e86e
test no changes
hdunham Mar 31, 2025
3f4b69b
add ac prefix to (dis)charge_efficiency
hdunham Apr 1, 2025
344c521
rename to dvHybridInverterSizeAC
hdunham Apr 1, 2025
9a95fda
todo comment
hdunham Apr 1, 2025
8536f9c
default ElectricStorage.dc_coupled=true if any PV.dc_coupled_with_sto…
hdunham Apr 1, 2025
c2c1bfd
fix syntax
hdunham Apr 1, 2025
3bf2cd9
rm dc_coupled input from tests to test default behavior
hdunham Apr 1, 2025
72fa189
test no changes
hdunham Apr 1, 2025
4a2a579
update constraint numbering
hdunham Jun 10, 2025
89c432a
update constraint numbering/comment
hdunham Jul 2, 2025
b99841f
use time_step_wrap_around more places where needed
hdunham Aug 7, 2025
526654e
update comment
hdunham Aug 7, 2025
1034c6f
Apply rectifier efficiency when dc coupled in OR constraints 1,4
hdunham Sep 10, 2025
72dc85c
handle dc coupled stor in OR constr 3
hdunham Sep 10, 2025
ec3dea1
docstring notes about cost defaults being ac coupled
hdunham Oct 29, 2025
542f67a
small helptext update
adfarth Nov 19, 2025
7eb1b32
minor comment mods
adfarth Nov 20, 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
27 changes: 18 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ Classify the change according to the following categories:
### Deprecated
### Removed

## new-dc-couple
### Added
- Add option to model DC-coupled **PV** and **ElectricStorage**
- Add **PV** input **dc_coupled_with_storage** and **ElectricStorage** input **dc_coupled**, which both default to _false_
Comment thread
adfarth marked this conversation as resolved.
- **ElectricStorage** inputs **inverter_efficiency_fraction** and **rectifier_efficiency_fraction** define the DC-coupled inverter and **PV** input **inv_eff** is ignored
- Add sets in **Techs** struct (**dc_coupled_with_storage** and **ac_coupled_with_storage**) and **StorageTypes** struct (**dc_coupled** and **ac_coupled**)
- Modify constraints to account for AC and DC coupling
### Removed
- Don't expose **ElectricStorage** fields **charge_efficiency**, **discharge_efficiency**, and **grid_charge_efficiency**. It can lead to unexpected behavior when users provide these instead of the inputs they are calculated from (**inverter_efficiency_fraction**, **rectifier_efficiency_fraction**, and **internal_efficiency_fraction**).

## v0.51.1
### Added
Expand Down Expand Up @@ -70,7 +79,7 @@ Classify the change according to the following categories:

## v0.50.0
### Added
- New parameter `force_dispatch` in the **ASHPSpaceHeater** and **ASHPWaterHeater** technologies (default = `true`). When kept at `true`, the ASHP's thermal output will be the minimum of the site load(s) served and the system size (adjusted for timestep-specific capacity factor) in each period. If set to `false`, ASHP will do economic dispatch considering COP and CF along with electricity prices.
- New parameter `force_dispatch` in the **ASHPSpaceHeater** and **ASHPWaterHeater** technologies (default = _true_). When kept at _true_, the ASHP's thermal output will be the minimum of the site load(s) served and the system size (adjusted for timestep-specific capacity factor) in each period. If set to `false`, ASHP will do economic dispatch considering COP and CF along with electricity prices.
### Fixed
- Align heating and cooling load profiles based on electric load year input, if using custom electric load profile with simulated (CRB or schedule-based flatloads) heating/cooling loads
- Handling of leap years for `ElectricLoad.loads_kw` inputs to align with URDB rate structures
Expand Down Expand Up @@ -334,7 +343,7 @@ Classify the change according to the following categories:

## v0.37.0
### Added
- Added Bool attribute `is_electric_only` to CHP; if true, default installed and O&M costs are reduced by 25% and, for the reciprocating engine and combustion turbine prime movers, the federal ITC fraction is reduced to zero.
- Added Bool attribute `is_electric_only` to CHP; if _true_, default installed and O&M costs are reduced by 25% and, for the reciprocating engine and combustion turbine prime movers, the federal ITC fraction is reduced to zero.
- Las Vegas CRB data was missing from ElectricLoad, but the climate_cities.shp file does not distinguish between Las Angeles and Las Vegas
### Changed
- Update `CHP.size_class` after heuristic size is determined based on size_class=0 guess (not input)
Expand Down Expand Up @@ -654,7 +663,7 @@ The following name changes were made:
- The `GhpGhx` module calls for sizing the GHE can only be done if you first "add https://github.com/NREL/GhpGhx.jl" to the environment and then load the package by "using GhpGhx" before running REopt with `GHP`.
- The `GHP` size and dispatch of the different `GHP` options is pre-determined by the `GhpGhx` package, so the REopt model just chooses one or none of the `GHP` options with a binary decision variable.
### Changed
- Change default value for `wind.jl` **operating_reserve_required_pct** from 0.1 to 0.5 (only applicable when **off_grid_flag**=_True_.)
- Change default value for `wind.jl` **operating_reserve_required_pct** from 0.1 to 0.5 (only applicable when **off_grid_flag**=_true_.)
- allow user to specify emissions_region in ElectricUtility, which is used instead of lat/long to look up AVERT data if emissions factors aren't provided by the user
- Updated results keys in `results/absorption_chiller.jl`
### Fixed
Expand All @@ -678,7 +687,7 @@ The following name changes were made:
- constrain renewable electricity percentage based on user inputs
- Add "Emissions and Renewable Energy Percent" testset
### Changed
- Allow Wind tech to be included when `off_grid_flag` is true
- Allow Wind tech to be included when `off_grid_flag` is _true_
- Add `operating_reserve_required_pct` to Wind struct and incorporate wind into operating reserve constraints
- Add hot, cold TES results for MPC model
- Update documentation and add `docs/devdeploy.jl` to locally host the REopt.jl documentation
Expand All @@ -699,13 +708,13 @@ The following name changes were made:

## v0.16.1
### Fixed
- bug fix for outage simulator when `microgrid_only=true`
- bug fix for outage simulator when `microgrid_only`=_true_

## v0.16.0
### Added
Allows users to model "off-grid" systems as a year-long outage:
- add flag to "turn on" off-grid modeling `Settings.off_grid_flag`
- when `off_grid_flag` is "true", adjust default values in core/ `electric_storage`, `electric_load`, `financial`, `generator`, `pv`
- when `off_grid_flag` is _true_, adjust default values in core/ `electric_storage`, `electric_load`, `financial`, `generator`, `pv`
- add operating reserve requirement inputs, outputs, and constraints based on load and PV generation
- add minimum load met percent input and constraint
- add generator replacement year and cost (for off-grid and on-grid)
Expand Down Expand Up @@ -803,7 +812,7 @@ Other changes:
- all of these tiered rates require binaries, which are conditionally added to the model
- add modeling capability for lookback demand charges
- add more outputs from the API (eg. `initial_capital_costs`)
- add option to run Business As Usual scenario in parallel with optimal scenario (default is `true`)
- add option to run Business As Usual scenario in parallel with optimal scenario (default is _true_)
- add incentives (and cost curves) to `Wind` and `Generator`
### Changed
- removed "_us_dollars" from all names and generally aligned names with API
Expand All @@ -813,7 +822,7 @@ Other changes:

## v0.9.0
### Changed
- `ElectricTariff.NEM` boolean is now determined by `ElectricUtility.net_metering_limit_kw` (true if limit > 0)
- `ElectricTariff.NEM` boolean is now determined by `ElectricUtility.net_metering_limit_kw` (_true_ if limit > 0)
### Added
- add `ElectricUtility` inputs for `net_metering_limit_kw` and `interconnection_limit_kw`
- add binary choice for net metering vs. wholesale export
Expand Down Expand Up @@ -929,7 +938,7 @@ Other changes:
- include existing capacity in microgrid upgrade cost
- previously only had to pay to upgrade new capacity
- implement ElectricLoad `loads_kw_is_net` and `critical_loads_kw_is_net`
- add existing PV production to raw load profile if `true`
- add existing PV production to raw load profile if _true_
- add `min_resil_time_steps` input and optional constraint for minimum time_steps that critical load must be met in every outage
### Fixed
- enforce storage cannot grid charge
Expand Down
7 changes: 0 additions & 7 deletions src/constraints/electric_utility_constraints.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# REopt®, Copyright (c) Alliance for Sustainable Energy, LLC. See also https://github.com/NREL/REopt.jl/blob/master/LICENSE.
function add_export_constraints(m, p; _n="")

##Constraint (8e): Production export and curtailment no greater than production
Comment thread
adfarth marked this conversation as resolved.
@constraint(m, [t in p.techs.elec, ts in p.time_steps_with_grid],
p.production_factor[t,ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
>= sum(m[Symbol("dvProductionToGrid"*_n)][t, u, ts] for u in p.export_bins_by_tech[t]) +
m[Symbol("dvCurtail"*_n)][t, ts]
)

binNEM = 0
binWHL = 0
NEM_benefit = 0
Expand Down
78 changes: 56 additions & 22 deletions src/constraints/load_balance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ function add_elec_load_balance_constraints(m, p; _n="")
##Constraint (8a): Electrical Load Balancing with Grid
if isempty(p.s.electric_tariff.export_bins)
conrefs = @constraint(m, [ts in p.time_steps_with_grid],
sum(p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts] for t in p.techs.elec)
+ sum(m[Symbol("dvDischargeFromStorage"*_n)][b,ts] for b in p.s.storage.types.elec)
sum(p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
- sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.ac_coupled)
- m[Symbol("dvCurtail"*_n)][t, ts]
for t in p.techs.ac_coupled_with_storage)
+ sum(p.s.storage.attr["ElectricStorage"].inverter_efficiency_fraction * ( # convert DC to AC
p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
- sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.dc_coupled)
- m[Symbol("dvCurtail"*_n)][t, ts])
for t in p.techs.dc_coupled_with_storage)
+ sum(m[Symbol("dvDischargeFromStorage"*_n)][b,ts] for b in p.s.storage.types.elec) # dvDischargeFromStorage is AC
+ sum(m[Symbol("dvGridPurchase"*_n)][ts, tier] for tier in 1:p.s.electric_tariff.n_energy_tiers)
==
sum(sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.elec)
+ 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("dvGridToStorage"*_n)][b, ts] for b in p.s.storage.types.elec)
+ sum(m[Symbol("dvCoolingProduction"*_n)][t, ts] / p.cooling_cop[t][ts] for t in setdiff(p.techs.cooling,p.techs.ghp))
+ sum(m[Symbol("dvHeatingProduction"*_n)][t, q, ts] / p.heating_cop[t][ts] for q in p.heating_loads, t in p.techs.electric_heater)
+ p.s.electric_load.loads_kw[ts]
Expand All @@ -20,13 +26,19 @@ function add_elec_load_balance_constraints(m, p; _n="")
)
else
conrefs = @constraint(m, [ts in p.time_steps_with_grid],
sum(p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts] for t in p.techs.elec)
sum(p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
- sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.ac_coupled)
- m[Symbol("dvCurtail"*_n)][t, ts]
for t in p.techs.ac_coupled_with_storage)
+ sum(p.s.storage.attr["ElectricStorage"].inverter_efficiency_fraction * ( # convert DC to AC
p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
- sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.dc_coupled)
- m[Symbol("dvCurtail"*_n)][t, ts])
for t in p.techs.dc_coupled_with_storage)
+ sum(m[Symbol("dvDischargeFromStorage"*_n)][b,ts] for b in p.s.storage.types.elec )
+ sum(m[Symbol("dvGridPurchase"*_n)][ts, tier] for tier in 1:p.s.electric_tariff.n_energy_tiers)
==
sum(sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.elec)
+ sum(m[Symbol("dvProductionToGrid"*_n)][t, u, ts] for u in p.export_bins_by_tech[t])
+ m[Symbol("dvCurtail"*_n)][t, ts] for t in p.techs.elec)
sum(m[Symbol("dvProductionToGrid"*_n)][t, u, ts] for t in p.techs.elec, u in p.export_bins_by_tech[t])
+ sum(m[Symbol("dvGridToStorage"*_n)][b, ts] for b in p.s.storage.types.elec)
+ sum(m[Symbol("dvCoolingProduction"*_n)][t, ts] / p.cooling_cop[t][ts] for t in setdiff(p.techs.cooling,p.techs.ghp))
+ sum(m[Symbol("dvHeatingProduction"*_n)][t, q, ts] / p.heating_cop[t][ts] for q in p.heating_loads, t in p.techs.electric_heater)
Expand All @@ -43,21 +55,34 @@ function add_elec_load_balance_constraints(m, p; _n="")
##Constraint (8b): Electrical Load Balancing without Grid
if !p.s.settings.off_grid_flag # load balancing constraint for grid-connected runs
@constraint(m, [ts in p.time_steps_without_grid],
sum(p.production_factor[t,ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts] for t in p.techs.elec)
sum(p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
- sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.ac_coupled)
- m[Symbol("dvCurtail"*_n)][t, ts]
for t in p.techs.ac_coupled_with_storage)
+ sum(p.s.storage.attr["ElectricStorage"].inverter_efficiency_fraction * ( # convert DC to AC
p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
- sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.dc_coupled)
- m[Symbol("dvCurtail"*_n)][t, ts])
for t in p.techs.dc_coupled_with_storage)
+ sum(m[Symbol("dvDischargeFromStorage"*_n)][b,ts] for b in p.s.storage.types.elec)
==
sum(sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.elec)
+ m[Symbol("dvCurtail"*_n)][t, ts] for t in p.techs.elec)
+ p.s.electric_load.critical_loads_kw[ts]
p.s.electric_load.critical_loads_kw[ts]
)
else # load balancing constraint for off-grid runs
# TODO: make off-grid compatible with dc coupled tech + storage by updating add_operating_reserve_constraints
@constraint(m, [ts in p.time_steps_without_grid],
sum(p.production_factor[t,ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts] for t in p.techs.elec)
sum(p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
Copy link
Copy Markdown
Collaborator

@adfarth adfarth Apr 1, 2025

Choose a reason for hiding this comment

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

is this just partially set up for off-grid runs for if you have time to finish this in the future (with the OR constraints)? If so, maybe add a note / TODO here?

- sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.ac_coupled)
- m[Symbol("dvCurtail"*_n)][t, ts]
for t in p.techs.ac_coupled_with_storage)
+ sum(p.s.storage.attr["ElectricStorage"].inverter_efficiency_fraction * ( # convert DC to AC
p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t,ts]
- sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.dc_coupled)
- m[Symbol("dvCurtail"*_n)][t, ts])
for t in p.techs.dc_coupled_with_storage)
+ sum(m[Symbol("dvDischargeFromStorage"*_n)][b,ts] for b in p.s.storage.types.elec)
==
sum(sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.elec)
+ m[Symbol("dvCurtail"*_n)][t, ts] for t in p.techs.elec)
+ p.s.electric_load.critical_loads_kw[ts] * m[Symbol("dvOffgridLoadServedFraction"*_n)][ts]
p.s.electric_load.critical_loads_kw[ts] * m[Symbol("dvOffgridLoadServedFraction"*_n)][ts]
)
##Constraint : For off-grid scenarios, annual load served must be >= minimum percent specified
@constraint(m,
Expand All @@ -80,12 +105,21 @@ function add_production_constraints(m, p; _n="")
p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t, ts]
)
else
@constraint(m, [t in p.techs.elec, ts in p.time_steps_with_grid],
sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.elec)
+ m[Symbol("dvCurtail"*_n)][t, ts]
+ sum(m[Symbol("dvProductionToGrid"*_n)][t, u, ts] for u in p.export_bins_by_tech[t])
<=
@constraint(m, [t in p.techs.ac_coupled_with_storage, ts in p.time_steps_with_grid],
sum(m[Symbol("dvProductionToGrid"*_n)][t, u, ts] for u in p.export_bins_by_tech[t])
<=
p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t, ts]
- sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.elec)
- m[Symbol("dvCurtail"*_n)][t, ts]
)
@constraint(m, [t in p.techs.dc_coupled_with_storage, ts in p.time_steps_with_grid],
sum(m[Symbol("dvProductionToGrid"*_n)][t, u, ts] for u in p.export_bins_by_tech[t])
<=
p.s.storage.attr["ElectricStorage"].inverter_efficiency_fraction * (
p.production_factor[t, ts] * p.levelization_factor[t] * m[Symbol("dvRatedProduction"*_n)][t, ts]
- sum(m[Symbol("dvProductionToStorage"*_n)][b, t, ts] for b in p.s.storage.types.elec)
- m[Symbol("dvCurtail"*_n)][t, ts]
)
)
end

Expand Down
Loading
Loading