All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.powsybl.iidm.modification.AbstractDisconnection Maven / Gradle / Ivy

There is a newer version: 6.5.0-RC1
Show newest version
/*
 * 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.iidm.modification;

import com.powsybl.commons.report.ReportNode;
import com.powsybl.iidm.network.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.function.Predicate;

import static com.powsybl.iidm.modification.util.ModificationReports.identifiableDisconnectionReport;

/**
 * 

This network modification is used to disconnect a network element from the bus or bus bar section to which it is * currently connected.

*

It works on:

*
    *
  • Connectables
  • *
  • HVDC lines by disconnecting their converter stations
  • *
  • Tie lines by disconnecting their underlying dangling lines
  • *
*

The user can specify a side of the element to disconnect. If no side is specified, the network modification will * try to disconnect every side.

* @author Nicolas Rol {@literal } */ public abstract class AbstractDisconnection extends AbstractConnectDisconnectModification { private static final Logger LOG = LoggerFactory.getLogger(AbstractDisconnection.class); final Predicate openableSwitches; AbstractDisconnection(String identifiableId, Predicate openableSwitches, ThreeSides side) { super(identifiableId, side, false); this.openableSwitches = openableSwitches; } public void applyModification(Network network, boolean isPlanned, boolean throwException, ReportNode reportNode) { // Add the reportNode to the network reportNode context network.getReportNodeContext().pushReportNode(reportNode); // Get the connectable Identifiable identifiable = network.getIdentifiable(identifiableId); // Disconnect the identifiable if it exists if (identifiable == null) { logOrThrow(throwException, "Identifiable '" + identifiableId + "' not found"); } else { disconnectIdentifiable(identifiable, network, isPlanned, throwException, reportNode); } } private void disconnectIdentifiable(Identifiable identifiable, Network network, boolean isPlanned, boolean throwException, ReportNode reportNode) { boolean hasBeenDisconnected; try { hasBeenDisconnected = disconnect(identifiable, throwException); } finally { network.getReportNodeContext().popReportNode(); } if (hasBeenDisconnected) { LOG.info("Identifiable {} has been disconnected ({} disconnection) {}.", identifiableId, isPlanned ? "planned" : "unplanned", side == null ? "on each side" : "on side " + side.getNum()); } else { LOG.info("Identifiable {} has NOT been disconnected ({} disconnection) {}.", identifiableId, isPlanned ? "planned" : "unplanned", side == null ? "on each side" : "on side " + side.getNum()); } identifiableDisconnectionReport(reportNode, identifiable, hasBeenDisconnected, isPlanned, side); } private boolean disconnect(Identifiable identifiable, boolean throwException) { boolean hasBeenDisconnected = false; if (identifiable instanceof Connectable connectable) { hasBeenDisconnected = connectable.disconnect(openableSwitches, side); } else if (identifiable instanceof TieLine tieLine) { hasBeenDisconnected = tieLine.disconnectDanglingLines(openableSwitches, side == null ? null : side.toTwoSides()); } else if (identifiable instanceof HvdcLine hvdcLine) { hasBeenDisconnected = hvdcLine.disconnectConverterStations(openableSwitches, side == null ? null : side.toTwoSides()); } else { logOrThrow(throwException, String.format("Disconnection not implemented for identifiable '%s'", identifiableId)); } return hasBeenDisconnected; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy