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

Cgmes import update. Import EQ and SSH separately. Transformers #3201

Draft
wants to merge 53 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
dcce636
update loads.
marqueslanauja Oct 16, 2024
6bc53a8
Update loads
marqueslanauja Oct 16, 2024
0241870
Adjust validationUtil
marqueslanauja Oct 16, 2024
e1e04b2
Adjust FunctionalLogsTests
marqueslanauja Oct 16, 2024
3eafccf
Fix all the tests
marqueslanauja Oct 16, 2024
3884a51
Fix issues
marqueslanauja Oct 16, 2024
71bb0f0
Pretty code
marqueslanauja Oct 16, 2024
fafaf11
Pretty code
marqueslanauja Oct 16, 2024
004b824
Pretty code
marqueslanauja Oct 18, 2024
8dc44cf
update
marqueslanauja Nov 6, 2024
81954c6
Typo
marqueslanauja Nov 6, 2024
2e6657b
Typo
marqueslanauja Nov 6, 2024
cbb0f54
Updating report
marqueslanauja Nov 6, 2024
2812eec
Merge branch 'main' into cgmes_import_update_network_loads
marqueslanauja Nov 6, 2024
32559be
Merge branch 'main' into cgmes_import_update_network_transformers
marqueslanauja Nov 6, 2024
b3d0945
update voltage and angles after the update
marqueslanauja Nov 6, 2024
7e3766a
Fix code smells
marqueslanauja Nov 7, 2024
df10d15
Minor changes
marqueslanauja Nov 7, 2024
5114bde
Pretty code
marqueslanauja Nov 7, 2024
69ade84
Reduce complexity
marqueslanauja Nov 7, 2024
e4b95b3
Reduce complexity
marqueslanauja Nov 7, 2024
81376bd
Undo mistake made before
marqueslanauja Nov 7, 2024
e7da075
pretty code
marqueslanauja Nov 7, 2024
4884abb
Some improvements
marqueslanauja Nov 13, 2024
779d778
Some improvements
marqueslanauja Nov 13, 2024
cdc18f7
More improvements
marqueslanauja Nov 13, 2024
5b2796c
update by using static classes
marqueslanauja Nov 14, 2024
324c805
Remove unused methods
marqueslanauja Nov 14, 2024
160edf1
update by using static classes
marqueslanauja Nov 14, 2024
c9075ca
Update comment
marqueslanauja Nov 14, 2024
79e54ae
Fix operational limits and pretty code
marqueslanauja Nov 14, 2024
42e4a14
pretty code
marqueslanauja Nov 14, 2024
3037fc2
Merge branch 'main' into cgmes_import_update_network_loads
marqueslanauja Dec 11, 2024
90c1caa
Merge branch 'main' into cgmes_import_update_network_transformers
marqueslanauja Dec 11, 2024
cfbcdde
unitary tests
marqueslanauja Dec 11, 2024
5be3060
Merge branch 'main' into cgmes_import_update_network_loads
zamarrenolm Dec 11, 2024
a23bad2
use proposed API for network updates
zamarrenolm Dec 11, 2024
52a6c8f
Add unitary tests
marqueslanauja Dec 12, 2024
eee776c
Pretty code
marqueslanauja Dec 12, 2024
a0b8bfd
Merge branch 'main' into cgmes_import_update_network_transformers
marqueslanauja Dec 12, 2024
5968a0b
Merge branch 'cgmes_import_update_network_loads' into cgmes_import_up…
marqueslanauja Dec 12, 2024
3a5a3ae
Minor changes.
marqueslanauja Dec 12, 2024
4485ba1
Fix code smell
marqueslanauja Dec 12, 2024
b63bbcd
Clean load queries
marqueslanauja Dec 12, 2024
c3a3893
Clean transformer queries
marqueslanauja Dec 12, 2024
9409954
Improve the management of properties associated with operational limi…
marqueslanauja Dec 12, 2024
fadfa86
Merge branch 'main' into cgmes_import_update_network_transformers
marqueslanauja Jan 2, 2025
7d6b4be
remove unused update queries
marqueslanauja Jan 2, 2025
35e8d42
Merge branch 'main' into cgmes_import_update_network_transformers
marqueslanauja Jan 7, 2025
80db8d1
Remove printf
marqueslanauja Jan 9, 2025
66fa642
Merge branch 'main' into cgmes_import_update_network_transformers
marqueslanauja Jan 9, 2025
ba4e224
Enhance the EQ files used in unit tests
marqueslanauja Jan 15, 2025
9619600
Improve EQ files used in unit tests
marqueslanauja Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Pretty code
Signed-off-by: marquesja1 <[email protected]>
  • Loading branch information
marqueslanauja committed Dec 12, 2024

Verified

This commit was signed with the committer’s verified signature.
kirillkurko Kirill Kurko
commit eee776ce3aaad4749dbdb1cc897efed7bba2fe84
Original file line number Diff line number Diff line change
@@ -26,9 +26,6 @@
*/
public class EnergyConsumerConversion extends AbstractConductingEquipmentConversion {

private static final String P_FIXED = "pFixed";
private static final String Q_FIXED = "qFixed";

public EnergyConsumerConversion(PropertyBag ec, Context context) {
super(CgmesNames.ENERGY_CONSUMER, ec, context);
loadKind = ec.getLocal("type");
@@ -44,8 +41,8 @@ public void convert() {
} else {
loadType = LoadType.UNDEFINED;
}
double pFixed = p.asDouble(P_FIXED, 0.0);
double qFixed = p.asDouble(Q_FIXED, 0.0);
double pFixed = p.asDouble(CgmesNames.P_FIXED, 0.0);
double qFixed = p.asDouble(CgmesNames.Q_FIXED, 0.0);
LoadAdder adder = voltageLevel().newLoad()
.setLoadType(loadType);
identify(adder);
@@ -61,8 +58,8 @@ public void convert() {

private void addSpecificProperties(Load newLoad, double pFixed, double qFixed) {
newLoad.setProperty(Conversion.PROPERTY_CGMES_ORIGINAL_CLASS, loadKind);
newLoad.setProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + P_FIXED, String.valueOf(pFixed));
newLoad.setProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + Q_FIXED, String.valueOf(qFixed));
newLoad.setProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + CgmesNames.P_FIXED, String.valueOf(pFixed));
newLoad.setProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + CgmesNames.Q_FIXED, String.valueOf(qFixed));
}

private void model(LoadAdder adder) {
@@ -145,8 +142,8 @@ private static void setLoadDetail(String type, Load newLoad, double pFixed, doub
public static void update(Load load, PropertyBag cgmesData, Context context) {
updateTerminals(load, context, load.getTerminal());

double pFixed = Double.parseDouble(load.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + P_FIXED));
double qFixed = Double.parseDouble(load.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + Q_FIXED));
double pFixed = Double.parseDouble(load.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + CgmesNames.P_FIXED));
double qFixed = Double.parseDouble(load.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + CgmesNames.Q_FIXED));

PowerFlow updatedPowerFlow = updatedPowerFlow(load, cgmesData, context);
load.setP0(updatedPowerFlow.defined() ? updatedPowerFlow.p() : defaultValue(pFixed, load.getP0(), 0.0, Double.NaN, getDefaultValueSelector(context)));
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@
*/
package com.powsybl.cgmes.conversion.test;

import com.powsybl.cgmes.conversion.Conversion;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.iidm.network.Load;
import com.powsybl.iidm.network.Network;
import org.junit.jupiter.api.Test;
@@ -28,13 +30,13 @@ void importEqTest() {
assertEquals(3, network.getLoadCount());

Load loadEnergyConsumer = network.getLoad("EnergyConsumer");
assertTrue(checkNaNLoad(loadEnergyConsumer));
assertTrue(checkEq(loadEnergyConsumer));

Load loadEnergySource = network.getLoad("EnergySource");
assertTrue(checkNaNLoad(loadEnergySource));
assertTrue(checkEq(loadEnergySource));

Load loadAsynchronousMachine = network.getLoad("AsynchronousMachine");
assertTrue(checkNaNLoad(loadAsynchronousMachine));
assertTrue(checkEq(loadAsynchronousMachine));
}

@Test
@@ -43,67 +45,73 @@ void importEqAndSshTogetherTest() {
assertEquals(3, network.getLoadCount());

Load loadEnergyConsumer = network.getLoad("EnergyConsumer");
assertTrue(checkLoad(loadEnergyConsumer, 10.0, 5.0));
assertTrue(checkSsh(loadEnergyConsumer, 10.0, 5.0));

Load loadEnergySource = network.getLoad("EnergySource");
assertTrue(checkLoad(loadEnergySource, -200.0, -90.0));
assertTrue(checkSsh(loadEnergySource, -200.0, -90.0));

Load loadAsynchronousMachine = network.getLoad("AsynchronousMachine");
assertTrue(checkLoad(loadAsynchronousMachine, 200.0, 50.0));
assertTrue(checkSsh(loadAsynchronousMachine, 200.0, 50.0));
}

@Test
void importEAndSshSeparatelyTest() {
void importEqAndSshSeparatelyTest() {
Network network = readCgmesResources(DIR, "load_EQ.xml");
assertEquals(3, network.getLoadCount());

Load loadEnergyConsumer = network.getLoad("EnergyConsumer");
assertTrue(checkNaNLoad(loadEnergyConsumer));
assertTrue(checkEq(loadEnergyConsumer));
Load loadEnergySource = network.getLoad("EnergySource");
assertTrue(checkNaNLoad(loadEnergySource));
assertTrue(checkEq(loadEnergySource));
Load loadAsynchronousMachine = network.getLoad("AsynchronousMachine");
assertTrue(checkNaNLoad(loadAsynchronousMachine));
assertTrue(checkEq(loadAsynchronousMachine));

readCgmesResources(network, DIR, "load_SSH.xml");

assertTrue(checkLoad(loadEnergyConsumer, 10.0, 5.0));
assertTrue(checkLoad(loadEnergySource, -200.0, -90.0));
assertTrue(checkLoad(loadAsynchronousMachine, 200.0, 50.0));
assertTrue(checkSsh(loadEnergyConsumer, 10.0, 5.0));
assertTrue(checkSsh(loadEnergySource, -200.0, -90.0));
assertTrue(checkSsh(loadAsynchronousMachine, 200.0, 50.0));
}

@Test
void importEAndTwoSshsTest() {
void importEqAndTwoSshsTest() {
Network network = readCgmesResources(DIR, "load_EQ.xml");
assertEquals(3, network.getLoadCount());

Load loadEnergyConsumer = network.getLoad("EnergyConsumer");
assertTrue(checkNaNLoad(loadEnergyConsumer));
assertTrue(checkEq(loadEnergyConsumer));
Load loadEnergySource = network.getLoad("EnergySource");
assertTrue(checkNaNLoad(loadEnergySource));
assertTrue(checkEq(loadEnergySource));
Load loadAsynchronousMachine = network.getLoad("AsynchronousMachine");
assertTrue(checkNaNLoad(loadAsynchronousMachine));
assertTrue(checkEq(loadAsynchronousMachine));

readCgmesResources(network, DIR, "load_SSH.xml");

assertTrue(checkLoad(loadEnergyConsumer, 10.0, 5.0));
assertTrue(checkLoad(loadEnergySource, -200.0, -90.0));
assertTrue(checkLoad(loadAsynchronousMachine, 200.0, 50.0));
assertTrue(checkSsh(loadEnergyConsumer, 10.0, 5.0));
assertTrue(checkSsh(loadEnergySource, -200.0, -90.0));
assertTrue(checkSsh(loadAsynchronousMachine, 200.0, 50.0));

readCgmesResources(network, DIR, "load_SSH_1.xml");

assertTrue(checkLoad(loadEnergyConsumer, 10.5, 5.5));
assertTrue(checkLoad(loadEnergySource, -200.5, -90.5));
assertTrue(checkLoad(loadAsynchronousMachine, 200.5, 50.5));
assertTrue(checkSsh(loadEnergyConsumer, 10.5, 5.5));
assertTrue(checkSsh(loadEnergySource, -200.5, -90.5));
assertTrue(checkSsh(loadAsynchronousMachine, 200.5, 50.5));
}

private static boolean checkNaNLoad(Load load) {
private static boolean checkEq(Load load) {
assertNotNull(load);
assertTrue(Double.isNaN(load.getP0()));
assertTrue(Double.isNaN(load.getQ0()));
String originalClass = load.getProperty(Conversion.PROPERTY_CGMES_ORIGINAL_CLASS);
if (originalClass.equals(CgmesNames.ENERGY_CONSUMER)) {
assertNotNull(load.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + CgmesNames.P_FIXED));
assertNotNull(load.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + CgmesNames.Q_FIXED));
}
load.getPropertyNames().forEach(pn -> System.err.printf("Property %s %s %n", pn, load.getProperty(pn)));
return true;
}

private static boolean checkLoad(Load load, double p0, double q0) {
private static boolean checkSsh(Load load, double p0, double q0) {
assertNotNull(load);
assertEquals(p0, load.getP0());
assertEquals(q0, load.getQ0());
Original file line number Diff line number Diff line change
@@ -144,6 +144,8 @@ public final class CgmesNames {
public static final String CURRENT_LIMIT = "CurrentLimit";
public static final String ACTIVE_POWER_LIMIT = "ActivePowerLimit";
public static final String APPARENT_POWER_LIMIT = "ApparentPowerLimit";
public static final String P_FIXED = "pFixed";
public static final String Q_FIXED = "qFixed";

private CgmesNames() {
}
Loading