Skip to content

Enhance/transfer energy potentials#81

Merged
JulStraus merged 21 commits intomainfrom
enhance/transfer_energy_potentials
Mar 25, 2026
Merged

Enhance/transfer energy potentials#81
JulStraus merged 21 commits intomainfrom
enhance/transfer_energy_potentials

Conversation

@espenbodal
Copy link
Contributor

Create new functions that enable dispatch on resource types in extension packages. This allows for new variables and constraints on existing elements when they are combined with specific resource types. New variables must have a unique name for each combination of element and resource. Couple functions must also be defined for the coupling between two elements for each resource.

- CompoundResource is a super type for ResourcePotential
- Any CompoundResource creates new varaibles
 potential_in and potential_out on nodes and links.
- In junctions the pontentials are transferred by
 equality rather than summation (as for flow_in, link_in etc.)
- This allows for transfers of voltages and pressures,
 along with a quantity (e.g. energy or material flows)
- added function `variables_flow_resource` to create new variables
 by dispatching on resource types, it is called inside
 `variables_flow`
- added function `constraints_link_resource` to create new constraints
 by dispatching on resource types, it is called inside
 `create_link`
- added function `res_types` to extract an array of unique resource
 types from an array of resources
- Added function for resouce type constratints on node-link coupling
    that dispatch on resouce type
- Removed old functions on potential variables and constratints
- Resource vector is segmented into sub-vectors based on resource type
- Constraint functions for flows can be dispatched on these sub-vectors
- New function are created to say if EMB flow-variables should be added,
 which can be dispatched on resource type, default is true
- Function is available for adding new variables that are specific for
 a resource type
- Avioids repeating constraints that are not dependent on resources
 (doesnt have resouce in the constraint index)
- Moved the constraint-function for special
    resource constraint to create_element function
* Updated `res_types` and `res_types_seg` to take `Vector{<:Resource}` instead of `Array{<:Resource}` as input.
* Added missing tests for new resource functions
@espenbodal espenbodal linked an issue Mar 23, 2026 that may be closed by this pull request
Copy link
Member

@JulStraus JulStraus left a comment

Choose a reason for hiding this comment

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

These two comments are related to potential breaking changes which should be revised.

* Revert changes for create_link
* `total_duration` is added to SimpleTimes, and the docstring is updated to reflect this.
@espenbodal
Copy link
Contributor Author

Resolves #61

@espenbodal espenbodal requested review from JulStraus and hellemo March 23, 2026 16:29
@espenbodal espenbodal marked this pull request as ready for review March 23, 2026 16:30
Copy link
Member

@JulStraus JulStraus 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 in general quite well, but there must be the following changes:

  1. a description regarding how one can incorporate the new feature. This should be included within the how-to section and
  2. a proper test set in which we check that the specific functions are called and can be worked on.

We also have to discuss whether we want to have it breaking or not. There is a potential to avoid breaking changes, as outlined by me.

- add resource-type dispatch integration in `model.jl` for variable creation and coupling constraints
- add resource type helpers in `resource.jl`
- extend functional docs index and internals references in `make.jl`, `index.md`, and `functions.md`
- add/expand end-to-end resource dispatch tests, including node/resource unpacking and bound constraints, in `test_resource.jl`
- add release note update in `NEWS.md`
- add new how-to page `extend-resource-functionality.md`
@espenbodal espenbodal requested a review from JulStraus March 24, 2026 17:20
- Changes in documentation
- Changed argument order in fallback method
- Rearranged tests
@JulStraus JulStraus force-pushed the enhance/transfer_energy_potentials branch from fd5b7ea to 9113b56 Compare March 25, 2026 09:32
Copy link
Member

@JulStraus JulStraus 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 to me. It should be a squash and merge as most loc changed are in the documentation and the test set.

@JulStraus JulStraus merged commit bfdfec6 into main Mar 25, 2026
5 checks passed
@JulStraus JulStraus deleted the enhance/transfer_energy_potentials branch March 25, 2026 12:08
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.

Transfer of energy potentials

3 participants