-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #343 from itesla/projector_load_flow
Ampl based load flow implementation
- Loading branch information
Showing
3 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
case-projector/src/main/java/eu/itesla_project/case_projector/CaseProjectorLoadFlow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright (c) 2018, 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 eu.itesla_project.case_projector; | ||
|
||
import java.nio.file.Path; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import com.powsybl.computation.ComputationManager; | ||
import com.powsybl.iidm.network.Network; | ||
import com.powsybl.loadflow.LoadFlow; | ||
import com.powsybl.loadflow.LoadFlowParameters; | ||
import com.powsybl.loadflow.LoadFlowResult; | ||
import com.powsybl.loadflow.LoadFlowResultImpl; | ||
|
||
/** | ||
* @author Giovanni Ferrari <giovanni.ferrari at techrain.eu> | ||
*/ | ||
public class CaseProjectorLoadFlow implements LoadFlow { | ||
|
||
private final Network network; | ||
private final ComputationManager computationManager; | ||
|
||
public CaseProjectorLoadFlow(Network network, ComputationManager computationManager, int priority) { | ||
this.network = Objects.requireNonNull(network); | ||
this.computationManager = Objects.requireNonNull(computationManager); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "case-projector-load-flow"; | ||
} | ||
|
||
@Override | ||
public String getVersion() { | ||
return "1.0.0"; | ||
} | ||
|
||
@Override | ||
public LoadFlowResult run(LoadFlowParameters params) throws Exception { | ||
CaseProjectorLoadFlowParameters amplParams = params.getExtension(CaseProjectorLoadFlowParameters.class); | ||
Path generatorsDomains = amplParams.getGeneratorsDomainsFile(); | ||
Map<String, String> metrics = new HashMap<>(); | ||
CompletableFuture<Boolean> result = CaseProjectorUtils.createAmplTask(computationManager, network, network.getStateManager().getWorkingStateId(), new CaseProjectorConfig(amplParams.getAmplHomeDir(), generatorsDomains, amplParams.isDebug())); | ||
Boolean wres = result.join(); | ||
return new LoadFlowResultImpl(wres, metrics, null); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...rojector/src/main/java/eu/itesla_project/case_projector/CaseProjectorLoadFlowFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright (c) 2018, 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 eu.itesla_project.case_projector; | ||
|
||
import com.powsybl.computation.ComputationManager; | ||
import com.powsybl.iidm.network.Network; | ||
import com.powsybl.loadflow.LoadFlow; | ||
import com.powsybl.loadflow.LoadFlowFactory; | ||
|
||
/** | ||
* @author Giovanni Ferrari <giovanni.ferrari at techrain.eu> | ||
*/ | ||
public class CaseProjectorLoadFlowFactory implements LoadFlowFactory { | ||
|
||
@Override | ||
public LoadFlow create(Network network, ComputationManager computationManager, int priority) { | ||
|
||
return new CaseProjectorLoadFlow(network, computationManager, priority); | ||
} | ||
|
||
} |
85 changes: 85 additions & 0 deletions
85
...ector/src/main/java/eu/itesla_project/case_projector/CaseProjectorLoadFlowParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Copyright (c) 2018, 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 eu.itesla_project.case_projector; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Objects; | ||
|
||
import com.google.auto.service.AutoService; | ||
import com.powsybl.commons.config.ModuleConfig; | ||
import com.powsybl.commons.config.PlatformConfig; | ||
import com.powsybl.commons.extensions.AbstractExtension; | ||
import com.powsybl.loadflow.LoadFlowParameters; | ||
|
||
/** | ||
* @author Giovanni Ferrari <giovanni.ferrari at techrain.eu> | ||
*/ | ||
public class CaseProjectorLoadFlowParameters extends AbstractExtension<LoadFlowParameters> { | ||
|
||
private Path amplHomeDir; | ||
private Path generatorsDomainsFile; | ||
private boolean debug; | ||
|
||
public CaseProjectorLoadFlowParameters(PlatformConfig config) { | ||
Objects.requireNonNull(config); | ||
|
||
if (config.moduleExists("caseProjector")) { | ||
ModuleConfig amplConfig = config.getModuleConfig("caseProjector"); | ||
this.amplHomeDir = amplConfig.getPathProperty("amplHomeDir"); | ||
this.generatorsDomainsFile = amplConfig.getPathProperty("generatorsDomainsFile"); | ||
this.debug = amplConfig.getBooleanProperty("debug"); | ||
} | ||
} | ||
|
||
public CaseProjectorLoadFlowParameters(Path amplHomeDir, Path generatorsDomainsFile, boolean debug) { | ||
this.amplHomeDir = Objects.requireNonNull(amplHomeDir); | ||
this.generatorsDomainsFile = Objects.requireNonNull(generatorsDomainsFile); | ||
this.debug = debug; | ||
} | ||
|
||
@AutoService(LoadFlowParameters.ConfigLoader.class) | ||
public static class AmplLoadFlowConfigLoader implements LoadFlowParameters.ConfigLoader<CaseProjectorLoadFlowParameters> { | ||
|
||
@Override | ||
public CaseProjectorLoadFlowParameters load(PlatformConfig config) { | ||
return new CaseProjectorLoadFlowParameters(config); | ||
} | ||
|
||
@Override | ||
public String getCategoryName() { | ||
return "loadflow-parameters"; | ||
} | ||
|
||
@Override | ||
public Class<? super CaseProjectorLoadFlowParameters> getExtensionClass() { | ||
return CaseProjectorLoadFlowParameters.class; | ||
} | ||
|
||
@Override | ||
public String getExtensionName() { | ||
return "ampl"; | ||
} | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "ampl"; | ||
} | ||
|
||
public Path getAmplHomeDir() { | ||
return amplHomeDir; | ||
} | ||
|
||
public boolean isDebug() { | ||
return debug; | ||
} | ||
|
||
public Path getGeneratorsDomainsFile() { | ||
return generatorsDomainsFile; | ||
} | ||
|
||
} |