-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create write_operating_reserve_price_revenue.jl #611
Merged
Merged
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
b01c606
Create write_operating_reserve_price_revenue.jl
sambuddhac 012959f
Update write_operating_reserve_price_revenue.jl
sambuddhac 87fe00c
Update write_operating_reserve_price_revenue.jl
sambuddhac 962f18f
Moved wrtiting of operating reserve revenue from capacity reserve mar…
sambuddhac e89b0bf
Modified write__operating_reserve_price_revenue
sambuddhac 6c9dfdd
Updated operating reserve and regulation revenue categorized accordin…
sambuddhac 6ec3a46
Updated operating reserve and regulation revenue doc pages
sambuddhac 435bbe0
Updated CHANGELOG.md
sambuddhac df459bc
Modified the write_net_revenue.jl to take into account the addition o…
sambuddhac 7c12325
Update write_net_revenue.jl
sambuddhac 848b192
Code refactoring for only selecting RSV and REG rows
sambuddhac 1ffe28a
Code refactoring for only selecting RSV and REG rows
sambuddhac ee76261
Create write_operating_reserve_price_revenue.jl
sambuddhac f522df7
Update write_operating_reserve_price_revenue.jl
sambuddhac bae5fee
Update write_operating_reserve_price_revenue.jl
sambuddhac 3ac2cce
Moved wrtiting of operating reserve revenue from capacity reserve mar…
sambuddhac 63e4ed8
Modified write__operating_reserve_price_revenue
sambuddhac 36c439b
Updated operating reserve and regulation revenue categorized accordin…
sambuddhac c0644e5
Updated operating reserve and regulation revenue doc pages
sambuddhac c5d0371
Updated CHANGELOG.md
sambuddhac 34adab3
Modified the write_net_revenue.jl to take into account the addition o…
sambuddhac d777c1b
Code refactoring for only selecting RSV and REG rows
sambuddhac 2fbd18f
Clean and fix notation
lbonaldo 5c3cca5
Clean write_energy_revenue
lbonaldo a334250
Update write_operating_reserve_price_revenue.jl
sambuddhac 475aa47
Update write_net_revenue.jl
sambuddhac 3b35243
Update write_outputs.jl
sambuddhac 1f4a7f6
Update write_operating_reserve_price_revenue.jl
sambuddhac d763f73
Minor typo fix and successful run
sambuddhac 99af8ba
Updated CHANGELOG.md
sambuddhac 3cee2c0
Updated CHANGELOG.md to eliminate unnecessary entries in Fix, since t…
sambuddhac 6503a17
Cleanup
lbonaldo 4469420
Merge branch 'develop' into sambuddhac-patch-3
lbonaldo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -19,6 +19,7 @@ function load_cap_reserve_margin!(setup::Dict, path::AbstractString, inputs::Dic | |||
mat = extract_matrix_from_dataframe(df, "CapRes") | ||||
inputs["dfCapRes"] = mat | ||||
inputs["NCapacityReserveMargin"] = size(mat, 2) | ||||
print("Number of CRM types is ",inputs["NCapacityReserveMargin"]) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|
||||
println(filename * " Successfully Read!") | ||||
end | ||||
|
68 changes: 68 additions & 0 deletions
68
src/write_outputs/reserves/write_operating_reserve_price_revenue.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@doc raw""" | ||
write_operating_reserve_price_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) | ||
|
||
Function for reporting the operating reserve and regulation revenue earned by generators listed in the input file. | ||
GenX will print this file only when operating reserve and regulation are modeled and the shadow price can be obtained from the solver. | ||
The revenues are calculated as the operating reserve and regulation contributions in each time step multiplied by the corresponding shadow price, and then the sum is taken over all modeled time steps. | ||
The last column is the total revenue received from all operating reserve and regulation constraints. | ||
As a reminder, GenX models the operating reserve and regulation at the time-dependent level, and each constraint either stands for an overall market or a locality constraint. | ||
""" | ||
function write_operating_reserve_regulation_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model) | ||
scale_factor = setup["ParameterScale"] == 1 ? ModelScalingFactor : 1 | ||
dfGen = inputs["dfGen"] | ||
RSV = inputs["RSV"] | ||
REG = inputs["REG"] | ||
|
||
dfOpRsvRevenue = DataFrame(Region = dfGen[RSV, :region], Resource = dfGen[RSV, :Resource], Zone = dfGen[RSV, :Zone], Cluster = dfGen[RSV, :cluster], AnnualSum = Array{Float64}(undef, length(RSV)),) | ||
dfOpRegRevenue = DataFrame(Region = dfGen[REG, :region], Resource = dfGen[REG, :Resource], Zone = dfGen[REG, :Zone], Cluster = dfGen[REG, :cluster], AnnualSum = Array{Float64}(undef, length(REG)),) | ||
|
||
weighted_reg_price = operating_regulation_price(EP, inputs, setup) | ||
weighted_rsv_price = operating_reserve_price(EP, inputs, setup) | ||
|
||
rsvrevenue = value.(EP[:vRSV][RSV, :].data).* transpose(weighted_rsv_price) | ||
regrevenue = value.(EP[:vREG][REG, :].data) .* transpose(weighted_reg_price) | ||
|
||
|
||
rsvrevenue *= scale_factor | ||
regrevenue *= scale_factor | ||
|
||
dfOpRsvRevenue.AnnualSum .= rsvrevenue * inputs["omega"] | ||
dfOpRegRevenue.AnnualSum .= regrevenue * inputs["omega"] | ||
write_simple_csv(joinpath(path, "OperatingReserveRevenue.csv"), dfOpRsvRevenue) | ||
write_simple_csv(joinpath(path, "OperatingRegulationRevenue.csv"), dfOpRegRevenue) | ||
return dfOpRegRevenue, dfOpRsvRevenue | ||
end | ||
|
||
@doc raw""" | ||
operating_regulation_price(EP::Model, | ||
inputs::Dict, | ||
setup::Dict)::Vector{Float64} | ||
|
||
Operating regulation price for each time step. | ||
This is equal to the dual variable of the regulation requirement constraint. | ||
|
||
Returns a vector, with units of $/MW | ||
""" | ||
|
||
function operating_regulation_price(EP::Model, inputs::Dict, setup::Dict)::Vector{Float64} | ||
ω = inputs["omega"] | ||
scale_factor = setup["ParameterScale"] == 1 ? ModelScalingFactor : 1 | ||
return dual.(EP[:cReg]) ./ ω * scale_factor | ||
end | ||
|
||
@doc raw""" | ||
operating_reserve_price(EP::Model, | ||
inputs::Dict, | ||
setup::Dict)::Vector{Float64} | ||
|
||
Operating reserve price for each time step. | ||
This is equal to the dual variable of the reserve requirement constraint. | ||
|
||
Returns a vector, with units of $/MW | ||
""" | ||
|
||
function operating_reserve_price(EP::Model, inputs::Dict, setup::Dict)::Vector{Float64} | ||
ω = inputs["omega"] | ||
scale_factor = setup["ParameterScale"] == 1 ? ModelScalingFactor : 1 | ||
return dual.(EP[:cRsvReq]) ./ ω * scale_factor | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
@doc raw""" | ||
write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model, dfCap::DataFrame, dfESRRev::DataFrame, dfResRevenue::DataFrame, dfChargingcost::DataFrame, dfPower::DataFrame, dfEnergyRevenue::DataFrame, dfSubRevenue::DataFrame, dfRegSubRevenue::DataFrame, dfVreStor::DataFrame) | ||
write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model, dfCap::DataFrame, dfESRRev::DataFrame, dfResRevenue::DataFrame, dfChargingcost::DataFrame, dfPower::DataFrame, dfEnergyRevenue::DataFrame, dfSubRevenue::DataFrame, dfRegSubRevenue::DataFrame, dfVreStor::DataFrame, dfOpRegRevenue::DataFrame, dfOpRsvRevenue::DataFrame) | ||
|
||
Function for writing net revenue of different generation technologies. | ||
""" | ||
function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model, dfCap::DataFrame, dfESRRev::DataFrame, dfResRevenue::DataFrame, dfChargingcost::DataFrame, dfPower::DataFrame, dfEnergyRevenue::DataFrame, dfSubRevenue::DataFrame, dfRegSubRevenue::DataFrame, dfVreStor::DataFrame) | ||
function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model, dfCap::DataFrame, dfESRRev::DataFrame, dfResRevenue::DataFrame, dfChargingcost::DataFrame, dfPower::DataFrame, dfEnergyRevenue::DataFrame, dfSubRevenue::DataFrame, dfRegSubRevenue::DataFrame, dfVreStor::DataFrame, dfOpRegRevenue::DataFrame, dfOpRsvRevenue::DataFrame) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a comment. We should really have an "outputs" dictionary so that we don't have this huge list of dataframes. |
||
dfGen = inputs["dfGen"] | ||
T = inputs["T"] # Number of time steps (hours) | ||
Z = inputs["Z"] # Number of zones | ||
G = inputs["G"] # Number of generators | ||
G = inputs["G"] | ||
RSV = inputs["RSV"] | ||
REG = inputs["REG"] # Number of generators | ||
COMMIT = inputs["COMMIT"] # Thermal units for unit commitment | ||
STOR_ALL = inputs["STOR_ALL"] | ||
VRE_STOR = inputs["VRE_STOR"] | ||
|
@@ -53,7 +55,7 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP:: | |
# Add operations and maintenance cost to the dataframe | ||
dfNetRevenue.Fixed_OM_cost_MW = dfGen[!,:Fixed_OM_Cost_per_MWyr] .* dfCap[1:G,:EndCap] | ||
dfNetRevenue.Fixed_OM_cost_MWh = dfGen[!,:Fixed_OM_Cost_per_MWhyr] .* dfCap[1:G,:EndEnergyCap] | ||
dfNetRevenue.Fixed_OM_cost_charge_MW = dfGen[!, :Fixed_OM_Cost_Charge_per_MWyr] .* dfCap[1:G, :EndChargeCap] | ||
dfNetRevenue.Fixed_OM_cost_charge_MW = dfGen[!, :Fixed_OM_Cost_Charge_per_MWyr] .* dfCap[1:G, :EndChargeCap] | ||
|
||
dfNetRevenue.Var_OM_cost_out = (dfGen[!,:Var_OM_Cost_per_MWh]) .* dfPower[1:G,:AnnualSum] | ||
if !isempty(VRE_STOR) | ||
|
@@ -117,33 +119,41 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP:: | |
end | ||
# Add charge cost to the dataframe | ||
dfNetRevenue.Charge_cost = zeros(nrow(dfNetRevenue)) | ||
if has_duals(EP) == 1 | ||
if has_duals(EP) | ||
dfNetRevenue.Charge_cost = dfChargingcost[1:G,:AnnualSum] # Unit is confirmed to be US$ | ||
end | ||
|
||
# Add energy and subsidy revenue to the dataframe | ||
dfNetRevenue.EnergyRevenue = zeros(nrow(dfNetRevenue)) | ||
dfNetRevenue.SubsidyRevenue = zeros(nrow(dfNetRevenue)) | ||
if has_duals(EP) == 1 | ||
if has_duals(EP) | ||
dfNetRevenue.EnergyRevenue = dfEnergyRevenue[1:G,:AnnualSum] # Unit is confirmed to be US$ | ||
dfNetRevenue.SubsidyRevenue = dfSubRevenue[1:G,:SubsidyRevenue] # Unit is confirmed to be US$ | ||
end | ||
|
||
# Add energy and subsidy revenue to the dataframe | ||
dfNetRevenue.OperatingReserveRevenue = zeros(nrow(dfNetRevenue)) | ||
dfNetRevenue.OperatingRegulationRevenue = zeros(nrow(dfNetRevenue)) | ||
if setup["Reserves"] > 0 && has_duals(EP) | ||
dfNetRevenue.OperatingReserveRevenue[RSV] = dfOpRsvRevenue.AnnualSum # Unit is confirmed to be US$ | ||
dfNetRevenue.OperatingRegulationRevenue[REG] = dfOpRegRevenue.AnnualSum # Unit is confirmed to be US$ | ||
end | ||
|
||
# Add capacity revenue to the dataframe | ||
dfNetRevenue.ReserveMarginRevenue = zeros(nrow(dfNetRevenue)) | ||
if setup["CapacityReserveMargin"] > 0 && has_duals(EP) == 1 # The unit is confirmed to be $ | ||
if setup["CapacityReserveMargin"] > 0 && has_duals(EP) # The unit is confirmed to be $ | ||
dfNetRevenue.ReserveMarginRevenue = dfResRevenue[1:G,:AnnualSum] | ||
end | ||
|
||
# Add RPS/CES revenue to the dataframe | ||
dfNetRevenue.ESRRevenue = zeros(nrow(dfNetRevenue)) | ||
if setup["EnergyShareRequirement"] > 0 && has_duals(EP) == 1 # The unit is confirmed to be $ | ||
if setup["EnergyShareRequirement"] > 0 && has_duals(EP) # The unit is confirmed to be $ | ||
dfNetRevenue.ESRRevenue = dfESRRev[1:G,:Total] | ||
end | ||
|
||
# Calculate emissions cost | ||
dfNetRevenue.EmissionsCost = zeros(nrow(dfNetRevenue)) | ||
if setup["CO2Cap"] >=1 && has_duals(EP) == 1 | ||
if setup["CO2Cap"] >=1 && has_duals(EP) | ||
for cap in 1:inputs["NCO2Cap"] | ||
co2_cap_dual = dual(EP[:cCO2Emissions_systemwide][cap]) | ||
CO2ZONES = findall(x->x==1, inputs["dfCO2CapZones"][:,cap]) | ||
|
@@ -166,11 +176,11 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP:: | |
|
||
# Add regional technology subsidy revenue to the dataframe | ||
dfNetRevenue.RegSubsidyRevenue = zeros(nrow(dfNetRevenue)) | ||
if setup["MinCapReq"] >= 1 && has_duals(EP) == 1 # The unit is confirmed to be US$ | ||
if setup["MinCapReq"] >= 1 && has_duals(EP)# The unit is confirmed to be US$ | ||
dfNetRevenue.RegSubsidyRevenue = dfRegSubRevenue[1:G,:SubsidyRevenue] | ||
end | ||
|
||
dfNetRevenue.Revenue = dfNetRevenue.EnergyRevenue .+ dfNetRevenue.SubsidyRevenue .+ dfNetRevenue.ReserveMarginRevenue .+ dfNetRevenue.ESRRevenue .+ dfNetRevenue.RegSubsidyRevenue | ||
dfNetRevenue.Revenue = dfNetRevenue.EnergyRevenue .+ dfNetRevenue.SubsidyRevenue .+ dfNetRevenue.ReserveMarginRevenue .+ dfNetRevenue.ESRRevenue .+ dfNetRevenue.RegSubsidyRevenue .+ dfNetRevenue.OperatingReserveRevenue .+ dfNetRevenue.OperatingRegulationRevenue | ||
dfNetRevenue.Cost = (dfNetRevenue.Inv_cost_MW | ||
.+ dfNetRevenue.Inv_cost_MWh | ||
.+ dfNetRevenue.Inv_cost_charge_MW | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Sam, this "fixed" line is now duplicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll again comment that it's useful to summarize for the reader what has been fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, both lines should be removed as the change has been more accurately summarized in the Added section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @cfe316 , just did