From 5f993b64d4128b3b347ff0df72fdaedfaf60e03a Mon Sep 17 00:00:00 2001 From: Martin Moraga Date: Wed, 8 Mar 2023 15:31:14 +0100 Subject: [PATCH] solve rebase errors Signed-off-by: Martin Moraga --- .../dpsim-models/DP/DP_Ph1_ResIndSeries.h | 12 +- .../include/dpsim-models/DP/DP_Ph1_Resistor.h | 2 +- .../dpsim-models/EMT/EMT_Ph1_VoltageSource.h | 2 - .../dpsim-models/EMT/EMT_Ph3_ResIndSeries.h | 2 +- .../dpsim-models/EMT/EMT_Ph3_Resistor.h | 2 +- .../include/dpsim-models/SP/SP_Ph1_Inductor.h | 4 +- .../dpsim-models/SP/SP_Ph1_ResIndSeries.h | 4 +- .../include/dpsim-models/SP/SP_Ph1_Resistor.h | 4 +- dpsim-models/src/DP/DP_Ph1_PiLine.cpp | 3 +- dpsim-models/src/DP/DP_Ph1_ResIndSeries.cpp | 1 - .../src/EMT/EMT_Ph1_VoltageSource.cpp | 4 +- dpsim-models/src/EMT/EMT_Ph3_ResIndSeries.cpp | 2 +- dpsim-models/src/SP/SP_Ph1_ResIndSeries.cpp | 4 +- .../Circuits/Validation_RL_Element.ipynb | 106 ++++++++++++++---- examples/Notebooks/Components/Line.ipynb | 8 +- 15 files changed, 112 insertions(+), 48 deletions(-) diff --git a/dpsim-models/include/dpsim-models/DP/DP_Ph1_ResIndSeries.h b/dpsim-models/include/dpsim-models/DP/DP_Ph1_ResIndSeries.h index a92889c25c..b48f27d6a1 100644 --- a/dpsim-models/include/dpsim-models/DP/DP_Ph1_ResIndSeries.h +++ b/dpsim-models/include/dpsim-models/DP/DP_Ph1_ResIndSeries.h @@ -56,8 +56,8 @@ namespace Ph1 { void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) override; void mnaCompInitializeHarm(Real omega, Real timeStep, std::vector::Ptr> leftVectors) override; /// Stamps system matrix - void mnaCompApplySystemMatrixStamp(Matrix& systemMatrix) override; - void mnaCompApplySystemMatrixStampHarm(Matrix& systemMatrix, Int freqIdx) override; + void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override; + void mnaCompApplySystemMatrixStampHarm(SparseMatrixRow& systemMatrix, Int freqIdx) override; /// Stamps right side (source) vector void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) override; void mnaCompApplyRightSideVectorStampHarm(Matrix& rightVector) override; @@ -108,8 +108,12 @@ namespace Ph1 { std::vector< Attribute::Ptr > mLeftVectors; }; - // #### MNA Tear Section #### - void mnaTearApplyMatrixStamp(Matrix& tearMatrix) override; + // #### Tearing methods #### + void mnaTearInitialize(Real omega, Real timestep) override; + void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) override; + void mnaTearApplyVoltageStamp(Matrix& voltageVector) override; + void mnaTearPostStep(Complex voltage, Complex current) override; + }; } } diff --git a/dpsim-models/include/dpsim-models/DP/DP_Ph1_Resistor.h b/dpsim-models/include/dpsim-models/DP/DP_Ph1_Resistor.h index 127cea1985..ac59f9605d 100644 --- a/dpsim-models/include/dpsim-models/DP/DP_Ph1_Resistor.h +++ b/dpsim-models/include/dpsim-models/DP/DP_Ph1_Resistor.h @@ -71,7 +71,7 @@ namespace Ph1 { }; // #### MNA Tear Section #### - void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix); + void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) override; // #### DAE Section #### ///Residual Function for DAE Solver diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph1_VoltageSource.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph1_VoltageSource.h index 0f663c5f40..6e9a990f17 100644 --- a/dpsim-models/include/dpsim-models/EMT/EMT_Ph1_VoltageSource.h +++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph1_VoltageSource.h @@ -25,8 +25,6 @@ namespace Ph1 { class VoltageSource : public MNASimPowerComp, public SharedFactory { - private: - Real mTimeStep; protected: void updateVoltage(Real time); public: diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_ResIndSeries.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_ResIndSeries.h index fb3545fcc7..84951333bd 100644 --- a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_ResIndSeries.h +++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_ResIndSeries.h @@ -52,7 +52,7 @@ namespace CPS { /// Initializes internal variables of the component void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftSideVector) override; /// Stamps system matrix - void mnaCompApplySystemMatrixStamp(Matrix& systemMatrix) override; + void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override; /// Stamps right side (source) vector void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) override; /// Update interface voltage from MNA system result diff --git a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Resistor.h b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Resistor.h index 7266b40f50..607b24fc2c 100644 --- a/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Resistor.h +++ b/dpsim-models/include/dpsim-models/EMT/EMT_Ph3_Resistor.h @@ -40,7 +40,7 @@ class Resistor : /// Initializes internal variables of the component void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftSideVector) override; /// Stamps system matrix - void mnaCompApplySystemMatrixStamp(Matrix& systemMatrix) override; + void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override; /// Stamps right side (source) vector void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) override { } /// Update interface voltage from MNA system result diff --git a/dpsim-models/include/dpsim-models/SP/SP_Ph1_Inductor.h b/dpsim-models/include/dpsim-models/SP/SP_Ph1_Inductor.h index 143cbf959f..b58d26a58d 100644 --- a/dpsim-models/include/dpsim-models/SP/SP_Ph1_Inductor.h +++ b/dpsim-models/include/dpsim-models/SP/SP_Ph1_Inductor.h @@ -51,8 +51,8 @@ namespace Ph1 { void mnaCompPostStep(Real time, Int timeStepCount, Attribute::Ptr &leftVector); /// Add MNA post step dependencies void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector); - - void mnaTearApplyMatrixStamp(Matrix& tearMatrix) override; + // + void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) override; }; } } diff --git a/dpsim-models/include/dpsim-models/SP/SP_Ph1_ResIndSeries.h b/dpsim-models/include/dpsim-models/SP/SP_Ph1_ResIndSeries.h index d01cf5517d..26093af8ee 100644 --- a/dpsim-models/include/dpsim-models/SP/SP_Ph1_ResIndSeries.h +++ b/dpsim-models/include/dpsim-models/SP/SP_Ph1_ResIndSeries.h @@ -46,7 +46,7 @@ namespace Ph1 { /// Initializes MNA specific variables void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) override; /// Stamps system matrix - void mnaCompApplySystemMatrixStamp(Matrix& systemMatrix) override; + void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override; /// Update interface voltage from MNA system result void mnaCompUpdateVoltage(const Matrix& leftVector) override; /// Update interface current from MNA system result @@ -57,7 +57,7 @@ namespace Ph1 { void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector) override; // #### MNA Tear Section #### - void mnaTearApplyMatrixStamp(Matrix& tearMatrix) override; + void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) override; }; } } diff --git a/dpsim-models/include/dpsim-models/SP/SP_Ph1_Resistor.h b/dpsim-models/include/dpsim-models/SP/SP_Ph1_Resistor.h index 32231851d4..8ccea3bf06 100644 --- a/dpsim-models/include/dpsim-models/SP/SP_Ph1_Resistor.h +++ b/dpsim-models/include/dpsim-models/SP/SP_Ph1_Resistor.h @@ -69,7 +69,7 @@ namespace Ph1 { /// void mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) override; /// Stamps system matrix - void mnaCompApplySystemMatrixStamp(Matrix& systemMatrix) override; + void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override; /// Update interface voltage from MNA system result void mnaCompUpdateVoltage(const Matrix& leftVector) override; /// Update interface current from MNA system result @@ -80,7 +80,7 @@ namespace Ph1 { void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute::Ptr &leftVector) override; // #### MNA Tear Section #### - void mnaTearApplyMatrixStamp(Matrix& tearMatrix) override; + void mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) override; }; } diff --git a/dpsim-models/src/DP/DP_Ph1_PiLine.cpp b/dpsim-models/src/DP/DP_Ph1_PiLine.cpp index 65c9182607..39e0653ebb 100644 --- a/dpsim-models/src/DP/DP_Ph1_PiLine.cpp +++ b/dpsim-models/src/DP/DP_Ph1_PiLine.cpp @@ -149,8 +149,7 @@ void DP::Ph1::PiLine::mnaTearInitialize(Real omega, Real timeStep) { } void DP::Ph1::PiLine::mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) { - mSubSeriesResistor->mnaTearApplyMatrixStamp(tearMatrix); - mSubSeriesInductor->mnaTearApplyMatrixStamp(tearMatrix); + mSubSeriesElement->mnaTearApplyMatrixStamp(tearMatrix); } void DP::Ph1::PiLine::mnaTearApplyVoltageStamp(Matrix& voltageVector) { diff --git a/dpsim-models/src/DP/DP_Ph1_ResIndSeries.cpp b/dpsim-models/src/DP/DP_Ph1_ResIndSeries.cpp index d722f29abf..9de8888c54 100644 --- a/dpsim-models/src/DP/DP_Ph1_ResIndSeries.cpp +++ b/dpsim-models/src/DP/DP_Ph1_ResIndSeries.cpp @@ -298,5 +298,4 @@ void DP::Ph1::ResIndSeries::mnaTearApplyVoltageStamp(Matrix& voltageVector) { void DP::Ph1::ResIndSeries::mnaTearPostStep(Complex voltage, Complex current) { (**mIntfVoltage)(0, 0) = voltage; (**mIntfCurrent)(0, 0) = mEquivCond(0,0) * voltage + mEquivCurrent(0,0); - } diff --git a/dpsim-models/src/EMT/EMT_Ph1_VoltageSource.cpp b/dpsim-models/src/EMT/EMT_Ph1_VoltageSource.cpp index cc4afb5cba..8af828066f 100644 --- a/dpsim-models/src/EMT/EMT_Ph1_VoltageSource.cpp +++ b/dpsim-models/src/EMT/EMT_Ph1_VoltageSource.cpp @@ -36,8 +36,6 @@ SimPowerComp::Ptr EMT::Ph1::VoltageSource::clone(String name) { void EMT::Ph1::VoltageSource::mnaCompInitialize(Real omega, Real timeStep, Attribute::Ptr leftVector) { updateMatrixNodeIndices(); (**mIntfVoltage)(0,0) = Math::abs(**mVoltageRef) * cos(Math::phase(**mVoltageRef)); - - mTimeStep = timeStep; } void EMT::Ph1::VoltageSource::mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) { @@ -68,7 +66,7 @@ void EMT::Ph1::VoltageSource::updateVoltage(Real time) { Complex voltageRef = mVoltageRef->get(); Real srcFreq = mSrcFreq->get(); if (srcFreq > 0) - (**mIntfVoltage)(0,0) = Math::abs(voltageRef) * cos((time) * 2.*PI*srcFreq + Math::phase(voltageRef)); + (**mIntfVoltage)(0,0) = Math::abs(voltageRef) * cos(time * 2. * PI * srcFreq + Math::phase(voltageRef)); else (**mIntfVoltage)(0,0) = voltageRef.real(); } diff --git a/dpsim-models/src/EMT/EMT_Ph3_ResIndSeries.cpp b/dpsim-models/src/EMT/EMT_Ph3_ResIndSeries.cpp index b5004530eb..1130981808 100644 --- a/dpsim-models/src/EMT/EMT_Ph3_ResIndSeries.cpp +++ b/dpsim-models/src/EMT/EMT_Ph3_ResIndSeries.cpp @@ -99,7 +99,7 @@ void EMT::Ph3::ResIndSeries::mnaCompInitialize(Real omega, Real timeStep, Attrib mSLog->flush(); } -void EMT::Ph3::ResIndSeries::mnaCompApplySystemMatrixStamp(Matrix& systemMatrix) { +void EMT::Ph3::ResIndSeries::mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) { // Set diagonal entries if (terminalNotGrounded(0)) { diff --git a/dpsim-models/src/SP/SP_Ph1_ResIndSeries.cpp b/dpsim-models/src/SP/SP_Ph1_ResIndSeries.cpp index 427c0f0ce0..32f00ad63d 100644 --- a/dpsim-models/src/SP/SP_Ph1_ResIndSeries.cpp +++ b/dpsim-models/src/SP/SP_Ph1_ResIndSeries.cpp @@ -73,7 +73,7 @@ void SP::Ph1::ResIndSeries::mnaCompInitialize(Real omega, Real timeStep, Attribu Logger::phasorToString((**mIntfCurrent)(0, 0))); } -void SP::Ph1::ResIndSeries::mnaCompApplySystemMatrixStamp(Matrix& systemMatrix) { +void SP::Ph1::ResIndSeries::mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) { Complex conductance = 1. / mImpedance; for (UInt freq = 0; freq < mNumFreqs; freq++) { @@ -132,6 +132,6 @@ void SP::Ph1::ResIndSeries::mnaCompUpdateCurrent(const Matrix& leftVector) { } // #### Tear Methods #### -void SP::Ph1::ResIndSeries::mnaTearApplyMatrixStamp(Matrix& tearMatrix) { +void SP::Ph1::ResIndSeries::mnaTearApplyMatrixStamp(SparseMatrixRow& tearMatrix) { Math::addToMatrixElement(tearMatrix, mTearIdx, mTearIdx, mImpedance); } diff --git a/examples/Notebooks/Circuits/Validation_RL_Element.ipynb b/examples/Notebooks/Circuits/Validation_RL_Element.ipynb index 40ca86eb2b..b9a24506bd 100644 --- a/examples/Notebooks/Circuits/Validation_RL_Element.ipynb +++ b/examples/Notebooks/Circuits/Validation_RL_Element.ipynb @@ -42,7 +42,8 @@ "resistance = 10\n", "inductance = 1e-3\n", "capacitance = 5e-6\n", - "frequency = 50" + "frequency = 50\n", + "epsilon = 1e-12" ] }, { @@ -319,7 +320,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -327,8 +328,11 @@ "err_current = ts.rmse(ts_dpsim_comps[\"l1.i_intf_shift\"], ts_dpsim_dp[\"rl.i_intf_shift\"])\n", "err_voltage = ts.rmse(ts_dpsim_comps[\"n3.v_shift\"], ts_dpsim_dp[\"n2.v_shift\"])\n", "\n", - "assert err_current < 0.00001\n", - "assert err_voltage < 0.00001" + "print(err_current)\n", + "print(err_voltage)\n", + "\n", + "assert err_current < epsilon\n", + "assert err_voltage < epsilon" ] }, { @@ -450,9 +454,9 @@ "# Components\n", "vs = dpsimpy.emt.ph3.VoltageSource('vs', dpsimpy.LogLevel.off)\n", "vs.set_parameters(V_ref=dpsimpy.Math.single_phase_variable_to_three_phase(complex(10, 0)), f_src=frequency)\n", - "rl = dpsimpy.emt.ph3.ResInductor('rl', dpsimpy.LogLevel.off)\n", + "rl = dpsimpy.emt.ph3.ResInductor('rl', dpsimpy.LogLevel.debug)\n", "rl.set_parameters(R=dpsimpy.Math.single_phase_parameter_to_three_phase(resistance), L=dpsimpy.Math.single_phase_parameter_to_three_phase(inductance))\n", - "c1 = dpsimpy.emt.ph3.Capacitor('c1', dpsimpy.LogLevel.off)\n", + "c1 = dpsimpy.emt.ph3.Capacitor('c1', dpsimpy.LogLevel.debug)\n", "c1.set_parameters(C=dpsimpy.Math.single_phase_parameter_to_three_phase(capacitance))\n", "\n", "# Connections\n", @@ -473,7 +477,7 @@ "sim = dpsimpy.Simulation(name_emt, dpsimpy.LogLevel.off)\n", "sim.set_system(system)\n", "sim.set_domain(dpsimpy.Domain.EMT)\n", - "sim.set_time_step(0.00001)\n", + "sim.set_time_step(0.0001)\n", "sim.set_final_time(0.02)\n", "sim.add_logger(logger)\n", "sim.run()" @@ -503,7 +507,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Plot Results" + "### Plot Results phase a" ] }, { @@ -512,10 +516,10 @@ "metadata": {}, "outputs": [], "source": [ - "ts_dpsim_emt_ref[\"l1.i_intf_0\"].label = 'i - REF'\n", - "ts_dpsim_emt_ref[\"n3.v_0\"].label = 'vc - REF'\n", - "ts_dpsim_emt[\"rl.i_intf_0\"].label = 'i RL Element'\n", - "ts_dpsim_emt[\"n2.v_0\"].label = 'vc RL Element'\n", + "ts_dpsim_emt_ref[\"l1.i_intf_0\"].label = 'i (phase a) - REF'\n", + "ts_dpsim_emt_ref[\"n3.v_0\"].label = 'vc (phase a) - REF'\n", + "ts_dpsim_emt[\"rl.i_intf_0\"].label = 'i (phase a) RL Element'\n", + "ts_dpsim_emt[\"n2.v_0\"].label = 'vc (phase a) RL Element'\n", "\n", "pt.plot_timeseries(3, ts_dpsim_emt_ref[\"n3.v_0\"])\n", "pt.plot_timeseries(3, ts_dpsim_emt[\"n2.v_0\"], plt_linestyle='--')\n", @@ -524,6 +528,42 @@ "pt.plot_timeseries(4, ts_dpsim_emt[\"rl.i_intf_0\"], plt_linestyle='--')" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ts_dpsim_emt_ref[\"l1.i_intf_1\"].label = 'i (phase b) - REF'\n", + "ts_dpsim_emt_ref[\"n3.v_1\"].label = 'vc (phase b) - REF'\n", + "ts_dpsim_emt[\"rl.i_intf_1\"].label = 'i (phase b) RL Element'\n", + "ts_dpsim_emt[\"n2.v_1\"].label = 'vc RL (phase b) Element'\n", + "\n", + "pt.plot_timeseries(3, ts_dpsim_emt_ref[\"n3.v_1\"])\n", + "pt.plot_timeseries(3, ts_dpsim_emt[\"n2.v_1\"], plt_linestyle='--')\n", + "\n", + "pt.plot_timeseries(4, ts_dpsim_emt_ref[\"l1.i_intf_1\"])\n", + "pt.plot_timeseries(4, ts_dpsim_emt[\"rl.i_intf_1\"], plt_linestyle='--')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ts_dpsim_emt_ref[\"l1.i_intf_2\"].label = 'i (phase c) - REF'\n", + "ts_dpsim_emt_ref[\"n3.v_2\"].label = 'vc (phase c) - REF'\n", + "ts_dpsim_emt[\"rl.i_intf_2\"].label = 'i (phase c) RL Element'\n", + "ts_dpsim_emt[\"n2.v_2\"].label = 'vc RL (phase c) Element'\n", + "\n", + "pt.plot_timeseries(3, ts_dpsim_emt_ref[\"n3.v_2\"])\n", + "pt.plot_timeseries(3, ts_dpsim_emt[\"n2.v_2\"], plt_linestyle='--')\n", + "\n", + "pt.plot_timeseries(4, ts_dpsim_emt_ref[\"l1.i_intf_2\"])\n", + "pt.plot_timeseries(4, ts_dpsim_emt[\"rl.i_intf_2\"], plt_linestyle='--')" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -534,16 +574,39 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "# calculate the RMSE between both models\n", + "# calculate the RMSE between both models phase a\n", "err_current = ts.rmse(ts_dpsim_emt_ref[\"l1.i_intf_0\"], ts_dpsim_emt[\"rl.i_intf_0\"])\n", "err_voltage = ts.rmse(ts_dpsim_emt_ref[\"n3.v_0\"], ts_dpsim_emt[\"n2.v_0\"])\n", "\n", - "assert err_current < 0.001\n", - "assert err_voltage < 0.001" + "print(err_current)\n", + "print(err_voltage)\n", + "\n", + "assert err_current < epsilon\n", + "assert err_voltage < epsilon\n", + "\n", + "# calculate the RMSE between both models phase b\n", + "err_current = ts.rmse(ts_dpsim_emt_ref[\"l1.i_intf_1\"], ts_dpsim_emt[\"rl.i_intf_1\"])\n", + "err_voltage = ts.rmse(ts_dpsim_emt_ref[\"n3.v_1\"], ts_dpsim_emt[\"n2.v_1\"])\n", + "\n", + "print(err_current)\n", + "print(err_voltage)\n", + "\n", + "assert err_current < epsilon\n", + "assert err_voltage < epsilon\n", + "\n", + "# calculate the RMSE between both models phase a\n", + "err_current = ts.rmse(ts_dpsim_emt_ref[\"l1.i_intf_2\"], ts_dpsim_emt[\"rl.i_intf_2\"])\n", + "err_voltage = ts.rmse(ts_dpsim_emt_ref[\"n3.v_2\"], ts_dpsim_emt[\"n2.v_2\"])\n", + "\n", + "print(err_current)\n", + "print(err_voltage)\n", + "\n", + "assert err_current < epsilon\n", + "assert err_voltage < epsilon" ] }, { @@ -756,7 +819,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -764,8 +827,11 @@ "err_current = ts.rmse(ts_dpsim_sp_ref[\"l1.i_intf_shift\"], ts_dpsim_sp[\"rl.i_intf_shift\"])\n", "err_voltage = ts.rmse(ts_dpsim_sp_ref[\"n3.v_shift\"], ts_dpsim_sp[\"n2.v_shift\"])\n", "\n", - "assert err_current < 0.00001\n", - "assert err_voltage < 0.00001" + "print(err_current)\n", + "print(err_voltage)\n", + "\n", + "assert err_current < epsilon\n", + "assert err_voltage < epsilon" ] } ], @@ -785,7 +851,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13 (main, May 18 2022, 00:00:00) \n[GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]" + "version": "3.9.13" }, "orig_nbformat": 4, "vscode": { diff --git a/examples/Notebooks/Components/Line.ipynb b/examples/Notebooks/Components/Line.ipynb index 1c6a275061..19ae104ae4 100644 --- a/examples/Notebooks/Components/Line.ipynb +++ b/examples/Notebooks/Components/Line.ipynb @@ -21,7 +21,7 @@ "\n", "#%matplotlib widget\n", "\n", - "epsilon = 1e-12" + "epsilon = 2e-6" ] }, { @@ -785,7 +785,7 @@ "outputs": [], "source": [ "plt.figure()\n", - "for name in ['v1_0', 'v2_0', 'iline_0']:\n", + "for name in ['v1_0', 'v2_0', 'iline_0', 'v1_1', 'v2_1', 'iline_1', 'v1_2', 'v2_2', 'iline_2']:\n", " plt.plot(piline_elements_emt[name].time, piline_elements_emt[name].values - piline_component_emt[name].values, label=name+'_error')\n", "plt.legend()\n", "plt.show()" @@ -805,7 +805,7 @@ "outputs": [], "source": [ "errors_emt = []\n", - "for name in ['v1_0', 'v2_0', 'iline_0']:\n", + "for name in ['v1_0', 'v2_0', 'iline_0', 'v1_1', 'v2_1', 'iline_1', 'v1_2', 'v2_2', 'iline_2']:\n", " errors_emt.append(np.absolute(piline_elements_emt[name].values - piline_component_emt[name].values).max())\n", " print(name + ': ' + str(errors_emt[-1]))\n", "assert np.max(errors_emt) < epsilon" @@ -1243,7 +1243,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.10" + "version": "3.9.13" } }, "nbformat": 4,