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.

UCM | Definition File

UCM Definition File

  • The UCM definition file to be edited for the UCM Example is named ucm_Exemple.def and is shown below. All lines that start with %% are comments in the template to explain the format of data to be entered by the user. The file contains various sections that correspond to the UCM building procedure described above.
  • The UCM Preparation and Simulation functions are coded according to standard C.


NOTE: The UCM definition file is self-documenting. By this we mean that comments are left for each section clarifying for users the input required.

See the sample definition file below. Definition file is in code/preformatted text; user entries are in bold. For sample UCm definition files, see UCM | Editing.



%% UCM Model Definition File -- Generated from:
%%
%% Model “Example” definition file -- Date: Tue Mar 22 16:16:10 EST 2005
%%-----------------------------------------------------------------------------
%%
%% Definition of a user's created HYPERSIM® model
%% ---------------------------------------------
%%
%% Comments used by the definition file are preceded by this string: "%%"
%%
%% ***************************
%% * DO NOT MODIFY COMMENTS! *
%% ***************************
%%
%% Only edit zones between comments.
%% Follow directives describing format of data.
%%
%% This file is divided en 3 major sections : “General description”,
%% “Preparatory data preprocessing” and “Model simulation”.
%%
%% Here is the file general structure :
%%
%% I- Model description.
%% 1- General informations or parameters.
%% 2- Model's documentation.
%% 3- Form parameters (tunables).
%% 3.1- General parameters table.
%% 3.2- (Load Flow parameters table. NOT IMPLEMENTED!!!)
%% 4- Control IOs.
%% 5- Network nodes.
%% 6- Current sources.
%% 7- Historical currents.
%%
%% II- Preparatory data preprocessing.
%% 8- Calculated values.
%% 8.1- Calculated parameters table.
%% 8.2- (Calculated Load Flow values. NOT IMPLEMENTED!!!)
%% 8.3- Preparation function code.
%% 8.3.1- Function's global code.
%% 8.3.2- Parameters & initial admittance matrix (Yini) calculation code.
%% 8.3.3- (Load Flow results calculation code. NOT IMPLEMENTED!!!)
%% 8.4- “Includes” paths list.
%% 8.5- Required libraries list.
%% 8.6- Required libraries paths list.
%%
%% III- Model simulation.
%% 9- Simulation code.
%% 9.1- Historical values table.
%% 9.2- Test points table.
%% 9.3- Simulation functions global code.
%% 9.4- Simulation initialization function.
%% 9.5- Before “nodes voltage calculation” function code.
%% 9.5.1- Sources calculation.
%% 9.5.2- Command selection.
%% 9.5.3- Admittances matrix calculation (YMadd).
%% 9.6- After “nodes voltage calculation” function code.
%% 9.6.1- Historical values calculation.
%% 9.6.2- Commands outputs calculation.
%% 9.6.3- Determine nodes to recalculate.
%% 9.7- “Includes” paths list.
%% 9.8- Required libraries list.
%% 9.9- Required libraries paths list.
%%
%%-----------------------------------------------------------------------------
%% Beginning of model definition:
%%-----------------------------------------------------------------------------
%%
%% I- Model description.
%%
%% 1- General informations or parameters.
%% -----------------------------------
%%
%% UCM_NAME: Model Unique Name, already assigned
%% UCM_TYPE: Model type (Choice of NetworkElement or CommandBlock)
%% Default: NetworkElement.
%% UCM_CATEGORY: Model category (Breaker, Transformer, etc.)
%% UCM_VERSION: User's model version number (in a string)
%% UCM_EXEC_TIME: Estimated model's average simulation step time.
%% Default: 5.0e-6 s.
%% UCM_DESCRIPTION: Short description of model (one phrase).
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN GENERAL INFORMATION -- Enter or modify general information

UCM_NAME = Example

UCM_TYPE = NetworkElement

UCM_CATEGORY = User

UCM_VERSION = “1.0”

UCM_EXEC_TIME = 5.0e-6

UCM_DESCRIPTION = “Voltage source with non-linear inductor”

%% END GENERAL INFORMATION
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 2- Model's documentation.
%% ----------------------
%%
%% Enter text or reference after comments.
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN DOCUMENTATION -- Enter model's documentation after this line...

Three-phase sine-wave voltage source with:

  • Programmable amplitude of sine waves
  • Voltage sources have resistor in series with non-linear inductor at output
  • Inductor voltages are rectified and sent out for display

%% END DOCUMENTATION
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 3- Form parameters (tunables).
%%
%% Form parameters can be changed by the user, through an editable form
%% or by any other public mean. Parameters definitions
%% are in a tabular form.
%%
%% 3.1- General parameters table (10 columns).
%% Contains the general parameters of the model.
%%
%% Format: ( 10 columns records)
%%
%% Name Tag Units Type Size Default Min Max Flags Description
%% ---- --- ----- ---- ---- ------- --- --- ------ -----------
%%
%% Columns descriptions:
%%
%% Name : Unique name of parameter (in model's scope).
%% Tag : Descriptive name to use in forms.
%% Units : Parameter's units.
%% Text field : Must follows the SI symbols definitions.
%% Enter a "-" when not used
%% Type : Type of parameter
%% Enter: intInteger value(s)
%% double Real value(s)
%% Size : Parameter size (1->n).
%% 1 defines a scalar.
%% Default : Default value(s) of parameter.
%% v : Default value for a scalar or an array.
%% (all array's cell will have the same value).
%% [v1 v2 v3 ... vn] : Default values for an array.
%% The last value will be propagated to remaining of array
%% if the default value set is smaller than the array.
%% Min : Minimum value allowed.
%% Max : Maximum value allowed.
%% Flags : Ored values of flags definitions or '-'.
%% Available values :
%% NOT_SIMUL_MOD : Cannot be modified during simulation.
%% Description : Short description of parameter (BETWEEN DOUBLE QUOTES)
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN TUNABLE PARAMETERS -- Enter parameters table after this line...

Rs "Rs" Ohm double 1 0.01 0.0 1.0e12 - "Rs"

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"

freq "freq" Hz double 1 60.0 30.0 90.0 - "freq"

%% END TUNABLE PARAMETERS
%% 3.2- Load Flow parameters NOT IMPLEMENTED!!
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 4- Control IOs.
%% ------------
%%
%% Control IOs will be visible on network schematics as inputs
%% and outputs connectors.
%%
%% Control IOs definitions table (7 columns).
%%
%% Format: ( 7 fields records)
%%
%% NOTE: All control connectors have a UNITARY width
%% but they can be grouped.
%%
%% Name Units Type Direction Position Group Description
%% ---- ----- ---- --------- -------- ----- -----------
%%
%% Fields descriptions:
%%
%% Name : Connector's unique identifier (tag).
%%
%% Units : Signal's units.
%% Text field: use the official SI symbols.
%% Enter a "-" when not used
%% Type : Signal type
%% Enter: int : Integer
%% double : Real double precision
%% Direction : Enter: in For model's input signal
%% out For model's output signal
%% Position : Position of connector around the Ucm box
%% in schematic.
%% Choice of :
%% left, right, top, bottom, auto
%% Group : Group name or "-" for "no group".
%% All the connectors with the same group name
%% will use a single "multiplexed" connector
%% bearing the group name.
%% Description : Short description of connector.
%% (BETWEEN DOUBLE QUOTES)
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN CONTROL IOS -- Enter control IOs table after this line...

A V double in auto - "Voltage Amplitude"

IL_a A double out auto I "L current, phase a"

IL_b A double out auto I "L current, phase b"

IL_c A double out auto I "L current, phase c"

VLrec V double out auto - "Rectified L voltage" Ind - double out auto - "Current index in Lvec"

%% END CONTROL IOS
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 5- Model nodes definitions table (6 columns).
%%
%%
%% Format: ( 6 fields records)
%%
%% Name Phases IntExt Position Connect NL element Description
%% ---- -------- ------ -------- ------------------ -----------
%%
%% Fields descriptions:
%%
%% Name : Node's unique identifier.
%%
%% Phases : Number of phases.
%% Text field: Enter a number (1, 3) or
%% 0 for dynamic number of phases.
%% IntExt : Nodes can be internal or external.
%% An external node has a connection to the network
%% and will be visible as a "network connector"
%% on the schematic.
%% Values : intern/extern
%% Position : Position of connector around the Ucm box
%% in schematic (external nodes only!).
%% Choice of :
%% left, right, top, bottom, auto
%% or '-' : Non applicable.
%% Connect NL element :
%% Indicates if a non linear element is connected
%% to this node.
%% Text field : Enter "yes" or "no".
%% Description : Short description of node.
%% (BETWEEN DOUBLE QUOTES)
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN NODES DEFINITIONS -- Enter nodes table after this line...

NE 3 extern top yes "Network Connection"

NI 3 intern - yes "Internal node"


%% END NODES DEFINITIONS
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 6- Current sources definitions table (single phase).
%%
%%
%% Format: ( 3 fields records)                    [1] o +
%%                                                    |
%% Name Pos. End conn. Neg. End conn.                 |
%% ---- -------------- --------------                _|_
%%                                                  / ^ \ I
%% Fields descriptions:                             \_|_/
%%                                                    |
%% Name : Current source unique identifier.           |
%% (Append phase suffix : _a, _b, etc.)           [2] o -
%% if applicable.
%% Pos. End conn. : Positive end connection point [1].
%% Neg. End conn. : Negative end connection point [2].
%%
%% Connections points accepted values:
%%
%% Node name : The name of a node defined in section 4.
%% ground : Connected to ground.
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN CURRENT SOURCES -- Enter sources table after this line...

Isrc_a NI_a ground
Isrc_b NI_b ground
Isrc_c NI_c ground

%% END CURRENT SOURCES
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 7- Historical currents definitions table (single phase).
%%
%%
%% Format: ( 3 fields records)                    [1] o +
%%                                                    |
%% Name Pos. End conn. Neg. End conn.                 |
%% ---- -------------- --------------                _|_
%%                                                  / ^ \ I
%% Fields descriptions:                             \_|_/
%%                                                    |
%% Name : Historical current unique identifier.       |
%% (Append phase suffix : _a, _b, etc.)           [2] o -
%% if applicable.
%% Pos. End conn. : Positive end connection point [1].
%% Neg. End conn. : Negative end connection point [2].
%%
%% Connections points accepted values:
%%
%% Node name : The name of a node defined in section 4.
%% ground : Connected to ground.
%% - : Not connected
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN HISTORICAL CURRENTS -- Enter historical currents table after this...

Ihist_a NE_a NI_a
Ihist_b NE_b NI_b
Ihist_c NE_c NI_c

%% END HISTORICAL CURRENTS
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% II- Preparatory data preprocessing.
%%
%% Due to performances issues, we must do as much work as possible
%% before simulation starts. This part never runs in real time.
%%
%% 8- Calculated values (used as parameters).
%% ---------------------------------------
%%
%% Values to calculate before the simulation starts.
%% Simulation tasks will use results of this calculations.
%%
%% 8.1- Calculated parameters table. (5 columns).
%% Contains the calculated parameters definitions.
%% Format: ( 5 columns records)
%%
%% Name Units Type Size Description
%% ---- ----- ---- ---- -----------
%%
%% Columns descriptions:
%%
%% Name : Unique name of parameter (in model's scope).
%% Units : Parameter's units.
%% Text field : Must follows the SI symbols definitions.
%% Enter a "-" when not used
%% Type : Type of parameter
%% Enter: intInteger value(s)
%% double Real value(s)
%% Size : Parameter size (1->n).
%% 1 defines a scalar.
%% Description : Short description of parameter (BETWEEN DOUBLE QUOTES)
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN CALCULATED PARAMETERS -- Enter parameters table after this line...

GaddVec - double 9 "GaddVec"
Lchanged - int 1 "Lchanged"
Lindex - int 1 "Lindex"
omega - double 1 "omega"
period - double 1 "period"

%% END CALCULATED PARAMETERS
%% 8.2- Calculated Load Flow values. NOT IMPLEMENTED!!!
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 8.3- Preparation function code.
%% Contains the code to produce the calculated values .
%%
%% 8.3.1- Functions global code.
%% The following code will be at the beginning of the
%% preparatory code file.
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN PREPARATORY GLOBAL CODE -- Enter code under the appropriate comment...

/* 8.3.1.1 -- User includes */
#include <stdio.h>
/* 8.3.1.2 -- Definitions */
/* 8.3.1.3 -- Declarations */
/* 8.3.1.4 -- Local functions (static) */

%% END PREPARATORY GLOBAL CODE
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 8.3.2- Parameters & initial admittance matrix (Yini) calculation code.
%%
%% Enter code here to calculate the initial admittance matrix
%% and the calculated parameters.
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN PREPARATION FUNCTION CODE -- Enter code after this line...

int i, j;
doubleGLo, Lo, Gs;
printf ("********** ucm_Exemple_prep: Rs = %f *******************\n", Rs);
/* Initialize Yini and Yfill to 0 */
for (i = 0; i < 6; i++)
{
for (j = 0; j < 6; j++)
{
ucmYini(i,j) = 0.0;
ucmYfill(i,j) = 0;
}
}
/* Compute Yini, Yfill */
Lo = Lvec[0];
GLo = ucmTimeStep / (2.0 * Lo);
Gs = 1.0 / Rs;
ucmYini(NI_a, NI_a) = Gs + GLo;
ucmYini(NI_b, NI_b) = Gs + GLo;
ucmYini(NI_c, NI_c) = Gs + GLo;
ucmYfill (NI_a, NI_a) = 1;
ucmYfill (NI_b, NI_b) = 1;
ucmYfill (NI_c, NI_c) = 1;
ucmYini(NI_a,NE_a) = ucmYini(NE_a, NI_a) = -GLo;
ucmYini(NI_b,NE_b) = ucmYini(NE_b, NI_b) = -GLo;
ucmYini(NI_c,NE_c) = ucmYini(NE_c, NI_c) = -GLo;
ucmYfill(NI_a,NE_a) = ucmYfill(NE_a,NI_a) = 1;
ucmYfill(NI_b,NE_b) = ucmYfill(NE_b,NI_b) = 1;
ucmYfill(NI_c,NE_c) = ucmYfill(NE_c,NI_c) = 1;
ucmYini(NE_a,NE_a) = GLo;
ucmYini(NE_b,NE_b) = GLo;
ucmYini(NE_c,NE_c) = GLo;
ucmYfill(NE_a,NE_a) = 1;
ucmYfill(NE_b,NE_b) = 1;
ucmYfill(NE_c,NE_c) = 1;
/* Calculer GaddVec (param de simulation) */
for (i = 0; i < Ldim; i++)
{
GaddVec[i] = (ucmTimeStep / (2.0 * Lvec[i])) - GLo;
}
/* Calculate other parameters */

omega = 2.0 * 3.141593 * freq; period = 1.0 / freq;

%% END PREPARATION FUNCTION CODE
%% 8.3.3- Load Flow results function code. NOT IMPLEMENTED!!!
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 8.4- "Includes" paths list.
%% Enter paths of your include files separated by spaces after "=".
%% Put an "\" at end of line to continue list on next line.
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN PREPARATORY INCLUDES PATHS LIST -- Modify the following list...

UCM_PREP_INCLUDES_PATHS =

%% END PREPARATORY INCLUDES PATHS LIST
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 8.5- Required dependency libraries pathnames list.
%%
%% Enter the pathnames of your dependency libraries
%% separated by spaces after "=".
%% Put an "\" at end of line to continue list on next line.
%%
%% NOTE :
%%
%% Use the following special names to select the proper paths and/or
%% libraries names if needed. They will be replaced according to
%% the system architecture.
%%
%% <UCMA_DIR> : Will be replaced by a directory name
%% according to the computer/os
%% combination you have.
%% <UCMA_LIB_SUFFX> : Current library name suffix (Ex.: .a).
%% <UCMA_LIB_RSUFFX> : Current dynamic library name suffix
%% (Ex. : .so).
%% <UCMA_LIB_PREFX> : Current library name prefix (Ex.: lib).
%%
%% Exemples :
%%
%% UCM_PREP_DEP_LIBS_PATHNAMES = \! Always the same library
%% /usr/ucm/libmath.a
%%
%% UCM_PREP_DEP_LIBS_PATHNAMES = \! Change according to architecture
%% /user/ucm/libs/<UCMA_DIR>/<UCMA_LIB_PREFX>math<UCMA_LIB_SUFFX>
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN PREPARATORY DEPENDANT LIBRARIES LIST -- Modify the following list...

UCM_PREP_DEP_LIBS_PATHNAMES =

%% END PREPARATORY DEPENDANT LIBRARIES LIST
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 8.6- Required libraries for preparatory functions.
%% Enter full paths or lib notation (-Lpath -llibrary) of your
%% libraries separated by spaces after "=".
%% Put an "\" at end of line to continue list on next line.
%% ARCHITECTURE DEPENDANT PATHS: See NOTE in section 8.5
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN PREPARATORY LIBRARIES LIST -- Modify the following list...

UCM_PREP_LIBRARIES =

%% END PREPARATORY LIBRARIES LIST
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% III- Model simulation.
%%
%% This sections deals with model's simulation topics.
%%
%% 9- Simulation code.
%%
%% Code to simulate the model can be executed before or after the nodes
%% voltages calculations. Code that change topology and cause
%% recalculation of admittances matrix (YMadd) must be executed before.
%%
%% 9.1- Historical values table.
%%
%% Contains the historical values of the model.
%% Historical values are used to keep data from step to step.
%%
%% Format: ( 5 columns records)
%%
%% Name Type Size Default Description
%% ---- ---- ---- ------- -----------
%%
%% Columns descriptions:
%%
%% Name : Unique name of historical (in model's scope).
%% Type : Type of historical value
%% Enter: intInteger value(s)
%% double Real value(s)
%% Size : Historical value size (1->n).
%% 1 defines a scalar.
%% Default : Default value(s).
%% v : Default value for a scalar or an array.
%% (all array's cell will have the same value).
%% [v1 v2 v3 ... vn] : Default values for an array.
%% The last value will be propagated to remaining of array
%% if the default value set is smaller than the array.
%% Description : Short description of historical value
%% (BETWEEN DOUBLE QUOTES)
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN HISTORICAL VALUES -- Enter the table after this line...

time double 1 0.0 "time"

%% END HISTORICAL VALUES
%% 9.2- (Test points table. NOT IMPLEMENTED!!!)
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 9.3- Simulation functions global code.
%% The following code will be at the beginning of the
%% simulation functions file.
%%%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN SIMULATION GLOBAL CODE -- Enter code under the appropriate comment...

/* 9.3.1 -- User includes */
#include <math.h>
/* 9.3.2 -- Definitions */
/* 9.3.3 -- Declarations */
/* 9.3.4 -- Local functions (static) */

%% END SIMULATION GLOBAL CODE
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 9.4- Simulation initialization function.
%% Code executed once before simulation starts.
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN SIMULATION INITIALIZATION FUNCTION CODE -- Enter code ->...

time = 0;
Lindex = 0;
Lchanged = 0;

%% END SIMULATION INITIALIZATION FUNCTION CODE
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 9.5- Before "nodes voltage calculation" function code.
%% Code executed before "nodes voltages calculations".
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN BEFORE VOLTAGE CALCULATION CODE -- Enter code ->...

/* User code: calulate Yadd */
inti;
doubleVsrc_a, Vsrc_b, Vsrc_c;
doubleTwoPiOver3 = 2.094395333; /* 2.0 Pi / 3 */
/* Calculate current sources */
Vsrc_a = A * sin (omega * time);
Vsrc_b = A * sin (omega * time - TwoPiOver3);
Vsrc_c = A * sin (omega * time + TwoPiOver3);
Isrc_a = Vsrc_a / Rs;
Isrc_b = Vsrc_b / Rs;
Isrc_c = Vsrc_c / Rs;
/* Compute Yadd if non-linearity changes */
for (i = 0; i < 6; i++)
ucmNodeChanged(i) = 0;
if (Lchanged)
{
ucmYadd(NI_a,NI_a) = GaddVec[Lindex];
ucmYadd(NI_a,NE_a) = -GaddVec[Lindex];

ucmYadd(NE_a,NE_a) = GaddVec[Lindex]; ucmYadd(NI_b,NI_b) = GaddVec[Lindex];
ucmYadd(NI_b,NE_b) = -GaddVec[Lindex];
ucmYadd(NE_b,NE_b) = GaddVec[Lindex];
ucmYadd(NI_c,NI_c) = GaddVec[Lindex];
ucmYadd(NI_c,NE_c) = -GaddVec[Lindex];
ucmYadd(NE_c,NE_c) = GaddVec[Lindex];
/* Indicate to HYPERSIM® that nodes are affected by */
/* non-linear change */
ucmNodeChanged(NI_a) = ucmNodeChanged(NE_a) = 1;
ucmNodeChanged(NI_b) = ucmNodeChanged(NE_b) = 1;
ucmNodeChanged(NI_c) = ucmNodeChanged(NE_c) = 1;
}

%% END BEFORE VOLTAGE CALCULATION CODE
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 9.6- After "nodes voltage calculation" function code.
%% Code executed after "nodes voltages calculations".
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN AFTER VOLTAGE CALCULATION -- Enter code ->...

doubleLo, GLo, GL;
doubleVL_a, VL_b, VL_c;
intindex;
time += ucmTimeStep;
/* Calculate historic currents */
Lo = Lvec[0];
GLo = ucmTimeStep / (2.0 * Lo);
GL = GLo + GaddVec[Lindex];
VL_a = ucmVNode(NI_a) - ucmVNode(NE_a);
IL_a = VL_a*GL + Ihist_a;
Ihist_a = IL_a + VL_a*GL;
VL_b = ucmVNode(NI_b) - ucmVNode(NE_b);
IL_b = VL_b*GL + Ihist_b;
Ihist_b = IL_b + VL_b*GL;
VL_c = ucmVNode(NI_c) - ucmVNode(NE_c);
IL_c = VL_c*GL + Ihist_c;
Ihist_c = IL_c + VL_c*GL;
/* Compute 3-phase rectified voltage accross inductance */
VLrec = fabs (VL_a);
if (VLrec < fabs(VL_b))
VLrec = fabs(VL_b);
if (VLrec < fabs(VL_c))
VLrec = fabs(VL_c);

/* New operating point of L */ Lchanged = 0;
index = (int)(VLrec / Vinc);
if (index > Ldim-1)
index = Ldim - 1;
if (index < 0)
index = 0;
if (index != Lindex)
{
Lindex = index;
Lchanged = 1;
}
Ind = Lindex;
/* Other calculations */
time += ucmTimeStep;
if (time >= period) /* To avoid truncation error */
time -= period;

%% END AFTER VOLTAGE CALCULATION CODE
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 9.7- "Includes" paths list.
%% Enter paths of your include files separated by spaces after "=".
%% Put an "\" at end of line to continue list on next line.
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN SIMULATION INCLUDES PATHS LIST -- Modify the following list...

UCM_SIMULATION_INCLUDES_PATHS =

%% END SIMULATION INCLUDES PATHS LIST
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 9.8- Required simulation dependency libraries pathnames list.
%% Enter the pathnames of your libraries separated
%% by spaces after "=".
%% Put an "\" at end of line to continue list on next line.
%%
%% ARCHITECTURE DEPENDANT PATHS: See NOTE in section 8.5
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN SIMULATION DEP LIBS LIST -- Modify the following list...

UCM_SIMULATION_DEP_LIBS_PATHNAMES =

%% END SIMULATION DEP LIBS LIST
%%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%%
%% 9.9- Libraries required by simulation functions.
%% Enter full paths or lib notation (-Lpath -llibrary) of your
%% libraries separated by spaces after "=".
%% Put an "\" at end of line to continue list on next line.
%%
%% ARCHITECTURE DEPENDANT PATHS: See NOTE in section 8.5
%%
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
%% BEGIN SIMULATION LIBRARIES LIST -- Modify the following list...

UCM_SIMULATION_LIBRARIES =

%% END SIMULATION LIBRARIES LIST
%% END OF FILE

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323