CFPRIME AGOV4                                                           AGOV4       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 AGOV4(ISTATE,HM)                                       AGOV4       3
CD                                                                      AGOV4       4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 4 GOVERNOR.            AGOV4       5
CD                                                                      AGOV4       6
      INCLUDE 'PARX.INS'                                                AGOV4       7
      INCLUDE 'CNB8.INS'                                                AGOV4       8
      INCLUDE 'CNB19.INS'                                               AGOV4       9
      INCLUDE 'CNEXC.INS'                                               AGOV4      10
      INCLUDE 'CNPARX.INS'                                              AGOV4      11
      INCLUDE 'CNMDAT.INS'                                              AGOV4      12
      INCLUDE 'CNMSTA.INS'                                              AGOV4      13
      INCLUDE 'CNXSTA.INS'                                              AGOV4      14
      INCLUDE 'CNSTAB.INS'                                              AGOV4      15
C                                                                       AGOV4      16
      INCLUDE 'CNABAK.INS'                                              AGOV4      17
C                                                                       AGOV4      18
C     T1, T2 BLOCK                                                      AGOV4      19
C                                                                       AGOV4      20
      CC1=DDAT(JGG+1)/WXBASE                                            AGOV4      21
      IF (IDDAT(JGG+2).EQ.0) THEN                                       AGOV4      22
         T2T1=1.0                                                       AGOV4      23
      ELSE                                                              AGOV4      24
         T1I=1.0/DDAT(JGG+2)                                            AGOV4      25
         T2T1=DDAT(JGG+3)*T1I                                           AGOV4      26
         A(ISTATE+1,ISTATE+1)=-T1I                                      AGOV4      27
         A(ISTATE+1,1)=CC1*T1I                                          AGOV4      28
      END IF                                                            AGOV4      29
C                                                                       AGOV4      30
C     INTEGRATION BLOCK                                                 AGOV4      31
C                                                                       AGOV4      32
      T3I=1.0/DDAT(JGG+4)                                               AGOV4      33
      A(ISTATE+2,ISTATE+2)=-T3I                                         AGOV4      34
      A(ISTATE+2,ISTATE+1)=-T3I*(1.0-T2T1)                              AGOV4      35
      A(ISTATE+2,1)=-CC1*T2T1*T3I                                       AGOV4      36
C                                                                       AGOV4      37
C     T4 BLOCK                                                          AGOV4      38
C                                                                       AGOV4      39
      IF (IDDAT(JGG+9).NE.0) THEN                                       AGOV4      40
         T4I=1.0/DDAT(JGG+9)                                            AGOV4      41
         A(ISTATE+3,ISTATE+3)=-T4I                                      AGOV4      42
         A(ISTATE+3,ISTATE+2)=T4I                                       AGOV4      43
      END IF                                                            AGOV4      44
C                                                                       AGOV4      45
C     T5 BLOCK                                                          AGOV4      46
C                                                                       AGOV4      47
      IF (IDDAT(JGG+10).NE.0) THEN                                      AGOV4      48
         T5I=1.0/DDAT(JGG+10)                                           AGOV4      49
         A(ISTATE+4,ISTATE+4)=-T5I                                      AGOV4      50
         A(ISTATE+4,ISTATE+3)=T5I                                       AGOV4      51
      END IF                                                            AGOV4      52
C                                                                       AGOV4      53
C     T6 BLOCK                                                          AGOV4      54
      IF (IDDAT(JGG+11).NE.0) THEN                                      AGOV4      55
         T6I=1.0/DDAT(JGG+11)                                           AGOV4      56
         A(ISTATE+5,ISTATE+5)=-T6I                                      AGOV4      57
         A(ISTATE+5,ISTATE+4)=T6I                                       AGOV4      58
      END IF                                                            AGOV4      59
C                                                                       AGOV4      60
C     T7 BLOCK                                                          AGOV4      61
C                                                                       AGOV4      62
      IF (IDDAT(JGG+12).NE.0) THEN                                      AGOV4      63
         T7I=1.0/DDAT(JGG+12)                                           AGOV4      64
         A(ISTATE+6,ISTATE+6)=-T7I                                      AGOV4      65
         A(ISTATE+6,ISTATE+5)=T7I                                       AGOV4      66
      END IF                                                            AGOV4      67
C                                                                       AGOV4      68
C     CONNECTION WITH MACHINE (OUTPUT EQUATION)                         AGOV4      69
C                                                                       AGOV4      70
      PMAX=HM*DDAT(JGG+7)                                               AGOV4      71
      A(1,ISTATE+3)=PMAX*DDAT(JGG+13)                                   AGOV4      72
      A(1,ISTATE+4)=PMAX*DDAT(JGG+14)                                   AGOV4      73
      A(1,ISTATE+5)=PMAX*DDAT(JGG+15)                                   AGOV4      74
      A(1,ISTATE+6)=PMAX*DDAT(JGG+16)                                   AGOV4      75
C                                                                       AGOV4      76
      DWTERM=0.0                                                        AGOV4      77
C                                                                       AGOV4      78
C     NOTE THAT THE 7TH STATE IS RESERVED FOR FUTURE USE                AGOV4      79
C                                                                       AGOV4      80
      ISTATE=ISTATE+7                                                   AGOV4      81
C                                                                       AGOV4      82
      RETURN                                                            AGOV4      83
      END                                                               AGOV4      84
