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

[Shortcircuit] Add new parameters #2638

Merged
merged 50 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ce59859
Add subTransientCoefficient to ShortCircuitParameters and FaultParame…
colinepiloquet Jul 6, 2023
771079b
Add test
colinepiloquet Jul 6, 2023
16a8f9a
Add new parameters in ShortCircuitParameters
colinepiloquet Jul 28, 2023
9fdd8c6
Add new parameters in FaultParameters
colinepiloquet Jul 28, 2023
5169780
Merge branch 'main' into add_subtransient_coefficient
colinepiloquet Jul 28, 2023
191ad94
Add tests
colinepiloquet Jul 31, 2023
d2fe45d
Add some javadoc
colinepiloquet Jul 31, 2023
89bbf40
Fix version in ShortCircuitAnalysisResult
colinepiloquet Aug 1, 2023
6435505
Add initial voltage profile and coefficients in parameters
colinepiloquet Aug 2, 2023
6417e3c
Merge branch 'main' into add_subtransient_coefficient
colinepiloquet Aug 2, 2023
b675539
Increase test coverage
colinepiloquet Aug 2, 2023
c9c3a37
change switch/case and casting
colinepiloquet Aug 7, 2023
3a03eec
Some fixes
colinepiloquet Aug 7, 2023
cd35a17
fix
colinepiloquet Aug 7, 2023
3c9f6c7
Merge branch 'main' into add_subtransient_coefficient
colinepiloquet Aug 10, 2023
9dbcce7
Merge branch 'main' into add_subtransient_coefficient
olperr1 Aug 11, 2023
53d375c
Renaming
colinepiloquet Aug 21, 2023
cc5898b
Add checks
colinepiloquet Aug 21, 2023
56bab08
review
colinepiloquet Aug 21, 2023
44a02af
Merge branch 'main' into add_subtransient_coefficient
colinepiloquet Aug 22, 2023
ac1dc80
Fix code smells
colinepiloquet Aug 22, 2023
f439d6c
Merge branch 'main' into add_subtransient_coefficient
annetill Aug 23, 2023
2f59365
review
colinepiloquet Aug 24, 2023
024cd51
fix
colinepiloquet Aug 24, 2023
702a9ce
Proposal for a builder
colinepiloquet Aug 24, 2023
81cbc9e
Make withNeutralTapChanger false by default.
colinepiloquet Aug 24, 2023
6f6a621
Make withNeutralTapChanger false by default - test fix
colinepiloquet Aug 24, 2023
0c4093c
Revert "Proposal for a builder"
colinepiloquet Aug 29, 2023
d2f09a9
Add check on parameters in runAsync
colinepiloquet Aug 29, 2023
6e94823
Merge branch 'main' into add_subtransient_coefficient
colinepiloquet Aug 30, 2023
7e7b2b9
Add checks
colinepiloquet Aug 30, 2023
9db0275
Fix code smells + one test
colinepiloquet Aug 30, 2023
6efbc9d
Fixes
colinepiloquet Aug 30, 2023
902c764
Add test, fix check
colinepiloquet Aug 31, 2023
294d671
Remove default in switch
colinepiloquet Aug 31, 2023
e0019eb
Fix wording
colinepiloquet Sep 4, 2023
e49a914
Add voltage range data file in config + add test with multiple feeders
colinepiloquet Sep 7, 2023
6e41236
Return empty collection instead of null
colinepiloquet Sep 7, 2023
bb3c529
Renaming + one test
colinepiloquet Sep 11, 2023
3a79cee
Enhance getVoltageRangeDataFromConfig method
colinepiloquet Sep 11, 2023
d71f5df
Merge branch 'main' into add_subtransient_coefficient
colinepiloquet Sep 11, 2023
da85b8c
Merge branch 'main' into add_subtransient_coefficient
annetill Sep 12, 2023
b21ba27
Merge branch 'main' into add_subtransient_coefficient
annetill Sep 13, 2023
e4caccb
Renaming
colinepiloquet Sep 14, 2023
7be6608
Merge branch 'main' into add_subtransient_coefficient
colinepiloquet Sep 14, 2023
7649a3b
Merge branch 'main' into add_subtransient_coefficient
colinepiloquet Sep 18, 2023
95a83d5
Voltage range path is now absolute
colinepiloquet Sep 18, 2023
9f5b94e
Clean
geofjamg Sep 18, 2023
c8a60c7
Merge branch 'main' into add_subtransient_coefficient
colinepiloquet Sep 18, 2023
077cd9a
Clean
geofjamg Sep 18, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,36 @@
package com.powsybl.shortcircuit;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.powsybl.commons.PowsyblException;
import com.powsybl.commons.json.JsonUtil;
import com.powsybl.shortcircuit.json.ShortCircuitAnalysisJsonModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import static com.powsybl.shortcircuit.VoltageRange.checkVoltageRange;

/**
* @author Thomas Adam <tadam at silicom.fr>
*/
public class FaultParameters {

private static final Logger LOGGER = LoggerFactory.getLogger(FaultParameters.class);

// VERSION = 1.0 withLimitViolations, withVoltageMap, withFeederResult, studyType and minVoltageDropProportionalThreshold
// VERSION = 1.1 withVoltageMap -> withFortescueResult and withVoltageResult
public static final String VERSION = "1.1";
// VERSION = 1.2 subTransientCoefficient, withLoads, withShuntCompensators, withVSCConverterStations, withNeutralPosition,
// initialVoltageProfileMode, voltageRanges
public static final String VERSION = "1.2";

private final String id;

Expand All @@ -42,6 +52,20 @@ public class FaultParameters {

private final double minVoltageDropProportionalThreshold;

private final double subTransientCoefficient;

private final boolean withLoads;

private final boolean withShuntCompensators;

private final boolean withVSCConverterStations;

private final boolean withNeutralPosition;

private final InitialVoltageProfileMode initialVoltageProfileMode;

private final List<VoltageRange> voltageRanges;

/** Fault id */
public String getId() {
return id;
Expand Down Expand Up @@ -77,20 +101,85 @@ public double getMinVoltageDropProportionalThreshold() {
return minVoltageDropProportionalThreshold;
}

/** Override general parameter subTransientCoefficient from {@link ShortCircuitParameters} */
public double getSubTransientCoefficient() {
return subTransientCoefficient;
}

/** Override general parameter withLoads from {@link com.powsybl.shortcircuit.ShortCircuitParameters} */
public boolean isWithLoads() {
return withLoads;
}

/** Override general parameter withShuntCompensators from {@link com.powsybl.shortcircuit.ShortCircuitParameters} */
public boolean isWithShuntCompensators() {
return withShuntCompensators;
}

/** Override general parameter withVSCConverterStations from {@link com.powsybl.shortcircuit.ShortCircuitParameters} */
public boolean isWithVSCConverterStations() {
return withVSCConverterStations;
}

/** Override general parameter withNeutralPosition from {@link com.powsybl.shortcircuit.ShortCircuitParameters} */
public boolean isWithNeutralPosition() {
return withNeutralPosition;
}

/** Override general parameter initialVoltageProfileMode from {@link com.powsybl.shortcircuit.ShortCircuitParameters} */
public InitialVoltageProfileMode getInitialVoltageProfileMode() {
return initialVoltageProfileMode;
}

/** Override general parameter voltageRanges from {@link ShortCircuitParameters}*/
public List<VoltageRange> getVoltageRanges() {
return voltageRanges;
}

public FaultParameters(String id,
boolean withLimitViolations,
boolean withVoltageResult,
boolean withFeederResult,
StudyType studyType,
double minVoltageDropProportionalThreshold,
boolean withFortescueResult) {
boolean withFortescueResult,
double subTransientCoefficient,
boolean withLoads,
boolean withShuntCompensators,
boolean withVSCConverterStations,
boolean withNeutralPosition,
InitialVoltageProfileMode initialVoltageProfileMode,
List<VoltageRange> voltageRanges) {
this.id = Objects.requireNonNull(id);
this.withLimitViolations = withLimitViolations;
this.withVoltageResult = withVoltageResult;
this.withFeederResult = withFeederResult;
this.studyType = studyType;
this.minVoltageDropProportionalThreshold = minVoltageDropProportionalThreshold;
this.withFortescueResult = withFortescueResult;
this.subTransientCoefficient = checkSubTransientCoefficient(subTransientCoefficient);
this.withLoads = withLoads;
this.withShuntCompensators = withShuntCompensators;
this.withVSCConverterStations = withVSCConverterStations;
this.withNeutralPosition = withNeutralPosition;
this.initialVoltageProfileMode = initialVoltageProfileMode;
this.voltageRanges = new ArrayList<>();
if (voltageRanges != null) {
if (initialVoltageProfileMode == InitialVoltageProfileMode.CONFIGURED) {
checkVoltageRange(voltageRanges);
this.voltageRanges.addAll(voltageRanges);
} else {
LOGGER.warn("Nominal voltage ranges with associated coefficient are defined but InitialVoltageProfileMode is not CONFIGURED: they are ignored");
}
}
this.validate();
}

private double checkSubTransientCoefficient(double subTransientCoefficient) {
if (subTransientCoefficient > 1) {
throw new PowsyblException("subTransientCoefficient > 1");
}
return subTransientCoefficient;
}

@Override
Expand All @@ -108,12 +197,22 @@ public boolean equals(Object o) {
Objects.equals(withFeederResult, that.withFeederResult) &&
Objects.equals(studyType, that.studyType) &&
Objects.equals(minVoltageDropProportionalThreshold, that.minVoltageDropProportionalThreshold) &&
Objects.equals(withFortescueResult, that.withFortescueResult);
Objects.equals(withFortescueResult, that.withFortescueResult) &&
Objects.equals(subTransientCoefficient, that.subTransientCoefficient) &&
Objects.equals(withLoads, that.withLoads) &&
Objects.equals(withShuntCompensators, that.withShuntCompensators) &&
Objects.equals(withVSCConverterStations, that.withVSCConverterStations) &&
Objects.equals(withNeutralPosition, that.withNeutralPosition) &&
Objects.equals(initialVoltageProfileMode, that.initialVoltageProfileMode) &&
Objects.equals(voltageRanges, that.voltageRanges);
}

@Override
public int hashCode() {
return Objects.hash(id, withLimitViolations, withVoltageResult, withFeederResult, studyType, minVoltageDropProportionalThreshold, withFortescueResult);
return Objects.hash(id, withLimitViolations, withVoltageResult, withFeederResult, studyType,
minVoltageDropProportionalThreshold, withFortescueResult, subTransientCoefficient,
withLoads, withShuntCompensators, withVSCConverterStations, withNeutralPosition,
initialVoltageProfileMode, voltageRanges);
}

@Override
Expand All @@ -126,6 +225,13 @@ public String toString() {
", studyType=" + studyType +
", minVoltageDropProportionalThreshold=" + minVoltageDropProportionalThreshold +
", withFortescueResult=" + withFortescueResult +
", subTransientCoefficient=" + subTransientCoefficient +
", withLoads=" + withLoads +
", withShuntCompensators=" + withShuntCompensators +
", withVSCConverterStations=" + withVSCConverterStations +
", withNeutralPosition=" + withNeutralPosition +
", initialVoltageProfileMode=" + initialVoltageProfileMode +
", voltageRanges=" + voltageRanges +
'}';
}

Expand All @@ -148,4 +254,10 @@ public static List<FaultParameters> read(Path jsonFile) {
throw new UncheckedIOException(e);
}
}

public void validate() {
if (initialVoltageProfileMode == InitialVoltageProfileMode.CONFIGURED && (voltageRanges == null || voltageRanges.isEmpty())) {
throw new PowsyblException("Configured initial voltage profile but nominal voltage ranges with associated coefficients are missing.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright (c) 2023, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.shortcircuit;

/**
* @author Coline Piloquet <coline.piloquet at rte-france.com>
*/
public enum InitialVoltageProfileMode {
NOMINAL,
CONFIGURED, // Voltage profile given by the user
PREVIOUS_VALUE // Voltage profile from the loadflow

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public CompletableFuture<ShortCircuitAnalysisResult> runAsync(Network network,
Objects.requireNonNull(computationManager, NOT_NULL_COMPUTATION_MANAGER_MESSAGE);
Objects.requireNonNull(parameters, NOT_NULL_PARAMETERS_MESSAGE);
Objects.requireNonNull(reporter, "Reporter should not be null");
validateParameters(parameters);
return provider.run(network, faults, parameters, computationManager, faultParameters, reporter);
}

Expand All @@ -66,9 +67,14 @@ public CompletableFuture<ShortCircuitAnalysisResult> runAsync(Network network,
Objects.requireNonNull(faults, NOT_NULL_FAULT_MESSAGE);
Objects.requireNonNull(computationManager, NOT_NULL_COMPUTATION_MANAGER_MESSAGE);
Objects.requireNonNull(parameters, NOT_NULL_PARAMETERS_MESSAGE);
validateParameters(parameters);
return provider.run(network, faults, parameters, computationManager, faultParameters);
}

private void validateParameters(ShortCircuitParameters shortCircuitParameters) {
shortCircuitParameters.validate();
}

public ShortCircuitAnalysisResult run(Network network, List<Fault> faults,
ShortCircuitParameters parameters,
ComputationManager computationManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class ShortCircuitAnalysisResult extends AbstractExtendable<ShortCircuitAnalysisResult> {

// VERSION = 1.0 faultResults
// VERSION = 1.0 status in faultResult
// VERSION = 1.1 status in faultResult
public static final String VERSION = "1.1";

private final Map<String, FaultResult> resultByFaultId = new TreeMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ private ShortCircuitConstants() {
public static final boolean DEFAULT_WITH_FEEDER_RESULT = true;
public static final double DEFAULT_MIN_VOLTAGE_DROP_PROPORTIONAL_THRESHOLD = 0.0;
public static final boolean DEFAULT_WITH_FORTESCUE_RESULT = true;
public static final double DEFAULT_SUB_TRANSIENT_COEFFICIENT = 0.7;
public static final boolean DEFAULT_WITH_LOADS = true;
public static final boolean DEFAULT_WITH_SHUNT_COMPENSATORS = true;
public static final boolean DEFAULT_WITH_VSC_CONVERTER_STATIONS = true;
public static final boolean DEFAULT_WITH_NEUTRAL_POSITION = false;
public static final InitialVoltageProfileMode DEFAULT_INITIAL_VOLTAGE_PROFILE_MODE = InitialVoltageProfileMode.NOMINAL;
}
colinepiloquet marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading