-
Notifications
You must be signed in to change notification settings - Fork 1
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
add regulating point for ratio and phase tap changers #84
base: move-boolean-regulating-from-equipment-to-regulatingPoint
Are you sure you want to change the base?
add regulating point for ratio and phase tap changers #84
Conversation
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.
Some first comments, not tested yet
network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreRepository.java
Show resolved
Hide resolved
network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreRepository.java
Outdated
Show resolved
Hide resolved
network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreRepository.java
Outdated
Show resolved
Hide resolved
network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreRepository.java
Show resolved
Hide resolved
network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreRepository.java
Outdated
Show resolved
Hide resolved
...e-server/src/main/resources/db/changelog/changesets/twt_regulationPoint_20241126T110000Z.sql
Outdated
Show resolved
Hide resolved
...e-server/src/main/resources/db/changelog/changesets/twt_regulationPoint_20241126T110000Z.sql
Outdated
Show resolved
Hide resolved
...e-server/src/main/resources/db/changelog/changesets/twt_regulationPoint_20241126T110000Z.sql
Outdated
Show resolved
Hide resolved
...e-server/src/main/resources/db/changelog/changesets/twt_regulationPoint_20241126T110000Z.sql
Outdated
Show resolved
Hide resolved
...e-server/src/main/resources/db/changelog/changesets/twt_regulationPoint_20241126T110000Z.sql
Outdated
Show resolved
Hide resolved
4ff4275
to
3b5b544
Compare
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
3b5b544
to
efe2df9
Compare
// for two winding transformers | ||
// using the request on a small number of ids and not on all elements | ||
private void setTapChangerRegulatingPointAndRegulatingEquipmentsWithIds(List<Resource<TwoWindingsTransformerAttributes>> elements, UUID networkUuid, int variantNum) { | ||
// regulating points | ||
List<String> elementIds = elements.stream().map(Resource::getId).toList(); | ||
Map<RegulatingOwnerInfo, RegulatingPointAttributes> twtTapChangerRegulatingPointAttributes = getRegulatingPointsWithInClause(networkUuid, variantNum, | ||
REGULATING_EQUIPMENT_ID, elementIds, ResourceType.TWO_WINDINGS_TRANSFORMER); | ||
Map<OwnerInfo, List<RegulatingEquipmentIdentifier>> regulatingEquipments = getRegulatingEquipmentsWithInClause(networkUuid, variantNum, | ||
"regulatingterminalconnectableid", elementIds, ResourceType.TWO_WINDINGS_TRANSFORMER); | ||
elements.forEach(element -> { | ||
PhaseTapChangerAttributes phaseTapChangerAttributes = element.getAttributes().getPhaseTapChangerAttributes(); | ||
if (phaseTapChangerAttributes != null) { | ||
phaseTapChangerAttributes.setRegulatingPoint( | ||
twtTapChangerRegulatingPointAttributes.get(new RegulatingOwnerInfo(element.getId(), ResourceType.TWO_WINDINGS_TRANSFORMER, | ||
RegulatingTapChangerType.PHASE_TAP_CHANGER, networkUuid, variantNum))); | ||
} | ||
RatioTapChangerAttributes ratioTapChangerAttributes = element.getAttributes().getRatioTapChangerAttributes(); | ||
if (ratioTapChangerAttributes != null) { | ||
ratioTapChangerAttributes.setRegulatingPoint( | ||
twtTapChangerRegulatingPointAttributes.get(new RegulatingOwnerInfo(element.getId(), ResourceType.TWO_WINDINGS_TRANSFORMER, | ||
RegulatingTapChangerType.RATIO_TAP_CHANGER, networkUuid, variantNum))); | ||
} | ||
element.getAttributes().setRegulatingEquipments(regulatingEquipments.get( | ||
new OwnerInfo(element.getId(), ResourceType.TWO_WINDINGS_TRANSFORMER, networkUuid, variantNum))); | ||
}); | ||
} | ||
|
||
// on all elements of the network | ||
private void setTapChangerRegulatingPointAndRegulatingEquipments(List<Resource<TwoWindingsTransformerAttributes>> twoWindingTransformers, UUID networkUuid, int variantNum) { | ||
// regulating points | ||
Map<RegulatingOwnerInfo, RegulatingPointAttributes> twtRegulatingPointAttributes = getRegulatingPoints(networkUuid, variantNum, ResourceType.TWO_WINDINGS_TRANSFORMER); | ||
Map<OwnerInfo, List<RegulatingEquipmentIdentifier>> regulatingEquipments = getRegulatingEquipments(networkUuid, variantNum, ResourceType.TWO_WINDINGS_TRANSFORMER); | ||
twoWindingTransformers.forEach(element -> { | ||
PhaseTapChangerAttributes phaseTapChangerAttributes = element.getAttributes().getPhaseTapChangerAttributes(); | ||
if (phaseTapChangerAttributes != null) { | ||
phaseTapChangerAttributes.setRegulatingPoint( | ||
twtRegulatingPointAttributes.get(new RegulatingOwnerInfo(element.getId(), ResourceType.TWO_WINDINGS_TRANSFORMER, | ||
RegulatingTapChangerType.PHASE_TAP_CHANGER, networkUuid, variantNum))); | ||
} | ||
RatioTapChangerAttributes ratioTapChangerAttributes = element.getAttributes().getRatioTapChangerAttributes(); | ||
if (ratioTapChangerAttributes != null) { | ||
ratioTapChangerAttributes.setRegulatingPoint( | ||
twtRegulatingPointAttributes.get(new RegulatingOwnerInfo(element.getId(), ResourceType.TWO_WINDINGS_TRANSFORMER, | ||
RegulatingTapChangerType.RATIO_TAP_CHANGER, networkUuid, variantNum))); | ||
} | ||
element.getAttributes().setRegulatingEquipments(regulatingEquipments.get( | ||
new OwnerInfo(element.getId(), ResourceType.TWO_WINDINGS_TRANSFORMER, networkUuid, variantNum))); | ||
}); | ||
} | ||
|
||
// three windings transformers | ||
private void setRegulatingPointForThreeWindingsTransformers(List<Resource<ThreeWindingsTransformerAttributes>> threeWindingTransformers, UUID networkUuid, int variantNum) { | ||
Map<RegulatingOwnerInfo, RegulatingPointAttributes> twtRegulatingPointAttributes = getRegulatingPoints(networkUuid, variantNum, ResourceType.THREE_WINDINGS_TRANSFORMER); | ||
threeWindingTransformers.forEach(element -> { | ||
for (ThreeSides side : ThreeSides.values()) { | ||
PhaseTapChangerAttributes phaseTapChangerAttributes = element.getAttributes().getLeg(side.getNum()).getPhaseTapChangerAttributes(); | ||
if (phaseTapChangerAttributes != null) { | ||
phaseTapChangerAttributes.setRegulatingPoint( | ||
twtRegulatingPointAttributes.get(new RegulatingOwnerInfo(element.getId(), ResourceType.THREE_WINDINGS_TRANSFORMER, | ||
RegulatingTapChangerType.getThreeWindingType(side, RegulatingTapChangerType.PHASE_TAP_CHANGER), networkUuid, variantNum))); | ||
} | ||
RatioTapChangerAttributes ratioTapChangerAttributes = element.getAttributes().getLeg(side.getNum()).getRatioTapChangerAttributes(); | ||
if (ratioTapChangerAttributes != null) { | ||
ratioTapChangerAttributes.setRegulatingPoint( | ||
twtRegulatingPointAttributes.get(new RegulatingOwnerInfo(element.getId(), ResourceType.THREE_WINDINGS_TRANSFORMER, | ||
RegulatingTapChangerType.getThreeWindingType(side, RegulatingTapChangerType.RATIO_TAP_CHANGER), networkUuid, variantNum)) | ||
); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
private void setRegulatingPointForThreeWindingsTransformersWithIds(List<Resource<ThreeWindingsTransformerAttributes>> threeWindingTransformers, UUID networkUuid, int variantNum) { | ||
List<String> elementIds = threeWindingTransformers.stream().map(Resource::getId).toList(); | ||
Map<RegulatingOwnerInfo, RegulatingPointAttributes> twtRegulatingPointAttributes = getRegulatingPointsWithInClause(networkUuid, variantNum, | ||
REGULATING_EQUIPMENT_ID, elementIds, ResourceType.THREE_WINDINGS_TRANSFORMER); | ||
threeWindingTransformers.forEach(element -> { | ||
for (ThreeSides side : ThreeSides.values()) { | ||
PhaseTapChangerAttributes phaseTapChangerAttributes = element.getAttributes().getLeg(side.getNum()).getPhaseTapChangerAttributes(); | ||
if (phaseTapChangerAttributes != null) { | ||
phaseTapChangerAttributes.setRegulatingPoint( | ||
twtRegulatingPointAttributes.get(new RegulatingOwnerInfo(element.getId(), ResourceType.THREE_WINDINGS_TRANSFORMER, | ||
RegulatingTapChangerType.getThreeWindingType(side, RegulatingTapChangerType.PHASE_TAP_CHANGER), networkUuid, variantNum))); | ||
} | ||
RatioTapChangerAttributes ratioTapChangerAttributes = element.getAttributes().getLeg(side.getNum()).getRatioTapChangerAttributes(); | ||
if (ratioTapChangerAttributes != null) { | ||
ratioTapChangerAttributes.setRegulatingPoint( | ||
twtRegulatingPointAttributes.get(new RegulatingOwnerInfo(element.getId(), ResourceType.THREE_WINDINGS_TRANSFORMER, | ||
RegulatingTapChangerType.getThreeWindingType(side, RegulatingTapChangerType.RATIO_TAP_CHANGER), networkUuid, variantNum)) | ||
); | ||
} | ||
} | ||
}); | ||
} | ||
|
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.
can we share a bit the code or extract methods or I don't know but it would be nice to improve readability
...ork-store-server/src/main/java/com/powsybl/network/store/server/dto/RegulatingOwnerInfo.java
Outdated
Show resolved
Hide resolved
// the primary key is type + id + variant num + network uuid so there is no mean | ||
// to distinct ratio tap changer of leg one and the one from leg 2 | ||
// so the side will be added in the id |
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.
is this still a valid comment?
|
||
// three windings transformers | ||
private void setRegulatingPointForThreeWindingsTransformers(List<Resource<ThreeWindingsTransformerAttributes>> threeWindingTransformers, UUID networkUuid, int variantNum) { | ||
Map<RegulatingOwnerInfo, RegulatingPointAttributes> twtRegulatingPointAttributes = getRegulatingPoints(networkUuid, variantNum, ResourceType.THREE_WINDINGS_TRANSFORMER); |
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.
why no regulating equipments as 3wt?
|
||
private void setRegulatingPointForThreeWindingsTransformersWithIds(List<Resource<ThreeWindingsTransformerAttributes>> threeWindingTransformers, UUID networkUuid, int variantNum) { | ||
List<String> elementIds = threeWindingTransformers.stream().map(Resource::getId).toList(); | ||
Map<RegulatingOwnerInfo, RegulatingPointAttributes> twtRegulatingPointAttributes = getRegulatingPointsWithInClause(networkUuid, variantNum, |
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.
why no regulating equipments as 3wt?
network-store-server/src/main/java/com/powsybl/network/store/server/QueryCatalog.java
Outdated
Show resolved
Hide resolved
...-store-server/src/test/java/com/powsybl/network/store/server/NetworkStoreRepositoryTest.java
Outdated
Show resolved
Hide resolved
network-store-server/src/main/resources/db/changelog/changesets/changelog_20241205T110000Z.xml
Outdated
Show resolved
Hide resolved
network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreRepository.java
Outdated
Show resolved
Hide resolved
...e-server/src/main/resources/db/changelog/changesets/twt_regulationPoint_20241205T110000Z.sql
Outdated
Show resolved
Hide resolved
...e-server/src/main/resources/db/changelog/changesets/twt_regulationPoint_20241205T110000Z.sql
Outdated
Show resolved
Hide resolved
...e-server/src/main/resources/db/changelog/changesets/twt_regulationPoint_20241205T110000Z.sql
Outdated
Show resolved
Hide resolved
...e-server/src/main/resources/db/changelog/changesets/twt_regulationPoint_20241205T110000Z.sql
Outdated
Show resolved
Hide resolved
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.
error at first start of network-store-server
grid-network-store-server-1 | Caused by: liquibase.exception.DatabaseException: ERROR: more than one row returned by a subquery used as an expression [Failed SQL: (0) UPDATE regulatingpoint r1
grid-network-store-server-1 | SET regulatedequipmenttype = (select CASE
grid-network-store-server-1 | WHEN bat.id IS NOT NULL THEN 'BATTERY'
grid-network-store-server-1 | WHEN bbs.id IS NOT NULL THEN 'BUSBAR_SECTION'
grid-network-store-server-1 | WHEN ld.id IS NOT NULL THEN 'LOAD'
grid-network-store-server-1 | WHEN gen.id IS NOT NULL THEN 'GENERATOR'
grid-network-store-server-1 | WHEN sc.id IS NOT NULL THEN 'SHUNT_COMPENSATOR'
grid-network-store-server-1 | WHEN vsc.id IS NOT NULL THEN 'VSC_CONVERTER_STATION'
grid-network-store-server-1 | WHEN lcc.id IS NOT NULL THEN 'LCC_CONVERTER_STATION'
grid-network-store-server-1 | WHEN svc.id IS NOT NULL THEN 'STATIC_VAR_COMPENSATOR'
grid-network-store-server-1 | WHEN twt.id IS NOT NULL THEN 'TWO_WINDINGS_TRANSFORMER'
grid-network-store-server-1 | WHEN ttwt.id IS NOT NULL THEN 'THREE_WINDINGS_TRANSFORMER'
grid-network-store-server-1 | WHEN l.id IS NOT NULL THEN 'LINE'
grid-network-store-server-1 | WHEN hvdc.id IS NOT NULL THEN 'HVDC_LINE'
grid-network-store-server-1 | WHEN dl.id IS NOT NULL THEN 'DANGLING_LINE'
grid-network-store-server-1 | END
grid-network-store-server-1 | FROM regulatingpoint r LEFT JOIN battery bat ON r.regulatingterminalconnectableid = bat.id and r.networkuuid = bat.networkuuid and r.variantnum = bat.variantnum
grid-network-store-server-1 | LEFT JOIN busbarsection bbs ON r.regulatingterminalconnectableid = bbs.id and r.networkuuid = bbs.networkuuid and r.variantnum = bbs.variantnum
grid-network-store-server-1 | LEFT JOIN load ld ON r.regulatingterminalconnectableid = ld.id and r.networkuuid = ld.networkuuid and r.variantnum = ld.variantnum
grid-network-store-server-1 | LEFT JOIN generator gen ON r.regulatingterminalconnectableid = gen.id and r.networkuuid = gen.networkuuid and r.variantnum = gen.variantnum
grid-network-store-server-1 | LEFT JOIN shuntcompensator sc ON r.regulatingterminalconnectableid = sc.id and r.networkuuid = sc.networkuuid and r.variantnum = sc.variantnum
grid-network-store-server-1 | LEFT JOIN vscconverterstation vsc ON r.regulatingterminalconnectableid = vsc.id and r.networkuuid = vsc.networkuuid and r.variantnum = vsc.variantnum
grid-network-store-server-1 | LEFT JOIN lccconverterstation lcc ON r.regulatingterminalconnectableid = lcc.id and r.networkuuid = lcc.networkuuid and r.variantnum = lcc.variantnum
grid-network-store-server-1 | LEFT JOIN staticvarcompensator svc ON r.regulatingterminalconnectableid = svc.id and r.networkuuid = svc.networkuuid and r.variantnum = svc.variantnum
grid-network-store-server-1 | LEFT JOIN twowindingstransformer twt ON r.regulatingterminalconnectableid = twt.id and r.networkuuid = twt.networkuuid and r.variantnum = twt.variantnum
grid-network-store-server-1 | LEFT JOIN threewindingstransformer ttwt ON r.regulatingterminalconnectableid = ttwt.id and r.networkuuid = ttwt.networkuuid and r.variantnum = ttwt.variantnum
grid-network-store-server-1 | LEFT JOIN line l ON r.regulatingterminalconnectableid = l.id and r.networkuuid = l.networkuuid and r.variantnum = l.variantnum
grid-network-store-server-1 | LEFT JOIN hvdcline hvdc ON r.regulatingterminalconnectableid = hvdc.id and r.networkuuid = hvdc.networkuuid and r.variantnum = hvdc.variantnum
grid-network-store-server-1 | LEFT JOIN danglingline dl ON r.regulatingterminalconnectableid = dl.id and r.networkuuid = dl.networkuuid and r.variantnum = dl.variantnum
grid-network-store-server-1 | WHERE r1.networkuuid = r.networkuuid and r1.variantnum = r.variantnum
grid-network-store-server-1 | and r1.regulatingequipmentid = r.regulatingequipmentid and r1.regulatingequipmenttype = r.regulatingequipmenttype)
grid-network-store-server-1 | WHERE regulatedequipmenttype is null AND r1.regulatingequipmentid <> r1.regulatingterminalconnectableid]
on my network with 1 stanway study + 2 studies with 3wt
network-store-server/src/main/resources/db/changelog/changesets/changelog_20241205T110000Z.xml
Outdated
Show resolved
Hide resolved
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior (if this is a feature change)?
Does this PR introduce a breaking change or deprecate an API?
If yes, please check if the following requirements are fulfilled
What changes might users need to make in their application due to this PR? (migration steps)
Other information: