Skip to content

Commit

Permalink
Modify write outputs scripts for CCS
Browse files Browse the repository at this point in the history
  • Loading branch information
qluo0320github committed Jan 24, 2024
1 parent 488d849 commit 289558b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ function write_esr_revenue(path::AbstractString, inputs::Dict, setup::Dict, dfPo
dfESRRev.Total = sum(eachcol(dfESRRev[:, 6:nESR + 5]))
CSV.write(joinpath(path, "ESR_Revenue.csv"), dfESRRev)
return dfESRRev
end

end
9 changes: 5 additions & 4 deletions src/write_outputs/write_co2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ end
function write_co2_capture_plant(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
dfGen = inputs["dfGen"]
G = inputs["G"] # Number of resources (generators, storage, DR, and DERs)
CCS = inputs["CCS"]

Check warning on line 40 in src/write_outputs/write_co2.jl

View check run for this annotation

Codecov / codecov/patch

src/write_outputs/write_co2.jl#L40

Added line #L40 was not covered by tests
T = inputs["T"] # Number of time steps (hours)
Z = inputs["Z"] # Number of zones

dfCapturedEmissions_plant = DataFrame(Resource=inputs["RESOURCES"], Zone=dfGen[!, :Zone], AnnualSum=zeros(G))
if any(dfGen.CO2_Capture_Fraction .!= 0)
dfCapturedEmissions_plant = DataFrame(Resource=inputs["RESOURCES"][CCS], Zone=dfGen[CCS, :Zone], AnnualSum=zeros(length(CCS)))
if !isempty(CCS)

Check warning on line 45 in src/write_outputs/write_co2.jl

View check run for this annotation

Codecov / codecov/patch

src/write_outputs/write_co2.jl#L44-L45

Added lines #L44 - L45 were not covered by tests
# Captured CO2 emissions by plant
emissions_captured_plant = zeros(G, T)
emissions_captured_plant = (value.(EP[:eEmissionsCaptureByPlant]))
emissions_captured_plant = zeros(length(CCS), T)
emissions_captured_plant = (value.(EP[:eEmissionsCaptureByPlant]).data)

Check warning on line 48 in src/write_outputs/write_co2.jl

View check run for this annotation

Codecov / codecov/patch

src/write_outputs/write_co2.jl#L47-L48

Added lines #L47 - L48 were not covered by tests
if setup["ParameterScale"] == 1
emissions_captured_plant *= ModelScalingFactor
end
Expand Down
6 changes: 4 additions & 2 deletions src/write_outputs/write_costs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function write_costs(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
FLEX_ZONE = intersect(inputs["FLEX"], Y_ZONE)
COMMIT_ZONE = intersect(inputs["COMMIT"], Y_ZONE)
ELECTROLYZERS_ZONE = intersect(inputs["ELECTROLYZER"], Y_ZONE)
CCS_ZONE = intersect(inputs["CCS"], Y_ZONE)

Check warning on line 111 in src/write_outputs/write_costs.jl

View check run for this annotation

Codecov / codecov/patch

src/write_outputs/write_costs.jl#L111

Added line #L111 was not covered by tests

eCFix = sum(value.(EP[:eCFix][Y_ZONE]))
tempCFix += eCFix
Expand Down Expand Up @@ -218,8 +219,9 @@ function write_costs(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
tempCNSE = sum(value.(EP[:eCNSE][:,:,z]))
tempCTotal += tempCNSE

if any(dfGen.CO2_Capture_Fraction .!=0)
tempCCO2 = sum(value.(EP[:ePlantCCO2Sequestration][Y_ZONE,:]))
# if any(dfGen.CO2_Capture_Fraction .!=0)
if !isempty(CCS_ZONE)
tempCCO2 = sum(value.(EP[:ePlantCCO2Sequestration][CCS_ZONE]))

Check warning on line 224 in src/write_outputs/write_costs.jl

View check run for this annotation

Codecov / codecov/patch

src/write_outputs/write_costs.jl#L223-L224

Added lines #L223 - L224 were not covered by tests
tempCTotal += tempCCO2
end

Expand Down
6 changes: 4 additions & 2 deletions src/write_outputs/write_net_revenue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::
STOR_ALL = inputs["STOR_ALL"]
VRE_STOR = inputs["VRE_STOR"]
dfVRE_STOR = inputs["dfVRE_STOR"]
CCS = inputs["CCS"]

Check warning on line 15 in src/write_outputs/write_net_revenue.jl

View check run for this annotation

Codecov / codecov/patch

src/write_outputs/write_net_revenue.jl#L15

Added line #L15 was not covered by tests
if !isempty(VRE_STOR)
VRE_STOR_LENGTH = size(inputs["VRE_STOR"])[1]
SOLAR = inputs["VS_SOLAR"]
Expand Down Expand Up @@ -124,7 +125,8 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::
# Add CO2 releated sequestration cost or credit (e.g. 45 Q) to the dataframe
dfNetRevenue.CO2SequestrationCost = zeros(nrow(dfNetRevenue))
if any(dfGen.CO2_Capture_Fraction .!= 0)
dfNetRevenue.CO2SequestrationCost .= value.(EP[:ePlantCCO2Sequestration])
dfNetRevenue.CO2SequestrationCost = zeros(G)
dfNetRevenue[CCS, :CO2SequestrationCost] = value.(EP[:ePlantCCO2Sequestration]).data

Check warning on line 129 in src/write_outputs/write_net_revenue.jl

View check run for this annotation

Codecov / codecov/patch

src/write_outputs/write_net_revenue.jl#L126-L129

Added lines #L126 - L129 were not covered by tests
end
if setup["ParameterScale"] == 1
dfNetRevenue.CO2SequestrationCost *= ModelScalingFactor^2 # converting Million US$ to US$

Check warning on line 132 in src/write_outputs/write_net_revenue.jl

View check run for this annotation

Codecov / codecov/patch

src/write_outputs/write_net_revenue.jl#L131-L132

Added lines #L131 - L132 were not covered by tests
Expand Down Expand Up @@ -196,7 +198,7 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::
.+ dfNetRevenue.Charge_cost

Check warning on line 198 in src/write_outputs/write_net_revenue.jl

View check run for this annotation

Codecov / codecov/patch

src/write_outputs/write_net_revenue.jl#L198

Added line #L198 was not covered by tests
.+ dfNetRevenue.EmissionsCost
.+ dfNetRevenue.StartCost

Check warning on line 200 in src/write_outputs/write_net_revenue.jl

View check run for this annotation

Codecov / codecov/patch

src/write_outputs/write_net_revenue.jl#L200

Added line #L200 was not covered by tests
.+dfNetRevenue.CO2SequestrationCost)
.+ dfNetRevenue.CO2SequestrationCost)
dfNetRevenue.Profit = dfNetRevenue.Revenue .- dfNetRevenue.Cost

CSV.write(joinpath(path, "NetRevenue.csv"), dfNetRevenue)
Expand Down

0 comments on commit 289558b

Please sign in to comment.