CFPRIME AGOV22                                                          AGOV22      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 AGOV22(ISTATE,HM)                                      AGOV22      3
CD                                                                      AGOV22      4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 22 GOVERNOR.           AGOV22      5
CD                                                                      AGOV22      6
      INCLUDE 'PARX.INS'                                                AGOV22      7
      INCLUDE 'CNB8.INS'                                                AGOV22      8
      INCLUDE 'CNB19.INS'                                               AGOV22      9
      INCLUDE 'CNEXC.INS'                                               AGOV22     10
      INCLUDE 'CNPARX.INS'                                              AGOV22     11
      INCLUDE 'CNMDAT.INS'                                              AGOV22     12
      INCLUDE 'CNMSTA.INS'                                              AGOV22     13
      INCLUDE 'CNXSTA.INS'                                              AGOV22     14
      INCLUDE 'CNSTAB.INS'                                              AGOV22     15
C                                                                       AGOV22     16
      INCLUDE 'CNABAK.INS'                                              AGOV22     17
C                                                                       AGOV22     18
      IE=ISTATE                                                         AGOV22     19
      CCT=1.0/(WXBASE*DDAT(JGG+2))                                      AGOV22     20
C                                                                       AGOV22     21
C     T1, T2 BLOCK (OPTIONAL)                                           AGOV22     22
C                                                                       AGOV22     23
      IF (IDDAT(JGG+3).EQ.0) THEN                                       AGOV22     24
         ISUB1=0                                                        AGOV22     25
         T2T1=1.0                                                       AGOV22     26
      ELSE                                                              AGOV22     27
         IE=IE+1                                                        AGOV22     28
         ISUB1=IE                                                       AGOV22     29
         T1I=1.0/DDAT(JGG+3)                                            AGOV22     30
         T2T1=DDAT(JGG+4)*T1I                                           AGOV22     31
         A(ISUB1,ISUB1)=-T1I                                            AGOV22     32
         A(ISUB1,1)=T1I*CCT                                             AGOV22     33
         CCT=CCT*T2T1                                                   AGOV22     34
      END IF                                                            AGOV22     35
C                                                                       AGOV22     36
C     T3, T4 BLOCK (OPTIONAL)                                           AGOV22     37
C                                                                       AGOV22     38
      IF (IDDAT(JGG+5).EQ.0) THEN                                       AGOV22     39
         ISUB2=0                                                        AGOV22     40
         T4T3=1.0                                                       AGOV22     41
      ELSE                                                              AGOV22     42
         IE=IE+1                                                        AGOV22     43
         ISUB2=IE                                                       AGOV22     44
         T3I=1.0/DDAT(JGG+5)                                            AGOV22     45
         T4T3=DDAT(JGG+6)*T3I                                           AGOV22     46
         A(ISUB2,ISUB2)=-T3I                                            AGOV22     47
         IF (ISUB1.NE.0) A(ISUB2,ISUB1)=T3I*(1.0-T2T1)                  AGOV22     48
         A(ISUB2,1)=T3I*CCT                                             AGOV22     49
         CCT=CCT*T4T3                                                   AGOV22     50
      END IF                                                            AGOV22     51
C                                                                       AGOV22     52
C     TW BLOCK                                                          AGOV22     53
C                                                                       AGOV22     54
      IE=IE+1                                                           AGOV22     55
      ISUB3=IE                                                          AGOV22     56
      TWI=2.0/DDAT(JGG+9)                                               AGOV22     57
      A(ISUB3,ISUB3)=-TWI                                               AGOV22     58
      IF (ISUB2.NE.0) A(ISUB3,ISUB2)=-TWI*(1.0-T4T3)                    AGOV22     59
      IF (ISUB1.NE.0) A(ISUB3,ISUB1)=-TWI*T4T3*(1.0-T2T1)               AGOV22     60
      A(ISUB3,1)=-TWI*CCT                                               AGOV22     61
C                                                                       AGOV22     62
C     INTEGRATION WITH MACHINE (OUTPUT EQUATION)                        AGOV22     63
C                                                                       AGOV22     64
      PMAX=HM*DDAT(JGG+1)                                               AGOV22     65
      WS1=PMAX*DDAT(JGG+10)                                             AGOV22     66
      A(1,ISUB3)=PMAX*DDAT(JGG+11)                                      AGOV22     67
      IF (ISUB2.NE.0) A(1,ISUB2)=-WS1*(1.0-T4T3)                        AGOV22     68
      IF (ISUB1.NE.0) A(1,ISUB1)=-WS1*T4T3*(1.0-T2T1)                   AGOV22     69
C                                                                       AGOV22     70
      DWTERM=-WS1*CCT                                                   AGOV22     71
      A(1,1)=A(1,1)+DWTERM                                              AGOV22     72
C                                                                       AGOV22     73
      ISTATE=IE                                                         AGOV22     74
C                                                                       AGOV22     75
      RETURN                                                            AGOV22     76
      END                                                               AGOV22     77
