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

fix syncv #460

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

fix syncv #460

wants to merge 17 commits into from

Conversation

jonenst
Copy link
Collaborator

@jonenst jonenst commented Sep 27, 2024

No description provided.

@jonenst
Copy link
Collaborator Author

jonenst commented Sep 30, 2024

example fixes for #452

Signed-off-by: Franck LECUYER <[email protected]>
Signed-off-by: Franck LECUYER <[email protected]>
…tWithSwitchTest, with buses in bus breaker view between retained switches and with no equipments.

Signed-off-by: Franck LECUYER <[email protected]>
@FranckLecuyer FranckLecuyer changed the title wip fix syncv fix syncv Oct 22, 2024
if (foundConfiguredBus.get() != null) {
v.set(foundConfiguredBus.get().getResource().getAttributes().getV());
angle.set(foundConfiguredBus.get().getResource().getAttributes().getAngle());
if (foundConfiguredBus.get() == null) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

break early instead of checking if found in the loop

@jonenst jonenst changed the base branch from synchronize_set_v_angle_on_bus_between_views to main October 22, 2024 09:00
LineImpl l1 = (LineImpl) network.getLine("L1");

// Update angle using BusView
l1.getTerminal1().getBusView().getBus().setAngle(111);
Copy link
Collaborator Author

@jonenst jonenst Oct 22, 2024

Choose a reason for hiding this comment

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

for better coverage, start the angle busbreaker topology test with a setAngle in the busbreakerview
and the nodebreaker topology test start with a setAngle in the busview

to do the opposite of the setV test

String busbreakerviewbusid = entry.getKey();
String busviewbusid = entry.getValue();

for (Bus bbvb : vl.getBusBreakerView().getBuses()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we need to refactor these test to allow testing with or without already calculated buses. Here because we force getBuses before the tests, we always run with calculated bus already computed

AtomicDouble v,
AtomicDouble angle,
boolean isBusView) {
if (voltageLevelResource.getAttributes().getTopologyKind() == TopologyKind.NODE_BREAKER) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should we use if (isCalculatedBusesValid(voltageLevelResource, !isBusView)) {
like in getCalculatedBusAttributesList ?

Copy link

sonarcloud bot commented Oct 22, 2024

@jonenst
Copy link
Collaborator Author

jonenst commented Dec 4, 2024

@FranckLecuyer can you take a look ?

@jonenst jonenst requested a review from antoinebhs December 4, 2024 23:12
…ws, simplify code, throw exceptions instead of silently doing nothing

Signed-off-by: HARPER Jon <[email protected]>
Copy link

sonarcloud bot commented Dec 4, 2024

Copy link
Collaborator

@antoinebhs antoinebhs left a comment

Choose a reason for hiding this comment

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

Quick reading of this PR, no tests

Comment on lines +385 to +406
private CalculatedBusAttributes createCalculatedBusAttributesWithVAndAngle(NetworkObjectIndex index,
Resource<VoltageLevelAttributes> voltageLevelResource,
ConnectedSetResult<T> connectedSet,
boolean isBusView) {
double v = Double.NaN;
double angle = Double.NaN;
if (voltageLevelResource.getAttributes().getTopologyKind() == TopologyKind.NODE_BREAKER) {
CalculatedBusAttributes busAttributes = findFirstMatchingNodeBreakerCalculatedBusAttributes(voltageLevelResource, connectedSet, isBusView);
if (busAttributes != null) {
v = busAttributes.getV();
angle = busAttributes.getAngle();
}
} else { // BUS_BREAKER
// currently for busbreakertopology the values are always preserved
// when using only the busbreakerview. So mimic the behavior and always preserve them
// when using the busview: get V and Angle values from configured buses
String configuredBusId = ((ConnectedSetResult<String>) connectedSet).getConnectedNodesOrBuses().iterator().next(); // nondeterministic
Bus b = index.getConfiguredBus(configuredBusId).orElseThrow();
v = b.getV();
angle = b.getAngle();
}
return new CalculatedBusAttributes(connectedSet.getConnectedVertices(), null, null, v, angle);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This if/else makes me think that this should be implemented in BusBreakerTopology/NodeBreakerTopology classes ? Maybe an abstraction here

@@ -471,4 +509,43 @@ public <E extends Extension<Bus>, B extends ExtensionAdder<Bus, E>> B newExtensi
public int getCalculatedBusNum() {
return calculatedBusNum;
}

private void updateBusesAttributes(double value, ObjDoubleConsumer<CalculatedBusAttributes> setValue) {
// busnum of this bus -> nodes in this bus -> busnums in the other view -> buses of the other view
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is not clear

Comment on lines +528 to +530
List<CalculatedBusAttributes> calculatedBusAttributes = isBusView
? vlAttributes.getCalculatedBusesForBusBreakerView()
: vlAttributes.getCalculatedBusesForBusView();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this inside the for loop? It looks like it's constant? Similarly to nodesToCalculatedBuses, etc

Comment on lines +138 to +152
private void setVInCalculatedBus(CalculatedBusAttributes calculatedBusAttributes, double value) {
calculatedBusAttributes.setV(value);
}

private void setVInConfiguredBus(ConfiguredBusImpl configuredBus, double value) {
configuredBus.setConfiguredBusV(value);
}

private void setAngleInCalculatedBus(CalculatedBusAttributes calculatedBusAttributes, double value) {
calculatedBusAttributes.setAngle(value);
}

private void setAngleInConfiguredBus(ConfiguredBusImpl configuredBus, double value) {
configuredBus.setConfiguredBusAngle(value);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we have some consistency in naming?
setAngleInConfiguredBus // setConfiguredBusAngle
setAngleInCalculatedBus // setAngle
same for V

return this;
}

void setAngle(double angle, boolean updateCalculatedBus) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

private?

.add();

// add busbar sections in star coupling to have a bus in the middle without any equipment. It will
// exist in the busbreaker view but not in the busview. For this one use closed switches so that it
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lot of suspense...

/**
* @author Jon Harper <jon.harper at rte-france.com>
*
* complex specific exhaustive tests for setV and setAngle interactions with calculated views.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice 👍

// currently for busbreakertopology the values are always preserved
// when using only the busbreakerview. So mimic the behavior and always preserve them
// when using the busview: get V and Angle values from configured buses
String configuredBusId = ((ConnectedSetResult<String>) connectedSet).getConnectedNodesOrBuses().iterator().next(); // nondeterministic
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe check iterator with hasNext before calling next ...

// when using only the busbreakerview. So mimic the behavior and always preserve them
// when using the busview: get V and Angle values from configured buses
String configuredBusId = ((ConnectedSetResult<String>) connectedSet).getConnectedNodesOrBuses().iterator().next(); // nondeterministic
Bus b = index.getConfiguredBus(configuredBusId).orElseThrow();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe customize the exception, in order to have a more accurate message ...

for (Map.Entry<String, String > entry : busBreakerViewBusToBusViewBus.entrySet()) {
String busbreakerviewbusid = entry.getKey();
String busviewbusid = entry.getValue();
setAllBbvbAndBvb(vl, Double.NaN, setter);
Copy link
Contributor

Choose a reason for hiding this comment

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

setAllBusBreakerViewBusAndBusViewBus ?

if (vl.getTopologyKind() == TopologyKind.NODE_BREAKER) {
// test one same view
vl = networkVoltageLevelSupplier.get();
setAllBbvb(vl, 1.0, setter);
Copy link
Contributor

Choose a reason for hiding this comment

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

setAllBusBreakerViewBus ?


// test one other view
vl = networkVoltageLevelSupplier.get();
setAllBvb(vl, 1.0, setter);
Copy link
Contributor

Choose a reason for hiding this comment

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

setAllBusViewBus ?

// so test only with busview view
// NOTE: for busbreakertopology we keep the previous values.
vl = networkVoltageLevelSupplier.get();
setAllBvb(vl, 1.0, setter);
Copy link
Contributor

Choose a reason for hiding this comment

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

setAllBusViewBus ?

for (Map.Entry<String, List<String> > entry : busViewBusToBusBreakerViewBus.entrySet()) {
String busviewbusid = entry.getKey();
List<String> busbreakerviewbusids = entry.getValue();
setAllBbvbAndBvb(vl, Double.NaN, setter);
Copy link
Contributor

Choose a reason for hiding this comment

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

setAllBusBreakerViewBusAndBusViewBus ?

// test one same view, nodebreakertopology and busbreakertopology behave the same here
if (vl.getTopologyKind() == TopologyKind.NODE_BREAKER) {
vl = networkVoltageLevelSupplier.get();
setAllBvb(vl, 1.0, setter);
Copy link
Contributor

Choose a reason for hiding this comment

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

setAllBusViewBus ?


// test one other view
vl = networkVoltageLevelSupplier.get();
setAllBvb(vl, 1.0, setter);
Copy link
Contributor

Choose a reason for hiding this comment

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

setAllBusViewBus ?

// so test only with busview view
// NOTE: for busbreakertopology we keep the previous values.
vl = networkVoltageLevelSupplier.get();
setAllBvb(vl, 1.0, setter);
Copy link
Contributor

Choose a reason for hiding this comment

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

setAllBusViewBus ?

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.

3 participants