Exercise 2:
Series Resistor-Inductor
Build an UCM to represent a three-phase RL circuit. R and L are in series in each phase. Use control outputs to send out monitoring signals as needed.
Description
Build a UCM to represent a three-phase RL circuit. R and L are in series and connected by an internal node Ti. L is grounded while R is connected to the outside by an external node T.
Code
%%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %% BEGIN GENERAL INFORMATION -- Enter or modify general information UCM_NAME = RL UCM_TYPE = NetworkElement UCM_CATEGORY = User UCM_VERSION = "1.0" UCM_EXEC_TIME = 5.0e-6 UCM_DESCRIPTION = "R and L in series" # Description du modele %% END GENERAL INFORMATION %%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %% BEGIN DOCUMENTATION -- Enter model’s documentation after this line... Documentation de Exemple. --------------------- Three-phase series R-L connected in Y grounded %% END DOCUMENTATION %%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %% BEGIN TUNABLE PARAMETERS -- Enter parameters table after this line... L "L" H double 3 [0.01 0.01 0.01] 0.0 1.0e12 - "Inductors" R "R" ohm double 3 [0.1 0.1 0.1] 0.0 1.0e12 - "Resistors" %% END TUNABLE PARAMETERS %%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %% BEGIN CONTROL IOS -- Enter control IOs table after this line... ILa A double out auto IL "ILa" ILb A double out auto IL "ILb" ILc A double out auto IL "ILc" IRa A double out auto IR "IRa" IRb A double out auto IR "IRb" IRc A double out auto IR "IRc" %% END CONTROL IOS %%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %% BEGIN NODES DEFINITIONS -- Enter nodes table after this line... T 3 extern bottom no "Network Connection" Ti 3 intern - no "Internal node" %% END NODES DEFINITIONS %%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %% BEGIN HISTORICAL CURRENTS -- Enter historical currents table after this... Ihist_a ground Ti_a Ihist_b ground Ti_b Ihist_c ground Ti_c %% END HISTORICAL CURRENTS %%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %% BEGIN CALCULATED PARAMETERS -- Enter parameters table after this line... GL - double 3 "Equiv.L conductance" GR - double 3 "Equiv.R conductance" %% END CALCULATED PARAMETERS %%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %% BEGIN PREPARATORY GLOBAL CODE -- Enter code under the appropriate comment... /* 8.3.1.1 -- User includes */ #include <stdio.h> /* Needed for using printf */ %% END PREPARATORY GLOBAL CODE %%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %% BEGIN PREPARATION FUNCTION CODE -- Enter code after this line... int i, j; /* Calculate equivalent L conductances */ GL[0] = ucmTimeStep / (2.0 * L[0]); GL[1] = ucmTimeStep / (2.0 * L[1]); GL[2] = ucmTimeStep / (2.0 * L[2]); /* Calculate R’s conductances */ GR[0] = 1.0 / R[0]; GR[1] = 1.0 / R[1]; GR[2] = 1.0 / R[2]; /* 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; } } /* Calculate Yini and define Yfill */ ucmYini(Ti_a, Ti_a) = GL[0] + GR[0]; ucmYini(Ti_b, Ti_b) = GL[1] + GR[1]; ucmYini(Ti_c, Ti_c) = GL[2] + GR[2]; printf ("**** Preparation: GL[0] = %f, GR[0] = %f, ucmYini(Ti_a,Ti_a) = %f *****\n", GL[0], GR[0], ucmYini(Ti_a, Ti_a)); ucmYini(T_a, T_a) = GR[0]; ucmYini(T_b, T_b) = GR[1]; ucmYini(T_c, T_c) = GR[2]; ucmYini (Ti_a, T_a) = ucmYini (T_a, Ti_a) = -GR[0]; ucmYini (Ti_b, T_b) = ucmYini (T_b, Ti_b) = -GR[1]; ucmYini (Ti_c, T_c) = ucmYini (T_c, Ti_c) = -GR[2]; ucmYfill(T_a, T_a) = 1; ucmYfill(T_b, T_b) = 1; ucmYfill(T_c, T_c) = 1; ucmYfill(Ti_a, Ti_a) = 1; ucmYfill(Ti_b, Ti_b) = 1; ucmYfill(Ti_c, Ti_c) = 1; ucmYfill(Ti_a, T_a) = ucmYfill(T_a, Ti_a) = 1; ucmYfill(Ti_b, T_b) = ucmYfill(T_b, Ti_b) = 1; ucmYfill(Ti_c, T_c) = ucmYfill(T_c, Ti_c) = 1; %% END PREPARATION FUNCTION CODE %%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %% BEGIN AFTER VOLTAGE CALCULATION -- Enter code ->... ILa = ucmVNode(Ti_a) * G[0] + Ihist_a; Ihist_a = ILa + ucmVNode(Ti_a) * G[0]; ILb = ucmVNode(Ti_b) * G[1] + Ihist_b; Ihist_b = ILb + ucmVNode(Ti_b) * G[1]; ILc = ucmVNode(Ti_c) * G[2] + Ihist_c; Ihist_c = ILc + ucmVNode(Ti_c) * G[2]; IRa = (ucmVNode(T_a) - ucmVNode(Ti_a)) * GR[0]; IRb = (ucmVNode(T_b) - ucmVNode(Ti_b)) * GR[1]; IRc = (ucmVNode(T_c) - ucmVNode(Ti_c)) * GR[2]; %% END AFTER VOLTAGE CALCULATION CODE %%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^