Skip to content

Commit

Permalink
Merge pull request #380 from NREL/develop
Browse files Browse the repository at this point in the history
Lookback demand charge fixes
  • Loading branch information
Bill-Becker authored Nov 10, 2022
2 parents ba13ccb + b045279 commit 17edd5e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 216 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ Classify the change according to the following categories:
##### Deprecated
##### Removed
### Patches

## v2.3.1
### Minor Updates
##### Fixed
Lookback charge parameters expected from the URDB API call were changed to the non-caplitalized format, so they are now used properly.

## v2.3.0
### Minor Updates
Expand Down
102 changes: 54 additions & 48 deletions julia_src/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ version = "3.4.0"

[[deps.ArchGDAL]]
deps = ["CEnum", "ColorTypes", "Dates", "DiskArrays", "Extents", "GDAL", "GeoFormatTypes", "GeoInterface", "GeoInterfaceRecipes", "ImageCore", "Tables"]
git-tree-sha1 = "65cdad9f49e0d2fec6b6abc80668ca49c034824b"
git-tree-sha1 = "83b8798c00f556c0a8ac89cad7bde716a28fe9c9"
uuid = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
version = "0.9.1"
version = "0.9.2"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand Down Expand Up @@ -73,9 +73,9 @@ version = "0.5.1"

[[deps.ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "dc4405cee4b2fe9e1108caec2d760b7ea758eca2"
git-tree-sha1 = "e7ff6cadf743c098e08fca25c91103ee4303c9bb"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.15.5"
version = "1.15.6"

[[deps.ChangesOfVariables]]
deps = ["ChainRulesCore", "LinearAlgebra", "Test"]
Expand Down Expand Up @@ -114,9 +114,9 @@ uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.12.8"

[[deps.CommonSolve]]
git-tree-sha1 = "332a332c97c7071600984b3c31d9067e1a4e6e25"
git-tree-sha1 = "9441451ee712d1aec22edad62db1a9af3dc8d852"
uuid = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
version = "0.2.1"
version = "0.2.3"

[[deps.CommonSubexpressions]]
deps = ["MacroTools", "Test"]
Expand All @@ -126,9 +126,9 @@ version = "0.3.0"

[[deps.Compat]]
deps = ["Dates", "LinearAlgebra", "UUIDs"]
git-tree-sha1 = "5856d3031cdb1f3b2b6340dfdc66b6d9a149a374"
git-tree-sha1 = "3ca828fe1b75fa84b021a7860bd039eaea84d2f2"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "4.2.0"
version = "4.3.0"

[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
Expand All @@ -153,9 +153,9 @@ uuid = "3351c21f-4feb-5f29-afb9-f4fcb0e27549"
version = "6.4.2+0"

[[deps.DataAPI]]
git-tree-sha1 = "1106fa7e1256b402a86a8e7b15c00c85036fef49"
git-tree-sha1 = "46d2680e618f8abd007bce0c3026cb0c4a8f2032"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.11.0"
version = "1.12.0"

[[deps.DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
Expand All @@ -177,28 +177,28 @@ deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"

[[deps.DiffResults]]
deps = ["StaticArrays"]
git-tree-sha1 = "c18e98cba888c6c25d1c3b048e4b3380ca956805"
deps = ["StaticArraysCore"]
git-tree-sha1 = "782dd5f4561f5d267313f23853baaaa4c52ea621"
uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"
version = "1.0.3"
version = "1.1.0"

[[deps.DiffRules]]
deps = ["IrrationalConstants", "LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"]
git-tree-sha1 = "992a23afdb109d0d2f8802a30cf5ae4b1fe7ea68"
git-tree-sha1 = "8b7a4d23e22f5d44883671da70865ca98f2ebf9d"
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
version = "1.11.1"
version = "1.12.0"

[[deps.DiskArrays]]
deps = ["OffsetArrays"]
git-tree-sha1 = "230d999fc78652ea070312373ed1bfe2489e4fe5"
git-tree-sha1 = "bd0543363fc8ceac0c9fb24d38783ffffd95c20c"
uuid = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
version = "0.3.6"
version = "0.3.7"

[[deps.DocStringExtensions]]
deps = ["LibGit2"]
git-tree-sha1 = "5158c2b41018c5f7eb1470d558127ac274eca0c9"
git-tree-sha1 = "c36550cb29cbe373e95b3f40486b9a4148f89ffd"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.9.1"
version = "0.9.2"

[[deps.Downloads]]
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
Expand All @@ -217,9 +217,9 @@ version = "0.1.1"

[[deps.FileIO]]
deps = ["Pkg", "Requires", "UUIDs"]
git-tree-sha1 = "94f5101b96d2d968ace56f7f2db19d0a5f592e28"
git-tree-sha1 = "7be5f99f7d15578798f338f5433b6c432ea8037b"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.15.0"
version = "1.16.0"

[[deps.FixedPointNumbers]]
deps = ["Statistics"]
Expand Down Expand Up @@ -286,9 +286,9 @@ version = "0.1.0"

[[deps.HDF5]]
deps = ["Compat", "HDF5_jll", "Libdl", "Mmap", "Random", "Requires"]
git-tree-sha1 = "899f041bf330ebeead3637073b2ca7477760edde"
git-tree-sha1 = "19effd6b5af759c8aaeb9c77f89422d3f975ab65"
uuid = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
version = "0.16.11"
version = "0.16.12"

[[deps.HDF5_jll]]
deps = ["Artifacts", "JLLWrappers", "LibCURL_jll", "Libdl", "OpenSSL_jll", "Pkg", "Zlib_jll"]
Expand Down Expand Up @@ -325,9 +325,9 @@ version = "0.6.2"

[[deps.InverseFunctions]]
deps = ["Test"]
git-tree-sha1 = "b3364212fb5d870f724876ffcd34dd8ec6d98918"
git-tree-sha1 = "49510dfcb407e572524ba94aeae2fced1f3feb0f"
uuid = "3587e190-3f89-42d0-90ee-14403ec27112"
version = "0.1.7"
version = "0.1.8"

[[deps.IrrationalConstants]]
git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151"
Expand Down Expand Up @@ -444,9 +444,9 @@ version = "1.9.3+0"

[[deps.MacroTools]]
deps = ["Markdown", "Random"]
git-tree-sha1 = "3d3e902b31198a27340d0bf00d6ac452866021cf"
git-tree-sha1 = "42324d08725e200c23d4dfb549e0d5d89dede2d2"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
version = "0.5.9"
version = "0.5.10"

[[deps.MappedArrays]]
git-tree-sha1 = "e8b359ef06ec72e8c030463fe02efe5527ee5142"
Expand All @@ -465,9 +465,9 @@ version = "0.9.22"

[[deps.MbedTLS]]
deps = ["Dates", "MbedTLS_jll", "MozillaCACerts_jll", "Random", "Sockets"]
git-tree-sha1 = "6872f9594ff273da6d13c7c1a1545d5a8c7d0c1c"
git-tree-sha1 = "03a9b9718f5682ecb107ac9f7308991db4ce395b"
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "1.1.6"
version = "1.1.7"

[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
Expand Down Expand Up @@ -501,9 +501,9 @@ uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"

[[deps.OffsetArrays]]
deps = ["Adapt"]
git-tree-sha1 = "1ea784113a6aa054c5ebd95945fa5e52c2f378e7"
git-tree-sha1 = "f71d8950b724e9ff6110fc948dff5a329f901d64"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.12.7"
version = "1.12.8"

[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
Expand Down Expand Up @@ -550,9 +550,9 @@ version = "0.5.11"

[[deps.Parsers]]
deps = ["Dates"]
git-tree-sha1 = "3d5bf43e3e8b412656404ed9466f1dcbf7c50269"
git-tree-sha1 = "6c01a9b494f6d2a9fc180a08b182fcb06f0958a0"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.4.0"
version = "2.4.2"

[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
Expand All @@ -578,9 +578,9 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[deps.REopt]]
deps = ["ArchGDAL", "CoolProp", "Dates", "DelimitedFiles", "HTTP", "JLD", "JSON", "JuMP", "LinDistFlow", "LinearAlgebra", "Logging", "MathOptInterface", "Requires", "Roots", "Statistics", "TestEnv"]
git-tree-sha1 = "4b2e8b7ec3bc44a68c7a58c20bc42a04ced820e0"
git-tree-sha1 = "70e34138a437cb1a224646c45e230f90ae2d7283"
uuid = "d36ad4e8-d74a-4f7a-ace1-eaea049febf6"
version = "0.20.0"
version = "0.20.1"

[[deps.Random]]
deps = ["SHA", "Serialization"]
Expand All @@ -592,9 +592,10 @@ uuid = "b3c3ace0-ae52-54e7-9d0b-2c1406fd6b9d"
version = "0.3.2"

[[deps.RecipesBase]]
git-tree-sha1 = "6bf3f380ff52ce0832ddd3a2a7b9538ed1bcca7d"
deps = ["SnoopPrecompile"]
git-tree-sha1 = "d12e612bba40d189cead6ff857ddb67bd2e6a387"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "1.2.1"
version = "1.3.1"

[[deps.Reexport]]
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
Expand All @@ -608,19 +609,19 @@ uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.3.0"

[[deps.Roots]]
deps = ["CommonSolve", "Printf", "Setfield"]
git-tree-sha1 = "90a03cebb786c568d3c1f0fb2f71dcb26115e13e"
deps = ["ChainRulesCore", "CommonSolve", "Printf", "Setfield"]
git-tree-sha1 = "a3db467ce768343235032a1ca0830fc64158dadf"
uuid = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
version = "2.0.3"
version = "2.0.8"

[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[deps.SQLite_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "e7c1d14d4c93e2d0f85970f818052de200eba5d2"
git-tree-sha1 = "9d920c4ee8cd5684e23bf84f43ead45c0af796e7"
uuid = "76ed43ae-9a5d-5a62-8c75-30186b810ce8"
version = "3.39.2+0"
version = "3.39.4+0"

[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Expand All @@ -631,6 +632,11 @@ git-tree-sha1 = "e2cc6d8c88613c05e1defb55170bf5ff211fbeac"
uuid = "efcf1570-3423-57d1-acb7-fd33fddbac46"
version = "1.1.1"

[[deps.SnoopPrecompile]]
git-tree-sha1 = "f604441450a3c0569830946e5b33b78c928e1a85"
uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c"
version = "1.0.1"

[[deps.Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

Expand All @@ -652,14 +658,14 @@ version = "0.1.1"

[[deps.StaticArrays]]
deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"]
git-tree-sha1 = "efa8acd030667776248eabb054b1836ac81d92f0"
git-tree-sha1 = "f86b3a049e5d05227b10e15dbb315c5b90f14988"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.5.7"
version = "1.5.9"

[[deps.StaticArraysCore]]
git-tree-sha1 = "ec2bd695e905a3c755b33026954b119ea17f2d22"
git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a"
uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
version = "1.3.0"
version = "1.4.0"

[[deps.Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
Expand All @@ -677,9 +683,9 @@ version = "1.0.1"

[[deps.Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits", "Test"]
git-tree-sha1 = "7149a60b01bf58787a1b83dad93f90d4b9afbe5d"
git-tree-sha1 = "c79322d36826aa2f4fd8ecfa96ddb47b174ac78d"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.8.1"
version = "1.10.0"

[[deps.Tar]]
deps = ["ArgTools", "SHA"]
Expand Down
13 changes: 5 additions & 8 deletions julia_src/reopt_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@ function add_bigM_adjustments(m, p)
for mth in p.Month
if n > 1
m[:NewMaxDemandMonthsInTier][mth,n] = minimum([p.MaxDemandMonthsInTier[n],
added_power + 2*maximum([p.ElecLoad[ts] + p.CoolingLoad[ts] +
added_power + 2*maximum([100*p.ElecLoad[ts] + p.CoolingLoad[ts] +
add_ghp_heating_elec * p.HeatingLoad[ts]
for ts in p.TimeStepRatchetsMonth[mth]]) -
sum(m[:NewMaxDemandMonthsInTier][mth,np] for np in 1:(n-1))]
)
else
m[:NewMaxDemandMonthsInTier][mth,n] = minimum([p.MaxDemandMonthsInTier[n],
added_power + 2*maximum([p.ElecLoad[ts] + p.CoolingLoad[ts] +
added_power + 2*maximum([100*p.ElecLoad[ts] + p.CoolingLoad[ts] +
add_ghp_heating_elec * p.HeatingLoad[ts]
for ts in p.TimeStepRatchetsMonth[mth]])]
)
Expand Down Expand Up @@ -1069,7 +1069,8 @@ function add_tou_demand_charge_constraints(m, p)

if !isempty(p.DemandRates)
m[:DemandTOUCharges] = @expression(m, p.pwf_e * sum( p.DemandRates[r,e] * m[:dvPeakDemandE][r,e] for r in p.Ratchets, e in p.DemandBin) )

else
m[:DemandTOUCharges] = 0.0
end
end

Expand Down Expand Up @@ -1499,11 +1500,7 @@ function reopt_run(m, p::Parameter)
### Constraint set (11): Peak Electrical Power Demand Charges: binDemandMonthsTier
add_monthly_demand_charge_constraints(m, p)
### Constraint set (12): Peak Electrical Power Demand Charges: Ratchets
if !isempty(p.TimeStepRatchets)
add_tou_demand_charge_constraints(m, p)
else
m[:DemandTOUCharges] = 0
end
add_tou_demand_charge_constraints(m, p)
m[:TotalDemandCharges] = @expression(m, m[:DemandTOUCharges] + m[:DemandFlatCharges])

### Constraint set (14): Coincident Peak Charges
Expand Down
34 changes: 17 additions & 17 deletions reo/src/urdb_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def __init__(self, rate):
'demandwindow',
'demandreactivepowercharge',
# lookback demand charges
'lookbackMonths',
'lookbackPercent',
'lookbackRange',
'lookbackmonths',
'lookbackpercent',
'lookbackrange',
# coincident rates
'coincidentrateunit',
'coincidentratestructure',
Expand Down Expand Up @@ -447,31 +447,31 @@ def prepare_demand_periods(self, current_rate):
def prepare_demand_lookback(self, current_rate):
"""
URDB lookback fields:
lookbackMonths
lookbackmonths
Type: array
Array of 12 booleans, true or false, indicating months in which lookbackPercent applies.
If any of these is true, lookbackRange should be zero.
Array of 12 booleans, true or false, indicating months in which lookbackpercent applies.
If any of these is true, lookbackrange should be zero.
lookbackPercent
lookbackpercent
Type: decimal
Lookback percentage. Applies to either lookbackMonths with value=1, or a lookbackRange.
Lookback percentage. Applies to either lookbackmonths with value=1, or a lookbackrange.
lookbackRange
lookbackrange
Type: integer
Number of months for which lookbackPercent applies. If not 0, lookbackMonths values should all be 0.
Number of months for which lookbackpercent applies. If not 0, lookbackmonths values should all be 0.
"""
if current_rate.lookbackPercent in [None, 0, []]:
if current_rate.lookbackpercent in [None, 0, []]:
reopt_lookback_months = []
lookback_percentage = 0
lookback_range = 0
else:
lookback_percentage = current_rate.lookbackPercent or 0.0
lookback_months = current_rate.lookbackMonths # defaults to empty list
lookback_range = current_rate.lookbackRange or 0
lookback_percentage = current_rate.lookbackpercent or 0.0
lookback_months = current_rate.lookbackmonths # defaults to empty list
lookback_range = current_rate.lookbackrange or 0
reopt_lookback_months = []
if lookback_range != 0 and len(lookback_months) == 12:
for month in range(1, 13):
if lookback_months[month] == 1:
if lookback_range == 0 and len(lookback_months) == 12:
for month in range(1,13):
if lookback_months[month-1] == True:
reopt_lookback_months.append(month)

self.reopt_args.demand_lookback_months = reopt_lookback_months
Expand Down
Loading

0 comments on commit 17edd5e

Please sign in to comment.