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