com.powsybl.python.security.SecurityAnalysisContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pypowsybl Show documentation
Show all versions of pypowsybl Show documentation
A C interface to powsybl, for pypowsybl implementation
The newest version!
/**
* Copyright (c) 2021, 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.python.security;
import com.powsybl.action.Action;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.contingency.ContingenciesProvider;
import com.powsybl.iidm.network.Network;
import com.powsybl.python.commons.CommonObjects;
import com.powsybl.python.contingency.ContingencyContainerImpl;
import com.powsybl.security.*;
import com.powsybl.security.monitor.StateMonitor;
import com.powsybl.security.strategy.OperatorStrategy;
import java.util.ArrayList;
import java.util.List;
/**
* @author Geoffroy Jamgotchian {@literal }
*/
class SecurityAnalysisContext extends ContingencyContainerImpl {
private final List actions = new ArrayList<>();
private final List operatorStrategies = new ArrayList<>();
private final List monitors = new ArrayList<>();
SecurityAnalysisResult run(Network network, SecurityAnalysisParameters securityAnalysisParameters, String provider, ReportNode reportNode) {
ContingenciesProvider contingencies = this::createContingencies;
SecurityAnalysisRunParameters runParameters = new SecurityAnalysisRunParameters()
.setSecurityAnalysisParameters(securityAnalysisParameters)
.setComputationManager(CommonObjects.getComputationManager())
.setOperatorStrategies(operatorStrategies)
.setActions(actions)
.setMonitors(monitors)
.setReportNode(reportNode == null ? ReportNode.NO_OP : reportNode);
SecurityAnalysisReport report = SecurityAnalysis.find(provider)
.run(network, network.getVariantManager().getWorkingVariantId(), contingencies, runParameters);
return report.getResult();
}
void addAction(Action action) {
actions.add(action);
}
void addOperatorStrategy(OperatorStrategy strategy) {
operatorStrategies.add(strategy);
}
void addMonitor(StateMonitor monitor) {
monitors.add(monitor);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy