CFPRIME DEGV06                                                          DEGV06      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 DEGV06(JSGV)                                           DEGV06      3
CD                                                                      DEGV06      4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF TYPE 6 GOVERNOR,    DEGV06      5
CD    USED BY BOTH RUNGE-KUTTA AND TRAPEZOIDAL METHOD.                  DEGV06      6
CD                                                                      DEGV06      7
CD    THE DATA STRUCTURE FOR THIS TYPE OF GOVERNOR IS GIVEN BELOW.      DEGV06      8
CD                                                                      DEGV06      9
CD   9.4 Prime-mover governor-turbine model type 6                      DEGV06     10
CD                                                                      DEGV06     11
CD     Governor data                                                    DEGV06     12
CD                                                                      DEGV06     13
CD     DDAT(JGG+ 1)   = R                                               DEGV06     14
CD     DDAT(JGG+ 2)   = T1                                              DEGV06     15
CD     DDAT(JGG+ 3)   = T2                                              DEGV06     16
CD     DDAT(JGG+ 4)   = T3                                              DEGV06     17
CD     DDAT(JGG+ 5)   = PFL                                             DEGV06     18
CD     DDAT(JGG+ 6)   = VMIN                                            DEGV06     19
CD     DDAT(JGG+ 7)   = DT                                              DEGV06     20
CD                                                                      DEGV06     21
CD     Governor states                                                  DEGV06     22
CD                                                                      DEGV06     23
CD     XSTATE(JPS+ 1) = T1 block                    : compulsory        DEGV06     24
CD     XSTATE(JPS+2)  = T3 block                    : compulsory        DEGV06     25
CD                                                                      DEGV06     26
CD     Governor Y-variables                                             DEGV06     27
CD                                                                      DEGV06     28
CD     XLDREF(JYP+ 1) = load reference signal                           DEGV06     29
CD                                                                      DEGV06     30
      INCLUDE 'PARX.INS'                                                DEGV06     31
      INCLUDE 'CNB3.INS'                                                DEGV06     32
      INCLUDE 'CNB8.INS'                                                DEGV06     33
      INCLUDE 'CNB10.INS'                                               DEGV06     34
      INCLUDE 'CNB19.INS'                                               DEGV06     35
      INCLUDE 'CNPARX.INS'                                              DEGV06     36
      INCLUDE 'CNXSTA.INS'                                              DEGV06     37
      INCLUDE 'CNQSTA.INS'                                              DEGV06     38
      INCLUDE 'CNMDAT.INS'                                              DEGV06     39
      INCLUDE 'CNEXC.INS'                                               DEGV06     40
      INCLUDE 'CNPRGV.INS'                                              DEGV06     41
      INCLUDE 'CNMYVA.INS'                                              DEGV06     42
      INCLUDE 'CNYVAR.INS'                                              DEGV06     43
C                                                                       DEGV06     44
C     TYPE 6                                                            DEGV06     45
C                                                                       DEGV06     46
      JSGV=JSTATE                                                       DEGV06     47
      XSUM=(XLDREF(JYP+1)-XSPU)/DDAT(JGG+1)                             DEGV06     48
      DSTATE(LSTATE+1)=(XSUM-XSTATE(JSTATE+1))/DDAT(JGG+2)              DEGV06     49
      IF (XSTATE(JSTATE+1).GE.1.0) THEN                                 DEGV06     50
         XSTATE(JSTATE+1)=1.0                                           DEGV06     51
         IF (DSTATE(LSTATE+1).GT.0.0) THEN                              DEGV06     52
            DSTATE(LSTATE+1)=0.0                                        DEGV06     53
            QSTATE(JSTATE+1)=0.0                                        DEGV06     54
         END IF                                                         DEGV06     55
      ELSE IF (XSTATE(JSTATE+1).LE.DDAT(JGG+6)) THEN                    DEGV06     56
         XSTATE(JSTATE+1)=DDAT(JGG+6)                                   DEGV06     57
         IF (DSTATE(LSTATE+1).LT.0.0) THEN                              DEGV06     58
            DSTATE(LSTATE+1)=0.0                                        DEGV06     59
            QSTATE(JSTATE+1)=0.0                                        DEGV06     60
         END IF                                                         DEGV06     61
      END IF                                                            DEGV06     62
C                                                                       DEGV06     63
      IF (IDDAT(JGG+4).NE.0) THEN                                       DEGV06     64
         DSTATE(LSTATE+2)=(XSTATE(JSTATE+1)+DSTATE(LSTATE+1)*DDAT(JGG+3)DEGV06     65
     +   -XSTATE(JSTATE+2))/DDAT(JGG+4)                                 DEGV06     66
      ELSE                                                              DEGV06     67
         DSTATE(JSTATE+2)=0.0                                           DEGV06     68
         XSTATE(JSTATE+2)=XSTATE(JSTATE+1)                              DEGV06     69
      ENDIF                                                             DEGV06     70
C                                                                       DEGV06     71
      LSTATE=LSTATE+2                                                   DEGV06     72
C                                                                       DEGV06     73
      RETURN                                                            DEGV06     74
      END                                                               DEGV06     75
