CFPRIME INGV20                                                          INGV20      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 INGV20                                                 INGV20      3
CD                                                                      INGV20      4
CD    TO PERFORM INITIALIZATION AND DATA CHECK FOR GOVERNOR TYPE 20.    INGV20      5
CD                                                                      INGV20      6
CD    THE DATA STRUCTURE AFTER THE INITIALIZATION IS GIVEN BELOW.       INGV20      7
CD                                                                      INGV20      8
CD   9.7 Hydraulic turbine-governor type 20                             INGV20      9
CD                                                                      INGV20     10
CD     Governor data                                                    INGV20     11
CD                                                                      INGV20     12
CD     DDAT(JGG+ 1)   = KS                                              INGV20     13
CD     DDAT(JGG+ 2)   = RP                                              INGV20     14
CD     DDAT(JGG+ 3)   = RT                                              INGV20     15
CD     DDAT(JGG+ 4)   = TW                                              INGV20     16
CD     DDAT(JGG+ 5)   = TR                                              INGV20     17
CD     DDAT(JGG+ 6)   = TG                                              INGV20     18
CD     DDAT(JGG+ 7)   = PFL                                             INGV20     19
CD     DDAT(JGG+ 8)   = HEAD                                            INGV20     20
CD     DDAT(JGG+ 9)   = GFL                                             INGV20     21
CD     DDAT(JGG+10)   = GNL                                             INGV20     22
CD     DDAT(JGG+11)   = RMXO                                            INGV20     23
CD     DDAT(JGG+12)   = RMXC                                            INGV20     24
CD     DDAT(JGG+13)   = GBF                                             INGV20     25
CD     DDAT(JGG+14)   = RBFC                                            INGV20     26
CD     DDAT(JGG+15)   = DB1                                             INGV20     27
CD                                                                      INGV20     28
CD     Governor states                                                  INGV20     29
CD                                                                      INGV20     30
CD     XSTATE(JPS+1)  = first integrator block      : compulsory        INGV20     31
CD     XSTATE(JPS+2)  = second integrator block          : compulsory   INGV20     32
CD     XSTATE(JPS+3)  = TW block                    : compulsory        INGV20     33
CD     XSTATE(JPS+4)  = TG block                    : compulsory        INGV20     34
CD                                                                      INGV20     35
CD     Governor Y-variables                                             INGV20     36
CD                                                                      INGV20     37
CD     XLDREF(JYP+1)  = load reference signal                           INGV20     38
CD                                                                      INGV20     39
      INCLUDE 'PARX.INS'                                                INGV20     40
      INCLUDE 'CNB1.INS'                                                INGV20     41
      INCLUDE 'CNB3.INS'                                                INGV20     42
      INCLUDE 'CNB4.INS'                                                INGV20     43
      INCLUDE 'CNB19.INS'                                               INGV20     44
      INCLUDE 'CNXSTA.INS'                                              INGV20     45
      INCLUDE 'CNMDAT.INS'                                              INGV20     46
      INCLUDE 'CNSTN.INS'                                               INGV20     47
      INCLUDE 'CNMSTA.INS'                                              INGV20     48
      INCLUDE 'CNEXC.INS'                                               INGV20     49
      INCLUDE 'CNMYVA.INS'                                              INGV20     50
      INCLUDE 'CNYVAR.INS'                                              INGV20     51
      INCLUDE 'CNPRGV.INS'                                              INGV20     52
      INCLUDE 'CNUNIT.INS'                                              INGV20     53
      INCLUDE 'CNMSG.INS'                                               INGV20     54
C                                                                       INGV20     55
C                                                                       INGV20     56
C     HYDRO GOVERNOR                                                    INGV20     57
C                                                                       INGV20     58
C  INPUT TIME CONSTANTS CHECK AND RESET                                 INGV20     59
C                                                                       INGV20     60
      IF(DDAT(JGG+4).LT.TMIN)THEN                                       INGV20     61
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),                INGV20     62
     *    INAME(KN),NDGC(N)                                             INGV20     63
         WRITE(MSG(2),9020) 'TW',DDAT(JGG+4),TMIN                       INGV20     64
         IF(MTFLAG.EQ.0) THEN                                           INGV20     65
            CALL PRTMSG(2)                                              INGV20     66
         ELSE                                                           INGV20     67
            WRITE(MSG(3),9030) 'TW',TMIN                                INGV20     68
            CALL PRTMSG(3)                                              INGV20     69
            DDAT(JGG+4)=TMIN                                            INGV20     70
         ENDIF                                                          INGV20     71
      ENDIF                                                             INGV20     72
C                                                                       INGV20     73
      IF(DDAT(JGG+6).LT.TMIN.AND.IDDAT(JGG+6).NE.0)THEN                 INGV20     74
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),                INGV20     75
     *    INAME(KN),NDGC(N)                                             INGV20     76
         WRITE(MSG(2),9020) 'TG',DDAT(JGG+6),TMIN                       INGV20     77
         IF(MTFLAG.EQ.0) THEN                                           INGV20     78
            CALL PRTMSG(2)                                              INGV20     79
         ELSE                                                           INGV20     80
            WRITE(MSG(3),9030) 'TG',0.                                  INGV20     81
            CALL PRTMSG(3)                                              INGV20     82
            DDAT(JGG+6)=0.0                                             INGV20     83
         ENDIF                                                          INGV20     84
      ENDIF                                                             INGV20     85
C                                                                       INGV20     86
C     IF INITIAL HEAD NOT SET, SET IT TO DEFAULT VALUE                  INGV20     87
C                                                                       INGV20     88
      IF (IDDAT(JGG+8).EQ.0) DDAT(JGG+8)=1.0                            INGV20     89
C - TEMP. FOR NEGATIVE INPUT OF CLOSING RATE                            INGV20     90
      DDAT(JGG+12)=ABS(DDAT(JGG+12))                                    INGV20     91
C                                                                       INGV20     92
      BASPRN=DDAT(JG+3)/BASPC                                           INGV20     93
      DDAT(JGG+7)=DDAT(JGG+7)*BASPRN                                    INGV20     94
      KSTATE=4                                                          INGV20     95
C                                                                       INGV20     96
      XLDREF(JYP+1)=0.0                                                 INGV20     97
C                                                                       INGV20     98
C     INITIALIZE IDEAL AND MEASURED GATE RELATIONSHIP "At", NO LOAD WATEINGV20     99
C     VELOCITY "UNL", AND DEADBAND INPUT "DDAT+17"                      INGV20    100
C                                                                       INGV20    101
      DDAT(JGG+17)=0.0                                                  INGV20    102
      DDAT(JGG+18)=1.0/(DDAT(JGG+9)-DDAT(JGG+10))                       INGV20    103
      DDAT(JGG+19)=DDAT(JGG+18)*DDAT(JGG+10)*SQRT(DDAT(JGG+8))          INGV20    104
      PZERO=TIN(JYG+1)/DDAT(JGG+7)                                      INGV20    105
C                                                                       INGV20    106
C     INITIALIZE THE STATE VARIABLES                                    INGV20    107
C                                                                       INGV20    108
      XSTATE(JSTATE+3)=PZERO/DDAT(JGG+8)+DDAT(JGG+19)                   INGV20    109
      XSTATE(JSTATE+4)=XSTATE(JSTATE+3)/SQRT(DDAT(JGG+8))               INGV20    110
      XSTATE(JSTATE+1)=XSTATE(JSTATE+4)/DDAT(JGG+18)                    INGV20    111
      XSTATE(JSTATE+2)=XSTATE(JSTATE+1)*DDAT(JGG+3)*DDAT(JGG+5)         INGV20    112
C                                                                       INGV20    113
      IF (XSTATE(JSTATE+1).GT.1.0.OR.XSTATE(JSTATE+1).LT.0.0) THEN      INGV20    114
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INGV20    115
     *                     ,NDGC(N)                                     INGV20    116
         WRITE(MSG(2),9040) XSTATE(JSTATE+1)                            INGV20    117
         WRITE(MSG(3),9050)                                             INGV20    118
         CALL PRTMSG(3)                                                 INGV20    119
      END IF                                                            INGV20    120
C                                                                       INGV20    121
C                                                                       INGV20    122
C     INITIALIZE THE EQUIBRIUM GATE POSITION "G0"                       INGV20    123
C                                                                       INGV20    124
C----------------------------------------------------------------       INGV20    125
C      DDAT(JGG+20)=XSTATE(JSTATE+1)+XSTATE(JSTATE+2)/DDAT(JGG+2)       INGV20    126
C----------------------------------------------------------------       INGV20    127
      DDAT(JGG+20)=XSTATE(JSTATE+1)                                     INGV20    128
C                                                                       INGV20    129
C     SET STATE POINTER AND PRINT INITIAL CONDITIONS                    INGV20    130
C                                                                       INGV20    131
      JSTATE=JSTATE+KSTATE                                              INGV20    132
      MSTATE(6,N)=JSTATE                                                INGV20    133
C                                                                       INGV20    134
C                                                                       INGV20    135
C     CHANGE THE SIGNS OF DDAT+12 AND DDAT+14 TO IMPROVE EXECUTION SPEEDINGV20    136
C                                                                       INGV20    137
      DDAT(JGG+12)=-DDAT(JGG+12)                                        INGV20    138
      DDAT(JGG+14)=-DDAT(JGG+14)                                        INGV20    139
C                                                                       INGV20    140
      JY=JY+1                                                           INGV20    141
C==                                                                     INGV20    142
C      WRITE(IU6,74) JGG,(DDAT(JGG+KK),KK=1,20)                         INGV20    143
C      WRITE(IU6,76) JSTATE,(XSTATE(JSTATE+KX),KX=1,4)                  INGV20    144
C  74  FORMAT(1X,'INGV20:JGG,DDAT1-20 ',I5,/,(1X,10G12.5))              INGV20    145
C  76  FORMAT(1X,'INGV20:JSTATE,XSTATE1-4 ',I5,5X,5G12.5)               INGV20    146
C==                                                                     INGV20    147
      RETURN                                                            INGV20    148
C                                                                       INGV20    149
 9000 FORMAT(' *** WARNING GENERATOR AT BUS: ',I5,' STATION: ',3A4      INGV20    150
     *,' GID:',A4)                                                      INGV20    151
 9020 FORMAT(5X,'TYPE 20 GOVERNOR ',A,'=',F8.6                          INGV20    152
     *,' IS BELOW THE LIMIT VALUE OF ',F4.2)                            INGV20    153
 9030 FORMAT(5X,A,' HAS BEEN SET TO ',F4.2)                             INGV20    154
 9040 FORMAT(5X,'TYPE 20 GOVERNOR  STATE 1 = ',G12.5,' EXCEEDS')        INGV20    155
 9050 FORMAT(5X,'ITS LIMITS OF 0.0 AND 1.0')                            INGV20    156
C                                                                       INGV20    157
      END                                                               INGV20    158
