CFPRIME AEXC1                                                           AEXC1       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 AEXC1(ISTATE)                                          AEXC1       3
CD                                                                      AEXC1       4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 1 AND TYPE 2 EXCITERS  AEXC1       5
CD    (IEEE TYPES DC1 AND DC2).                                         AEXC1       6
CD                                                                      AEXC1       7
      INCLUDE 'PARX.INS'                                                AEXC1       8
      INCLUDE 'CNB8.INS'                                                AEXC1       9
      INCLUDE 'CNEXC.INS'                                               AEXC1      10
      INCLUDE 'CNPARX.INS'                                              AEXC1      11
      INCLUDE 'CNMDAT.INS'                                              AEXC1      12
      INCLUDE 'CNXSTA.INS'                                              AEXC1      13
      INCLUDE 'CNMSTA.INS'                                              AEXC1      14
      INCLUDE 'CNABAK.INS'                                              AEXC1      15
C                                                                       AEXC1      16
C     TF BLOCK                                                          AEXC1      17
C                                                                       AEXC1      18
      IF (IDDAT(JE+11).EQ.0) THEN                                       AEXC1      19
         CFTF=0.0                                                       AEXC1      20
      ELSE                                                              AEXC1      21
         TFI=1.0/DDAT(JE+11)                                            AEXC1      22
         CFTF=DDAT(JE+10)*TFI                                           AEXC1      23
         A(ISTATE+2,ISTATE+2)=-TFI                                      AEXC1      24
         A(ISTATE+2,ISTATE+5)=TFI                                       AEXC1      25
      END IF                                                            AEXC1      26
C                                                                       AEXC1      27
C     TC, TB BLOCK                                                      AEXC1      28
C                                                                       AEXC1      29
      IF (IDDAT(JE+13).EQ.0) THEN                                       AEXC1      30
         TCTB=1.0                                                       AEXC1      31
      ELSE                                                              AEXC1      32
         TBI=1.0/DDAT(JE+13)                                            AEXC1      33
         TCTB=DDAT(JE+12)*TBI                                           AEXC1      34
         WS1=CFTF*TBI                                                   AEXC1      35
         A(ISTATE+3,ISTATE+2)=WS1                                       AEXC1      36
         A(ISTATE+3,ISTATE+3)=-TBI                                      AEXC1      37
         A(ISTATE+3,ISTATE+5)=-WS1                                      AEXC1      38
C                                                                       AEXC1      39
         IF (INPUTR.EQ.0) THEN                                          AEXC1      40
            CALL BCBTEM(ISTATE+3,TBI)                                   AEXC1      41
         ELSE                                                           AEXC1      42
            A(ISTATE+3,ISTATE+1)=-TBI                                   AEXC1      43
         END IF                                                         AEXC1      44
C                                                                       AEXC1      45
         IUST(1)=ISTATE+3                                               AEXC1      46
         GUST(1)=TBI                                                    AEXC1      47
C                                                                       AEXC1      48
      END IF                                                            AEXC1      49
C                                                                       AEXC1      50
C     TA AND TE BLOCKS                                                  AEXC1      51
C                                                                       AEXC1      52
      VE=XSTATE(JSTATE+5)                                               AEXC1      53
      BETA=DDAT(JE+4)+DDAT(JE+6)*DDAT(JE+7)                             AEXC1      54
     *     *EXP(DDAT(JE+7)*VE)                                          AEXC1      55
      TEI=1.0/DDAT(JE+5)                                                AEXC1      56
C                                                                       AEXC1      57
      IF (IDDAT(JE+3).EQ.0) THEN                                        AEXC1      58
C                                                                       AEXC1      59
C     TA EQUAL TO ZERO                                                  AEXC1      60
C                                                                       AEXC1      61
         CATE=DDAT(JE+2)*TEI                                            AEXC1      62
         WS1=TCTB*CATE                                                  AEXC1      63
         WS2=WS1*CFTF                                                   AEXC1      64
         A(ISTATE+5,ISTATE+2)=WS2                                       AEXC1      65
         A(ISTATE+5,ISTATE+3)=CATE-WS1                                  AEXC1      66
         A(ISTATE+5,ISTATE+5)=-BETA*TEI-WS2                             AEXC1      67
C                                                                       AEXC1      68
         IF (INPUTR.EQ.0) THEN                                          AEXC1      69
            CALL BCBTEM(ISTATE+5,WS1)                                   AEXC1      70
         ELSE                                                           AEXC1      71
            A(ISTATE+5,ISTATE+1)=-WS1                                   AEXC1      72
         END IF                                                         AEXC1      73
C                                                                       AEXC1      74
         IF (IUST(1).EQ.0) THEN                                         AEXC1      75
            IUST(1)=ISTATE+5                                            AEXC1      76
            GUST(1)=WS1                                                 AEXC1      77
         ELSE                                                           AEXC1      78
            IUST(2)=ISTATE+5                                            AEXC1      79
            GUST(2)=WS1                                                 AEXC1      80
         END IF                                                         AEXC1      81
C                                                                       AEXC1      82
      ELSE                                                              AEXC1      83
C                                                                       AEXC1      84
C     NON-ZERO TA                                                       AEXC1      85
C                                                                       AEXC1      86
         TAI=1.0/DDAT(JE+3)                                             AEXC1      87
         CATA=DDAT(JE+2)*TAI                                            AEXC1      88
         WS1=TCTB*CATA                                                  AEXC1      89
         WS2=WS1*CFTF                                                   AEXC1      90
         A(ISTATE+4,ISTATE+2)=WS2                                       AEXC1      91
         A(ISTATE+4,ISTATE+3)=CATA-WS1                                  AEXC1      92
         A(ISTATE+4,ISTATE+4)=-TAI                                      AEXC1      93
         A(ISTATE+4,ISTATE+5)=-WS2                                      AEXC1      94
C                                                                       AEXC1      95
         IF (INPUTR.EQ.0) THEN                                          AEXC1      96
            CALL BCBTEM(ISTATE+4,WS1)                                   AEXC1      97
         ELSE                                                           AEXC1      98
            A(ISTATE+4,ISTATE+1)=-WS1                                   AEXC1      99
         END IF                                                         AEXC1     100
C                                                                       AEXC1     101
         IF (IUST(1).EQ.0) THEN                                         AEXC1     102
            IUST(1)=ISTATE+4                                            AEXC1     103
            GUST(1)=WS1                                                 AEXC1     104
         ELSE                                                           AEXC1     105
            IUST(2)=ISTATE+4                                            AEXC1     106
            GUST(2)=WS1                                                 AEXC1     107
         END IF                                                         AEXC1     108
C                                                                       AEXC1     109
C     TE BLOCK                                                          AEXC1     110
C                                                                       AEXC1     111
         A(ISTATE+5,ISTATE+4)=TEI                                       AEXC1     112
         A(ISTATE+5,ISTATE+5)=-BETA*TEI                                 AEXC1     113
C                                                                       AEXC1     114
      END IF                                                            AEXC1     115
C                                                                       AEXC1     116
C     INTERCONNECTION WITH GENERATOR (OUTPUT EQUATION)                  AEXC1     117
C                                                                       AEXC1     118
      A(3,ISTATE+5)=CFEXC                                               AEXC1     119
C                                                                       AEXC1     120
      ISTATE=ISTATE+5                                                   AEXC1     121
C                                                                       AEXC1     122
      RETURN                                                            AEXC1     123
      END                                                               AEXC1     124
