Refactor GroupTreeRates to OPM style and integrate with updateWellControls#1
Conversation
Implements the group-tree rate distribution algorithm as standalone functions: - distributeGroupTreeRates: Main iterative rate balancing - setSubRates: Top-down guide-rate based distribution - findWorstOffendingChild: Find worst limit violation in subtree - updateParentStatus: Bottom-up status propagation Includes comprehensive unit tests covering unconstrained trees, single-well limits, group limit violations, cascading violations, and deep tree hierarchies. Co-authored-by: steink <6746854+steink@users.noreply.github.com>
…variable Co-authored-by: steink <6746854+steink@users.noreply.github.com>
Co-authored-by: steink <6746854+steink@users.noreply.github.com>
…pdateWellControls - Wrap free functions into GroupTreeRates<Scalar> class with static methods - Rename to snake_case: distributeGroupTreeRates -> distribute, setSubRates -> set_sub_rates, findWorstOffendingChild -> find_worst_offending_child, updateParentStatus -> update_parent_status - Rename struct member: guideRate -> guide_rate - Use OPM-style include guard and Doxygen documentation - Add include and integration comment in BlackoilWellModel_impl.hpp showing how distribute() fits into updateWellControls - Update all tests to use new class-based API Co-authored-by: steink <6746854+steink@users.noreply.github.com>
…rder Co-authored-by: steink <6746854+steink@users.noreply.github.com>
…al as updateWellControlsOriginal - Rename existing updateWellControls to updateWellControlsOriginal - New updateWellControls calls updateWellControlsOriginal, then: 1. Builds flat GroupTreeNode vector from the group hierarchy 2. Calls GroupTreeRates<Scalar>::distribute(tree) 3. Applies resulting rates back to well/group state - Add updateWellControlsOriginal declaration to BlackoilWellModel.hpp Co-authored-by: steink <6746854+steink@users.noreply.github.com>
Co-authored-by: steink <6746854+steink@users.noreply.github.com>
|
@copilot I have completely re-thought this algorithm, I belive I have a much better version in this matlab-file. I've tested it extensively and I'm happy with the performance. Even though it's very different from the current in ProdGroupTreeBalancer, I think we still can use the developed framework. One extra complication that we did not treat correct in the first attempt was the handling of groups that don't have guide-rates. These should be completely transparent unless they get an active limit (in which case they distribute rates to their children according to their active limit). Also note that groups which has a preferred control set to FIELD or NONE, should inherit the preferred control from their parents (or parent's parent). I would like you to update ProdGroupTreeBalancer with the algorithm outlined in the matlab-file. Please ask if anything is not clear or if you see parts that can be implemented more efficiently (in terms of code or runtime). |
I'd like to implement this updated algorithm, but I don't see the matlab file you're referencing — it doesn't appear to be attached to this comment or present in the repository. Could you either paste the matlab code directly in a comment here, or push it to the repo (e.g., under Also, to confirm my understanding of the key behavioral changes:
Is that correct? Once I have the matlab file I'll update the implementation. |
|
@copilot Sorry, I only pointed to it locally. It's now added to the repo (sortalgo2.m) |
The GroupTreeRates module used Matlab-style free functions and camelCase naming. The TODO in
updateWellControlsdescribed howdistributeGroupTreeRatesshould integrate but had no implementation.Style refactoring (GroupTreeRates.hpp/cpp)
GroupTreeRates<Scalar>class with static methods, matching OPM patterns likeBlackoilWellModelConstraintsdistributeGroupTreeRates→distribute,setSubRates→set_sub_rates,findWorstOffendingChild→find_worst_offending_child,updateParentStatus→update_parent_statusGroupTreeNode::guideRate→guide_rate\brief/\paramDoxygen tagsIntegration with updateWellControls (BlackoilWellModel_impl.hpp)
updateWellControlsOriginalupdateWellControlscalls original first, then implements the three TODO items:GroupTreeNodevector with rate limits (fromproductionControls), current rates (from well/group state), and guide ratesGroupTreeRates<Scalar>::distribute(tree)wellState().surface_ratesandgroupState().production_ratesOnly applies to single-phase rate controls (ORAT/WRAT/GRAT); skips LRAT/RESV/FLD where the simplified distribution doesn't apply.
Tests
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.