Skip to content
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 33 commits into from
Feb 13, 2024
Merged

Conversation

sambuddhac
Copy link
Collaborator

@sambuddhac sambuddhac commented Jan 11, 2024

Description

For printing the operating reserve prices and revenues: This PR adds the file write_operating_reserve_price_revenue.jl which calculates the annual revenue earned by
each resource for providing operating reserve and regulation services. This PR is motivated by and is attempting to
resolve the Issue #46.

The way this PR has been implemented is very similar to how annual energy revenue is calculated. That is, first the
dual variables corresponding to the operating reserve and regulation constraints are evaluated and then those are multiplied by the decision variable values for the regulation and reserves for each generator.

What type of PR is this? (check all applicable)

  • Feature
  • Documentation Update
  • Code Refactor

Related Tickets & Documents

Please use this format to link issue numbers: Fixes #46

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and .md files under /docs/src have been updated if necessary.
  • The latest changes on the target branch have been incorporated, so that any conflicts are taken care of before merging. This can be accomplished either by merging in the target branch (e.g. 'git merge develop') or by rebasing on top of the target branch (e.g. 'git rebase develop'). Please do not hesitate to reach out to the GenX development team if you need help with this.
  • Code has been tested to ensure all functionality works as intended.
  • CHANGELOG.md has been updated (if this is a 'notable' change).
  • I consent to the release of this PR's code under the GNU General Public license.

How this can be tested

This PR does not alter any output. It can be tested simply by running any of the example cases for which the Reserve option is checked.

Post-approval checklist for GenX core developers

After the PR is approved

  • Check that the latest changes on the target branch are incorporated, either via merge or rebase
  • Remember to squash and merge if incorporating into develop

For printing the operating reserve prices and revenues
@sambuddhac sambuddhac linked an issue Jan 11, 2024 that may be closed by this pull request
@sambuddhac
Copy link
Collaborator Author

@JesseJenkins @dharik13 could you please check the formulation? @lbonaldo will need some feedback to refurbish the output writing.

@sambuddhac sambuddhac marked this pull request as ready for review February 5, 2024 02:45
@@ -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"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("Number of CRM types is ",inputs["NCapacityReserveMargin"])

Copy link
Collaborator

@lbonaldo lbonaldo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me.

setup::Dict)::Vector{Float64}

Operating regulation price for each time step.
This is equal to the dual variable of the regulatin requirement constraint.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: regulatin > regulation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "can be obtained form the solver." -> "can be obtained from the solver."

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "of each time steps" --> "in each time step"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cfe316 . Addressed these.

Comment on lines 25 to 28
if setup["ParameterScale"] == 1
rsvrevenue *= scale_factor
regrevenue *= scale_factor
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be wrapped with the if statement since scale_factor is always defined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cfe316 . Addressed this.


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)
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

@@ -179,6 +179,14 @@ function write_outputs(EP::Model, path::AbstractString, setup::Dict, inputs::Dic
dfResMar_slack = write_reserve_margin_slack(path, inputs, setup, EP)
end
end

if setup["Reserves"]==1 && has_duals(EP) == 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this code is duplicated from elsewhere in the file, but has_duals returns a boolean, so it's a bit redundant to use an == 1. You can just do if setup["Reserves"]==1 && has_duals(EP).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cfe316 . Addressed these in all the instances

Typo fix in documentation. Name of function changed from write_operating_reserve_revenue to write_operating_reserve_regulation_revenue, since the function outputs both reserve and regulation revenue
Replaced all the has_duals(EP)==1 by has_duals(EP), since has_duals(EP) itself returns Boolean
Changed the name of function write_operating_reserve_revenue to write_operating_reserve_regulation_revenue. Also replaced has_duals(EP)==1 by has_duals(EP)
Got rid of the redundant if statement in scale factor
Copy link
Collaborator

@cfe316 cfe316 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Sam,
I'd recommend removing the (... doubled) CHANGELOG entry under Fixed, since this is adding a new feature and not fixing a bug. Usually a PR will be either "Added" or "Fixed" but not both.

CHANGELOG.md Outdated
Comment on lines 43 to 46
- Fixes issue #46
- Add validation for `Reg_Max` and `Rsv_Max` columns in `Generators_data.csv` when `MUST_RUN` is set to 1 (#576)
- Fix scaling of transmission losses in write_transmission_losses.jl (#621)
- Fixes issue #46 (#611)
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cfe316 , just did

Copy link
Collaborator

@cfe316 cfe316 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, thanks!

@lbonaldo lbonaldo merged commit 91d4678 into develop Feb 13, 2024
9 checks passed
@lbonaldo lbonaldo deleted the sambuddhac-patch-3 branch February 13, 2024 00:26
@lbonaldo lbonaldo restored the sambuddhac-patch-3 branch February 13, 2024 00:26
lbonaldo added a commit that referenced this pull request Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Output Operating Reserve Constraint prices and revenues
3 participants