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: fix HVDC active power set point conversion #2012

Merged
merged 15 commits into from
Mar 25, 2022

Conversation

annetill
Copy link
Member

Signed-off-by: Anne Tilloy anne.tilloy@rte-france.com

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem ? If so, link to this issue using '#XXX' and skip the rest

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change or deprecate an API? If yes, check the following:

  • The Breaking Change or Deprecated label has been added
  • The migration guide has been updated in the github wiki (What changes might users need to make in their application due to this PR?)

Other information:

(if any of the questions/checkboxes don't apply, please delete them entirely)

Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
@annetill annetill requested a review from miovd March 14, 2022 15:45
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
@@ -101,19 +101,19 @@ private static double getMaxP(double pAC1, double pAC2, HvdcLine.ConvertersMode
return DEFAULT_MAXP_FACTOR * Math.abs(pAC1);
}

private static double getPDc(double pAC1, double pAC2, double poleLossP1, double poleLossP2,
HvdcLine.ConvertersMode mode) {
private static double getActivePowerSetpoint(double pAC1, double pAC2, double poleLossP1, double poleLossP2,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment saying that the active power set point of an HVDC should be interpreted on AC side of the rectifier converter

Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
@annetill annetill changed the title [WIP] CGMES import: fix HVDC active power set point conversion CGMES import: fix HVDC active power set point conversion Mar 22, 2022
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
Copy link
Contributor

@marqueslanauja marqueslanauja left a comment

Choose a reason for hiding this comment

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

I reviewed all the code and it is ok. Another way to avoid the duplicated code is to add a new method getPdc in the HvdcLine interface. The code of the method will be:

    public double getPdc() {
        if (getConvertersMode() == ConvertersMode.SIDE_1_RECTIFIER_SIDE_2_INVERTER) {
            return getActivePowerSetpoint() * (1 - converterStation1.getLossFactor() / 100);
        } else {
            return getActivePowerSetpoint() * (1 - converterStation2.getLossFactor() / 100);
        }
    }

@@ -441,9 +441,10 @@ private static void writeConverters(Network network, String cimNamespace, XMLStr
for (HvdcConverterStation<?> converterStation : network.getHvdcConverterStations()) {
double poleLoss;
if (CgmesExportUtil.isConverterStationRectifier(converterStation)) {
poleLoss = converterStation.getLossFactor() * converterStation.getHvdcLine().getActivePowerSetpoint() / (100 - converterStation.getLossFactor());
Copy link
Member Author

Choose a reason for hiding this comment

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

I think that we may have an issue here... why we don't rely on converter station terminals to get p?

Copy link
Contributor

Choose a reason for hiding this comment

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

We agree. We should use the terminal P to get poleLoss as a first option and only when terminal P is no available use the current code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you please make the fix?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I am doing it.

if (hvdcLine != null) {
return hvdcLine.getConverterStation1() == this ? hvdcLine.getConverterStation2() : hvdcLine.getConverterStation1();
} else {
throw new UnsupportedOperationException();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should throw an exception, maybe make the method return an optional that can be empty:

public Optional<HvdcConverterStation> getOtherConverterStation() {
        if (hvdcLine != null) {
            return hvdcLine.getConverterStation1() == this ? Optional.of(hvdcLine.getConverterStation2()) : Optional.of(hvdcLine.getConverterStation1());
        } 
     return Optional.empty();
}

Comment on lines 48 to 54
HvdcLine hvdcLine = getHvdcLine();
if (hvdcLine != null) {
return hvdcLine.getConverterStation1() == this ? hvdcLine.getConverterStation2() : hvdcLine.getConverterStation1();
} else {
throw new UnsupportedOperationException();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Only do: return getIndex().getHvdcConverterStation(getDelegate().getHvdcConverterStation());

annetill and others added 8 commits March 22, 2022 19:47
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
Signed-off-by: VEDELAGO MIORA <miora.ralambotiana@rte-france.com>
Signed-off-by: José Antonio Marqués <marquesja@aia.es>
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

71.4% 71.4% Coverage
0.0% 0.0% Duplication

@miovd miovd merged commit f284475 into main Mar 25, 2022
@miovd miovd deleted the fix-cgmes-conversion-hdvc branch March 25, 2022 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants