!-----------------------------------------------------------------------
! Component : Main
! Description : Main Page
!-----------------------------------------------------------------------
!=======================================================================
SUBROUTINE DSDyn()
!---------------------------------------
! Standard includes
!---------------------------------------
INCLUDE 'nd.h'
INCLUDE 'emtconst.h'
INCLUDE 'emtstor.h'
INCLUDE 's0.h'
INCLUDE 's1.h'
INCLUDE 's2.h'
INCLUDE 's4.h'
INCLUDE 'branches.h'
INCLUDE 'pscadv3.h'
INCLUDE 'fnames.h'
INCLUDE 'radiolinks.h'
INCLUDE 'matlab.h'
!---------------------------------------
! Function/Subroutine Declarations
!---------------------------------------
! SUBR graphsDyn !
! SUBR ESYS65_B ! 3-Phase RRL Source model (Branch Version) w/ Zero sequence
! SUBR TSAT21 ! Transformer Saturation Subroutine
! SUBR PQMDyn !
! SUBR VrmsSpecialDyn !
REAL REALPOLE ! Real Pole
! SUBR TVEKA3 ! 3-Phase PI-Controlled Phase-Locked Loop
! SUBR TVPULS ! Sawtooth Phase Signal Replication
! SUBR EMTDC_X2COMP ! 'Comparator with Interpolation'
! SUBR PQmeas_1Dyn !
REAL APLIN ! nonlinear transfer characteristic
! SUBR PhAmeasDyn !
REAL EMTDC_XPI ! 'Proportional-Integral Controller /w Interpolation'
REAL EMTDC_XINT ! 'Integrator /w Interpolation'
! SUBR EMTDC_IGFP ! Interpolated GTO Firing Pulses
!---------------------------------------
! Variable Declarations
!---------------------------------------
! Subroutine Parameters
! Electrical Node Indexes
INTEGER GND, NbR, NaR, NcR, NbI, NaI, NcI
INTEGER NT_7, NT_8, NT_9
! Control Signals
INTEGER IT_1, IT_2, Fault
REAL RT_1, RT_2, SEPh, RT_3, RT_4, RT_5
REAL RT_6, RT_7, VpuR, RT_8(6), RT_9
REAL RT_10, RT_11, RT_12, RT_13, RT_14
REAL RT_15, RT_16, BlkI, RT_17, RT_18
REAL RT_19, RT_20(6), RT_21, RT_22
REAL Pllerr, Via_c, Vic_b, Vib_a, RT_23
REAL RT_24, VbInv, VcInv, IserA, IserB
REAL IserC, deblk, RT_25, RT_26, RT_27
REAL RT_28, RT_29, dcVltg, Shft, dcCur1
REAL RT_30, REPh, RT_31, RT_32, RT_33
REAL RT_34, ThetaU, RT_35, RT_36, RT_37
REAL VaInv, C1a, C1b, C1c, VaRec, VbRec
REAL VcRec, RT_38, RT_39, RT_40, RT_41
REAL GiPLL, GpPLL, RefIon(6), RefIoff(6)
REAL VpuI, TconstI, PgainI, TrgRon(6)
REAL TrgRoff(6), RefRon(6), RefRoff(6)
REAL Rg1(2), Rg2(2), Rg3(2), Rg4(2)
REAL Rg5(2), Rg6(2), TrgIon(6)
REAL TrgIoff(6), Pdc, mr, Pse, SrcQI
REAL Vsina, Pacx, EIX, EIR, Shfti, RT_42
REAL RT_43, RT_44, RT_45, mi, RT_46
REAL RT_47, RT_48(6), RT_49(6), RT_50(6)
REAL RT_51, RT_52, RT_53(6), RT_54(6)
REAL RT_55(6), RT_56, RT_57, RT_58
REAL RT_59, RT_60, RT_61, RT_62, RT_63
REAL RT_64, RT_65, RT_66, RT_67, RT_68
REAL RT_69, RT_70, RT_71, RT_72, RT_73
REAL RT_74, RT_75, RT_76, RT_77
REAL RT_78(6), RT_79(6), g1(2), g2(2)
REAL g3(2), g4(2), g5(2), g6(2), IgtoR1
REAL VgtoR1, IdiR1, IgtoR3, VgtoR3
REAL IdiR3, IgtoR5, VgtoR5, IdiR5
REAL IgtoR4, VgtoR4, IdiR4, IgtoR6
REAL VgtoR6, IdiR6, IgtoR2, VgtoR2
REAL IdiR2, Fsep, Igto1, Vgto1, Idi1
REAL Igto3, Vgto3, Idi3, Igto5, Vgto5
REAL Idi5, Igto4, Vgto4, Idi4, Igto6
REAL Vgto6, Idi6, Igto2, Vgto2, Idi2
REAL Fre, SrcPI, SrcAI, IFlt, Vb_a, Vc_b
REAL Va_c, Icap, ViPhA, IphA, IphB, IphC
REAL Qse, AngSE
! Internal Variables
INTEGER IVD1_1, i
REAL P_MES, Q_MES, E_RMS, THETA_D, SRC_V
REAL SRC_F, SRC_P, X_KNEE, TURNS_V
REAL THO_FF, OM_GA, ERR_R, RVD2_1(2)
REAL RVD10_1(10), RVD10_2(10), DUMMY_1
REAL RVD2_2(2), RVD1_1, RVD1_2
! Fixed electrical node numbers
PARAMETER(GND=0)
! Indexing variables
INTEGER ISTOI, ISTOF, IT_0 ! Storage Indexes
INTEGER IPGB ! Control/Monitoring
INTEGER ISUBS, SS(1), IBRCH(1), INODE ! SS/Node/Branch/Xfmr
INTEGER IXFMR
!---------------------------------------
! Record local indexes
!---------------------------------------
! Dsdyn <-> Dsout transfer index storage
NTXFR = NTXFR + 1
TXFR(NTXFR,1) = NSTOL
TXFR(NTXFR,2) = NSTOI
TXFR(NTXFR,3) = NSTOF
! Record Offset and Increment Storage Counters
ISTOI = NSTOI
NSTOI = NSTOI + 3
ISTOF = NSTOF
NSTOF = NSTOF + 292
IPGB = NPGB
NPGB = NPGB + 37
INODE = NNODE + 2
NNODE = NNODE + 16
IXFMR = NXFMR
NXFMR = NXFMR + 6
! Initialize Subsystem Mapping
ISUBS = NSUBS + 0
NSUBS = NSUBS + 1
DO 100 IT_0 = 1,1
SS(IT_0) = SUBS(ISUBS + IT_0)
100 CONTINUE
! Initialize Branch Mapping.
IBRCH(1) = NBRCH(SS(1))
NBRCH(SS(1)) = NBRCH(SS(1)) + 45
!---------------------------------------
! Transfers from storage arrays
!---------------------------------------
RT_1 = STOF(ISTOF + 1)
RT_2 = STOF(ISTOF + 2)
IT_1 = STOI(ISTOI + 1)
SEPh = STOF(ISTOF + 3)
RT_3 = STOF(ISTOF + 4)
RT_4 = STOF(ISTOF + 5)
RT_5 = STOF(ISTOF + 6)
RT_6 = STOF(ISTOF + 7)
RT_7 = STOF(ISTOF + 8)
VpuR = STOF(ISTOF + 9)
RT_9 = STOF(ISTOF + 16)
RT_10 = STOF(ISTOF + 17)
RT_11 = STOF(ISTOF + 18)
RT_12 = STOF(ISTOF + 19)
RT_13 = STOF(ISTOF + 20)
RT_14 = STOF(ISTOF + 21)
IT_2 = STOI(ISTOI + 2)
RT_15 = STOF(ISTOF + 22)
RT_16 = STOF(ISTOF + 23)
BlkI = STOF(ISTOF + 24)
RT_17 = STOF(ISTOF + 25)
RT_18 = STOF(ISTOF + 26)
RT_19 = STOF(ISTOF + 27)
RT_21 = STOF(ISTOF + 34)
RT_22 = STOF(ISTOF + 35)
Pllerr = STOF(ISTOF + 36)
Via_c = STOF(ISTOF + 37)
Vic_b = STOF(ISTOF + 38)
Vib_a = STOF(ISTOF + 39)
RT_23 = STOF(ISTOF + 40)
RT_24 = STOF(ISTOF + 41)
VbInv = STOF(ISTOF + 42)
VcInv = STOF(ISTOF + 43)
IserA = STOF(ISTOF + 44)
IserB = STOF(ISTOF + 45)
IserC = STOF(ISTOF + 46)
deblk = STOF(ISTOF + 47)
RT_25 = STOF(ISTOF + 48)
RT_26 = STOF(ISTOF + 49)
RT_27 = STOF(ISTOF + 50)
RT_28 = STOF(ISTOF + 51)
RT_29 = STOF(ISTOF + 52)
dcVltg = STOF(ISTOF + 53)
Shft = STOF(ISTOF + 54)
dcCur1 = STOF(ISTOF + 55)
RT_30 = STOF(ISTOF + 56)
REPh = STOF(ISTOF + 57)
RT_31 = STOF(ISTOF + 58)
RT_32 = STOF(ISTOF + 59)
RT_33 = STOF(ISTOF + 60)
RT_34 = STOF(ISTOF + 61)
ThetaU = STOF(ISTOF + 62)
RT_35 = STOF(ISTOF + 63)
RT_36 = STOF(ISTOF + 64)
RT_37 = STOF(ISTOF + 65)
VaInv = STOF(ISTOF + 66)
C1a = STOF(ISTOF + 67)
C1b = STOF(ISTOF + 68)
C1c = STOF(ISTOF + 69)
VaRec = STOF(ISTOF + 70)
VbRec = STOF(ISTOF + 71)
VcRec = STOF(ISTOF + 72)
RT_38 = STOF(ISTOF + 73)
RT_39 = STOF(ISTOF + 74)
RT_40 = STOF(ISTOF + 75)
RT_41 = STOF(ISTOF + 76)
GiPLL = STOF(ISTOF + 77)
GpPLL = STOF(ISTOF + 78)
VpuI = STOF(ISTOF + 91)
TconstI = STOF(ISTOF + 92)
PgainI = STOF(ISTOF + 93)
Pdc =