-
Notifications
You must be signed in to change notification settings - Fork 8
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
Remove transformer voltage controls when no PV buses at non controlled side #482
Changes from 12 commits
f3b81d9
041bfff
50aa78a
bbbc949
c2e5ffe
87e7861
e998470
bdb8d6c
70aadf9
e654eaf
11214c3
0d551b3
c1929d4
d464b2b
3f34fb5
d169bbc
e468ed2
a37c3a8
f23b250
55e075b
42f5a70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,16 @@ | |
import com.powsybl.openloadflow.ac.outerloop.OuterLoopContext; | ||
import com.powsybl.openloadflow.ac.outerloop.OuterLoopStatus; | ||
import com.powsybl.openloadflow.network.LfBranch; | ||
import com.powsybl.openloadflow.network.LfBus; | ||
import com.powsybl.openloadflow.network.LfNetwork; | ||
import com.powsybl.openloadflow.network.PiModel; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
|
@@ -47,4 +51,41 @@ protected OuterLoopStatus roundVoltageRatios(OuterLoopContext context) { | |
} | ||
return status; | ||
} | ||
|
||
public static void checkControl(LfNetwork network) { | ||
var connectivity = network.getConnectivity(); | ||
List<LfBranch> controllerBranches = new ArrayList<>(1); | ||
for (LfBranch branch : network.getBranches()) { | ||
if (!branch.isDisabled() && branch.isVoltageController() && branch.isVoltageControlEnabled()) { | ||
controllerBranches.add(branch); | ||
} | ||
if (branch.isDisabled()) { | ||
// apply contingency (in case we are inside a security analysis) | ||
connectivity.cut(branch); | ||
} | ||
} | ||
for (LfBranch branch : controllerBranches) { | ||
connectivity.cut(branch); | ||
} | ||
for (LfBranch branch : controllerBranches) { | ||
var voltageControl = branch.getVoltageControl().orElseThrow(); | ||
var controlledBus = voltageControl.getControlled(); | ||
Set<LfBus> componentOnNotControlledSide = null; | ||
if (controlledBus.equals(branch.getBus1())) { | ||
componentOnNotControlledSide = connectivity.getConnectedComponent(branch.getBus2()); | ||
} else if (controlledBus.equals(branch.getBus2())) { | ||
componentOnNotControlledSide = connectivity.getConnectedComponent(branch.getBus1()); | ||
} else { | ||
// I don't know. | ||
} | ||
if (componentOnNotControlledSide != null) { | ||
Optional<LfBus> generatorControlledBus = componentOnNotControlledSide.stream().filter(LfBus::isVoltageControlled).findAny(); | ||
sylvlecl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!generatorControlledBus.isPresent()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can replace these two lines by |
||
branch.setVoltageControlEnabled(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not forget to restore it in the outer loop cleanup! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is done as the condition is only to have a voltage control, no? |
||
LOGGER.error("Transformer {} with voltage control on is disabled", branch.getId()); | ||
} | ||
} | ||
} | ||
connectivity.reset(); | ||
} | ||
} |
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.
I'm wondering if using the EvenShiloachGraphDecrementalConnectivity here is consistent, as the init is costly.
If we launch a security analysis, that's not a question as the init will be reused.
But if we only launch a loadflow, that's not really appropriate, and the naive approach is 4 times faster.
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.
If we keep it this way, the performance issue has been fixed by #537. It was because we get the main connected component many times. And EvenShiloach algorithm recomputes the main connected component each time it is asked (it was first implemented for use cases where only the small components were needed).
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.
This piece of code is ran both for a simple LF and a SA. We probably should use naive implementation for the LF and EvenShiloach for the SA but in both cases it has to be fast so it's a good thing that you improved performance for EvenShiloach.
I also think that performance issue was more visible for the SA than simple LF.