Skip to content

Commit

Permalink
add tests for electric_heater
Browse files Browse the repository at this point in the history
  • Loading branch information
zolanaj committed Aug 25, 2023
1 parent 057085c commit a4cdc69
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/scenarios/electric_heater.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"Site": {
"latitude": 37.78,
"longitude": -122.45
},
"ExistingBoiler": {
"production_type": "steam",
"efficiency": 0.8,
"fuel_type": "natural_gas",
"fuel_cost_per_mmbtu": 10
},
"ElectricHeater": {
"min_kw": 0.0,
"max_kw": 100000,
"heating_cop": 1.0,
"installed_cost_per_kw": 1000,
"om_cost_per_kw": 0.0,
"macrs_option_years": 0,
"macrs_bonus_fraction": 0.0,
"can_supply_steam_turbine": false
},
"Financial": {
"om_cost_escalation_rate_fraction": 0.025,
"elec_cost_escalation_rate_fraction": 0.023,
"existing_boiler_fuel_cost_escalation_rate_fraction": 0.034,
"boiler_fuel_cost_escalation_rate_fraction": 0.034,
"offtaker_tax_rate_fraction": 0.26,
"offtaker_discount_rate_fraction": 0.083,
"third_party_ownership": false,
"owner_tax_rate_fraction": 0.26,
"owner_discount_rate_fraction": 0.083,
"analysis_years": 25
},
"ElectricLoad": {
"doe_reference_name": "FlatLoad",
"annual_kwh": 87600.0
},
"SpaceHeatingLoad": {
"doe_reference_name": "FlatLoad"
},
"DomesticHotWaterLoad": {
"doe_reference_name": "FlatLoad"
},
"ElectricTariff": {
"monthly_energy_rates": [0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1]
}
}
35 changes: 35 additions & 0 deletions test/test_with_xpress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,41 @@ end
end
end

@testset "Electric Heater" begin
d = JSON.parsefile("./scenarios/electric_heater.json")
d["SpaceHeatingLoad"]["annual_mmbtu"] = 0.5 * 8760
d["DomesticHotWaterLoad"]["annual_mmbtu"] = 0.5 * 8760
s = Scenario(d)
p = REoptInputs(s)
m = Model(optimizer_with_attributes(Xpress.Optimizer, "OUTPUTLOG" => 0))
results = run_reopt(m, p)

#first run: Boiler produces the required heat instead of the electric heater - electric heater should not be purchased
@test results["ElectricHeater"]["size_kw"] 0.0 atol=0.1
@test results["ElectricHeater"]["annual_thermal_production_mmbtu"] 0.0 atol=0.1
@test results["ElectricHeater"]["annual_electric_consumption_kwh"] 0.0 atol=0.1
@test results["ElectricUtility"]["annual_energy_supplied_kwh"] 87600.0 atol=0.1

d["ExistingBoiler"]["fuel_cost_per_mmbtu"] = 100
d["ElectricHeater"]["installed_cost_per_kw"] = 1.0
d["ElectricTariff"]["monthly_energy_rates"] = [0,0,0,0,0,0,0,0,0,0,0,0]
s = Scenario(d)
p = REoptInputs(s)
m = Model(optimizer_with_attributes(Xpress.Optimizer, "OUTPUTLOG" => 0))
results = run_reopt(m, p)

annual_thermal_prod = 0.8 * 8760 #80% efficient boiler --> 0.8 MMBTU of heat load per hour
annual_electric_heater_consumption = annual_thermal_prod * KWH_PER_MMBTU #1.0 COP
annual_energy_supplied = 87600 + annual_electric_heater_consumption

#Second run: ElectricHeater produces the required heat with free electricity
@test results["ElectricHeater"]["size_mmbtu_per_hour"] 0.8 atol=0.1
@test results["ElectricHeater"]["annual_thermal_production_mmbtu"] annual_thermal_prod atol=0.1
@test results["ElectricHeater"]["annual_electric_consumption_kwh"] annual_electric_heater_consumption atol=0.1
@test results["ElectricUtility"]["annual_energy_supplied_kwh"] annual_energy_supplied atol=0.1

end

@testset "Custom REopt logger" begin

# Throw a handled error
Expand Down

0 comments on commit a4cdc69

Please sign in to comment.