CFPRIME AEXC15                                                          AEXC15      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 AEXC15(ISTATE,VCOMP,XAD)                               AEXC15      3
CD                                                                      AEXC15      4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 15 EXCITER.            AEXC15      5
CD                                                                      AEXC15      6
      INCLUDE 'PARX.INS'                                                AEXC15      7
      INCLUDE 'CNB8.INS'                                                AEXC15      8
      INCLUDE 'CNEXC.INS'                                               AEXC15      9
      INCLUDE 'CNYVAR.INS'                                              AEXC15     10
      INCLUDE 'CNPARX.INS'                                              AEXC15     11
      INCLUDE 'CNMDAT.INS'                                              AEXC15     12
      INCLUDE 'CNXSTA.INS'                                              AEXC15     13
      INCLUDE 'CNMSTA.INS'                                              AEXC15     14
C                                                                       AEXC15     15
      INCLUDE 'CNABAK.INS'                                              AEXC15     16
C                                                                       AEXC15     17
      CF=0.0                                                            AEXC15     18
      TF2I=0.0                                                          AEXC15     19
C                                                                       AEXC15     20
C     SUBSCRIPTS                                                        AEXC15     21
C                                                                       AEXC15     22
      ISUB1=ISTATE+1                                                    AEXC15     23
      ISUB2=ISTATE+2                                                    AEXC15     24
      ISUB3=ISTATE+3                                                    AEXC15     25
      ISUB4=ISTATE+4                                                    AEXC15     26
      ISUB5=ISTATE+5                                                    AEXC15     27
C                                                                       AEXC15     28
      ICASE=IDDAT(JE+21)                                                AEXC15     29
C                                                                       AEXC15     30
      GOTO (100,200,300,400), ICASE                                     AEXC15     31
C                                                                       AEXC15     32
C     NORMAL CASE -- TA AND TB ARE NON-ZERO                             AEXC15     33
C                                                                       AEXC15     34
C     KF, TF BLOCK                                                      AEXC15     35
C                                                                       AEXC15     36
 100  IF (IDDAT(JE+5).EQ.0) THEN                                        AEXC15     37
         CFTF=0.0                                                       AEXC15     38
         TF1TF2=0.0                                                     AEXC15     39
      ELSE                                                              AEXC15     40
         TFI=1.0/DDAT(JE+5)                                             AEXC15     41
         CFTF=DDAT(JE+4)*TFI                                            AEXC15     42
         A(ISUB2,ISUB2)=-TFI                                            AEXC15     43
         A(ISUB2,ISUB4)=TFI                                             AEXC15     44
C                                                                       AEXC15     45
C     TF1, TF2 BLOCK                                                    AEXC15     46
C                                                                       AEXC15     47
         IF (IDDAT(JE+9).EQ.0) THEN                                     AEXC15     48
            TF1TF2=1.0                                                  AEXC15     49
         ELSE                                                           AEXC15     50
            TF2I=1.0/DDAT(JE+9)                                         AEXC15     51
            TF1TF2=DDAT(JE+8)*TF2I                                      AEXC15     52
            A(ISUB5,ISUB2)=-CFTF*TF2I                                   AEXC15     53
            A(ISUB5,ISUB4)=-A(ISUB5,ISUB2)                              AEXC15     54
            A(ISUB5,ISUB5)=-TF2I                                        AEXC15     55
         END IF                                                         AEXC15     56
C                                                                       AEXC15     57
      END IF                                                            AEXC15     58
C                                                                       AEXC15     59
C     TB BLOCK                                                          AEXC15     60
C                                                                       AEXC15     61
      TBI=1.0/DDAT(JE+10)                                               AEXC15     62
      GAIN1=CFTF*TF1TF2*TBI                                             AEXC15     63
      A(ISUB3,ISUB2)=GAIN1                                              AEXC15     64
      A(ISUB3,ISUB3)=-TBI                                               AEXC15     65
      A(ISUB3,ISUB4)=-GAIN1                                             AEXC15     66
      A(ISUB3,ISUB5)=-TBI*(1.0-TF1TF2)                                  AEXC15     67
C                                                                       AEXC15     68
      IF (INPUTR.EQ.0) THEN                                             AEXC15     69
         CALL BCBTEM(ISUB3,TBI)                                         AEXC15     70
      ELSE                                                              AEXC15     71
         A(ISUB3,ISUB1)=-TBI                                            AEXC15     72
      END IF                                                            AEXC15     73
C                                                                       AEXC15     74
      IUST(1)=ISUB3                                                     AEXC15     75
      GUST(1)=TBI                                                       AEXC15     76
C                                                                       AEXC15     77
C     TA BLOCK                                                          AEXC15     78
C                                                                       AEXC15     79
      TAI=1.0/DDAT(JE+3)                                                AEXC15     80
      A(ISUB4,ISUB3)=DDAT(JE+2)*TAI                                     AEXC15     81
      A(ISUB4,ISUB4)=-TAI                                               AEXC15     82
C                                                                       AEXC15     83
C     INTERCONNECTION WITH GENERATOR (OUTPUT EQUATION)                  AEXC15     84
C                                                                       AEXC15     85
      A(3,ISUB4)=CFEXC*VCOMP                                            AEXC15     86
      CF=CFEXC*XAD*XSTATE(JSTATE+4)                                     AEXC15     87
      BC(3,1)=BC(3,1)+CF*ALP1                                           AEXC15     88
      BC(3,2)=BC(3,2)+CF*ALP2                                           AEXC15     89
      B(3,KN-1)=B(3,KN-1)+CF*ALP3                                       AEXC15     90
      B(3,KN)=B(3,KN)+CF*ALP4                                           AEXC15     91
C                                                                       AEXC15     92
      GOTO 500                                                          AEXC15     93
C                                                                       AEXC15     94
C     CASE 2 -- TA EQUAL TO ZERO, TB NON-ZERO                           AEXC15     95
C                                                                       AEXC15     96
 200  CA=DDAT(JE+2)                                                     AEXC15     97
C                                                                       AEXC15     98
C     KF, TF BLOCK                                                      AEXC15     99
C                                                                       AEXC15    100
      IF (IDDAT(JE+5).EQ.0) THEN                                        AEXC15    101
         CFTF=0.0                                                       AEXC15    102
         TF1TF2=0.0                                                     AEXC15    103
      ELSE                                                              AEXC15    104
         TFI=1.0/DDAT(JE+5)                                             AEXC15    105
         CFTF=DDAT(JE+4)*TFI                                            AEXC15    106
         A(ISUB2,ISUB2)=-TFI                                            AEXC15    107
         A(ISUB2,ISUB3)=CA*TFI                                          AEXC15    108
C                                                                       AEXC15    109
C     TF1, TF2 BLOCK                                                    AEXC15    110
C                                                                       AEXC15    111
         IF (IDDAT(JE+9).EQ.0) THEN                                     AEXC15    112
            TF1TF2=1.0                                                  AEXC15    113
         ELSE                                                           AEXC15    114
            TF2I=1.0/DDAT(JE+9)                                         AEXC15    115
            TF1TF2=DDAT(JE+8)*TF2I                                      AEXC15    116
            A(ISUB5,ISUB2)=-CFTF*TF2I                                   AEXC15    117
            A(ISUB5,ISUB3)=-CA*A(ISUB5,ISUB2)                           AEXC15    118
            A(ISUB5,ISUB5)=-TF2I                                        AEXC15    119
         END IF                                                         AEXC15    120
C                                                                       AEXC15    121
      END IF                                                            AEXC15    122
C                                                                       AEXC15    123
C     TB BLOCK                                                          AEXC15    124
C                                                                       AEXC15    125
      TBI=1.0/DDAT(JE+10)                                               AEXC15    126
      GAIN1=CFTF*TF1TF2*TBI                                             AEXC15    127
      A(ISUB3,ISUB2)=GAIN1                                              AEXC15    128
      A(ISUB3,ISUB3)=-(TBI+CA*GAIN1)                                    AEXC15    129
      A(ISUB3,ISUB5)=-TBI*(1.0-TF1TF2)                                  AEXC15    130
C                                                                       AEXC15    131
      IF (INPUTR.EQ.0) THEN                                             AEXC15    132
         CALL BCBTEM(ISUB3,TBI)                                         AEXC15    133
      ELSE                                                              AEXC15    134
         A(ISUB3,ISUB1)=-TBI                                            AEXC15    135
      END IF                                                            AEXC15    136
C                                                                       AEXC15    137
      IUST(1)=ISUB3                                                     AEXC15    138
      GUST(1)=TBI                                                       AEXC15    139
C                                                                       AEXC15    140
C     INTERCONNECTION WITH GENERATOR (OUTPUT EQUATION)                  AEXC15    141
C                                                                       AEXC15    142
      A(3,ISUB3)=CFEXC*CA*VCOMP                                         AEXC15    143
      CF=CFEXC*XAD*CA*XSTATE(JSTATE+3)                                  AEXC15    144
      BC(3,1)=BC(3,1)+CF*ALP1                                           AEXC15    145
      BC(3,2)=BC(3,2)+CF*ALP2                                           AEXC15    146
      B(3,KN-1)=B(3,KN-1)+CF*ALP3                                       AEXC15    147
      B(3,KN)=B(3,KN)+CF*ALP4                                           AEXC15    148
C                                                                       AEXC15    149
      GOTO 500                                                          AEXC15    150
C                                                                       AEXC15    151
C     CASE 3 -- TA NON-ZERO AND TB EQUAL TO ZERO                        AEXC15    152
C                                                                       AEXC15    153
C     KF, TF BLOCK                                                      AEXC15    154
C                                                                       AEXC15    155
 300  IF (IDDAT(JE+5).EQ.0) THEN                                        AEXC15    156
         CFTF=0.0                                                       AEXC15    157
         TF1TF2=0.0                                                     AEXC15    158
      ELSE                                                              AEXC15    159
         TFI=1.0/DDAT(JE+5)                                             AEXC15    160
         CFTF=DDAT(JE+4)*TFI                                            AEXC15    161
         A(ISUB2,ISUB2)=-TFI                                            AEXC15    162
         A(ISUB2,ISUB4)=TFI                                             AEXC15    163
C                                                                       AEXC15    164
C     TF1, TF2 BLOCK                                                    AEXC15    165
C                                                                       AEXC15    166
         IF (IDDAT(JE+9).EQ.0) THEN                                     AEXC15    167
            TF1TF2=1.0                                                  AEXC15    168
         ELSE                                                           AEXC15    169
            TF2I=1.0/DDAT(JE+9)                                         AEXC15    170
            TF1TF2=DDAT(JE+8)*TF2I                                      AEXC15    171
            A(ISUB5,ISUB2)=-CFTF*TF2I                                   AEXC15    172
            A(ISUB5,ISUB4)=-A(ISUB5,ISUB2)                              AEXC15    173
            A(ISUB5,ISUB5)=-TF2I                                        AEXC15    174
         END IF                                                         AEXC15    175
C                                                                       AEXC15    176
      END IF                                                            AEXC15    177
C                                                                       AEXC15    178
C     TA BLOCK                                                          AEXC15    179
C                                                                       AEXC15    180
      TAI=1.0/DDAT(JE+3)                                                AEXC15    181
      CATA=DDAT(JE+2)*TAI                                               AEXC15    182
      GAIN1=CFTF*TF1TF2*CATA                                            AEXC15    183
      A(ISUB4,ISUB2)=GAIN1                                              AEXC15    184
      A(ISUB4,ISUB4)=-(TAI+GAIN1)                                       AEXC15    185
      A(ISUB4,ISUB5)=-CATA*(1.0-TF1TF2)                                 AEXC15    186
C                                                                       AEXC15    187
      IF (INPUTR.EQ.0) THEN                                             AEXC15    188
         CALL BCBTEM(ISUB4,CATA)                                        AEXC15    189
      ELSE                                                              AEXC15    190
         A(ISUB4,ISUB1)=-CATA                                           AEXC15    191
      END IF                                                            AEXC15    192
C                                                                       AEXC15    193
      IUST(1)=ISUB4                                                     AEXC15    194
      GUST(1)=CATA                                                      AEXC15    195
C                                                                       AEXC15    196
C     INTERCONNECTION WITH GENERATOR (OUTPUT EQUATION)                  AEXC15    197
C                                                                       AEXC15    198
      A(3,ISUB4)=CFEXC*VCOMP                                            AEXC15    199
      CF=CFEXC*XAD*XSTATE(JSTATE+4)                                     AEXC15    200
      BC(3,1)=BC(3,1)+CF*ALP1                                           AEXC15    201
      BC(3,2)=BC(3,2)+CF*ALP2                                           AEXC15    202
      B(3,KN-1)=B(3,KN-1)+CF*ALP3                                       AEXC15    203
      B(3,KN)=B(3,KN)+CF*ALP4                                           AEXC15    204
C                                                                       AEXC15    205
      GOTO 500                                                          AEXC15    206
C                                                                       AEXC15    207
C     CASE 4 -- BOTH TA AND TB EQUAL TO ZERO                            AEXC15    208
C                                                                       AEXC15    209
 400  GAIN3=0.0                                                         AEXC15    210
      CA=DDAT(JE+2)                                                     AEXC15    211
C                                                                       AEXC15    212
C     KF, TF BLOCK                                                      AEXC15    213
C                                                                       AEXC15    214
      IF (IDDAT(JE+5).EQ.0) THEN                                        AEXC15    215
         ALP6=1.0                                                       AEXC15    216
      ELSE                                                              AEXC15    217
         TFI=1.0/DDAT(JE+5)                                             AEXC15    218
         CFTF=DDAT(JE+4)*TFI                                            AEXC15    219
C                                                                       AEXC15    220
C     TF1, TF2 BLOCK                                                    AEXC15    221
C                                                                       AEXC15    222
         IF (IDDAT(JE+9).EQ.0) THEN                                     AEXC15    223
            TF1TF2=1.0                                                  AEXC15    224
         ELSE                                                           AEXC15    225
            TF2I=1.0/DDAT(JE+9)                                         AEXC15    226
            TF1TF2=DDAT(JE+8)*TF2I                                      AEXC15    227
         END IF                                                         AEXC15    228
C                                                                       AEXC15    229
         GAIN1=CFTF*TF1TF2*CA                                           AEXC15    230
         ALP6=1.0/(1.0+GAIN1)                                           AEXC15    231
         GAIN2=ALP6*CA*TFI                                              AEXC15    232
C                                                                       AEXC15    233
         A(ISUB2,ISUB2)=-TFI*(1.0-ALP6*GAIN1)                           AEXC15    234
         A(ISUB2,ISUB5)=-GAIN2*(1.0-TF1TF2)                             AEXC15    235
C                                                                       AEXC15    236
         IF (INPUTR.EQ.0) THEN                                          AEXC15    237
            CALL BCBTEM(ISUB2,GAIN2)                                    AEXC15    238
         ELSE                                                           AEXC15    239
            A(ISUB2,ISUB1)=-GAIN2                                       AEXC15    240
         END IF                                                         AEXC15    241
C                                                                       AEXC15    242
         IUST(1)=ISUB2                                                  AEXC15    243
         GUST(1)=GAIN2                                                  AEXC15    244
C                                                                       AEXC15    245
         A(3,ISUB2)=CFEXC*VCOMP*ALP6*GAIN1                              AEXC15    246
         GAIN3=GAIN3+GAIN1*XSTATE(JSTATE+2)/CA                          AEXC15    247
C                                                                       AEXC15    248
         IF (IDDAT(JE+9).NE.0) THEN                                     AEXC15    249
            GAIN2=ALP6*CA*CFTF*TF2I                                     AEXC15    250
            A(ISUB5,ISUB2)=-CFTF*TF2I*(1.0-ALP6*GAIN1)                  AEXC15    251
            A(ISUB5,ISUB5)=-TF2I*(1.0+ALP6*CA*CFTF*(1.0-TF1TF2))        AEXC15    252
C                                                                       AEXC15    253
            IF (INPUTR.EQ.0) THEN                                       AEXC15    254
               CALL BCBTEM(ISUB5,GAIN2)                                 AEXC15    255
            ELSE                                                        AEXC15    256
               A(ISUB5,ISUB1)=-GAIN2                                    AEXC15    257
            END IF                                                      AEXC15    258
C                                                                       AEXC15    259
            IUST(2)=ISUB5                                               AEXC15    260
            GUST(2)=GAIN2                                               AEXC15    261
C                                                                       AEXC15    262
            A(3,ISUB5)=-CFEXC*ALP6*CA*VCOMP*(1.0-TF1TF2)                AEXC15    263
            GAIN3=GAIN3-(1.0-TF1TF2)*XSTATE(JSTATE+5)                   AEXC15    264
C                                                                       AEXC15    265
         END IF                                                         AEXC15    266
C                                                                       AEXC15    267
      END IF                                                            AEXC15    268
C                                                                       AEXC15    269
      IF (INPUTR.EQ.0) THEN                                             AEXC15    270
         GAIN3=GAIN3-VCOMP                                              AEXC15    271
      ELSE                                                              AEXC15    272
         A(3,ISUB1)=-CFEXC*ALP6*CA*VCOMP                                AEXC15    273
         GAIN3=GAIN3-XSTATE(JSTATE+1)                                   AEXC15    274
      END IF                                                            AEXC15    275
C                                                                       AEXC15    276
      IF (IUST(1).EQ.0) THEN                                            AEXC15    277
         IUST(1)=3                                                      AEXC15    278
         GUST(1)=ALP6*CA*VCOMP                                          AEXC15    279
      ELSE IF (IUST(2).EQ.0) THEN                                       AEXC15    280
         IUST(2)=3                                                      AEXC15    281
         GUST(2)=ALP6*CA*VCOMP                                          AEXC15    282
      ELSE                                                              AEXC15    283
         IUST(3)=3                                                      AEXC15    284
         GUST(3)=ALP6*CA*VCOMP                                          AEXC15    285
      END IF                                                            AEXC15    286
C                                                                       AEXC15    287
      IF (ISTABN.GT.0) GAIN3=GAIN3+VSS(JYS+1)                           AEXC15    288
      IF ((IUALN.NE.0.AND.IUALN.LT.10).OR.IUALN.EQ.50)                  AEXC15    289
     & GAIN3=GAIN3+VUAL(JYU+1)                                          AEXC15    290
      IF (ITEBN.NE.0) GAIN3=GAIN3+TEB(JYTB+1)                           AEXC15    291
C                                                                       AEXC15    292
      IF (IMXLN.NE.0.AND.IMXLN.LE.10) GAIN3=GAIN3-VMXL(JYMX+1)          AEXC15    293
C                                                                       AEXC15    294
      GAIN3=CFEXC*XAD*ALP6*CA*GAIN3                                     AEXC15    295
      BC(3,1)=BC(3,1)+CF*ALP1                                           AEXC15    296
      BC(3,2)=BC(3,2)+CF*ALP2                                           AEXC15    297
      B(3,KN-1)=B(3,KN-1)+CF*ALP3                                       AEXC15    298
      B(3,KN)=B(3,KN)+CF*ALP4                                           AEXC15    299
C                                                                       AEXC15    300
 500  CONTINUE                                                          AEXC15    301
      ISTATE=ISUB5                                                      AEXC15    302
C                                                                       AEXC15    303
      RETURN                                                            AEXC15    304
      END                                                               AEXC15    305
