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

Massive update documentation for PowerSimulations #1099

Merged
merged 73 commits into from
May 13, 2024

Conversation

rodrigomha
Copy link
Contributor

@rodrigomha rodrigomha commented Apr 23, 2024

Preview PR docs: Not working for now

Massive update on docstrings and markdowns for documentation of PowerSimulations.

I will update the nomenclature to follow the following structure:

  • Lowercase letters are used for variables, e.g., p for power.
  • Uppercase letters are used for parameters, e.g., C for costs.
  • Subscripts are used for indexing, e.g., (\cdot)_t for indexing at time t.
  • Superscripts are used for descriptions, e.g., (\cdot)^\text{th} to describe a thermal (th) variable/parameter.
  • Bold letters are used for vectors, e.g., \boldsymbol{p} = \{p\}_{1,\dots,24}.

TODO for formulations:

  • Introduction to Formulations
  • Network formulations
  • Thermal Gen formulations
  • RenewableGen formulations
  • Load formulations
  • Branches formulations
  • Services formulations
  • Feedforward formulations

TODO docs:

  • Simulation feedforwards
  • Debugging infeasible models

TODO definitions:

  • Feedforward
  • Template
  • Simulation
  • Attributes
  • Optimizer/Solver
  • Service Model
  • Results vs Realized Results

TODO docstrings:

  • Docstrings

For next round of documentation:

  • Model developer guide: DeviceModel
  • Model developer guide: DecisionModel
  • Subsystem explanations

Copy link
Contributor

Performance Results

Version Precompile Time
Main 3.306117011
This Branch 3.412366792
Version Build Time
Main-Build Time Precompile 49.97515415
Main-Build Time Postcompile 2.359731154
This Branch-Build Time Precompile 54.540582953
This Branch-Build Time Postcompile 2.515036504
Version Solve Time
Main-Solve Time Precompile 651.675156431
Main-Solve Time Postcompile 639.978951977
This Branch-Solve Time Precompile 391.359268194
This Branch-Solve Time Postcompile 365.7897431

@jd-lara jd-lara changed the base branch from main to psy4 April 23, 2024 16:32
@rodrigomha
Copy link
Contributor Author

Preview is broken for now, given the requirements of using other branches of PSY and IS

@@ -33,7 +33,7 @@ Formulation type to enable standard dispatch with a range and enforce intertempo
"""
struct ThermalStandardDispatch <: AbstractThermalDispatchFormulation end
"""
Formulation type to enable basic dispatch without any intertemporal constraints and relaxed minimum generation. *may not work with PWL cost definitions*
Copy link
Member

Choose a reason for hiding this comment

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

Only in non-convex cases.

@rodrigomha rodrigomha marked this pull request as ready for review May 11, 2024 05:04
@rodrigomha
Copy link
Contributor Author

I'm done with this docs for now @jd-lara @claytonpbarrows

@rodrigomha rodrigomha changed the base branch from psy4 to rh/cost_funcs_updates_psy4 May 11, 2024 05:20
@@ -1,67 +1,356 @@
# `PowerSystems.Branch` Formulations

!!! note
The usage of reactive power variables and constraints will depend on the network model used, i.e. if it uses (or not) reactive power. If the network model is purely active power based, then no variables and constraints related to reactive power are created. For the sake of completion, if the formulation allows the usage of reactive power it will be included.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The usage of reactive power variables and constraints will depend on the network model used, i.e. if it uses (or not) reactive power. If the network model is purely active power based, then no variables and constraints related to reactive power are created. For the sake of completion, if the formulation allows the usage of reactive power it will be included.
The use of reactive power variables and constraints will depend on the network model used, i.e., whether it uses (or does not use) reactive power. If the network model is purely active power-based, reactive power variables and related constraints are not created.

Comment on lines 3 to 13
In PowerSimulations, chronologies define where information is flowing. There are two types
of chronologies.

- inter-stage chronologies: Define how information flows between stages. e.g. day-ahead solutions are used to inform economic dispatch problems
- intra-stage chronologies: Define how information flows between multiple executions of a single stage. e.g. the dispatch setpoints of the first period of an economic dispatch problem are constrained by the ramping limits from setpoints in the final period of the previous problem.

The definition of exactly what information is passed using the defined chronologies is accomplished using **FeedForwards**.

Specifically, a FeedForward is used to define what to do with information being passed with an inter-stage chronology in a Simulation. The most common FeedForward is the `SemiContinuousFeedForward` that affects the semi-continuous range constraints of thermal generators in the economic dispatch problems based on the value of the (already solved) unit-commitment variables.

The creation of a FeedForward requires at least to specify the `component_type` on which the FeedForward will be applied. The `source` variable specify which variable will be taken from the problem solved, for example the commitment variable of the thermal unit in the unit commitment problem. Finally, the `affected_values` specify which variables will be affected in the problem to be solved, for example the next economic dispatch problem.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
In PowerSimulations, chronologies define where information is flowing. There are two types
of chronologies.
- inter-stage chronologies: Define how information flows between stages. e.g. day-ahead solutions are used to inform economic dispatch problems
- intra-stage chronologies: Define how information flows between multiple executions of a single stage. e.g. the dispatch setpoints of the first period of an economic dispatch problem are constrained by the ramping limits from setpoints in the final period of the previous problem.
The definition of exactly what information is passed using the defined chronologies is accomplished using **FeedForwards**.
Specifically, a FeedForward is used to define what to do with information being passed with an inter-stage chronology in a Simulation. The most common FeedForward is the `SemiContinuousFeedForward` that affects the semi-continuous range constraints of thermal generators in the economic dispatch problems based on the value of the (already solved) unit-commitment variables.
The creation of a FeedForward requires at least to specify the `component_type` on which the FeedForward will be applied. The `source` variable specify which variable will be taken from the problem solved, for example the commitment variable of the thermal unit in the unit commitment problem. Finally, the `affected_values` specify which variables will be affected in the problem to be solved, for example the next economic dispatch problem.
**FeedForwards** are the mechanism to define how information is shared between models. Specifically, a FeedForward defines what to do with information passed with an inter-stage chronology in a Simulation. The most common FeedForward is the `SemiContinuousFeedForward` that affects the semi-continuous range constraints of thermal generators in the economic dispatch problems based on the value of the (already solved) unit-commitment variables.
The creation of a FeedForward requires at least specifying the `component_type` on which the FeedForward will be applied. The `source` variable specifies which variable will be taken from the problem solved, for example, the commitment variable of the thermal unit in the unit commitment problem. Finally, the `affected_values` specify which variables will be affected in the problem to be solved, for example, the next economic dispatch problem.

Copy link
Member

Choose a reason for hiding this comment

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

I removed the chronologies mentioned since that's related to the initial conditions and not specifically to the feedforwards.


**Parameters:**

The parameter `FixValueParameter` is used to match the result obtained from the source variable (from an upper level problem).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The parameter `FixValueParameter` is used to match the result obtained from the source variable (from an upper level problem).
The parameter `FixValueParameter` is used to match the result obtained from the source variable (from the simulation state).


**Parameters:**

The parameter `LowerBoundValueParameter` is used to store the result obtained from the source variable (from an upper level problem) that will be used as a lower bound to the affected variable.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The parameter `LowerBoundValueParameter` is used to store the result obtained from the source variable (from an upper level problem) that will be used as a lower bound to the affected variable.
The parameter `LowerBoundValueParameter` is used to store the result obtained from the source variable (from the simulation state) that will be used as a lower bound to the affected variable.

Copy link
Member

Choose a reason for hiding this comment

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

we should not mention this upper level state etc.

@@ -118,7 +118,7 @@ Adds an objective function cost term according to:

**Impact of different cost configurations:**

The following table describes all possible configuration of the `StorageManagementCost` with the target constraint in hydro or storage device models. Cases 1(a) & 2(a) will have no impact of the models operations and the target constraint will be rendered useless. In most cases that have no energy target and a non-zero value for ``C^{value}``, if this cost is too high (``C^{value} >> 0``) or too low (``C^{value} <<0``) can result in either the model holding on to stored energy till the end or the model not storing any energy in the device. This is caused by the fact that when energy target is zero, we have ``E_t = - E^{shortage}_t``, and ``- E^{shortage}_t * C^{value}`` in the objective function is replaced by ``E_t * C^{value}``, thus resulting in ``C^{value}`` to be seen as the cost of stored energy.
The following table describes all possible configuration of the `StorageCost` with the target constraint in hydro or storage device models. Cases 1(a) & 2(a) will have no impact of the models operations and the target constraint will be rendered useless. In most cases that have no energy target and a non-zero value for ``C^{value}``, if this cost is too high (``C^{value} >> 0``) or too low (``C^{value} <<0``) can result in either the model holding on to stored energy till the end or the model not storing any energy in the device. This is caused by the fact that when energy target is zero, we have ``E_t = - E^{shortage}_t``, and ``- E^{shortage}_t * C^{value}`` in the objective function is replaced by ``E_t * C^{value}``, thus resulting in ``C^{value}`` to be seen as the cost of stored energy.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The following table describes all possible configuration of the `StorageCost` with the target constraint in hydro or storage device models. Cases 1(a) & 2(a) will have no impact of the models operations and the target constraint will be rendered useless. In most cases that have no energy target and a non-zero value for ``C^{value}``, if this cost is too high (``C^{value} >> 0``) or too low (``C^{value} <<0``) can result in either the model holding on to stored energy till the end or the model not storing any energy in the device. This is caused by the fact that when energy target is zero, we have ``E_t = - E^{shortage}_t``, and ``- E^{shortage}_t * C^{value}`` in the objective function is replaced by ``E_t * C^{value}``, thus resulting in ``C^{value}`` to be seen as the cost of stored energy.
The following table describes all possible configurations of the `StorageCost` with the target constraint in hydro or storage device models. Cases 1(a) & 2(a) will not impact the model's operations, and the target constraint will be rendered useless. In most cases that have no energy target and a non-zero value for ``C^{value}``, if this cost is too high (``C^{value} >> 0``) or too low (``C^{value} <<0``) can result in either the model holding on to stored energy till the end of the model not storing any energy in the device. This is caused by the fact that when the energy target is zero, we have ``E_t = - E^{shortage}_t``, and ``- E^{shortage}_t * C^{value}`` in the objective function is replaced by ``E_t * C^{value}``, thus resulting in ``C^{value}`` to be seen as the cost of stored energy.

\end{align*}
```

Note that the `StaticPowerLoad` does not impose any cost to the objective function or any constraint, but add its power demand to the supply-balance demand of the `CopperPlatePowerModel` used. Since we are using the `ThermalDispatchNoMin` formulation for the thermal generation, the lower bound for the power is 0, instead of ``P^\text{th,min}``. In addition, we are assuming a linear cost ``C^\text{th}``. Finally, the `RenewableFullDispatch` formulation allows the dispatch of the renewable unit to be between 0 and its maximum injection time series ``p_t^\text{re,param}``.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Note that the `StaticPowerLoad` does not impose any cost to the objective function or any constraint, but add its power demand to the supply-balance demand of the `CopperPlatePowerModel` used. Since we are using the `ThermalDispatchNoMin` formulation for the thermal generation, the lower bound for the power is 0, instead of ``P^\text{th,min}``. In addition, we are assuming a linear cost ``C^\text{th}``. Finally, the `RenewableFullDispatch` formulation allows the dispatch of the renewable unit to be between 0 and its maximum injection time series ``p_t^\text{re,param}``.
Note that the `StaticPowerLoad` does not impose any cost to the objective function or constraint but adds its power demand to the supply-balance demand of the `CopperPlatePowerModel` used. Since we are using the `ThermalDispatchNoMin` formulation for the thermal generation, the lower bound for the power is 0, instead of ``P^\text{th,min}``. In addition, we are assuming a linear cost ``C^\text{th}``. Finally, the `RenewableFullDispatch` formulation allows the dispatch of the renewable unit between 0 and its maximum injection time series ``p_t^\text{re,param}``.

Comment on lines +59 to +64
In the formulations described in the other pages, the nomenclature is as follows:
- Lowercase letters are used for variables, e.g., ``p`` for power.
- Uppercase letters are used for parameters, e.g., ``C`` for costs.
- Subscripts are used for indexing, e.g., ``(\cdot)_t`` for indexing at time ``t``.
- Superscripts are used for descriptions, e.g., ``(\cdot)^\text{th}`` to describe a thermal (th) variable/parameter.
- Bold letters are used for vectors, e.g., ``\boldsymbol{p} = \{p\}_{1,\dots,24}``.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
In the formulations described in the other pages, the nomenclature is as follows:
- Lowercase letters are used for variables, e.g., ``p`` for power.
- Uppercase letters are used for parameters, e.g., ``C`` for costs.
- Subscripts are used for indexing, e.g., ``(\cdot)_t`` for indexing at time ``t``.
- Superscripts are used for descriptions, e.g., ``(\cdot)^\text{th}`` to describe a thermal (th) variable/parameter.
- Bold letters are used for vectors, e.g., ``\boldsymbol{p} = \{p\}_{1,\dots,24}``.
In the formulations described in the other pages, the nomenclature is as follows:
- Lowercase letters are used for variables, e.g., ``p`` for power.
- Uppercase letters are used for cost parameters, e.g., ``C``.
- Subscripts are used for indexing, e.g., ``(\cdot)_t`` for indexing at time ``t``.
- Superscripts are used for descriptions, e.g., ``(\cdot)^\text{th}`` to describe a thermal (th) variable/parameter.
- Bold letters are used for vectors, e.g., ``\boldsymbol{p} = \{p\}_{1,\dots,24}``.

mdtable(combo_table, latex = false)
```
!!! note
The usage of reactive power variables and constraints will depend on the network model used, i.e. if it uses (or not) reactive power. If the network model is purely active power based, then no variables and constraints related to reactive power are created. For the sake of completion, if the formulation allows the usage of reactive power it will be included.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The usage of reactive power variables and constraints will depend on the network model used, i.e. if it uses (or not) reactive power. If the network model is purely active power based, then no variables and constraints related to reactive power are created. For the sake of completion, if the formulation allows the usage of reactive power it will be included.
The use of reactive power variables and constraints will depend on the network model used, i.e., whether it uses (or does not use) reactive power. If the network model is purely active power-based, reactive power variables and related constraints are not created.


**Parameters:**

The parameter `UpperBoundValueParameter` is used to store the result obtained from the source variable (from an upper level problem) that will be used as an upper bound to the affected variable.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The parameter `UpperBoundValueParameter` is used to store the result obtained from the source variable (from an upper level problem) that will be used as an upper bound to the affected variable.
The parameter `UpperBoundValueParameter` stores the result obtained from the source variable (from the state) that will be used as an upper bound to the affected variable.


**Objective:**

The `ServiceRequirementVariable` is added as a piecewise linear cost based on the decreasing offers listed in the `variable_cost` time series. These decreasing cost represent the scarcity prices of not having sufficient reserves. For example, if the variable ``\text{req} = 0``, then a really high cost is paid for not having enough reserves, and if ``\text{req}`` is larger, then a lower cost (or even zero) is paid. TODO: actual implementation.
Copy link
Member

Choose a reason for hiding this comment

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

Still a TODO?

@jd-lara
Copy link
Member

jd-lara commented May 13, 2024

I think the PR looks good for now for me but I am worried about not catching typos and such
we need to review in detail before release

@rodrigomha rodrigomha merged commit 34b9c5e into rh/cost_funcs_updates_psy4 May 13, 2024
1 of 6 checks passed
@jd-lara jd-lara deleted the team/psi_docs_efforts branch May 15, 2024 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants