CFPRIME AGOV20                                                          AGOV20      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 AGOV20(ISTATE,HM)                                      AGOV20      3
CD                                                                      AGOV20      4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 20 GOVERNOR.           AGOV20      5
CD                                                                      AGOV20      6
      INCLUDE 'PARX.INS'                                                AGOV20      7
      INCLUDE 'CNB8.INS'                                                AGOV20      8
      INCLUDE 'CNB19.INS'                                               AGOV20      9
      INCLUDE 'CNEXC.INS'                                               AGOV20     10
      INCLUDE 'CNPARX.INS'                                              AGOV20     11
      INCLUDE 'CNMDAT.INS'                                              AGOV20     12
      INCLUDE 'CNMSTA.INS'                                              AGOV20     13
      INCLUDE 'CNXSTA.INS'                                              AGOV20     14
      INCLUDE 'CNSTAB.INS'                                              AGOV20     15
C                                                                       AGOV20     16
      INCLUDE 'CNABAK.INS'                                              AGOV20     17
C                                                                       AGOV20     18
C     SUBSCRIPTS                                                        AGOV20     19
C                                                                       AGOV20     20
      ISUB1=ISTATE+1                                                    AGOV20     21
      ISUB2=ISTATE+2                                                    AGOV20     22
      ISUB3=ISTATE+3                                                    AGOV20     23
      ISUB4=ISTATE+4                                                    AGOV20     24
C                                                                       AGOV20     25
      X3=XSTATE(JSTATE+3)                                               AGOV20     26
      X4=XSTATE(JSTATE+4)                                               AGOV20     27
      X3X4=X3/X4                                                        AGOV20     28
      X3X4S=X3X4*X3X4                                                   AGOV20     29
C                                                                       AGOV20     30
C     FIRST INTEGRATION BLOCK                                           AGOV20     31
C                                                                       AGOV20     32
      Q=DDAT(JGG+1)                                                     AGOV20     33
      RT=DDAT(JGG+3)                                                    AGOV20     34
      TRI=1.0/DDAT(JGG+5)                                               AGOV20     35
      A(ISUB1,ISUB1)=-Q*(DDAT(JGG+2)+RT)                                AGOV20     36
      A(ISUB1,ISUB2)=Q*TRI                                              AGOV20     37
      A(ISUB1,1)=-Q/WXBASE                                              AGOV20     38
C                                                                       AGOV20     39
C     SECOND INTEGRATION BLOCK                                          AGOV20     40
C                                                                       AGOV20     41
      A(ISUB2,ISUB2)=-TRI                                               AGOV20     42
      A(ISUB2,ISUB1)=RT                                                 AGOV20     43
C                                                                       AGOV20     44
C     TW BLOCK                                                          AGOV20     45
C                                                                       AGOV20     46
      WS1=2.0*X3X4/(X4*DDAT(JGG+4))                                     AGOV20     47
      A(ISUB3,ISUB3)=-WS1                                               AGOV20     48
C                                                                       AGOV20     49
C     TG BLOCK                                                          AGOV20     50
C                                                                       AGOV20     51
      IF (IDDAT(JGG+6).NE.0) THEN                                       AGOV20     52
         TGI=1.0/DDAT(JGG+6)                                            AGOV20     53
         A(ISUB4,ISUB4)=-TGI                                            AGOV20     54
         A(ISUB4,ISUB1)=DDAT(JGG+18)*TGI                                AGOV20     55
         A(ISUB3,ISUB4)=WS1*X3X4                                        AGOV20     56
      END IF                                                            AGOV20     57
C                                                                       AGOV20     58
C     INTEGRATION WITH MACHINE (OUTPUT EQUATION)                        AGOV20     59
C                                                                       AGOV20     60
      PFL=HM*DDAT(JGG+7)                                                AGOV20     61
      UNL=DDAT(JGG+19)                                                  AGOV20     62
      A(1,ISUB3)=PFL*X3X4*(3.0*X3-2.0*UNL)/X4                           AGOV20     63
      A(1,ISUB4)=-2.0*PFL*X3X4S*(X3-UNL)/X4                             AGOV20     64
C                                                                       AGOV20     65
      DWTERM=-PFL*X3X4S*(X3-UNL)/WXBASE                                 AGOV20     66
      A(1,1)=A(1,1)+DWTERM                                              AGOV20     67
C                                                                       AGOV20     68
      ISTATE=ISTATE+4                                                   AGOV20     69
C                                                                       AGOV20     70
      RETURN                                                            AGOV20     71
      END                                                               AGOV20     72
