CFPRIME AGOV21                                                          AGOV21      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 AGOV21(ISTATE,HM)                                      AGOV21      3
CD                                                                      AGOV21      4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 21 GOVERNOR.           AGOV21      5
CD                                                                      AGOV21      6
      INCLUDE 'PARX.INS'                                                AGOV21      7
      INCLUDE 'CNB8.INS'                                                AGOV21      8
      INCLUDE 'CNB19.INS'                                               AGOV21      9
      INCLUDE 'CNEXC.INS'                                               AGOV21     10
      INCLUDE 'CNPARX.INS'                                              AGOV21     11
      INCLUDE 'CNMDAT.INS'                                              AGOV21     12
      INCLUDE 'CNMSTA.INS'                                              AGOV21     13
      INCLUDE 'CNXSTA.INS'                                              AGOV21     14
      INCLUDE 'CNSTAB.INS'                                              AGOV21     15
C                                                                       AGOV21     16
      INCLUDE 'CNABAK.INS'                                              AGOV21     17
C                                                                       AGOV21     18
C     SUBSCRIPTS                                                        AGOV21     19
C                                                                       AGOV21     20
      ISUB1=ISTATE+1                                                    AGOV21     21
      ISUB2=ISTATE+2                                                    AGOV21     22
      ISUB3=ISTATE+3                                                    AGOV21     23
      ISUB4=ISTATE+4                                                    AGOV21     24
C                                                                       AGOV21     25
      ITP=IDDAT(JGG+4)                                                  AGOV21     26
C                                                                       AGOV21     27
      IF (ITP.NE.0) THEN                                                AGOV21     28
C                                                                       AGOV21     29
C     NORMAL CASE WITH TP NON-ZERO                                      AGOV21     30
C                                                                       AGOV21     31
C---------------------------------                                      AGOV21     32
C                                                                       AGOV21     33
C     TP BLOCK                                                          AGOV21     34
C                                                                       AGOV21     35
         TPI=1.0/DDAT(JGG+4)                                            AGOV21     36
         TGTP=TPI/DDAT(JGG+3)                                           AGOV21     37
         A(ISUB1,ISUB1)=-TPI                                            AGOV21     38
         A(ISUB1,ISUB2)=-(DDAT(JGG+2)+DDAT(JGG+6))*TGTP                 AGOV21     39
         A(ISUB1,1)=-TGTP/WXBASE                                        AGOV21     40
C                                                                       AGOV21     41
C     INTEGRATION BLOCK                                                 AGOV21     42
C                                                                       AGOV21     43
         A(ISUB2,ISUB1)=1.0                                             AGOV21     44
C                                                                       AGOV21     45
C     TD BLOCK                                                          AGOV21     46
C                                                                       AGOV21     47
         IF (IDDAT(JGG+5).NE.0) THEN                                    AGOV21     48
            TDP=1.0/DDAT(JGG+5)                                         AGOV21     49
            A(ISUB3,ISUB3)=-TDP                                         AGOV21     50
            A(ISUB3,ISUB2)=TDP                                          AGOV21     51
            A(ISUB1,ISUB3)=DDAT(JGG+6)*TGTP                             AGOV21     52
         END IF                                                         AGOV21     53
C                                                                       AGOV21     54
C     TW BLOCK                                                          AGOV21     55
C                                                                       AGOV21     56
         TWI=2.0/DDAT(JGG+9)                                            AGOV21     57
         A(ISUB4,ISUB4)=-TWI                                            AGOV21     58
         A(ISUB4,ISUB2)=TWI                                             AGOV21     59
         A(ISUB4,ISUB1)=-2.0                                            AGOV21     60
C                                                                       AGOV21     61
      ELSE                                                              AGOV21     62
C                                                                       AGOV21     63
C     CASE WITH ZERO TP                                                 AGOV21     64
C                                                                       AGOV21     65
C----------------------                                                 AGOV21     66
C                                                                       AGOV21     67
C     INTEGRATION BLOCK                                                 AGOV21     68
C                                                                       AGOV21     69
         TGI=1.0/DDAT(JGG+3)                                            AGOV21     70
         A(ISUB2,ISUB2)=-(DDAT(JGG+2)+DDAT(JGG+6))*TGI                  AGOV21     71
         A(ISUB2,1)=-TGI/WXBASE                                         AGOV21     72
C                                                                       AGOV21     73
C     TD BLOCK                                                          AGOV21     74
C                                                                       AGOV21     75
         IF (IDDAT(JGG+5).NE.0) THEN                                    AGOV21     76
            TDP=1.0/DDAT(JGG+5)                                         AGOV21     77
            A(ISUB3,ISUB3)=-TDP                                         AGOV21     78
            A(ISUB3,ISUB2)=TDP                                          AGOV21     79
            A(ISUB2,ISUB3)=DDAT(JGG+6)*TGI                              AGOV21     80
         END IF                                                         AGOV21     81
C                                                                       AGOV21     82
C     TW BLOCK                                                          AGOV21     83
C                                                                       AGOV21     84
         TWI=2.0/DDAT(JGG+9)                                            AGOV21     85
         A(ISUB4,ISUB4)=-TWI                                            AGOV21     86
         A(ISUB4,ISUB2)=TWI+2.0*(DDAT(JGG+2)+DDAT(JGG+6))*TGI           AGOV21     87
         IF (IDDAT(JGG+5).NE.0) A(ISUB4,ISUB3)=-2.0*DDAT(JGG+6)*TGI     AGOV21     88
         A(ISUB4,1)=2.0*TGI/WXBASE                                      AGOV21     89
C                                                                       AGOV21     90
      END IF                                                            AGOV21     91
C                                                                       AGOV21     92
C     INTEGRATION WITH MACHINE (OUTPUT EQUATION)                        AGOV21     93
C                                                                       AGOV21     94
      A(1,ISUB4)=HM*DDAT(JGG+1)                                         AGOV21     95
C                                                                       AGOV21     96
      DWTERM=0.0                                                        AGOV21     97
C                                                                       AGOV21     98
      ISTATE=ISTATE+4                                                   AGOV21     99
C                                                                       AGOV21    100
      RETURN                                                            AGOV21    101
      END                                                               AGOV21    102
