CFPRIME INGV22                                                          INGV22      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 INGV22                                                 INGV22      3
CD                                                                      INGV22      4
CD    TO PERFORM INITIALIZATION AND DATA CHECK FOR GOVERNOR TYPE 22.    INGV22      5
CD                                                                      INGV22      6
CD    THE DATA STRUCTURE AFTER THE INITIALIZATION IS GIVEN BELOW.       INGV22      7
CD                                                                      INGV22      8
CD   9.9 Hydraulic turbine-governor type 22                             INGV22      9
CD                                                                      INGV22     10
CD     Governor data                                                    INGV22     11
CD                                                                      INGV22     12
CD     DDAT(JGG+ 1)   = PMAX                                            INGV22     13
CD     DDAT(JGG+ 2)   = R                                               INGV22     14
CD     DDAT(JGG+ 3)   = T1                                              INGV22     15
CD     DDAT(JGG+ 4)   = T2                                              INGV22     16
CD     DDAT(JGG+ 5)   = T3                                              INGV22     17
CD     DDAT(JGG+ 6)   = T4                                              INGV22     18
CD     DDAT(JGG+ 7)   = GMAX                                            INGV22     19
CD     DDAT(JGG+ 8)   = GMIN                                            INGV22     20
CD     DDAT(JGG+ 9)   = TW                                              INGV22     21
CD     DDAT(JGG+10)   = K1                                              INGV22     22
CD     DDAT(JGG+11)   = K3                                              INGV22     23
CD                                                                      INGV22     24
CD     Governor states                                                  INGV22     25
CD                                                                      INGV22     26
CD     XSTATE(JPS+1)  = T1 block                    : optional          INGV22     27
CD     XSTATE(JPS+2)  = T3 block                    : optional          INGV22     28
CD     XSTATE(JPS+3)  = TW block                    : compulsory        INGV22     29
CD                                                                      INGV22     30
CD     Governor Y-variables                                             INGV22     31
CD                                                                      INGV22     32
CD     XLDREF(JYP+1)  = load reference signal                           INGV22     33
CD                                                                      INGV22     34
      INCLUDE 'PARX.INS'                                                INGV22     35
      INCLUDE 'CNB1.INS'                                                INGV22     36
      INCLUDE 'CNB3.INS'                                                INGV22     37
      INCLUDE 'CNB4.INS'                                                INGV22     38
      INCLUDE 'CNB19.INS'                                               INGV22     39
      INCLUDE 'CNSTN.INS'                                               INGV22     40
      INCLUDE 'CNXSTA.INS'                                              INGV22     41
      INCLUDE 'CNMDAT.INS'                                              INGV22     42
      INCLUDE 'CNMSTA.INS'                                              INGV22     43
      INCLUDE 'CNEXC.INS'                                               INGV22     44
      INCLUDE 'CNMYVA.INS'                                              INGV22     45
      INCLUDE 'CNYVAR.INS'                                              INGV22     46
      INCLUDE 'CNPRGV.INS'                                              INGV22     47
      INCLUDE 'CNUNIT.INS'                                              INGV22     48
      INCLUDE 'CNMSG.INS'                                               INGV22     49
C                                                                       INGV22     50
C  INPUT TIME CONSTANTS CHECK AND RESET                                 INGV22     51
C                                                                       INGV22     52
      IF(DDAT(JGG+3).LT.TMIN.AND.IDDAT(JGG+3).NE.0)THEN                 INGV22     53
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),                INGV22     54
     *    INAME(KN),NDGC(N)                                             INGV22     55
         WRITE(MSG(2),9020) 'T1',DDAT(JGG+3)                            INGV22     56
         IF(MTFLAG.EQ.0) THEN                                           INGV22     57
            WRITE(MSG(3),9030) TMIN                                     INGV22     58
         ELSE                                                           INGV22     59
            WRITE(MSG(3),9030) TMIN,'T1',0.0                            INGV22     60
            DDAT(JGG+3)=0.0                                             INGV22     61
         ENDIF                                                          INGV22     62
         CALL PRTMSG(3)                                                 INGV22     63
      ENDIF                                                             INGV22     64
C                                                                       INGV22     65
      IF(DDAT(JGG+5).LT.TMIN.AND.IDDAT(JGG+5).NE.0)THEN                 INGV22     66
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),                INGV22     67
     *    INAME(KN),NDGC(N)                                             INGV22     68
         WRITE(MSG(2),9020) 'T3',DDAT(JGG+5)                            INGV22     69
         IF(MTFLAG.EQ.0) THEN                                           INGV22     70
            WRITE(MSG(3),9030) TMIN                                     INGV22     71
         ELSE                                                           INGV22     72
            WRITE(MSG(3),9030) TMIN,'T3',0.0                            INGV22     73
            DDAT(JGG+5)=0.0                                             INGV22     74
         ENDIF                                                          INGV22     75
         CALL PRTMSG(3)                                                 INGV22     76
      ENDIF                                                             INGV22     77
C                                                                       INGV22     78
      IF(DDAT(JGG+9).LT.TMIN.AND.IDDAT(JGG+9).NE.0)THEN                 INGV22     79
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),                INGV22     80
     *    INAME(KN),NDGC(N)                                             INGV22     81
         WRITE(MSG(2),9020) 'TW/2',DDAT(JGG+9)                          INGV22     82
         IF(MTFLAG.EQ.0) THEN                                           INGV22     83
            WRITE(MSG(3),9030) TMIN                                     INGV22     84
         ELSE                                                           INGV22     85
            WRITE(MSG(3),9030) TMIN,'TW',0.0                            INGV22     86
            DDAT(JGG+9)=0.0                                             INGV22     87
         ENDIF                                                          INGV22     88
         CALL PRTMSG(3)                                                 INGV22     89
      ENDIF                                                             INGV22     90
C                                                                       INGV22     91
C     WSCC - EPRI TYPE "W" HYDRO GOVERNOR                               INGV22     92
C                                                                       INGV22     93
      IF (IDDAT(JGG+7).EQ.0) DDAT(JGG+7)=1.0                            INGV22     94
      IF (IDDAT(JGG+3).EQ.0) THEN                                       INGV22     95
         DDAT(JGG+3)=DDAT(JGG+5)                                        INGV22     96
         DDAT(JGG+4)=DDAT(JGG+6)                                        INGV22     97
         DDAT(JGG+5)=0.0                                                INGV22     98
      ENDIF                                                             INGV22     99
      BASPRN=DDAT(JG+3)/BASPC                                           INGV22    100
      DDAT(JGG+1)=DDAT(JGG+1)*BASPRN                                    INGV22    101
C                                                                       INGV22    102
C     INITIALIZE THE STATE VARIABLES                                    INGV22    103
C                                                                       INGV22    104
      NXS=0                                                             INGV22    105
      IF (IDDAT(JGG+3).NE.0) THEN                                       INGV22    106
         NXS=NXS+1                                                      INGV22    107
         XSTATE(JSTATE+NXS)=0.0                                         INGV22    108
      ENDIF                                                             INGV22    109
      IF (IDDAT(JGG+5).NE.0) THEN                                       INGV22    110
         NXS=NXS+1                                                      INGV22    111
         XSTATE(JSTATE+NXS)=0.0                                         INGV22    112
      ENDIF                                                             INGV22    113
      NXS=NXS+1                                                         INGV22    114
      XSTATE(JSTATE+NXS)=TIN(JYG+1)/DDAT(JGG+1)/                        INGV22    115
     +(DDAT(JGG+10)+DDAT(JGG+11))                                       INGV22    116
C                                                                       INGV22    117
C     DERIVE THE REFERENCE SIGNAL                                       INGV22    118
C                                                                       INGV22    119
      XLDREF(JYP+1)=XSTATE(JSTATE+NXS)                                  INGV22    120
C                                                                       INGV22    121
C    INITIAL CONDITION CHECK                                            INGV22    122
C                                                                       INGV22    123
      IF (XSTATE(JSTATE+NXS).GT.DDAT(JGG+7)) THEN                       INGV22    124
         XMAX=DDAT(JGG+7)                                               INGV22    125
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),                INGV22    126
     *    INAME(KN),NDGC(N)                                             INGV22    127
         WRITE(MSG(2),9100)                                             INGV22    128
         WRITE(MSG(3),9110) XSTATE(JSTATE+NXS),XMAX                     INGV22    129
         CALL PRTMSG(3)                                                 INGV22    130
      ENDIF                                                             INGV22    131
      IF (XSTATE(JSTATE+NXS).LT.DDAT(JGG+8)) THEN                       INGV22    132
         XMIN=DDAT(JGG+8)                                               INGV22    133
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),                INGV22    134
     *    INAME(KN),NDGC(N)                                             INGV22    135
         WRITE(MSG(2),9200)                                             INGV22    136
         WRITE(MSG(3),9110) XSTATE(JSTATE+NXS),XMIN                     INGV22    137
         CALL PRTMSG(3)                                                 INGV22    138
      ENDIF                                                             INGV22    139
C                                                                       INGV22    140
C     SET STATE POINTER AND PRINT INITIAL CONDITIONS                    INGV22    141
C                                                                       INGV22    142
      JSTATE=JSTATE+NXS                                                 INGV22    143
      MSTATE(6,N)=JSTATE                                                INGV22    144
C                                                                       INGV22    145
      JY=JY+1                                                           INGV22    146
      RETURN                                                            INGV22    147
C                                                                       INGV22    148
 9000 FORMAT(' *** WARNING GENERATOR AT BUS: ',I5,' STATION: ',3A4      INGV22    149
     *,' GID:',A4)                                                      INGV22    150
 9100 FORMAT(5X,'TYPE 22 (WSCC TYPE GW) GOVERNOR INITIAL CONDITION'     INGV22    151
     *,' VIOLATES GMAX LIMITER:')                                       INGV22    152
 9110 FORMAT(5X,'LIMITER OUTPUT =',G12.5,' LIMITING VALUE =',G12.5)     INGV22    153
 9020 FORMAT(5X,'TYPE 22 (WSCC TYPE GW) GOVERNOR ',A,'=',F8.6           INGV22    154
     *,' IS BELOW THE LIMIT VALUE')                                     INGV22    155
 9030 FORMAT(5X,'OF',F5.2,'. ',:,A,' HAS BEEN SET TO ',F4.2)            INGV22    156
 9200 FORMAT(5X,'TYPE 22 (WSCC TYPE GW) GOVERNOR INITIAL CONDITION'     INGV22    157
     *,' VIOLATES GMIN LIMITER:')                                       INGV22    158
C                                                                       INGV22    159
      END                                                               INGV22    160
