Skip to content

Commit

Permalink
Same provider name for LF, SA and Sensi (#556)
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
  • Loading branch information
geofjamg authored Jun 14, 2022
1 parent 0cedd9b commit 269b803
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.powsybl.openloadflow.util.Markers;
import com.powsybl.openloadflow.util.PerUnit;
import com.powsybl.openloadflow.util.PowsyblOpenLoadFlowVersion;
import com.powsybl.openloadflow.util.ProviderConstants;
import com.powsybl.tools.PowsyblCoreVersion;
import net.jafama.FastMath;
import org.slf4j.Logger;
Expand All @@ -56,8 +57,6 @@ public class OpenLoadFlowProvider implements LoadFlowProvider {

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

public static final String NAME = "OpenLoadFlow";

private final MatrixFactory matrixFactory;

private final GraphDecrementalConnectivityFactory<LfBus, LfBranch> connectivityFactory;
Expand All @@ -83,7 +82,7 @@ public void setForcePhaseControlOffAndAddAngle1Var(boolean forcePhaseControlOffA

@Override
public String getName() {
return NAME;
return ProviderConstants.NAME;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
import com.powsybl.iidm.network.Network;
import com.powsybl.math.matrix.MatrixFactory;
import com.powsybl.math.matrix.SparseMatrixFactory;
import com.powsybl.openloadflow.OpenLoadFlowProvider;
import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivityFactory;
import com.powsybl.openloadflow.graph.GraphDecrementalConnectivityFactory;
import com.powsybl.openloadflow.network.LfBranch;
import com.powsybl.openloadflow.network.LfBus;
import com.powsybl.openloadflow.util.PowsyblOpenLoadFlowVersion;
import com.powsybl.openloadflow.util.ProviderConstants;
import com.powsybl.security.*;
import com.powsybl.security.interceptors.SecurityAnalysisInterceptor;
import com.powsybl.security.monitor.StateMonitor;
Expand Down Expand Up @@ -80,7 +80,7 @@ public CompletableFuture<SecurityAnalysisReport> run(Network network, String wor

@Override
public String getName() {
return "OpenSecurityAnalysis";
return ProviderConstants.NAME;
}

@Override
Expand All @@ -90,7 +90,7 @@ public String getVersion() {

@Override
public Optional<String> getLoadFlowProviderName() {
return Optional.of(OpenLoadFlowProvider.NAME);
return Optional.of(ProviderConstants.NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
import com.powsybl.math.matrix.MatrixFactory;
import com.powsybl.math.matrix.SparseMatrixFactory;
import com.powsybl.openloadflow.OpenLoadFlowParameters;
import com.powsybl.openloadflow.OpenLoadFlowProvider;
import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivityFactory;
import com.powsybl.openloadflow.graph.GraphDecrementalConnectivityFactory;
import com.powsybl.openloadflow.network.LfBranch;
import com.powsybl.openloadflow.network.LfBus;
import com.powsybl.openloadflow.network.impl.PropagatedContingency;
import com.powsybl.openloadflow.util.ProviderConstants;
import com.powsybl.sensitivity.*;
import com.powsybl.sensitivity.json.SensitivityJsonModule;
import com.powsybl.tools.PowsyblCoreVersion;
Expand All @@ -59,8 +59,6 @@
@AutoService(SensitivityAnalysisProvider.class)
public class OpenSensitivityAnalysisProvider implements SensitivityAnalysisProvider {

private static final String NAME = "OpenSensitivityAnalysis";

public static final String DATE_TIME_FORMAT = "yyyy-dd-M--HH-mm-ss-SSS";

private final DcSensitivityAnalysis dcSensitivityAnalysis;
Expand All @@ -82,7 +80,7 @@ public OpenSensitivityAnalysisProvider(MatrixFactory matrixFactory, GraphDecreme

@Override
public String getName() {
return NAME;
return ProviderConstants.NAME;
}

@Override
Expand All @@ -92,7 +90,7 @@ public String getVersion() {

@Override
public Optional<String> getLoadFlowProviderName() {
return Optional.of(OpenLoadFlowProvider.NAME);
return Optional.of(ProviderConstants.NAME);
}

@Override
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/powsybl/openloadflow/util/ProviderConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright (c) 2022, 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/.
*/
package com.powsybl.openloadflow.util;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public final class ProviderConstants {

private ProviderConstants() {
}

public static final String NAME = "OpenLoadFlow";
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.powsybl.openloadflow.network.util.PreviousValueVoltageInitializer;
import com.powsybl.openloadflow.network.util.UniformValueVoltageInitializer;
import com.powsybl.openloadflow.network.util.VoltageInitializer;
import com.powsybl.openloadflow.util.ProviderConstants;
import com.powsybl.tools.PowsyblCoreVersion;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
Expand All @@ -41,7 +42,7 @@ class OpenLoadFlowProviderTest {
@Test
void test() {
LoadFlowProvider loadFlowProvider = new OpenLoadFlowProvider(new DenseMatrixFactory());
assertEquals("OpenLoadFlow", loadFlowProvider.getName());
assertEquals(ProviderConstants.NAME, loadFlowProvider.getName());
assertEquals(new PowsyblCoreVersion().getMavenProjectVersion(), loadFlowProvider.getVersion());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.powsybl.commons.AbstractConverterTest;
import com.powsybl.commons.config.InMemoryPlatformConfig;
import com.powsybl.openloadflow.util.PowsyblOpenLoadFlowVersion;
import com.powsybl.openloadflow.util.ProviderConstants;
import com.powsybl.security.SecurityAnalysisParameters;
import com.powsybl.security.json.JsonSecurityAnalysisParameters;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -36,9 +37,9 @@ public void setUp() throws IOException {

@Test
void basicTest() {
assertEquals("OpenSecurityAnalysis", provider.getName());
assertEquals(ProviderConstants.NAME, provider.getName());
assertEquals(new PowsyblOpenLoadFlowVersion().toString(), provider.getVersion());
assertEquals("OpenLoadFlow", provider.getLoadFlowProviderName().orElseThrow());
assertEquals(ProviderConstants.NAME, provider.getLoadFlowProviderName().orElseThrow());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.powsybl.openloadflow.sensi;

import com.powsybl.math.matrix.DenseMatrixFactory;
import com.powsybl.openloadflow.util.ProviderConstants;
import com.powsybl.sensitivity.SensitivityAnalysisParameters;
import com.powsybl.tools.PowsyblCoreVersion;
import org.junit.jupiter.api.Test;
Expand All @@ -25,9 +26,9 @@ class OpenSensitivityAnalysisProviderTest extends AbstractSensitivityAnalysisTes
@Test
void testGeneralInfos() {
OpenSensitivityAnalysisProvider provider = new OpenSensitivityAnalysisProvider(new DenseMatrixFactory());
assertEquals("OpenSensitivityAnalysis", provider.getName());
assertEquals(ProviderConstants.NAME, provider.getName());
assertEquals(new PowsyblCoreVersion().getMavenProjectVersion(), provider.getVersion());
assertEquals("OpenLoadFlow", provider.getLoadFlowProviderName().orElseThrow());
assertEquals(ProviderConstants.NAME, provider.getLoadFlowProviderName().orElseThrow());
}

@Test
Expand Down

0 comments on commit 269b803

Please sign in to comment.