CFPRIME DEGV22                                                          DEGV22      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 DEGV22(JSGV)                                           DEGV22      3
CD                                                                      DEGV22      4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF TYPE 22 GOVERNOR,   DEGV22      5
CD    USED BY BOTH RUNGE-KUTTA AND TRAPEZOIDAL METHOD.                  DEGV22      6
CD                                                                      DEGV22      7
CD    THE DATA STRUCTURE FOR THIS TYPE OF GOVERNOR IS GIVEN BELOW.      DEGV22      8
CD                                                                      DEGV22      9
CD   9.9 Hydraulic turbine-governor type 22                             DEGV22     10
CD                                                                      DEGV22     11
CD     Governor data                                                    DEGV22     12
CD                                                                      DEGV22     13
CD     DDAT(JGG+ 1)   = PMAX                                            DEGV22     14
CD     DDAT(JGG+ 2)   = R                                               DEGV22     15
CD     DDAT(JGG+ 3)   = T1                                              DEGV22     16
CD     DDAT(JGG+ 4)   = T2                                              DEGV22     17
CD     DDAT(JGG+ 5)   = T3                                              DEGV22     18
CD     DDAT(JGG+ 6)   = T4                                              DEGV22     19
CD     DDAT(JGG+ 7)   = GMAX                                            DEGV22     20
CD     DDAT(JGG+ 8)   = GMIN                                            DEGV22     21
CD     DDAT(JGG+ 9)   = TW                                              DEGV22     22
CD     DDAT(JGG+10)   = K1                                              DEGV22     23
CD     DDAT(JGG+11)   = K3                                              DEGV22     24
CD                                                                      DEGV22     25
CD     Governor states                                                  DEGV22     26
CD                                                                      DEGV22     27
CD     XSTATE(JPS+1)  = T1 block                    : optional          DEGV22     28
CD     XSTATE(JPS+2)  = T3 block                    : optional          DEGV22     29
CD     XSTATE(JPS+3)  = TW block                    : compulsory        DEGV22     30
CD                                                                      DEGV22     31
CD     Governor Y-variables                                             DEGV22     32
CD                                                                      DEGV22     33
CD     XLDREF(JYP+1)  = load reference signal                           DEGV22     34
CD                                                                      DEGV22     35
      INCLUDE 'PARX.INS'                                                DEGV22     36
      INCLUDE 'CNB3.INS'                                                DEGV22     37
      INCLUDE 'CNB19.INS'                                               DEGV22     38
      INCLUDE 'CNPARX.INS'                                              DEGV22     39
      INCLUDE 'CNXSTA.INS'                                              DEGV22     40
      INCLUDE 'CNMDAT.INS'                                              DEGV22     41
      INCLUDE 'CNEXC.INS'                                               DEGV22     42
C                                                                       DEGV22     43
      INCLUDE 'CNPRGV.INS'                                              DEGV22     44
      INCLUDE 'CNMYVA.INS'                                              DEGV22     45
      INCLUDE 'CNYVAR.INS'                                              DEGV22     46
C                                                                       DEGV22     47
C  HYDRO GOVERNOR                                                       DEGV22     48
C                                                                       DEGV22     49
      JSGV=JSTATE                                                       DEGV22     50
      NXS=0                                                             DEGV22     51
C                                                                       DEGV22     52
      XIN=XSPU/DDAT(JGG+2)                                              DEGV22     53
      IF (IDDAT(JGG+3).NE.0) THEN                                       DEGV22     54
         NXS=NXS+1                                                      DEGV22     55
         DSTATE(LSTATE+NXS)=(XIN-XSTATE(JSTATE+NXS))/DDAT(JGG+3)        DEGV22     56
         XIN=XSTATE(JSTATE+NXS)+DDAT(JGG+4)*DSTATE(LSTATE+NXS)          DEGV22     57
      ENDIF                                                             DEGV22     58
      IF (IDDAT(JGG+5).NE.0) THEN                                       DEGV22     59
         NXS=NXS+1                                                      DEGV22     60
         DSTATE(LSTATE+NXS)=(XIN-XSTATE(JSTATE+NXS))/DDAT(JGG+5)        DEGV22     61
         XIN=XSTATE(JSTATE+NXS)+DDAT(JGG+6)*DSTATE(LSTATE+NXS)          DEGV22     62
      ENDIF                                                             DEGV22     63
C                                                                       DEGV22     64
      XSUM=XLDREF(JYP+1)-XIN                                            DEGV22     65
C                                                                       DEGV22     66
C  LIMITS ON GOVERNOR OUTPUT                                            DEGV22     67
C                                                                       DEGV22     68
      IF (XSUM.GT.DDAT(JGG+7)) XSUM=DDAT(JGG+7)                         DEGV22     69
      IF (XSUM.LT.DDAT(JGG+8)) XSUM=DDAT(JGG+8)                         DEGV22     70
C                                                                       DEGV22     71
C  TURBINE                                                              DEGV22     72
C                                                                       DEGV22     73
      NXS=NXS+1                                                         DEGV22     74
      DSTATE(LSTATE+NXS)=(XSUM-XSTATE(JSTATE+NXS))*2.0/DDAT(JGG+9)      DEGV22     75
C                                                                       DEGV22     76
C      TIN(JYG+1)=DDAT(JGG+1)*(XSUM*DDAT(JGG+10)+XSTATE(JSTATE+NXS)*    DEGV22     77
C     +DDAT(JGG+11))                                                    DEGV22     78
C                                                                       DEGV22     79
      LSTATE=LSTATE+NXS                                                 DEGV22     80
C                                                                       DEGV22     81
      RETURN                                                            DEGV22     82
C                                                                       DEGV22     83
      END                                                               DEGV22     84
