-
Notifications
You must be signed in to change notification settings - Fork 122
/
write_co2.jl
62 lines (47 loc) · 2.06 KB
/
write_co2.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
@doc raw"""
write_co2(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for reporting time-dependent CO2 emissions by zone.
"""
function write_co2(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
write_co2_emissions_plant(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
write_co2_capture_plant(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
end
function write_co2_emissions_plant(path::AbstractString,
inputs::Dict,
setup::Dict,
EP::Model)
gen = inputs["RESOURCES"] # Resources (objects)
resources = inputs["RESOURCE_NAMES"] # Resource names
zones = zone_id.(gen)
zones = convert.(Float64,zones)
G = inputs["G"] # Number of resources (generators, storage, DR, and DERs)
weight = inputs["omega"]
scale_factor = setup["ParameterScale"] == 1 ? ModelScalingFactor : 1
emissions_plant = value.(EP[:eEmissionsByPlant])
emissions_plant *= scale_factor
df = DataFrame(Resource = resources,
Zone = zones,
AnnualSum = zeros(G))
df.AnnualSum .= emissions_plant * weight
write_temporal_data(df, emissions_plant, path, setup, setup["WriteResultsNamesDict"]["emissions"])
return nothing
end
function write_co2_capture_plant(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
gen = inputs["RESOURCES"] # Resources (objects)
CCS = inputs["CCS"]
resources = inputs["RESOURCE_NAMES"][CCS] # Resource names
zones = zone_id.(gen[CCS])
weight = inputs["omega"]
scale_factor = setup["ParameterScale"] == 1 ? ModelScalingFactor : 1
df = DataFrame(Resource = resources,
Zone = zones,
AnnualSum = zeros(length(CCS)))
if !isempty(CCS)
emissions_captured_plant = value.(EP[:eEmissionsCaptureByPlant]).data
emissions_captured_plant *= scale_factor
df.AnnualSum .= emissions_captured_plant * weight
write_temporal_data(
df, emissions_captured_plant, path, setup, setup["WriteResultsNamesDict"]["captured_emissions_plant"])
end
return nothing
end