Skip to content

Commit

Permalink
dynawo#30 Add smoothed out NodeFault for numerical stability
Browse files Browse the repository at this point in the history
Signed-off-by: FredericSabot <[email protected]>
  • Loading branch information
FredericSabot committed Feb 23, 2024
1 parent 74fc33a commit 8237c86
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ set(MODEL_FILES
package.order
NodeFault.mo
NodeFault.extvar
NodeFaultContinuous.mo
NodeFaultContinuous.extvar
)

#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Copyright (c) 2024, RTE (http://www.rte-france.com)
See AUTHORS.txt
All rights reserved.
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
This file is part of Dynawo, an hybrid C++/Modelica open source suite of
simulation tools for power systems.
-->
<external_variables xmlns="http://www.rte-france.com/dynawo">
<variable type="continuous" id="terminal.V.re"/>
<variable type="continuous" id="terminal.V.im"/>
</external_variables>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
within Dynawo.Electrical.Events;

/*
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* See AUTHORS.txt
* All rights reserved.
* 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
*
* This file is part of Dynawo, an hybrid C++/Modelica open source suite
* of simulation tools for power systems.
*/

model NodeFaultContinuous "Node fault which lasts from tBegin to tEnd"
/*
Between tBegin and tEnd, the impedance between the node and the ground is equal to ZPu.
*/
import Dynawo.NonElectrical.Logs.Timeline;
import Dynawo.NonElectrical.Logs.TimelineKeys;

Dynawo.Connectors.ACPower terminal annotation(
Placement(visible = true, transformation(origin = {2, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {0, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Dynawo.Connectors.BPin nodeFault(value(start = false)) "True when the fault is ongoing, false otherwise";

parameter Types.PerUnit RPu "Fault resistance in pu (base SnRef)";
parameter Types.PerUnit XPu "Fault reactance in pu (base SnRef)";
parameter Types.Time tBegin "Time when the fault begins";
parameter Types.Time tEnd "Time when the fault ends";
parameter Types.Time tFilter = 1e-3 "Filter to smooth out the behaviour of the fault";

protected
parameter Types.ComplexImpedancePu ZPu(re = RPu, im = XPu) "Impedance of the fault in pu (base SnRef)";

equation
when time >= tEnd then
Timeline.logEvent1(TimelineKeys.NodeFaultEnd);
nodeFault.value = false;
elsewhen time >= tBegin then
Timeline.logEvent1(TimelineKeys.NodeFaultBegin);
nodeFault.value = true;
end when;

if time > tEnd + tFilter or time < tBegin then
terminal.i = Complex(0);
elseif time >= tBegin and time < tBegin + tFilter then
terminal.i = 1/ZPu * terminal.V * (time - tBegin) / tFilter;
elseif time >= tBegin + tFilter and time < tEnd then
terminal.i = 1/ZPu * terminal.V;
else
terminal.i = 1/ZPu * terminal.V * (1 - (time - tEnd) / tFilter);
end if;

annotation(preferredView = "text",
Documentation(info = "<html><head></head><body>During the fault, the impedance between the node and the ground is defined by R and X values.</body></html>"),
Icon(graphics = {Polygon(origin = {0, 55}, fillPattern = FillPattern.Solid, points = {{0, 45}, {-6, 5}, {20, 5}, {0, -45}, {6, -5}, {-20, -5}, {0, 45}, {0, 45}})}));
end NodeFaultContinuous;
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Event
NodeFault
NodeFaultContinuous
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ set(MODELICA_PREASSEMBLED_MODELS
LVRT10Points.xml
Measurements.xml
NodeFault.xml
NodeFaultContinuous.xml
PhaseShifterBlockingI.xml
PhaseShifterI.xml
PhaseShifterP.xml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--
Copyright (c) 2024, RTE (http://www.rte-france.com)
See AUTHORS.txt
All rights reserved.
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
This file is part of Dynawo, an hybrid C++/Modelica open source suite of
simulation tools for power systems.
-->
<dyn:dynamicModelsArchitecture xmlns:dyn="http://www.rte-france.com/dynawo">
<!-- Short circuit on a node -->
<dyn:modelicaModel id="NodeFaultContinuous">
<dyn:unitDynamicModel id="fault" name="Dynawo.Electrical.Events.NodeFaultContinuous"/>
</dyn:modelicaModel>
</dyn:dynamicModelsArchitecture>

0 comments on commit 8237c86

Please sign in to comment.