Skip to content

Commit

Permalink
Merge pull request #260 from NREL/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Bill-Becker authored Sep 2, 2023
2 parents 3fecd74 + 9f77cc0 commit 2aeac21
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Classify the change according to the following categories:
### Deprecated
### Removed

## v0.32.7
### Fixed
- Bugs in EASIUR health cost calcs
- Type handling for CoolingLoad monthly_tonhour input

## v0.32.6
### Changed
- Required **fuel_cost_per_mmbtu** for modeling **Boiler** tech, otherwise throw a handled error.
Expand Down
15 changes: 8 additions & 7 deletions src/core/financial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ function easiur_costs(latitude::Real, longitude::Real, grid_or_onsite::String)
USD_2010_to_2020 = 1.246
try
costs_per_tonne = Dict(
"NOx" => EASIUR_data["NOX_Annual"][x - 1, y - 1] .* USD_2010_to_2020,
"SO2" => EASIUR_data["SO2_Annual"][x - 1, y - 1] .* USD_2010_to_2020,
"PM25" => EASIUR_data["PEC_Annual"][x - 1, y - 1] .* USD_2010_to_2020
"NOx" => EASIUR_data["NOX_Annual"][x, y] .* USD_2010_to_2020,
"SO2" => EASIUR_data["SO2_Annual"][x, y] .* USD_2010_to_2020,
"PM25" => EASIUR_data["PEC_Annual"][x, y] .* USD_2010_to_2020
)
return costs_per_tonne
catch
Expand Down Expand Up @@ -400,12 +400,13 @@ function get_EASIUR2005(stack::String; pop_year::Int64=2005, income_year::Int64=
end

fn_2005 = joinpath(EASIUR_data_lib,"sc_8.6MVSL_$(stack)_pop2005.hdf5")
ret_map = JLD.load(fn_2005)
ret_map = JLD.load(fn_2005)

if pop_year != 2005
fn_growth = joinpath(EASIUR_data_lib,"sc_growth_rate_pop2005_pop2040_$(stack).hdf5")
map_rate = JLD.load(fn_growth)
map_rate = JLD.load(fn_growth)
for (k,v) in map_rate
setindex!(ret_map, v .* (v.^(pop_year - 2005)), k)
setindex!(ret_map, ret_map[k] .* (v.^(pop_year - 2005)), k)
end
end
if income_year != 2005
Expand Down Expand Up @@ -504,4 +505,4 @@ function easiur_data(; latitude::Real, longitude::Real, inflation::Real)
response_dict[ekey*"_cost_escalation_rate_fraction"] = escalation[ekey]
end
return response_dict
end
end
4 changes: 2 additions & 2 deletions src/core/heating_cooling_loads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ function BuiltInDomesticHotWaterLoad(
annual_mmbtu *= addressable_load_fraction
end
if length(monthly_mmbtu) == 12
monthly_mmbtu = convert(Vector{Real}, monthly_mmbtu) .* addressable_load_fraction
monthly_mmbtu = monthly_mmbtu .* addressable_load_fraction
end
built_in_load("domestic_hot_water", city, buildingtype, year, annual_mmbtu, monthly_mmbtu)
end
Expand Down Expand Up @@ -1075,7 +1075,7 @@ function BuiltInSpaceHeatingLoad(
annual_mmbtu *= addressable_load_fraction
end
if length(monthly_mmbtu) == 12
monthly_mmbtu = convert(Vector{Real}, monthly_mmbtu) .* addressable_load_fraction
monthly_mmbtu = monthly_mmbtu .* addressable_load_fraction
end
built_in_load("space_heating", city, buildingtype, year, annual_mmbtu, monthly_mmbtu)
end
Expand Down
3 changes: 2 additions & 1 deletion src/core/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ function dictkeys_tosymbols(d::Dict)
"emissions_factor_series_lb_SO2_per_kwh",
"emissions_factor_series_lb_PM25_per_kwh",
#for ERP
"pv_production_factor_series", "battery_starting_soc_series_fraction"
"pv_production_factor_series", "battery_starting_soc_series_fraction",
"monthly_mmbtu", "monthly_tonhour"
] && !isnothing(v)
try
v = convert(Array{Real, 1}, v)
Expand Down
8 changes: 8 additions & 0 deletions test/test_with_xpress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,14 @@ end
# TODO test for tiered TOU demand rates
end

@testset "EASIUR" begin
d = JSON.parsefile("./scenarios/pv.json")
d["Site"]["latitude"] = 30.2672
d["Site"]["longitude"] = -97.7431
scen = Scenario(d)
@test scen.financial.NOx_grid_cost_per_tonne 4534.032470 atol=0.1
end

@testset "Wind" begin
m = Model(optimizer_with_attributes(Xpress.Optimizer, "OUTPUTLOG" => 0))
d = JSON.parsefile("./scenarios/wind.json")
Expand Down

0 comments on commit 2aeac21

Please sign in to comment.