CFPRIME AEXC14                                                          AEXC14      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 AEXC14(ISTATE,MD,XAD)                                  AEXC14      3
CD                                                                      AEXC14      4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 14 EXCITER.            AEXC14      5
CD                                                                      AEXC14      6
      INCLUDE 'PARX.INS'                                                AEXC14      7
      INCLUDE 'CNB8.INS'                                                AEXC14      8
      INCLUDE 'CNEXC.INS'                                               AEXC14      9
      INCLUDE 'CNPARX.INS'                                              AEXC14     10
      INCLUDE 'CNMDAT.INS'                                              AEXC14     11
      INCLUDE 'CNXSTA.INS'                                              AEXC14     12
      INCLUDE 'CNMSTA.INS'                                              AEXC14     13
C                                                                       AEXC14     14
      INCLUDE 'CNABAK.INS'                                              AEXC14     15
C                                                                       AEXC14     16
      DIMENSION FIELD(10),IFIELD(10)                                    AEXC14     17
      EQUIVALENCE (FIELD(1),IFIELD(1))                                  AEXC14     18
C                                                                       AEXC14     19
      DO 10 I=2,6                                                       AEXC14     20
         FIELD(I)=0.0                                                   AEXC14     21
  10  CONTINUE                                                          AEXC14     22
C                                                                       AEXC14     23
C     SUBSCRIPTS                                                        AEXC14     24
C                                                                       AEXC14     25
      ISUB1=ISTATE+1                                                    AEXC14     26
      ISUB2=ISTATE+2                                                    AEXC14     27
      ISUB3=ISTATE+3                                                    AEXC14     28
      ISUB4=ISTATE+4                                                    AEXC14     29
      ISUB5=ISTATE+5                                                    AEXC14     30
      ISUB6=ISTATE+6                                                    AEXC14     31
C                                                                       AEXC14     32
C     CALCULATE EXCITER CONSTANTS                                       AEXC14     33
C                                                                       AEXC14     34
      VE=XSTATE(JSTATE+5)                                               AEXC14     35
      XDEP=DDAT(JE+22)                                                  AEXC14     36
      VTH=VE-XDEP*CFDN                                                  AEXC14     37
      IF (VTH.EQ.0.0) THEN                                              AEXC14     38
         CIN=0.0                                                        AEXC14     39
      ELSE                                                              AEXC14     40
         CIN=DDAT(JE+9)*CFDN/VTH                                        AEXC14     41
      END IF                                                            AEXC14     42
      IF (CIN.LE.0.433) THEN                                            AEXC14     43
         FEX=1.0-0.58*CIN                                               AEXC14     44
         GAMA=-0.58                                                     AEXC14     45
      ELSE IF (CIN.GE.0.75) THEN                                        AEXC14     46
         FEX=1.732-1.732*CIN                                            AEXC14     47
         GAMA=-1.732                                                    AEXC14     48
      ELSE                                                              AEXC14     49
         FEX=SQRT(0.75-CIN*CIN)                                         AEXC14     50
         GAMA=-CIN/FEX                                                  AEXC14     51
      END IF                                                            AEXC14     52
C                                                                       AEXC14     53
      C15=FEX-GAMA*CIN                                                  AEXC14     54
      CF=GAMA*CIN*VE/CFDN-XDEP*FEX                                      AEXC14     55
C                                                                       AEXC14     56
C     TJ, TH BLOCK                                                      AEXC14     57
C                                                                       AEXC14     58
      BETA=DDAT(JE+4)+DDAT(JE+6)*DDAT(JE+7)                             AEXC14     59
     *     *EXP(DDAT(JE+7)*VE)                                          AEXC14     60
      ALP5=DDAT(JE+21)-XDEP                                             AEXC14     61
C                                                                       AEXC14     62
      IF (IDDAT(JE+11).EQ.0) THEN                                       AEXC14     63
         TJTH=1.0                                                       AEXC14     64
         TJKHTH=DDAT(JE+28)                                             AEXC14     65
      ELSE                                                              AEXC14     66
         THI=1.0/DDAT(JE+11)                                            AEXC14     67
         CHTH=DDAT(JE+28)*THI                                           AEXC14     68
         TJTH=DDAT(JE+10)*THI                                           AEXC14     69
         TJKHTH=DDAT(JE+10)*CHTH                                        AEXC14     70
         A(ISUB2,ISUB2)=-THI                                            AEXC14     71
         A(ISUB2,ISUB5)=BETA*CHTH                                       AEXC14     72
         A(ISUB2,ISUB6)=-CHTH                                           AEXC14     73
C                                                                       AEXC14     74
         FIELD(2)=ALP5*CHTH                                             AEXC14     75
C                                                                       AEXC14     76
      END IF                                                            AEXC14     77
C                                                                       AEXC14     78
C     TC, TB BLOCK                                                      AEXC14     79
C                                                                       AEXC14     80
      IF (IDDAT(JE+13).EQ.0) THEN                                       AEXC14     81
         TCTB=1.0                                                       AEXC14     82
      ELSE                                                              AEXC14     83
         TBI=1.0/DDAT(JE+13)                                            AEXC14     84
         TCTB=DDAT(JE+12)*TBI                                           AEXC14     85
         A(ISUB3,ISUB3)=-TBI                                            AEXC14     86
C                                                                       AEXC14     87
         IF (INPUTR.EQ.0) THEN                                          AEXC14     88
            CALL BCBTEM(ISUB3,TBI)                                      AEXC14     89
         ELSE                                                           AEXC14     90
            A(ISUB3,ISUB1)=-TBI                                         AEXC14     91
         END IF                                                         AEXC14     92
C                                                                       AEXC14     93
         IUST(1)=ISUB3                                                  AEXC14     94
         GUST(1)=TBI                                                    AEXC14     95
C                                                                       AEXC14     96
      END IF                                                            AEXC14     97
C                                                                       AEXC14     98
C     TK,TA BLOCK                                                       AEXC14     99
C                                                                       AEXC14    100
      IF (IDDAT(JE+3).EQ.0) THEN                                        AEXC14    101
         TDTA=1.0                                                       AEXC14    102
         GAIN1=DDAT(JE+2)*TCTB                                          AEXC14    103
      ELSE                                                              AEXC14    104
         TAI=1.0/DDAT(JE+3)                                             AEXC14    105
         CATA=DDAT(JE+2)*TAI                                            AEXC14    106
         TDTA=DDAT(JE+17)*TAI                                           AEXC14    107
         GAIN1=TCTB*CATA                                                AEXC14    108
         A(ISUB4,ISUB3)=CATA-GAIN1                                      AEXC14    109
         A(ISUB4,ISUB4)=-TAI                                            AEXC14    110
C                                                                       AEXC14    111
         IF (INPUTR.EQ.0) THEN                                          AEXC14    112
            CALL BCBTEM(ISUB4,GAIN1)                                    AEXC14    113
         ELSE                                                           AEXC14    114
            A(ISUB4,ISUB1)=-GAIN1                                       AEXC14    115
         END IF                                                         AEXC14    116
C                                                                       AEXC14    117
         IF (IUST(1).EQ.0) THEN                                         AEXC14    118
            IUST(1)=ISUB4                                               AEXC14    119
            GUST(1)=GAIN1                                               AEXC14    120
         ELSE                                                           AEXC14    121
            IUST(2)=ISUB4                                               AEXC14    122
            GUST(2)=GAIN1                                               AEXC14    123
         END IF                                                         AEXC14    124
C                                                                       AEXC14    125
         GAIN1=GAIN1*DDAT(JE+17)                                        AEXC14    126
C                                                                       AEXC14    127
      END IF                                                            AEXC14    128
C                                                                       AEXC14    129
C     TE BLOCK                                                          AEXC14    130
C                                                                       AEXC14    131
      TEI=1.0/DDAT(JE+5)                                                AEXC14    132
      GAIN1=GAIN1*TEI                                                   AEXC14    133
      A(ISUB5,ISUB2)=-TEI*(1.0-TJTH)                                    AEXC14    134
      A(ISUB5,ISUB3)=GAIN1/TCTB-GAIN1                                   AEXC14    135
      A(ISUB5,ISUB4)=TEI*(1.0-TDTA)                                     AEXC14    136
      A(ISUB5,ISUB5)=-BETA*TEI*(1.0+TJKHTH)                             AEXC14    137
      A(ISUB5,ISUB6)=TEI*TJKHTH                                         AEXC14    138
C                                                                       AEXC14    139
      IF (INPUTR.EQ.0) THEN                                             AEXC14    140
         CALL BCBTEM(ISUB5,GAIN1)                                       AEXC14    141
      ELSE                                                              AEXC14    142
         A(ISUB5,ISUB1)=-GAIN1                                          AEXC14    143
      END IF                                                            AEXC14    144
C                                                                       AEXC14    145
      FIELD(5)=-ALP5*TEI*(1.0+TJKHTH)                                   AEXC14    146
C                                                                       AEXC14    147
      IF (IUST(1).EQ.0) THEN                                            AEXC14    148
         IUST(1)=ISUB5                                                  AEXC14    149
         GUST(1)=GAIN1                                                  AEXC14    150
      ELSE IF (IUST(2).EQ.0) THEN                                       AEXC14    151
         IUST(2)=ISUB5                                                  AEXC14    152
         GUST(2)=GAIN1                                                  AEXC14    153
      ELSE                                                              AEXC14    154
         IUST(3)=ISUB5                                                  AEXC14    155
         GUST(3)=GAIN1                                                  AEXC14    156
      END IF                                                            AEXC14    157
C                                                                       AEXC14    158
C     TRB BLOCK                                                         AEXC14    159
C                                                                       AEXC14    160
      IF (IDDAT(JE+24).NE.0) THEN                                       AEXC14    161
         CRBTRB=DDAT(JE+23)/DDAT(JE+24)                                 AEXC14    162
         GAIN2=CRBTRB*TJKHTH                                            AEXC14    163
         A(ISUB6,ISUB2)=CRBTRB*(1.0-TJTH)                               AEXC14    164
         A(ISUB6,ISUB5)=BETA*GAIN2                                      AEXC14    165
         A(ISUB6,ISUB6)=-GAIN2                                          AEXC14    166
C                                                                       AEXC14    167
         FIELD(6)=ALP5*GAIN2                                            AEXC14    168
C                                                                       AEXC14    169
      END IF                                                            AEXC14    170
C                                                                       AEXC14    171
C     ELIMINATE THE FIELD CURRENT TERM IN STATE EQUATION                AEXC14    172
C                                                                       AEXC14    173
      DO 20 I=2,6                                                       AEXC14    174
         IF (IFIELD(I).EQ.0) GOTO 20                                    AEXC14    175
         II=ISTATE+I                                                    AEXC14    176
         WS1=XAD*FIELD(I)                                               AEXC14    177
C                                                                       AEXC14    178
         DO 30 J=1,MD+1                                                 AEXC14    179
            A(II,J+1)=WS1*FCTM(J)                                       AEXC14    180
  30     CONTINUE                                                       AEXC14    181
C                                                                       AEXC14    182
         BC(II,1)=BC(II,1)+WS1*FCTM(5)                                  AEXC14    183
         BC(II,2)=BC(II,2)+WS1*FCTM(6)                                  AEXC14    184
C                                                                       AEXC14    185
  20  CONTINUE                                                          AEXC14    186
C                                                                       AEXC14    187
C     INTERCONNECTION WITH GENERATOR (OUTPUT EQUATION)                  AEXC14    188
C                                                                       AEXC14    189
      A(3,ISUB5)=CFEXC*C15                                              AEXC14    190
      CF=CF*CFEXC*XAD                                                   AEXC14    191
      DO 120 I=1,MD+1                                                   AEXC14    192
         A(3,I+1)=A(3,I+1)+CF*FCTM(I)                                   AEXC14    193
 120  CONTINUE                                                          AEXC14    194
      BC(3,1)=BC(3,1)+CF*FCTM(5)                                        AEXC14    195
      BC(3,2)=BC(3,2)+CF*FCTM(6)                                        AEXC14    196
C                                                                       AEXC14    197
      ISTATE=ISUB6                                                      AEXC14    198
C                                                                       AEXC14    199
      RETURN                                                            AEXC14    200
      END                                                               AEXC14    201
