CFPRIME GTYR                                                            GTYR        1
C***********************************************************************RIGHTE      1
C*                                                                     *RIGHTE      2
C*        Extended Transient-Midterm Stability Program (ETMSP)         *RIGHTE      3
C*        ====================================================         *RIGHTE      4
C*                                                                     *RIGHTE      5
C*       Copyright (C) (1993) Electric Power Research Institute        *RIGHTE      6
C*                                                                     *RIGHTE      7
C* EPRI reserves all rights in the software and associated             *RIGHTE      8
C* documentation as delivered. The software and its associated         *RIGHTE      9
C* documention or any portion thereof may not be reproduced in any form*RIGHTE     10
C* whatsoever without the consent of EPRI, except as explicity provided*RIGHTE     11
C* for by license. Licensee shall submit a detailed description to EPRI*RIGHTE     12
C* of any changes or modifications to the software within two (2)      *RIGHTE     13
C* months after such changes or modifications are made. At EPRI's sole *RIGHTE     14
C* discretion, the software, as changed or modified, shall be given a  *RIGHTE     15
C* new designation sufficiently different from its then current        *RIGHTE     16
C* designation as to prevent mistake,confusion, or deception as between*RIGHTE     17
C* the current software as changed or modified.                        *RIGHTE     18
C*                                                                     *RIGHTE     19
C* A license under EPRI's rights in the software can be obtained       *RIGHTE     20
C* directly from EPRI.                                                 *RIGHTE     21
C*                                                                     *RIGHTE     22
C* This program and supporting materials may be independently available*RIGHTE     23
C* from Electric Power Software centre (EPSC) for an appropriate       *RIGHTE     24
C* distribution fee. The EPSC is a service of                          *RIGHTE     25
C*                                                                     *RIGHTE     26
C*                    Power Computing Company                          *RIGHTE     27
C*                    1930 Hi Line                                     *RIGHTE     28
C*                    Dallas, Tx 75207                                 *RIGHTE     29
C*                                                                     *RIGHTE     30
C* NEITHER EPRI, ANY MEMBER OF EPRI, NOR ANY PERSON OR  ORGANIZATION   *RIGHTE     31
C* ACTING ON BEHAVE OF THEM:                                           *RIGHTE     32
C*                                                                     *RIGHTE     33
C* 1. MAKE ANY WARRANTY OR REPRESENTATION WHATSOEVER, EXPRESS OR       *RIGHTE     34
C*    IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS OR *RIGHTE     35
C*    ANY PURPOSE WITH RESPECT TO THE SOFTWARE OR ITS ASSOCIATED       *RIGHTE     36
C*    DOCUMENTATION; OR                                                *RIGHTE     37
C*                                                                     *RIGHTE     38
C* 2. ASSUMES ANY LIABILITY WHATSOEVER WITH RESPECT TO ANY USE OF THE  *RIGHTE     39
C*    SOFTWARE OR ITS ASSOCIATED DOCUMENTATION OR ANY PORTION THEREOF  *RIGHTE     40
C*    OR WITH RESPECT TO ANY DAMAGES WHICH MAY RESULT FROM SUCH USE.   *RIGHTE     41
C*                                                                     *RIGHTE     42
C* THIS NOTICE MAY NOT BE REMOVED FROM THE SOFTWARE BY ANY USER        *RIGHTE     43
C* THEREOF.                                                            *RIGHTE     44
C*                                                                     *RIGHTE     45
C***********************************************************************RIGHTE     46
      SUBROUTINE  GTYR (JPOSN)                                          GTYR        3
CD -------------------------------------------------------------------  GTYR        4
CD                                                                      GTYR        5
CD              *****     GTYR    ROUTINE   *****                       GTYR        6
CD                                                                      GTYR        7
CD -------------------------------------------------------------------  GTYR        8
CD                                                                      GTYR        9
CD       PURPOSE:  Add resistor to G matrix.                            GTYR       10
CD                                                                      GTYR       11
CD                                                                      GTYR       12
CD       DEFINITION OF LOCAL VARIABLES:                                 GTYR       13
CD                 I      -  first bus in line.                         GTYR       14
CD                 J      -  second bus in line.                        GTYR       15
CD          (P)    POSN   -  storage position for dc information.       GTYR       16
CD                 SUBNAM -  subroutine name.                           GTYR       17
CD                 VALUE  -  admittance to be added to G matrix.        GTYR       18
CD                                                                      GTYR       19
CD -------------------------------------------------------------------  GTYR       20
C                                                                       GTYR       21
      INCLUDE 'PARX.INS'                                                GTYR       22
      INCLUDE 'CNPARX.INS'                                              GTYR       23
      INCLUDE 'CNUNIT.INS'                                              GTYR       24
      INCLUDE 'CNMSG.INS'                                               GTYR       25
      INCLUDE 'GRDC01.INS'                                              GTYR       26
      INCLUDE 'GRDC03.INS'                                              GTYR       27
      INCLUDE 'UDCA.INS'                                                GTYR       28
      INCLUDE 'UDCF.INS'                                                GTYR       29
      INCLUDE 'UDCG.INS'                                                GTYR       30
      INCLUDE 'UDCJ.INS'                                                GTYR       31
C                                                                       GTYR       32
      CHARACTER*20  SUBNAM                                              GTYR       33
      CHARACTER*8   TYPE                                                GTYR       34
C                                                                       GTYR       35
      DOUBLE PRECISION  VALUE, VALUE1, VALUE2, VALUE3                   GTYR       36
C                                                                       GTYR       37
      IF(SDBG)THEN                                                      GTYR       38
         SUBNAM = 'GTYR ROUTINE.'                                       GTYR       39
      ELSE                                                              GTYR       40
         SUBNAM = ' '                                                   GTYR       41
      END IF                                                            GTYR       42
C                                                                       GTYR       43
      I = LINREF(JPOSN,1)                                               GTYR       44
      J = LINREF(JPOSN,2)                                               GTYR       45
C                                                                       GTYR       46
      IF(I.EQ.0.AND.J.EQ.0) GOTO 500                                    GTYR       47
C                                                                       GTYR       48
      VALUE = 1.0 / RDCOHM(JPOSN)                                       GTYR       49
      VALUE2 = 0.                                                       GTYR       50
      VALUE3 = 0.                                                       GTYR       51
C                                                                       GTYR       52
      GOTO 200                                                          GTYR       53
C                                                                       GTYR       54
      ENTRY GTYRL (JPOSN)                                               GTYR       55
CD -------------------------------------------------------------------  GTYR       56
CD                                                                      GTYR       57
CD              *****     GTYRL   ROUTINE   *****                       GTYR       58
CD                                                                      GTYR       59
CD -------------------------------------------------------------------  GTYR       60
CD                                                                      GTYR       61
CD       PURPOSE:  Add equivalent circuit of RL line to G matrix.       GTYR       62
CD                                                                      GTYR       63
CD -------------------------------------------------------------------  GTYR       64
C                                                                       GTYR       65
      IF(SDBG)THEN                                                      GTYR       66
         SUBNAM = 'GTYRL ROUTINE.'                                      GTYR       67
      ELSE                                                              GTYR       68
         SUBNAM = ' '                                                   GTYR       69
      END IF                                                            GTYR       70
C                                                                       GTYR       71
      XK1(JPOSN) = STIME * (1.0 + ALPHAL) / (2.0 * XLDC(JPOSN))         GTYR       72
      XK2(JPOSN) = STIME * (1.0 - ALPHAL) / (2.0 * XLDC(JPOSN))         GTYR       73
C                                                                       GTYR       74
      I = LINREF(JPOSN,1)                                               GTYR       75
      J = LINREF(JPOSN,2)                                               GTYR       76
C                                                                       GTYR       77
      IF(I.EQ.0.AND.J.EQ.0) GOTO 500                                    GTYR       78
C                                                                       GTYR       79
      VALUE3=0.                                                         GTYR       80
      VALUE2=0.                                                         GTYR       81
      GOTO 100                                                          GTYR       82
C                                                                       GTYR       83
      ENTRY GCNOTV (JPOSN, TYPE)                                        GTYR       84
CD -------------------------------------------------------------------  GTYR       85
CD                                                                      GTYR       86
CD              *****     GCNOTV  ROUTINE   *****                       GTYR       87
CD                                                                      GTYR       88
CD -------------------------------------------------------------------  GTYR       89
CD                                                                      GTYR       90
CD       PURPOSE:  Adds all but voltage controlled converters, by       GTYR       91
CD                 adding Norton impedance of converter equivalent      GTYR       92
CD                 to network.                                          GTYR       93
CD                                                                      GTYR       94
CD -------------------------------------------------------------------  GTYR       95
C                                                                       GTYR       96
      IF(SDBG)THEN                                                      GTYR       97
         SUBNAM = 'GCNOTV ROUTINE.'                                     GTYR       98
      ELSE                                                              GTYR       99
         SUBNAM = ' '                                                   GTYR      100
      END IF                                                            GTYR      101
C                                                                       GTYR      102
      CONTYP(JPOSN) = TYPE                                              GTYR      103
C                                                                       GTYR      104
      IF(TYPE.NE.'ALPHA' .AND. TYPE.NE.'GAMMA' .AND.                    GTYR      105
     1    TYPE.NE.'CURRENT' .AND. TYPE.NE.'BLOCK') RETURN               GTYR      106
      I = ICONRE(JPOSN,1)                                               GTYR      107
      J = ICONRE(JPOSN,2)                                               GTYR      108
C                                                                       GTYR      109
      IF(I.EQ.0.AND.J.EQ.0) GOTO 550                                    GTYR      110
C                                                                       GTYR      111
      IF(TYPE.EQ.'ALPHA' .OR. TYPE.EQ.'GAMMA')THEN                      GTYR      112
         VALUE = PII / (3.0 * XCCONV(JPOSN))                            GTYR      113
      ELSE                                                              GTYR      114
         VALUE = 1.0E-12                                                GTYR      115
      END IF                                                            GTYR      116
C                                                                       GTYR      117
      IF(TYPE.EQ.'GAMMA') VALUE = -VALUE                                GTYR      118
      VALUE2=0.                                                         GTYR      119
      VALUE3=0.                                                         GTYR      120
C                                                                       GTYR      121
      GOTO 200                                                          GTYR      122
C                                                                       GTYR      123
      ENTRY GTYRLC (JPOSN)                                              GTYR      124
CD -------------------------------------------------------------------  GTYR      125
CD                                                                      GTYR      126
CD              *****     GTYRLCD ROUTINE   *****                       GTYR      127
CD                                                                      GTYR      128
CD -------------------------------------------------------------------  GTYR      129
CD                                                                      GTYR      130
CD       PURPOSE:  Add equivalent circuit of RLC line to G matrix.      GTYR      131
CD                                                                      GTYR      132
CD -------------------------------------------------------------------  GTYR      133
C                                                                       GTYR      134
      IF(SDBG)THEN                                                      GTYR      135
         SUBNAM = 'GTYRLC ROUTINE.'                                     GTYR      136
      ELSE                                                              GTYR      137
         SUBNAM = ' '                                                   GTYR      138
      END IF                                                            GTYR      139
C                                                                       GTYR      140
      XK1(JPOSN) = STIME * (1.0 + ALPHAL) / (2.0 * XLDC(JPOSN))         GTYR      141
      XK2(JPOSN) = 1.0 / (1.0 + ALPHAC)                                 GTYR      142
      XK3(JPOSN) = STIME * (1.0 - ALPHAL) / (2.0 * XLDC(JPOSN))         GTYR      143
      XK4(JPOSN) = (1.0 - ALPHAC)                                       GTYR      144
      XK5(JPOSN) = (2.0*CDCA(JPOSN)) / STIME                            GTYR      145
      XK6(JPOSN) = (2.0*CDCB(JPOSN)) / STIME                            GTYR      146
C                                                                       GTYR      147
      I = LINREF(JPOSN,1)                                               GTYR      148
      J = LINREF(JPOSN,2)                                               GTYR      149
C                                                                       GTYR      150
      IF(I.EQ.0.AND.J.EQ.0) GOTO 500                                    GTYR      151
C                                                                       GTYR      152
      REQ3(JPOSN) =(2.0*CDCB(JPOSN))/(STIME * (1.0 + ALPHAC))           GTYR      153
      VALUE3 = DBLE(REQ3(JPOSN))                                        GTYR      154
      REQ2(JPOSN) =(2.0*CDCA(JPOSN))/(STIME * (1.0 + ALPHAC))           GTYR      155
      VALUE2 = DBLE(REQ2(JPOSN))                                        GTYR      156
 100  REQ(JPOSN) = RDCOHM(JPOSN) + (1.0 / XK1(JPOSN))                   GTYR      157
      VALUE = 1.0 / REQ(JPOSN)                                          GTYR      158
C                                                                       GTYR      159
 200  IF(J .NE. 0)THEN                                                  GTYR      160
C                                                                       GTYR      161
C          First end of the dc line is not ground.                      GTYR      162
C                                                                       GTYR      163
        GMATRX(J,J)=GMATRX(J,J)+VALUE                                   GTYR      164
        GMATRX(J,J)=GMATRX(J,J)+VALUE3                                  GTYR      165
C                                                                       GTYR      166
      END IF                                                            GTYR      167
C                                                                       GTYR      168
C                                                                       GTYR      169
      IF(I .NE. 0)THEN                                                  GTYR      170
C                                                                       GTYR      171
C           Second end of the dc line is not ground.                    GTYR      172
C                                                                       GTYR      173
         GMATRX(I,I)=GMATRX(I,I)+VALUE                                  GTYR      174
         GMATRX(I,I)=GMATRX(I,I)+VALUE2                                 GTYR      175
C                                                                       GTYR      176
      END IF                                                            GTYR      177
C                                                                       GTYR      178
C                                                                       GTYR      179
      IF(I .NE. 0.AND.J .NE. 0)THEN                                     GTYR      180
C                                                                       GTYR      181
C           Neither end of the dc line is ground.                       GTYR      182
C                                                                       GTYR      183
         VALUE = -VALUE                                                 GTYR      184
         GMATRX(I,J)=GMATRX(I,J)+VALUE                                  GTYR      185
         GMATRX(J,I)=GMATRX(J,I)+VALUE                                  GTYR      186
C                                                                       GTYR      187
      END IF                                                            GTYR      188
C                                                                       GTYR      189
      RETURN                                                            GTYR      190
C                                                                       GTYR      191
      ENTRY VTYRL (JPOSN)                                               GTYR      192
CD -------------------------------------------------------------------  GTYR      193
CD                                                                      GTYR      194
CD              *****     VTYRL   ROUTINE   *****                       GTYR      195
CD                                                                      GTYR      196
CD -------------------------------------------------------------------  GTYR      197
CD                                                                      GTYR      198
CD       PURPOSE:  Calculates current injection for RL line.            GTYR      199
CD                 Injection is into node j, out of node i for line     GTYR      200
CD                 from i to j.                                         GTYR      201
CD                                                                      GTYR      202
CD -------------------------------------------------------------------  GTYR      203
C                                                                       GTYR      204
      VALUE1 = (1.0 - XK2(JPOSN) * RDCOHM(JPOSN)) * XHIST1(JPOSN)       GTYR      205
      VALUE1 = VALUE1 + XK2(JPOSN) * VHIST1(JPOSN)                      GTYR      206
      VALUE2 = 0                                                        GTYR      207
      VALUE3 = 0                                                        GTYR      208
C                                                                       GTYR      209
      GOTO 300                                                          GTYR      210
C                                                                       GTYR      211
      ENTRY VTYRLC (JPOSN)                                              GTYR      212
CD -------------------------------------------------------------------  GTYR      213
CD                                                                      GTYR      214
CD              *****     VTYRLCD ROUTINE   *****                       GTYR      215
CD                                                                      GTYR      216
CD -------------------------------------------------------------------  GTYR      217
CD                                                                      GTYR      218
CD       PURPOSE:  Calculates current injection for RLC line.           GTYR      219
CD                 Injection is into node j and node i, for a line      GTYR      220
CD                 from i to j.                                         GTYR      221
CD                                                                      GTYR      222
CD -------------------------------------------------------------------  GTYR      223
C                                                                       GTYR      224
      VALUE2 = (XK4(JPOSN) * XHIST2(JPOSN) + XK5(JPOSN) * VHIST2(JPOSN))GTYR      225
      XJ2(JPOSN) = XK2(JPOSN) * VALUE2                                  GTYR      226
      VALUE2=XJ2(JPOSN)                                                 GTYR      227
C                                                                       GTYR      228
      VALUE3 = (XK4(JPOSN) * XHIST3(JPOSN) + XK6(JPOSN) * VHIST3(JPOSN))GTYR      229
      XJ3(JPOSN) = XK2(JPOSN) * VALUE3                                  GTYR      230
      VALUE3=XJ3(JPOSN)                                                 GTYR      231
C                                                                       GTYR      232
      VALUE1 = (1.0 - XK3(JPOSN) * RDCOHM(JPOSN)) * XHIST1(JPOSN)       GTYR      233
      VALUE1 = VALUE1 + XK3(JPOSN) * VHIST1(JPOSN)                      GTYR      234
 300  XJ1(JPOSN) = (1.0 / (1.0 + XK1(JPOSN) * RDCOHM(JPOSN))) * VALUE1  GTYR      235
C                                                                       GTYR      236
      I = LINREF(JPOSN,1)                                               GTYR      237
      J = LINREF(JPOSN,2)                                               GTYR      238
      IF(I .NE. 0)THEN                                                  GTYR      239
         VALUE1 = -XJ1(JPOSN) + VALUE2                                  GTYR      240
         XINJVE(I)=XINJVE(I)+VALUE1                                     GTYR      241
      END IF                                                            GTYR      242
C                                                                       GTYR      243
      IF(J .NE. 0)THEN                                                  GTYR      244
         VALUE1 = XJ1(JPOSN) + VALUE3                                   GTYR      245
         XINJVE(J)=XINJVE(J)+VALUE1                                     GTYR      246
      END IF                                                            GTYR      247
C                                                                       GTYR      248
      RETURN                                                            GTYR      249
C                                                                       GTYR      250
C        Both ends of the dc line are ground, or undefined.             GTYR      251
C                                                                       GTYR      252
 500  WRITE(MSG(2),9003) DCLNAM(JPOSN)                                  GTYR      253
      GOTO 560                                                          GTYR      254
 550  WRITE(MSG(2),9004) DCCNAM(JPOSN)(1:29)                            GTYR      255
 560  WRITE(MSG(1),9002) SUBNAM                                         GTYR      256
      CALL PRTMSG(2)                                                    GTYR      257
C                                                                       GTYR      258
      RETURN                                                            GTYR      259
C                                                                       GTYR      260
 9002 FORMAT(' *** ERROR ',A)                                           GTYR      261
 9003 FORMAT(11X,'DC LINE: ',A,' HAS UNDEFINED NODE NAMES.')            GTYR      262
 9004 FORMAT(11X,'DC CONVERTER: ',A,' HAS UNDEFINED NODE NAMES.')       GTYR      263
C                                                                       GTYR      264
      ENTRY HTYRL (JPOSN)                                               GTYR      265
CD -------------------------------------------------------------------  GTYR      266
CD                                                                      GTYR      267
CD              *****     HTYRL   ROUTINE   *****                       GTYR      268
CD                                                                      GTYR      269
CD -------------------------------------------------------------------  GTYR      270
CD                                                                      GTYR      271
CD       PURPOSE:  Calculate and store required history terms for       GTYR      272
CD                 RL line.                                             GTYR      273
CD                                                                      GTYR      274
CD -------------------------------------------------------------------  GTYR      275
C                                                                       GTYR      276
      I = LINREF(JPOSN,1)                                               GTYR      277
      J = LINREF(JPOSN,2)                                               GTYR      278
C                                                                       GTYR      279
      GOTO 600                                                          GTYR      280
C                                                                       GTYR      281
      ENTRY HTYRLC (JPOSN)                                              GTYR      282
CD -------------------------------------------------------------------  GTYR      283
CD                                                                      GTYR      284
CD              *****     HTYRLCD ROUTINE   *****                       GTYR      285
CD                                                                      GTYR      286
CD -------------------------------------------------------------------  GTYR      287
CD                                                                      GTYR      288
CD       PURPOSE:  Calculates and store required history terms for      GTYR      289
CD                 RLC line.                                            GTYR      290
CD                                                                      GTYR      291
CD -------------------------------------------------------------------  GTYR      292
C                                                                       GTYR      293
      I = LINREF(JPOSN,1)                                               GTYR      294
      J = LINREF(JPOSN,2)                                               GTYR      295
C                                                                       GTYR      296
      IF(J.NE.0) THEN                                                   GTYR      297
         VHIST3(JPOSN) = VDCNOD(J)                                      GTYR      298
      ELSE                                                              GTYR      299
         VHIST3(JPOSN) = 0.0                                            GTYR      300
      END IF                                                            GTYR      301
      XHIST3(JPOSN) = VHIST3(JPOSN) * REQ3(JPOSN) - XJ3(JPOSN)          GTYR      302
C                                                                       GTYR      303
      IF(I.NE.0) THEN                                                   GTYR      304
         VHIST2(JPOSN) = VDCNOD(I)                                      GTYR      305
      ELSE                                                              GTYR      306
         VHIST2(JPOSN) = 0.0                                            GTYR      307
      END IF                                                            GTYR      308
      XHIST2(JPOSN) = VHIST2(JPOSN) * REQ2(JPOSN) - XJ2(JPOSN)          GTYR      309
C                                                                       GTYR      310
 600  IF(I.EQ.0)THEN                                                    GTYR      311
         VALUE = 0.0                                                    GTYR      312
      ELSE                                                              GTYR      313
         VALUE = VDCNOD(I)                                              GTYR      314
      END IF                                                            GTYR      315
C                                                                       GTYR      316
      IF(J .NE. 0)THEN                                                  GTYR      317
         VALUE = VALUE - VDCNOD(J)                                      GTYR      318
      END IF                                                            GTYR      319
C                                                                       GTYR      320
      VHIST1(JPOSN) = VALUE                                             GTYR      321
      XHIST1(JPOSN) = VHIST1(JPOSN) / REQ(JPOSN) + XJ1(JPOSN)           GTYR      322
C                                                                       GTYR      323
      RETURN                                                            GTYR      324
C                                                                       GTYR      325
      END                                                               GTYR      326
