-
Notifications
You must be signed in to change notification settings - Fork 122
/
write_fuel_consumption.jl
116 lines (102 loc) · 5.52 KB
/
write_fuel_consumption.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
@doc raw"""
write_fuel_consumption(path::AbstractString, inputs::Dict, setup::Dict, EP::Model).
Write fuel consumption of each power plant.
"""
function write_fuel_consumption(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
write_fuel_consumption_plant(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
if setup["WriteOutputs"] != "annual"
write_fuel_consumption_ts(path::AbstractString,
inputs::Dict,
setup::Dict,
EP::Model)
end
write_fuel_consumption_tot(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
end
function write_fuel_consumption_plant(path::AbstractString,
inputs::Dict,
setup::Dict,
EP::Model)
gen = inputs["RESOURCES"]
HAS_FUEL = inputs["HAS_FUEL"]
MULTI_FUELS = inputs["MULTI_FUELS"]
# Fuel consumption cost by each resource, including start up fuel
dfPlantFuel = DataFrame(Resource = inputs["RESOURCE_NAMES"][HAS_FUEL],
Fuel = fuel.(gen[HAS_FUEL]),
Zone = zone_id.(gen[HAS_FUEL]),
AnnualSumCosts = zeros(length(HAS_FUEL)))
tempannualsum = value.(EP[:ePlantCFuelOut][HAS_FUEL]) +
value.(EP[:ePlantCFuelStart][HAS_FUEL])
if !isempty(MULTI_FUELS)
fuel_cols_num = inputs["FUEL_COLS"]# TODO: rename it
max_fuels = inputs["MAX_NUM_FUELS"]
dfPlantFuel.Multi_Fuels = multi_fuels.(gen[HAS_FUEL])
for i in 1:max_fuels
tempannualsum_fuel_heat_multi_generation = zeros(length(HAS_FUEL))
tempannualsum_fuel_heat_multi_start = zeros(length(HAS_FUEL))
tempannualsum_fuel_heat_multi_total = zeros(length(HAS_FUEL))
tempannualsum_fuel_cost_multi = zeros(length(HAS_FUEL))
for g in MULTI_FUELS
tempannualsum_fuel_heat_multi_generation[findfirst(x -> x == g, HAS_FUEL)] = value.(EP[:ePlantFuelConsumptionYear_multi_generation][g,i])
tempannualsum_fuel_heat_multi_start[findfirst(x -> x == g, HAS_FUEL)] = value.(EP[:ePlantFuelConsumptionYear_multi_start][g,i])
tempannualsum_fuel_heat_multi_total[findfirst(x -> x == g, HAS_FUEL)] = value.(EP[:ePlantFuelConsumptionYear_multi][g,i])
tempannualsum_fuel_cost_multi[findfirst(x -> x == g, HAS_FUEL)] = value.(EP[:ePlantCFuelOut_multi][g,i]) + value.(EP[:ePlantCFuelOut_multi_start][g,i])
end
if setup["ParameterScale"] == 1
tempannualsum_fuel_heat_multi_generation *= ModelScalingFactor
tempannualsum_fuel_heat_multi_start *= ModelScalingFactor
tempannualsum_fuel_heat_multi_total *= ModelScalingFactor
tempannualsum_fuel_cost_multi *= ModelScalingFactor^2
end
dfPlantFuel[!, fuel_cols_num[i]] = fuel_cols.(gen[HAS_FUEL], tag = i)
dfPlantFuel[!, Symbol(string(fuel_cols_num[i], "_AnnualSum_Fuel_HeatInput_Generation_MMBtu"))] = tempannualsum_fuel_heat_multi_generation
dfPlantFuel[!, Symbol(string(fuel_cols_num[i], "_AnnualSum_Fuel_HeatInput_Start_MMBtu"))] = tempannualsum_fuel_heat_multi_start
dfPlantFuel[!, Symbol(string(fuel_cols_num[i], "_AnnualSum_Fuel_HeatInput_Total_MMBtu"))] = tempannualsum_fuel_heat_multi_total
dfPlantFuel[!, Symbol(string(fuel_cols_num[i], "_AnnualSum_Fuel_Cost"))] = tempannualsum_fuel_cost_multi
end
end
if setup["ParameterScale"] == 1
tempannualsum *= ModelScalingFactor^2 #
end
dfPlantFuel.AnnualSumCosts .+= tempannualsum
write_output_file(joinpath(path, setup["WriteResultsNamesDict"]["fuel_cost_plant"]), dfPlantFuel, filetype = setup["ResultsFileType"], compression = setup["ResultsCompressionType"])
end
function write_fuel_consumption_ts(path::AbstractString,
inputs::Dict,
setup::Dict,
EP::Model)
T = inputs["T"] # Number of time steps (hours)
HAS_FUEL = inputs["HAS_FUEL"]
# Fuel consumption by each resource per time step, unit is MMBTU
dfPlantFuel_TS = DataFrame(Resource = inputs["RESOURCE_NAMES"][HAS_FUEL])
tempts = value.(EP[:ePlantFuel_generation] + EP[:ePlantFuel_start])[HAS_FUEL, :]
if setup["ParameterScale"] == 1
tempts *= ModelScalingFactor # kMMBTU to MMBTU
end
dfPlantFuel_TS = hcat(dfPlantFuel_TS,
DataFrame(tempts, [Symbol("t$t") for t in 1:T]))
write_output_file(joinpath(path,
setup["WriteResultsNamesDict"]["fuel_consumption_plant"]),
dftranspose(dfPlantFuel_TS, true), filetype = setup["ResultsFileType"],
compression = setup["ResultsCompressionType"])
if setup["OutputFullTimeSeries"] == 1 && setup["TimeDomainReduction"] == 1
write_full_time_series_reconstruction(
path, setup, dftranspose(dfPlantFuel_TS, true),setup["WriteResultsNamesDict"]["fuel_consumption_plant"])
@info("Writing Full Time Series for Fuel Consumption")
end
end
function write_fuel_consumption_tot(path::AbstractString,
inputs::Dict,
setup::Dict,
EP::Model)
# types of fuel
fuel_types = inputs["fuels"]
fuel_number = length(fuel_types)
dfFuel = DataFrame(Fuel = fuel_types,
AnnualSum = zeros(fuel_number))
tempannualsum = value.(EP[:eFuelConsumptionYear])
if setup["ParameterScale"] == 1
tempannualsum *= ModelScalingFactor # billion MMBTU to MMBTU
end
dfFuel.AnnualSum .+= tempannualsum
write_output_file(joinpath(path, setup["WriteResultsNamesDict"]["fuel_consumption_total"]),dfFuel, filetype = setup["ResultsFileType"], compression = setup["ResultsCompressionType"])
end