Documentation Home Page HYPERSIM Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Exercise 4: 

Non-linear inductance

Build a UCM to model a three-phase sine-wave voltage source with the possibility of modulating the sine-wave amplitude. The modulating signal is a triangular wave of slow frequency.

Description

  • The three-phase non-linear inductor’s value depends on the rectified three-phase voltage across it.
  • The non linearity is defined by an inductance table Lvec of dimension Ldim values picked at regular voltage interval Vinc.
  • The inductor is connected to the network by its external node T. Three phase currents Ia, Ib, Ic are sent out to the connector I, the rectified three-phase voltage across L is sent out at connector Vrec. The inductor has Y grounded configuration.

Codes

%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN GENERAL INFORMATION -- Enter or modify general information
UCM_NAME = Lnlin
UCM_TYPE = NetworkElement
UCM_CATEGORY = User
UCM_VERSION = "1.0"
UCM_EXEC_TIME = 5.0e-6
UCM_DESCRIPTION = "Non-linear inductor"
%% END GENERAL INFORMATION
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN DOCUMENTATION -- Enter model’s documentation after this line...
Non-linear inductor:
L depend on rectified value of three-phase voltages across it
%% END DOCUMENTATION
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN TUNABLE PARAMETERS -- Enter parameters table after this line...
Lvec "Lvec" H double 9 [1.0 0.60 0.36 0.22 0.13 0.08 0.04 0.03 0.01] 0.0 10.0 - "Lvec"
Vinc "Vinc" V double 1 500 0.0 1000 - "Vinc"
Ldim "Ldim" - int 1 9 0.0 10.0 - "Ldim"
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN CONTROL IOS -- Enter control IOs table after this line...
Ia A double out auto I "Current phase a"
Ib A double out auto I "Current phase b"
Ic A double out auto I "Current phase c"
Db1 - double out auto Db "Debugging signal no. 1"
Db2 - double out auto Db "Debugging signal no. 2"
Db3 - double out auto Db "Debugging signal no. 3"
Vrec V double out auto - "Rectified 3-phase voltage across L"
%% END CONTROL IOS
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN NODES DEFINITIONS -- Enter nodes table after this line...
T 3 extern top yes "Network Connection"
%% END NODES DEFINITIONS
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN HISTORICAL CURRENTS -- Enter historical currents table after this...
Ihist_a ground T_a
Ihist_b ground T_b
Ihist_c ground T_c
%% END HISTORICAL CURRENTS
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN CALCULATED PARAMETERS -- Enter parameters table after this line...
GaddVec - double 9 "Additional conductance of L"
Lchanged - int 1 "Indicate that L has changed"
Lindex - int 1 "Index in table GaddVec"
%% END CALCULATED PARAMETERS
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN PREPARATION FUNCTION CODE -- Enter code after this line...
int i, j;
doubleGLo, Lo;
/* Initialize Yini and Yfill */
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
ucmYini(i,j) = 0.0;
ucmYfill(i,j) = 0;
}
}
/* Compute Yini and define Yfill */
Lo = Lvec[0];
GLo = ucmTimeStep / (2.0 * Lo);
ucmYini(T_a, T_a) = GLo;
ucmYini(T_b, T_b) = GLo;
ucmYini(T_c, T_c) = GLo;
ucmYfill(T_a, T_a) = 1;
ucmYfill(T_b, T_b) = 1;
ucmYfill(T_c, T_c) = 1;
/* Calculate GaddVec, conductance to be added when L changes */
for (i = 0; i < Ldim; i++)
{
GaddVec[i] = (ucmTimeStep / (2.0 * Lvec[i])) - GLo;
}
%% END PREPARATION FUNCTION CODE
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN SIMULATION INITIALIZATION FUNCTION CODE -- Enter code ->...
Lindex = 0;
Lchanged = 0;
%% END SIMULATION INITIALIZATION FUNCTION CODE
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN BEFORE VOLTAGE CALCULATION CODE -- Enter code ->...
/* User code: calulate Yadd */
int i;
/* Initialize indication of nodes affacted by changing in L */
for (i = 0; i < 3; i++)
ucmNodeChanged(i) = 0;
/* If L has been changed, determine the additional conductance and
indicate that corresponding nodes are affected */
if (Lchanged)
{
ucmYadd(T_a,T_a) = GaddVec[Lindex];
ucmYadd(T_b,T_b) = GaddVec[Lindex];
ucmYadd(T_c,T_c) = GaddVec[Lindex];
ucmNodeChanged(T_a) = 1;
ucmNodeChanged(T_b) = 1;
ucmNodeChanged(T_c) = 1;
}
%% END BEFORE VOLTAGE CALCULATION CODE
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%% BEGIN AFTER VOLTAGE CALCULATION -- Enter code ->...
doubleLo, GLo, GL;
doubleVL_a;
doubleVL_b;
doubleVL_c;
int index;
/* Calculate rectified of 3 phase voltage across L */
VL_a = ucmVNode(T_a);
VL_b = ucmVNode(T_b);
VL_c = ucmVNode(T_c);
Vrec = fabs(VL_a);
if (Vrec < fabs(VL_b))
Vrec = fabs(VL_b);
if (Vrec < fabs(VL_c))
Vrec = fabs(VL_c);
/* Calculate historic currents */
Lo = Lvec[0];
GLo = ucmTimeStep / (2.0 * Lo);
GL = GLo + GaddVec[Lindex];
Ia = VL_a * GL + Ihist_a;
Ihist_a = Ia + VL_a * GL;
Ib = VL_b * GL + Ihist_b;
Ihist_b = Ib + VL_b * GL;
Ic = VL_c * GL + Ihist_c;
Ihist_c = Ic + VL_c * GL;
/* New operating point of L: calculate the index in the non-linear table */
Lchanged = 0;
index = (int)(Vrec / Vinc);
if (index > Ldim-1) /* To avoid of going outside of the table */
index = Ldim - 1;
if (index < 0)
index = 0;
if (index != Lindex) /* Compare index with its past value (historic) */
{
Lindex = index;
Lchanged = 1;
}
/* Debugging signal */
Db1 = Lchanged;
Db2 = index;
Db3 = 0.0;
%% END AFTER VOLTAGE CALCULATION CODE
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


  • No labels