Upload
jandfor-tansfg-errott
View
220
Download
0
Embed Size (px)
Citation preview
7/28/2019 Help Power Modeling Block
1/15
Help on the Power Modeling Block
Page 1 www.powersimtech.com
Help on the Power Modeling Block
Powersim Inc.
This document describes how to use the Power Modeling Block in PSIM. It is organized in the following
way:
- Section 1: Background on the Power Modeling Block
- Section 2: Introduction on PSIMs numerical algorithm
- Section 3: Examples of using the Power Modeling Block
1. Background
The Power Modeling Block is a block that allows users to define algebraic and differential equations for a
device, and to build a model in the power circuit. Unlike control circuit models that have signal inputs and
signal outputs with no consideration of the power conservation (no input and output power balance), electric
currents can flow into and out of the terminals of the Power Modeling block.
Take the following dc converter circuit as an example:
In the circuit on the left, the inductor L1 uses the built-in model from the PSIM library. In the circuit on theright, the inductor L2 is modeled using the Power Modeling Block based on the differential equation vL =L
diL / dt.
The Power Modeling Block provides a very powerful way of modeling power devices. It can have power
terminals, control input/output terminals, and mechanical shaft terminals, and equations can be algebraic or
differential, linear or nonlinear. A significant feature of the Power Modeling Block is that these equations
are assembled and solved simultaneously with the other equations from the rest of the PSIM circuit, resulting
a very robust, stable, and efficient solution.
2. PSIMs Numerical Algorithm
In order to use the Power Modeling Block, one needs to understand how PSIM solves a circuit.
PSIMs solution involves three steps:
- Discretize differential equations based on the Trapezoidal Rule and Backward Euler integration
algorithm.
- Formulate circuit equations using the Nodal Analysis.
- Solve the nodal equation Y* V=Iwhere Yis the admittance matrix, Vis the voltage vector, andIis
the current vector.
7/28/2019 Help Power Modeling Block
2/15
Help on the Power Modeling Block
Page 2 www.powersimtech.com
Discretizing Differential Equations:
In PSIM, a differential equation is first discretized into an algebraic equation using the Trapezoidal Rule andthe Backward Euler method.
For example, the equation of an inductor is described:
dt
diLv LL =
With the Trapezoidal Rule, it can be discretized as follows:
t
iiL
vv LLLL
=
+ )0(
2
)0(
where tis the simulation time step, and vL(0) and iL(0) are the voltage and current at the previous time step.The above equation can be rearranged as:
)]0()0(
2
[
2
LLLL iv
L
tv
L
ti +
+
=
or
eq
eq
LL I
R
vi +=
where
t
LReq
=
2
)0()0(
L
eq
Leq i
R
vI +=
Similarly, with the Backward Euler method, and using half of the time step, the same differential equation
can be discretized as follows:
2
)0(
t
iiLv LLL
=
The above equation can be rearranged as:
)0(2
LLL ivL
ti +
=
or
eq
eq
LL I
R
vi +=
where
t
LReq
=
2
7/28/2019 Help Power Modeling Block
3/15
Help on the Power Modeling Block
Page 3 www.powersimtech.com
)0(Leq iI =
The reason of using the half time step is that the equivalent resistanceReq remains the same as in the case of
the Trapezoidal Rule.
Similarly, the equation of a capacitor is:
dtdvCi CC =
With the Trapezoidal Rule, it can be discretized as follows:
t
vvC
ii CCCC
=
+ )0(
2
)0(
With the Backward Euler, using half of the time step, it can be discretized as follows:
2
)0(
t
vvCi CCC
=
The above equations can be rearranged as:
eq
eq
CC I
R
vi +=
where
C
tReq
2
=
For Trapezoidal Rule:
)0(
)0(
Ceq
C
eq iR
v
I=
and for Backward Euler:
eq
Ceq
R
vI
)0(=
After the discretization, an inductor or capacitor is represented by an equivalent resistor, in parallel with a
current source that is a function of the values at the previous time step, as shown below:
7/28/2019 Help Power Modeling Block
4/15
Help on the Power Modeling Block
Page 4 www.powersimtech.com
Formulating Equations:
After inductors and capacitors are discretized, a circuit becomes a resistive circuit which contains only
resistors and voltage/current sources. Nodal analysis can then be used to formulate the circuit equations.
Take the following circuit as an example:
The circuit on the left is the original circuit. The circuit on the right is after the discretization. Nodal
equations can then be formulated for each node.
For Node 1:
1_3
1
2
1_
1
21
11)
11( Leq
Leq
IvR
vR
vRR
=+
For Node 2:
sCeqLeq
CeqLeqLeq
IIIvRR
vR
=++ 1_1_21_1_
1
1_
)11
(1
Voltage v3 is already known, and is the same as Vs. In the matrix form, the equations become:
+=
+
+
sCeqLeq
sLeq
CeqLeqLeq
Leq
III
VR
I
v
v
RRR
RRR
1_1_
1
1_
2
1
1_1_1_
1_21
1
111
111
or in a more general form:
IVY =
Please note that the right-hand-side vectorIcontains both the terms that depend on the values of the previous
time step (such asIeq_L1 andIeq_C1) and the terms due to fixed voltage/current sources (such as Vs andIs).
Once the nodal equation Y*V=Iis formulated, it can be solved.
3. Building the Device Model Using the Power Modeling Block
To build a device model, one needs to prepare a set of algebraic equationA*X=B for the device, and PSIM
will assemble this equation with the equation Y*V=Ifrom the rest of the circuit, and the complete equation
set will be solved simultaneously.
The following examples are used to illustrate this process.
1 23
7/28/2019 Help Power Modeling Block
5/15
Help on the Power Modeling Block
Page 5 www.powersimtech.com
Modeling a Resistor:
Assume that the device to be modeled is a resistor, and the resistor connects to the rest of the PSIM circuit
through two terminals, as shown below:
If the resistor is treated in isolation which is separate from the rest of the PSIM circuit, the nodal equations
for Node 1 and 2 are:
For Node 1:
011
21 = vR
vR
For Node 2:
011
21 =+ vR
vR
The implementation of the resistor model in a C code is shown below.
Device to be
modelled
The rest ofthe PSIM
circuit
1
2
1
2
void REQUESTSIMDATA(DllDeviceData * pDD, int *pnError, LPSTR szErrorMsg){
Internal_DLL_Block_Data * pData = (Internal_DLL_Block_Data *)(pDD->m_pUserData);double R;R = pData->m_fR; //resistance defined by the user
switch( pDD->m_nRequestCode ){case REQUEST_NODE_INFO: //Request the node information
pDD->m_nExtLinearNodes = 2;break;
case REQUEST_COEFF_A: //Request coefficient A for A*X = B{ //Calculate Yii and Yij
if (pDD->m_nRequestNodeIndex == 1) // Node E1{
pDD->m_pfCoeff_A[0] = 1. / R;pDD->m_pfCoeff_A[1] = - 1./R;
}else if (pDD->m_nRequestNodeIndex == 2) // Node E2{
pDD->m_pfCoeff_A[0] = -1./R;pDD->m_pfCoeff_A[1] = 1./R;
}}break;
case REQUEST_PREV: // Calculate Ieq for all L and Cbreak;
case REQUEST_COEFF_B: //Request coefficient B for A*X = Bbreak;
case REQUEST_STATE_UPDATE: //Request update of state variablesbreak;
case REQUEST_STATE_READ: //Request values of state variablesbreak;
case REQUEST_STATE_WRITE: //Receive modified values of statebreak;
case REQUEST_DLL_OUTPUT: //Request the DLL outputsbreak;
};*pnError = 0;
}
Coefficients for
equation at Node 1
Coefficients for
equation at Node 2
There are 2terminals.
7/28/2019 Help Power Modeling Block
6/15
Help on the Power Modeling Block
Page 6 www.powersimtech.com
In the code above, the lines marked in red are the code added by users.
As shown in the code, the coefficients of the equations at Node 1 and Node 2 are entered as they are. In this
case, there are no right-hand-side term and no historic terms.
Modeling an Inductor:
Assume that the device to be modeled is an inductor, and the inductor connects to the rest of the PSIM circuit
through two terminals, as shown below:
There are two ways to formulate the equation for the inductor. One is to treat the inductor current as an
internal variable (a variable that is not solved directly in the equation), and the other is to solve the inductorcurrent directly.
If the inductor current is treated as an internal variable, the nodal equations for Node 1 and 2 are (ignoring
the rest of the PSIM circuit):
For Node 1:
eq
eqeq
IvR
vR
= 2111
For Node 2:
eq
eqeq
IvR
vR
=+ 2111
The code implementation of the model will be as follows.
Device to be
modelled
The rest of
the PSIM
circuit
1
2
1
2
1
2
void REQUESTSIMDATA(DllDeviceData * pDD, int *pnError, LPSTR szErrorMsg){
Internal_DLL_Block_Data * pData = (Internal_DLL_Block_Data *)(pDD->m_pUserData);
double Req_L, vkm0, T, delt;T = pDD->m_fT;delt = pDD->m_fDeltaT;Req_L = 2.*pData->m_fL / delt;
switch( pDD->m_nRequestCode ){case REQUEST_NODE_INFO: //Request the node information
pDD->m_nExtLinearNodes = 2;pDD->m_nIntStates = 1;break;
There are two terminals, and oneinternal state variable (the inductor
current iL).
Calculate inductor equivalent
resistance Req = 2L / t
7/28/2019 Help Power Modeling Block
7/15
Help on the Power Modeling Block
Page 7 www.powersimtech.com
Alternative, the inductor can be modeled in such a way that the inductor current is solved directly. The
advantage of this method is that the inductor does not have to be treated as an internal variable, and there is
no need for extra calculation.
With the direction of the inductor current iL as shown in the diagram, the equations can be expressed as:
case REQUEST_COEFF_A: //Request coefficient A for A*X = B{ //Calculate Yii and Yij
if (pDD->m_nRequestNodeIndex == 1) // Node E1{
pDD->m_pfCoeff_A[0] = 1. / Req_L;pDD->m_pfCoeff_A[1] = - 1./Req_L;
}else if (pDD->m_nRequestNodeIndex == 2) // Node E2{
pDD->m_pfCoeff_A[0] = -1./Req_L;pDD->m_pfCoeff_A[1] = 1./Req_L;
}}break;
case REQUEST_PREV: // Calculate Ieq for all L and C// Ieq_L1 are internal variables.{
if (pDD->m_nRequestFlag == FLAG_BACKWARD_EULER){
pData->m_fIeq = pData->m_fIt;}else //if (pDD->m_nRequestFlag == FLAG_TRAPEZOIDAL){vkm0 = pDD->m_pfVoltages[0] - pDD->m_pfVoltages[1];
pData->m_fIeq = pData->m_fIt + vkm0/Req_L;
}}break;
case REQUEST_COEFF_B: //Request coefficient B for A*X = B{
pDD->m_pfCoeff_B[0] = - pData->m_fIeq; // Node E1pDD->m_pfCoeff_B[1] = pData->m_fIeq; // Node E2
}break;
case REQUEST_STATE_UPDATE: //Request update of state variables (i.e. iL(t)){
vkm0 = pDD->m_pfVoltages[0] - pDD->m_pfVoltages[1];pData->m_fIt = vkm0/Req_L + pData->m_fIeq;
}break;
case REQUEST_STATE_READ: //Request values of state variables (i.e. iL(t)){
pDD->m_pfStateVariables[0] = pData->m_fIt;}break;
case REQUEST_STATE_WRITE: //Receive modified state variables (i.e. iL(t)){
pData->m_fIt = pDD->m_pfStateVariables[0];
}break;
case REQUEST_DLL_OUTPUT: //Request the DLL outputsbreak;
};
*pnError = 0;}
Coefficients for
equation at Node
Coefficients for
equation at Node
Calculate Ieqbased
Backward Euler
Calculate Ieqbased
Trapezoidal Rule
Define the right-hand-side of the
equations for Node
and 2
Calculate the induc
current iL based on
iL = VL / Req + Ieq
Update the interna
state variable iL
7/28/2019 Help Power Modeling Block
8/15
Help on the Power Modeling Block
Page 8 www.powersimtech.com
For Node 1:
0=+ LiVY
For Node 2:
0= LiVY
For the variable iL:
eq
eq
LL I
R
vi +=
or
eqeqLeq IRiRvv =++ 21
In the equations for Node 1 or Node 2, the term Y*Vcorresponds to the contribution of the rest of the PSIMcircuit to the nodal equation at the node, and it represents the summation of the currents flowing away from
this node.
The model implementation in the code is shows as follows.
void REQUESTSIMDATA(DllDeviceData * pDD, int *pnError, LPSTR szErrorMsg){
Internal_DLL_Block_Data * pData = (Internal_DLL_Block_Data *)(pDD->m_pUserData);
double Req_L, vkm0, T, delt, iL;T = pDD->m_fT;delt = pDD->m_fDeltaT;Req_L = 2.*pData->m_fL / delt;
switch( pDD->m_nRequestCode ){case REQUEST_NODE_INFO: //Request the node information
pDD->m_nExtLinearNodes = 2;pDD->m_nIntLinearNodes = 1;break;
case REQUEST_COEFF_A: //Request coefficient A for A*X = B{ //Calculate Yii and Yij
if (pDD->m_nRequestNodeIndex == 1) // Node E1{
pDD->m_pfCoeff_A[0] = 0.;pDD->m_pfCoeff_A[1] = 0.;pDD->m_pfCoeff_A[1] = 1.;
}else if (pDD->m_nRequestNodeIndex == 2) // Node E2{
pDD->m_pfCoeff_A[0] = 0.;pDD->m_pfCoeff_A[1] = 0.;pDD->m_pfCoeff_A[1] = -1.;
}else if (pDD->m_nRequestNodeIndex == 3) // Node I1{
pDD->m_pfCoeff_A[0] = -1.;pDD->m_pfCoeff_A[1] = 1.;pDD->m_pfCoeff_A[1] = Req_L;
}}break;
There are 2 terminals, and 1 interna
node due to iL.
Calculate inductor equivalent
resistance Req = 2L / t
Define coefficients for equation at
Node 1. The node sequence is: v1, vand iL
Define coefficients for equation atNode 2.
Define coefficients for equation atNode 2.
7/28/2019 Help Power Modeling Block
9/15
Help on the Power Modeling Block
Page 9 www.powersimtech.com
Modeling a Capacitor:
Assume that the device to be modeled is a capacitor, and the capacitor connects to the rest of the PSIM
circuit through two terminals, as shown below:
Similar to the way equations are formulated for the inductor, the equations for the capacitor can be
formulated as follows.
For Node 1:
eq
eqeq
IvR
vR
= 2111
For Node 2:
eq
eqeq
IvR
vR
=+ 2111
The implementation of the model in the code will be as follows.
case REQUEST_PREV: //Calculate Ieq for all L and C{
if (pDD->m_nRequestFlag == FLAG_BACKWARD_EULER){
pData->m_fIeq = pDD->m_pfVoltages[2];}else //if (pDD->m_nRequestFlag == FLAG_TRAPEZOIDAL){
vkm0 = pDD->m_pfVoltages[0] - pDD->m_pfVoltages[1];pData->m_fIeq = pDD->m_pfVoltages[2] + vkm0/Req_L ;
}}break;
case REQUEST_COEFF_B: //Request coefficient B for A*X = B{
pDD->m_pfCoeff_B[0] = 0.; // Node E1pDD->m_pfCoeff_B[1] = 0.; // Node E2pDD->m_pfCoeff_B[2] = Req_L * pData->m_fIeq; //Node I1
}break;
case REQUEST_STATE_UPDATE: //Request update of state variablesbreak;
case REQUEST_STATE_READ: //Request values of state variables
break;
case REQUEST_STATE_WRITE: //Receive modified values of state variablesbreak;
case REQUEST_DLL_OUTPUT: //Request the DLL outputsbreak;
};
*pnError = 0;}
Calculate Ieqbase
Backward Euler.
Define the right-
hand-side of the
equations for Nodand 2 and iL.
Calculate Ieqbase
Trapezoidal Rule
Device to be
modelled
The rest of
the PSIM
circuit
1
2
1
2
1
2
7/28/2019 Help Power Modeling Block
10/15
Help on the Power Modeling Block
Page 10 www.powersimtech.com
void REQUESTSIMDATA(DllDeviceData * pDD, int *pnError, LPSTR szErrorMsg){
Internal_DLL_Block_Data * pData = (Internal_DLL_Block_Data *)(pDD->m_pUserData);
double Req_C, vkm0, T, delt;T = pDD->m_fT;delt = pDD->m_fDeltaT;Req_C = delt / (2.*pData->m_fC);
switch( pDD->m_nRequestCode ){case REQUEST_NODE_INFO: //Request the node information
pDD->m_nExtLinearNodes = 2;break;
case REQUEST_COEFF_A: //Request coefficient A for A*X = B{ //Calculate Yii and Yij
if (pDD->m_nRequestNodeIndex == 1) // Node E1{
pDD->m_pfCoeff_A[0] = 1. / Req_C;pDD->m_pfCoeff_A[1] = - 1./Req_C;
}else if (pDD->m_nRequestNodeIndex == 2) // Node E2{
pDD->m_pfCoeff_A[0] = -1./Req_C;pDD->m_pfCoeff_A[1] = 1./Req_C;}
}break;
case REQUEST_PREV: // Calculate Ieq for all L and C// Ieq_L1 are internal variables.{
vkm0 = pDD->m_pfVoltages[0] - pDD->m_pfVoltages[1];if (pDD->m_nRequestFlag == FLAG_BACKWARD_EULER){
pData->m_fIeq = - vkm0 / Req_C;}else //if (pDD->m_nRequestFlag == FLAG_TRAPEZOIDAL){
io = vkm0 / Req + pData->m_fIeq;
pData->m_fIeq = - vkm0 / Req_C - io;}
}break;
case REQUEST_COEFF_B: //Request coefficient B for A*X = B{
pDD->m_pfCoeff_B[0] = - pData->m_fIeq; // Node E1pDD->m_pfCoeff_B[1] = pData->m_fIeq; // Node E2
}break;
case REQUEST_STATE_UPDATE: //Request update of state variablesbreak;
case REQUEST_STATE_READ: //Request values of state variablesbreak;
case REQUEST_STATE_WRITE: //Receive modified values of state
break;case REQUEST_DLL_OUTPUT: //Request the DLL outputs
break;};*pnError = 0;
}
There are two
terminals.
Calculate capacitor
equivalent resistance
Re = t / (2C).
Calculate Ieqbased on
Backward Euler.
Define the right-
hand-side of the
equations for Node 1
and 2 and iL.
Calculate Ieqbased on
Trapezoidal Rule.
Define the equationcoefficients.
7/28/2019 Help Power Modeling Block
11/15
Help on the Power Modeling Block
Page 11 www.powersimtech.com
Modeling a DC Machine with Saturation:
The Power Modeling Block has the capability to model very complex power devices. As an example, a dc
machine with saturation is modeled using the equivalent circuit and the Power Modeling Block.
The armature winding equation, mechanical equation, and the field winding equation of the dc machine can
be expressed as:
aa
aaaa EdtdiLiRv ++=
mafa LE =
Lemm TT
dt
dJ =
aafem iLT =
dt
diLiRv
f
ffff +=
2.0372.0
6.1 +=
fi
af eL Here the field nonlinearity is considered.
Using the equivalent circuit method, the machine can be represented by the following equivalent circuit
model:
Armature resistance Ra = 0.5 Ohm
Armature inductance La = 50 mHField winding resistance Rf= 75 OhmField winding inductance Lf= 20 mH
Moment of inertia J = 0.3 kg/m2
Rated conditions:
Va = 120 V, Ia = 10 A, If= 1.6 A
n = 1200 rpm
7/28/2019 Help Power Modeling Block
12/15
Help on the Power Modeling Block
Page 12 www.powersimtech.com
To understand how the equivalent circuit for the mechanical equation is obtained, if we compare the
mechanical equationJ* dm / dt = Tem TL with the capacitor equation C* dvc / dt = ic, we will find that
they are analogous. Therefore, we can treat the moment of inertiaJas the capacitance, the mechanical speed
m as the voltage, and the torques as the currents. In the equivalent circuit, the voltage across the capacitorJ,
therefore, represents the mechanical speed m.
To implement the machine using the Power Modeling Block, we need to re-organize the equations as
follows:
At Node va+:
0=+ aiVY
At Node va-:
0= aiVY
At Node vf+:
0=+ fiVY
At Node vf-:
0=fiVY
Forif:
ffLfeqfff HiRRvv =+++ + )( _
Foria:
amafaLaeqaaa HLiRRvv =++++ + )( _
Form:
LJaaf
Jeq
m THiLR
=_
whereReq_La= 2 La / t,Req_Lf= 2 Lf/ t,Req_J= t / (2J), andHf,Ha, andHJare defined as follows:
For Backward Euler:Hf=Req_Lf* if(0), Ha =Req_La* ia(0), andHJ= m(0) /Req_J.
For Trapezoidal Rule:Hf=Req_Lf* if(0) + vLf(0), Ha =Req_La* ia(0) + vLa(0), andHJ= m(0) /Req_J+im(0).
To understand howHf,Ha, andHJare obtained, we take the equation forifas an example. We can rewrite the
differential equation forifas follows:
Lffff viRv +=
where vLf is defined as: vLf =Lf* dif / dt. If we discretize this equation using the Backward Euler (with half
of the time step), it becomes:
)0(__ fLfeqfLfeqLf iRiRv =
Substituting this equation to the field winding equation, we have:
)0(__ fLfeqfLfeqfff iRiRiRv +=
or
)0()( __ fLfeqfLfeqff iRiRRv =++
Similarly, if we discretize the equation vLf =Lf* dif / dt using the Trapezoidal Rule, it becomes:
)0()0(__ LffLfeqfLfeqLf viRiRv =
7/28/2019 Help Power Modeling Block
13/15
Help on the Power Modeling Block
Page 13 www.powersimtech.com
Substituting this equation to the field winding equation, we have:
)0()0(__ LffLfeqfLfeqfff viRiRiRv +=
or
)0()0()( __ LffLfeqfLfeqff viRiRRv +=++
The model implementation in the code is shows as follows.
void REQUESTSIMDATA(DllDeviceData * pDD, int *pnError, LPSTR szErrorMsg){
Internal_DLL_Block_Data * pData = (Internal_DLL_Block_Data *)(pDD->m_pUserData);
double AbsoluteTolerance = 2.e-2, RelativeTolerance = 1.e-4;double Ra, Rf, Req_La, Req_Lf, Req_J, Laf;double Ia, iL, If, Wm, VLa0, Ia0, VLf0, If0, Wm0, io, T, delt;T = pDD->m_fT;delt = pDD->m_fDeltaT;Ra = pData->m_fRa;Rf = pData->m_fRf;Req_La = 2. * pData->m_fLa / delt;Req_Lf = 2. * pData->m_fLf / delt;Req_J = delt / (2. * pData->m_fJ);
switch( pDD->m_nRequestCode ){case REQUEST_NODE_INFO: //Request the node information
(//The node sequence is as follows: Va+ Va- Vf+ Vf- If Ia Wm
pDD->m_nExtLinearNodes = 4; //Va+, Va-, Vf+, Vf-pDD->m_nIntLinearNodes = 1; //IfpDD->m_nIntNonLinearNodes = 1; //IapDD->m_nMechShaftNonLinear = 1; //WmpDD->m_pMechShaftFlags[0] = 1; //master/slave flagpDD->m_nOutputDisplay = 1;
}break;
case REQUEST_COEFF_A: //Request coefficient A for A*X = B{ //Calculate Yii and Yij
If = pDD->m_pfVoltages[4];
Laf = 0.372 * exp( - fabs(If) / 1.6) + 0.2;
pData->m_fIa = pDD->m_pfVoltages[5];pData->m_fWm = pDD->m_pfVoltages[6];
if (pDD->m_nRequestNodeIndex == 1) // Node Va+pDD->m_pfCoeff_A[5] = 1.;
else if (pDD->m_nRequestNodeIndex == 2) // Node Va-pDD->m_pfCoeff_A[5] = -1.;
else if (pDD->m_nRequestNodeIndex == 3) // Node Vf+pDD->m_pfCoeff_A[4] = 1.;
else if (pDD->m_nRequestNodeIndex == 4) // Node Vf-pDD->m_pfCoeff_A[4] = -1.;
else if (pDD->m_nRequestNodeIndex == 5) // Node If{
pDD->m_pfCoeff_A[2] = -1.;pDD->m_pfCoeff_A[3] = 1.;pDD->m_pfCoeff_A[4] = Rf + Req_Lf;
}
else if (pDD->m_nRequestNodeIndex == 6) // Node Ia{
pDD->m_pfCoeff_A[0] = -1.;pDD->m_pfCoeff_A[1] = 1.;pDD->m_pfCoeff_A[5] = Ra + Req_La;pDD->m_pfCoeff_A[6] = Laf;
}
Calculate equivalent
resistances.
Define the number of intern
and external nodes. Node I
nonlinear because of Laf. N
Wm is a mechanical node.
Calculate Laf and store Ia Wm for convergence check
Define matrix coefficients
7/28/2019 Help Power Modeling Block
14/15
Help on the Power Modeling Block
Page 14 www.powersimtech.com
else if (pDD->m_nRequestNodeIndex == 6) // Node Ia{
pDD->m_pfCoeff_A[0] = -1.;pDD->m_pfCoeff_A[1] = 1.;pDD->m_pfCoeff_A[5] = Ra + Req_La;pDD->m_pfCoeff_A[6] = Laf;
}else if (pDD->m_nRequestNodeIndex == 7) // Node Wm
{ pDD->m_pfCoeff_A[5] = -Laf;pDD->m_pfCoeff_A[6] = 1. / Req_J;
}break;
case REQUEST_PREV: // Calculate Ieq for all L and C{
If0 = pDD->m_pfVoltages[4];Ia0 = pDD->m_pfVoltages[5];Wm0 = pDD->m_pfVoltages[6];
if (pDD->m_nRequestFlag == FLAG_BACKWARD_EULER) //Backward Euler{
pData->m_fVLf0 = Req_Lf * If0;pData->m_fVLa0 = Req_La * Ia0;pData->m_fTem0 = Wm0 / Req_J;
}else // Trapezoidal Rule{
VLf0 = Req_Lf * If0 - pData->m_fVLf0;pData->m_fVLf0 = Req_Lf * If0 + VLf0;VLa0 = Req_La * Ia0 - pData->m_fVLa0;pData->m_fVLa0 = Req_La * Ia0 + VLa0;io = Wm0 / Req_J - pData->m_fTem0;pData->m_fTem0 = Wm0 / Req_J + io;
}}break;
case REQUEST_COEFF_B: //Request coefficient B for A*X = B{
pDD->m_pfCoeff_B[0] = 0; // Node Va+pDD->m_pfCoeff_B[1] = 0; // Node Va-
pDD->m_pfCoeff_B[2] = 0; // Node Vf+pDD->m_pfCoeff_B[3] = 0; // Node Vf-pDD->m_pfCoeff_B[4] = pData->m_fVLf0; // Node IfpDD->m_pfCoeff_B[5] = pData->m_fVLa0; // Node IapDD->m_pfCoeff_B[6] = pData->m_fTem0; // Node Wm
}break;
case REQUEST_STATE_UPDATE: //Request update of state variablesbreak;
case REQUEST_STATE_READ: //Request values of state variablesbreak;
case REQUEST_STATE_WRITE: //Receive modified values of state variablesbreak;
case REQUEST_CONVERGENCE: //Request convergence check{ //Set m_nConvergenceFlag = 1 if not converged
Ia0 = pData->m_fIa;Ia = pDD->m_pfVoltages[5];//Absolute toleranceif (fabs(Ia - Ia0) > AbsoluteTolerance) pDD->m_nConvergenceFlag = 1;//Relative toleranceif (fabs((Ia - Ia0)/Ia0) > RelativeTolerance) pDD->m_nConvergenceFlag = 1;
Wm0 = pData->m_fWm;Wm = pDD->m_pfVoltages[6];//Absolute toleranceif (fabs(Wm - Wm0) > AbsoluteTolerance) pDD->m_nConvergenceFlag = 1;//Relative toleranceif (fabs((Wm - Wm0)/Wm0) > RelativeTolerance) pDD->m_nConvergenceFlag = 1;
}break;
Calculate the historic te
Hf, Ha, and HJ.
Define the right-hand-s
terms of the equations.
Check if the solution fo
and Wm has converged
7/28/2019 Help Power Modeling Block
15/15
Help on the Power Modeling Block
Page 15 www powersimtech com
The image of the Power Modeling Block can be customized. The circuit below shows the how the dc
machine with the customized image is connected to the rest of the circuit. Please note that the mechanical
terminals of the Power Modeling Block are to be directly connected to the mechanical elements in PSIM, as
shown in this case.
case REQUEST_DLL_OUTPUT: //Request the DLL outputspDD->m_pfOutputDisplay[0] = pDD->m_pfVoltages[5];break;
};
*pnError = 0;}
Send Ia to the output for
display.
The dc machine model described by the
Power Modeling Block.