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