Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion cpp/pypowsybl-cpp/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ void dynamicSimulationBindings(py::module_& m) {
py::enum_<EventMappingType>(m, "EventMappingType")
.value("DISCONNECT", EventMappingType::DISCONNECT)
.value("NODE_FAULT", EventMappingType::NODE_FAULT)
.value("ACTIVE_POWER_VARIATION", EventMappingType::ACTIVE_POWER_VARIATION);
.value("ACTIVE_POWER_VARIATION", EventMappingType::ACTIVE_POWER_VARIATION)
.value("REACTIVE_POWER_VARIATION", EventMappingType::REACTIVE_POWER_VARIATION)
.value("REFERENCE_VOLTAGE_VARIATION", EventMappingType::REFERENCE_VOLTAGE_VARIATION);

py::enum_<OutputVariableType>(m, "OutputVariableType")
.value("CURVE", OutputVariableType::CURVE)
Expand Down
2 changes: 2 additions & 0 deletions cpp/pypowsybl-java/powsybl-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ typedef enum {
DISCONNECT = 0,
NODE_FAULT,
ACTIVE_POWER_VARIATION,
REACTIVE_POWER_VARIATION,
REFERENCE_VOLTAGE_VARIATION,
} EventMappingType;

typedef enum {
Expand Down
5 changes: 5 additions & 0 deletions docs/reference/dynamic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ ModelMapping
ModelMapping.add_base_generator
ModelMapping.add_synchronized_generator
ModelMapping.add_synchronous_generator
ModelMapping.add_signal_n_generator
ModelMapping.add_wecc
ModelMapping.add_grid_forming_converter
ModelMapping.add_inertial_grid
ModelMapping.add_hvdc_p
ModelMapping.add_hvdc_vsc
ModelMapping.add_base_transformer
Expand All @@ -38,6 +40,7 @@ ModelMapping
ModelMapping.add_under_voltage_automation_system
ModelMapping.add_phase_shifter_i_automation_system
ModelMapping.add_phase_shifter_p_automation_system
ModelMapping.add_phase_shifter_blocking_i_automation_system
ModelMapping.add_tap_changer_automation_system
ModelMapping.add_tap_changer_blocking_automation_system

Expand All @@ -49,6 +52,8 @@ EventMapping
EventMapping
EventMapping.add_disconnection
EventMapping.add_active_power_variation
EventMapping.add_reactive_power_variation
EventMapping.add_reference_voltage_variation
EventMapping.add_node_fault

OutputVariableMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,33 @@
package com.powsybl.dataframe.dynamic.adders;

import com.powsybl.commons.report.ReportNode;
import com.powsybl.dataframe.dynamic.PersistentDoubleSeries;
import com.powsybl.dataframe.dynamic.PersistentStringSeries;
import com.powsybl.dataframe.update.DoubleSeries;
import com.powsybl.dataframe.update.StringSeries;
import com.powsybl.dataframe.update.UpdatingDataframe;
import com.powsybl.dynamicsimulation.EventModel;
import com.powsybl.dynawo.builders.ModelBuilder;
import com.powsybl.iidm.network.Network;

import java.util.function.BiFunction;

import static com.powsybl.dataframe.dynamic.adders.DynamicModelDataframeConstants.START_TIME;
import static com.powsybl.dataframe.dynamic.adders.DynamicModelDataframeConstants.STATIC_ID;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
abstract class AbstractEventModelSeries<T extends ModelBuilder<EventModel>> implements EventModelSeries {

protected final StringSeries staticIds;
protected final DoubleSeries startTimes;

protected AbstractEventModelSeries(UpdatingDataframe dataframe) {
this.staticIds = PersistentStringSeries.copyOf(dataframe, STATIC_ID);
this.startTimes = PersistentDoubleSeries.copyOf(dataframe, START_TIME);
}

@Override
public BiFunction<Network, ReportNode, EventModel> getModelSupplier(int row) {
return (network, reportNode) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import com.powsybl.commons.report.ReportNode;
import com.powsybl.dataframe.SeriesMetadata;
import com.powsybl.dataframe.dynamic.PersistentDoubleSeries;
import com.powsybl.dataframe.dynamic.PersistentStringSeries;
import com.powsybl.dataframe.update.DoubleSeries;
import com.powsybl.dataframe.update.StringSeries;
import com.powsybl.dataframe.update.UpdatingDataframe;
import com.powsybl.dynawo.models.events.EventActivePowerVariationBuilder;
import com.powsybl.iidm.network.Network;
Expand All @@ -39,13 +37,10 @@ public List<SeriesMetadata> getMetadata() {

private static class ActivePowerVariationSeries extends AbstractEventModelSeries<EventActivePowerVariationBuilder> {

private final StringSeries staticIds;
private final DoubleSeries startTimes;
private final DoubleSeries deltaPs;

ActivePowerVariationSeries(UpdatingDataframe dataframe) {
this.staticIds = PersistentStringSeries.copyOf(dataframe, STATIC_ID);
this.startTimes = PersistentDoubleSeries.copyOf(dataframe, START_TIME);
super(dataframe);
this.deltaPs = PersistentDoubleSeries.copyOf(dataframe, DELTA_P);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

import com.powsybl.commons.report.ReportNode;
import com.powsybl.dataframe.SeriesMetadata;
import com.powsybl.dataframe.dynamic.PersistentDoubleSeries;
import com.powsybl.dataframe.dynamic.PersistentStringSeries;
import com.powsybl.dataframe.update.DoubleSeries;
import com.powsybl.dataframe.update.StringSeries;
import com.powsybl.dataframe.update.UpdatingDataframe;
import com.powsybl.dynawo.models.events.EventDisconnectionBuilder;
Expand Down Expand Up @@ -40,13 +38,10 @@ public List<SeriesMetadata> getMetadata() {

private static class DisconnectSeries extends AbstractEventModelSeries<EventDisconnectionBuilder> {

private final StringSeries staticIds;
private final DoubleSeries startTimes;
private final StringSeries disconnectOnly;

DisconnectSeries(UpdatingDataframe dataframe) {
this.staticIds = PersistentStringSeries.copyOf(dataframe, STATIC_ID);
this.startTimes = PersistentDoubleSeries.copyOf(dataframe, START_TIME);
super(dataframe);
this.disconnectOnly = PersistentStringSeries.copyOf(dataframe, DISCONNECT_ONLY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public final class DynamicModelDataframeConstants {
public static final String START_TIME = "start_time";
public static final String DISCONNECT_ONLY = "disconnect_only";
public static final String DELTA_P = "delta_p";
public static final String DELTA_Q = "delta_q";
public static final String DELTA_U = "delta_u";
public static final String FAULT_TIME = "fault_time";
public static final String X_PU = "x_pu";
public static final String R_PU = "r_pu";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public final class EventMappingHandler {
private static final Map<EventMappingType, EventMappingAdder> ADDERS = Map.ofEntries(
Map.entry(EventMappingType.DISCONNECT, new DisconnectAdder()),
Map.entry(EventMappingType.NODE_FAULT, new NodeFaultAdder()),
Map.entry(EventMappingType.ACTIVE_POWER_VARIATION, new ActivePowerVariationAdder())
Map.entry(EventMappingType.ACTIVE_POWER_VARIATION, new ActivePowerVariationAdder()),
Map.entry(EventMappingType.REACTIVE_POWER_VARIATION, new ReactivePowerVariationAdder()),
Map.entry(EventMappingType.REFERENCE_VOLTAGE_VARIATION, new ReferenceVoltageVariationAdder())
);

public static void addElements(EventMappingType type, PythonEventModelsSupplier modelMapping, UpdatingDataframe dataframe) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2026, 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.dataframe.dynamic.adders;

import com.powsybl.commons.report.ReportNode;
import com.powsybl.dataframe.dynamic.CategoryAttributeUtils;
import com.powsybl.dataframe.dynamic.CategoryInformation;
import com.powsybl.dataframe.update.UpdatingDataframe;
import com.powsybl.dynawo.builders.ModelInfo;
import com.powsybl.dynawo.models.generators.InertialGridBuilder;
import com.powsybl.iidm.network.Generator;
import com.powsybl.iidm.network.Network;

import java.util.Collection;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
public class InertialGridAdder extends AbstractEquipmentAdder {

private static final CategoryInformation CATEGORY_INFORMATION = new CategoryInformation(
"InertialGrid",
"Inertial grid",
CategoryAttributeUtils.createFromMetadata(EQUIPMENT_METADATA));

protected InertialGridAdder() {
super(CATEGORY_INFORMATION);
}

@Override
public Collection<ModelInfo> getSupportedModels() {
return InertialGridBuilder.getSupportedModelInfos();
}

@Override
protected DynamicModelSeries createDynamicModelSeries(UpdatingDataframe dataframe) {
return new AbstractEquipmentSeries<Generator, InertialGridBuilder>(dataframe) {

@Override
protected InertialGridBuilder createBuilder(Network network, ReportNode reportNode) {
return InertialGridBuilder.of(network, reportNode);
}

@Override
protected InertialGridBuilder createBuilder(Network network, String modelName, ReportNode reportNode) {
return InertialGridBuilder.of(network, modelName, reportNode);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class ModelAdderLoaderImpl implements ModelAdderLoader {
new LineAdder(),
new BaseBusAdder(),
new InfiniteBusAdder(),
new InertialGridAdder(),
// Automation systems
new DynamicOverloadManagementSystemAdder(),
new DynamicTwoLevelOverloadManagementSystemAdder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import com.powsybl.commons.report.ReportNode;
import com.powsybl.dataframe.SeriesMetadata;
import com.powsybl.dataframe.dynamic.PersistentDoubleSeries;
import com.powsybl.dataframe.dynamic.PersistentStringSeries;
import com.powsybl.dataframe.update.DoubleSeries;
import com.powsybl.dataframe.update.StringSeries;
import com.powsybl.dataframe.update.UpdatingDataframe;
import com.powsybl.dynawo.models.events.NodeFaultEventBuilder;
import com.powsybl.iidm.network.Network;
Expand Down Expand Up @@ -41,15 +39,12 @@ public List<SeriesMetadata> getMetadata() {

private static class NodeFaultSeries extends AbstractEventModelSeries<NodeFaultEventBuilder> {

private final StringSeries staticIds;
private final DoubleSeries startTimes;
private final DoubleSeries faultTimes;
private final DoubleSeries rPu;
private final DoubleSeries xPu;

NodeFaultSeries(UpdatingDataframe dataframe) {
this.staticIds = PersistentStringSeries.copyOf(dataframe, STATIC_ID);
this.startTimes = PersistentDoubleSeries.copyOf(dataframe, START_TIME);
super(dataframe);
this.faultTimes = PersistentDoubleSeries.copyOf(dataframe, FAULT_TIME);
this.rPu = PersistentDoubleSeries.copyOf(dataframe, R_PU);
this.xPu = PersistentDoubleSeries.copyOf(dataframe, X_PU);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright (c) 2026, 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.dataframe.dynamic.adders;

import com.powsybl.commons.report.ReportNode;
import com.powsybl.dataframe.SeriesMetadata;
import com.powsybl.dataframe.dynamic.PersistentDoubleSeries;
import com.powsybl.dataframe.update.DoubleSeries;
import com.powsybl.dataframe.update.UpdatingDataframe;
import com.powsybl.dynawo.models.events.EventReactivePowerVariationBuilder;
import com.powsybl.iidm.network.Network;

import java.util.List;

import static com.powsybl.dataframe.dynamic.adders.DynamicModelDataframeConstants.*;
import static com.powsybl.dataframe.network.adders.SeriesUtils.applyIfPresent;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
public class ReactivePowerVariationAdder extends AbstractEventModelAdder {

protected static final List<SeriesMetadata> METADATA = List.of(
SeriesMetadata.stringIndex(STATIC_ID),
SeriesMetadata.doubles(START_TIME),
SeriesMetadata.doubles(DELTA_Q));

@Override
public List<SeriesMetadata> getMetadata() {
return METADATA;
}

private static class ReactivePowerVariationSeries extends AbstractEventModelSeries<EventReactivePowerVariationBuilder> {

private final DoubleSeries deltaQs;

ReactivePowerVariationSeries(UpdatingDataframe dataframe) {
super(dataframe);
this.deltaQs = PersistentDoubleSeries.copyOf(dataframe, DELTA_Q);
}

@Override
protected void applyOnBuilder(int row, EventReactivePowerVariationBuilder builder) {
applyIfPresent(staticIds, row, builder::staticId);
applyIfPresent(startTimes, row, builder::startTime);
applyIfPresent(deltaQs, row, builder::deltaQ);
}

@Override
protected EventReactivePowerVariationBuilder createBuilder(Network network, ReportNode reportNode) {
return EventReactivePowerVariationBuilder.of(network, reportNode);
}
}

@Override
protected EventModelSeries createEventModelSeries(UpdatingDataframe dataframe) {
return new ReactivePowerVariationSeries(dataframe);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright (c) 2026, 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.dataframe.dynamic.adders;

import com.powsybl.commons.report.ReportNode;
import com.powsybl.dataframe.SeriesMetadata;
import com.powsybl.dataframe.dynamic.PersistentDoubleSeries;
import com.powsybl.dataframe.update.DoubleSeries;
import com.powsybl.dataframe.update.UpdatingDataframe;
import com.powsybl.dynawo.models.events.EventReferenceVoltageVariationBuilder;
import com.powsybl.iidm.network.Network;

import java.util.List;

import static com.powsybl.dataframe.dynamic.adders.DynamicModelDataframeConstants.*;
import static com.powsybl.dataframe.network.adders.SeriesUtils.applyIfPresent;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
public class ReferenceVoltageVariationAdder extends AbstractEventModelAdder {

protected static final List<SeriesMetadata> METADATA = List.of(
SeriesMetadata.stringIndex(STATIC_ID),
SeriesMetadata.doubles(START_TIME),
SeriesMetadata.doubles(DELTA_U));

@Override
public List<SeriesMetadata> getMetadata() {
return METADATA;
}

private static class ReferenceVoltageVariationSeries extends AbstractEventModelSeries<EventReferenceVoltageVariationBuilder> {

private final DoubleSeries deltaUs;

ReferenceVoltageVariationSeries(UpdatingDataframe dataframe) {
super(dataframe);
this.deltaUs = PersistentDoubleSeries.copyOf(dataframe, DELTA_U);
}

@Override
protected void applyOnBuilder(int row, EventReferenceVoltageVariationBuilder builder) {
applyIfPresent(staticIds, row, builder::staticId);
applyIfPresent(startTimes, row, builder::startTime);
applyIfPresent(deltaUs, row, builder::deltaU);
}

@Override
protected EventReferenceVoltageVariationBuilder createBuilder(Network network, ReportNode reportNode) {
return EventReferenceVoltageVariationBuilder.of(network, reportNode);
}
}

@Override
protected EventModelSeries createEventModelSeries(UpdatingDataframe dataframe) {
return new ReferenceVoltageVariationSeries(dataframe);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,9 @@ public interface DynamicSimulationParametersPointer extends PointerBase {
public enum EventMappingType {
DISCONNECT,
NODE_FAULT,
ACTIVE_POWER_VARIATION;
ACTIVE_POWER_VARIATION,
REACTIVE_POWER_VARIATION,
REFERENCE_VOLTAGE_VARIATION;

@CEnumValue
public native int getCValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ private static Stream<Arguments> equipmentDataProvider() {
Arguments.of("Bus", EurostagTutorialExample1Factory.create(), "NHV1"),
Arguments.of("InfiniteBus", EurostagTutorialExample1Factory.create(), "NHV1"),
Arguments.of("HvdcP", HvdcTestNetwork.createVsc(), "L"),
Arguments.of("HvdcVsc", HvdcTestNetwork.createVsc(), "L")
Arguments.of("HvdcVsc", HvdcTestNetwork.createVsc(), "L"),
Arguments.of("InertialGrid", EurostagTutorialExample1Factory.create(), "GEN")
);
}

Expand Down
Loading