CFPRIME DEGV01                                                          DEGV01      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 DEGV01(JSGV)                                           DEGV01      3
CD                                                                      DEGV01      4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF TYPES 1 AND 2       DEGV01      5
CD    GOVERNOR, USED BY BOTH RUNGE-KUTTA AND TRAPEZOIDAL METHOD.        DEGV01      6
CD                                                                      DEGV01      7
CD    THE DATA STRUCTURES FOR THESE TYPES OF GOVERNORS ARE GIVEN BELOW. DEGV01      8
CD                                                                      DEGV01      9
CD   9.1 Prime-mover turbine-governor type 1                            DEGV01     10
CD                                                                      DEGV01     11
CD     Governor data                                                    DEGV01     12
CD                                                                      DEGV01     13
CD     DDAT(JGG+ 1)   = K1                                              DEGV01     14
CD     DDAT(JGG+ 2)   = K2                                              DEGV01     15
CD     DDAT(JGG+ 3)   = V1                                              DEGV01     16
CD     DDAT(JGG+ 4)   = V2                                              DEGV01     17
CD     DDAT(JGG+ 5)   = V3                                              DEGV01     18
CD     DDAT(JGG+ 6)   = T1                                              DEGV01     19
CD     DDAT(JGG+ 7)   = T2                                              DEGV01     20
CD     DDAT(JGG+ 8)   = KR                                              DEGV01     21
CD     DDAT(JGG+ 9)   = TSR                                             DEGV01     22
CD     DDAT(JGG+10)   = L1                                              DEGV01     23
CD     DDAT(JGG+11)   = L2                                              DEGV01     24
CD     DDAT(JGG+12)   = TF1                                             DEGV01     25
CD     DDAT(JGG+13)   = TF2                                             DEGV01     26
CD     DDAT(JGG+14)   = XFV                                             DEGV01     27
CD     DDAT(JGG+15)   = TFCV2                                           DEGV01     28
CD     DDAT(JGG+16)   = XFCV                                            DEGV01     29
CD     DDAT(JGG+17)   = THP                                             DEGV01     30
CD     DDAT(JGG+18)   = TRH                                             DEGV01     31
CD     DDAT(JGG+19)   = TIP                                             DEGV01     32
CD     DDAT(JGG+20)   = TLP                                             DEGV01     33
CD     DDAT(JGG+21)   = KBR                                             DEGV01     34
CD     DDAT(JGG+22)   = FHP                                             DEGV01     35
CD     DDAT(JGG+23)   = FIP                                             DEGV01     36
CD     DDAT(JGG+24)   = PMAX                                            DEGV01     37
CD     DDAT(JGG+25)   = FBRPR                                           DEGV01     38
CD     DDAT(JGG+26)   = KA                                              DEGV01     39
CD     DDAT(JGG+27)   = PDROP                                           DEGV01     40
CD     DDAT(JGG+28)   = RLMT                                            DEGV01     41
CD     DDAT(JGG+29)   = TI1                                             DEGV01     42
CD     DDAT(JGG+30)   = TI2                                             DEGV01     43
CD     DDAT(JGG+31)   = TI3                                             DEGV01     44
CD     DDAT(JGG+32)   = TI4                                             DEGV01     45
CD     DDAT(JGG+33)   = TI5                                             DEGV01     46
CD     DDAT(JGG+34)   = LI1                                             DEGV01     47
CD     DDAT(JGG+35)   = LI2                                             DEGV01     48
CD     DDAT(JGG+36)   = IVOB                                            DEGV01     49
CD     DDAT(JGG+37)   = PI1                                             DEGV01     50
CD     DDAT(JGG+38)   = AI1                                             DEGV01     51
CD     DDAT(JGG+39)   = PI2                                             DEGV01     52
CD     DDAT(JGG+40)   = AI2                                             DEGV01     53
CD     DDAT(JGG+41)   = XI1                                             DEGV01     54
CD     DDAT(JGG+42)   = YI1                                             DEGV01     55
CD     DDAT(JGG+43)   = XI2                                             DEGV01     56
CD     DDAT(JGG+44)   = YI2                                             DEGV01     57
CD     DDAT(JGG+45)   = CIDB1                                           DEGV01     58
CD     DDAT(JGG+46)   = CIDB2                                           DEGV01     59
CD     DDAT(JGG+47)   = TC1                                             DEGV01     60
CD     DDAT(JGG+48)   = TC2                                             DEGV01     61
CD     DDAT(JGG+49)   = TC3                                             DEGV01     62
CD     DDAT(JGG+50)   = TC4                                             DEGV01     63
CD     DDAT(JGG+51)   = TC5                                             DEGV01     64
CD     DDAT(JGG+52)   = LC1                                             DEGV01     65
CD     DDAT(JGG+53)   = LC2                                             DEGV01     66
CD     DDAT(JGG+54)   = (reserved for future use)                       DEGV01     67
CD     DDAT(JGG+55)   = PC1                                             DEGV01     68
CD     DDAT(JGG+56)   = AC1                                             DEGV01     69
CD     DDAT(JGG+57)   = PC2                                             DEGV01     70
CD     DDAT(JGG+58)   = AC2                                             DEGV01     71
CD     DDAT(JGG+59)   = XC1                                             DEGV01     72
CD     DDAT(JGG+60)   = YC1                                             DEGV01     73
CD     DDAT(JGG+61)   = XC2                                             DEGV01     74
CD     DDAT(JGG+62)   = YC2                                             DEGV01     75
CD     DDAT(JGG+63)   = CDB1                                            DEGV01     76
CD     DDAT(JGG+64)   = CDB2                                            DEGV01     77
CD     IDDAT(JGG+65)  = ILN                                             DEGV01     78
CD     IDDAT(JGG+66)  = IFV                                             DEGV01     79
CD                                                                      DEGV01     80
CD     Governor states                                                  DEGV01     81
CD                                                                      DEGV01     82
CD     XSTATE(JPS+1)  = THP block                   : compulsory        DEGV01     83
CD     XSTATE(JPS+2)  = TRH block                   : compulsory        DEGV01     84
CD     XSTATE(JPS+3)  = TIP block                   : compulsory        DEGV01     85
CD     XSTATE(JPS+4)  = TLP block                   : compulsory        DEGV01     86
CD     XSTATE(JPS+5)  = TC3 block                   : compulsory        DEGV01     87
CD     XSTATE(JPS+6)  = TC1 block                   : compulsory        DEGV01     88
CD     XSTATE(JPS+7)  = TC5 block                   : compulsory        DEGV01     89
CD     XSTATE(JPS+8)  = TI3 block                   : compulsory        DEGV01     90
CD     XSTATE(JPS+9)  = TI1 block                   : compulsory        DEGV01     91
CD     XSTATE(JPS+10) = TI5 block                   : compulsory        DEGV01     92
CD     XSTATE(JPS+11) = TSR block                   : compulsory        DEGV01     93
CD                                                                      DEGV01     94
CD     Governor Y-variables                                             DEGV01     95
CD                                                                      DEGV01     96
CD     XLDREF(JYP+1)  = load reference signal                           DEGV01     97
CD     CVP(JYP+2)     = control valve position                          DEGV01     98
CD     BLRPR(JYP+3)   = boiler/reactor pressure                         DEGV01     99
CD     PVP(JYP+4)     = pilot valve position                            DEGV01    100
CD     AIV(JYP+5)     = updated value of multiplier A                   DEGV01    101
CD     FAIV(JYP+6)    = intercept valve flow area                       DEGV01    102
CD     FACV(JYP+7)    = control valve flow area                         DEGV01    103
CD     INTL(JYP+8)    = integer for acceleration sensitive control      DEGV01    104
CD                      = 0    the control is not triggered             DEGV01    105
CD                      = 1    the control is triggered for the time    DEGV01    106
CD                             less than T1 seconds; no signal has been DEGV01    107
CD                             applied yet                              DEGV01    108
CD                      = 2    the control is triggered and the signal  DEGV01    109
CD                             is applied                               DEGV01    110
CD     TSNTL(JYP+9)   = acceleration sensitive control trigger time     DEGV01    111
CD     AKIV(JYP+10)   = steady-state value of multiplier A              DEGV01    112
CD     PDEM(JYP+11)   = power demand from AGC control                   DEGV01    113
CD     PSET(JYP+12)   = set point for boiler pressure control           DEGV01    114
CD                                                                      DEGV01    115
CD   9.2 Prime-mover Turbine-governor type 2                            DEGV01    116
CD                                                                      DEGV01    117
CD     Governor data                                                    DEGV01    118
CD                                                                      DEGV01    119
CD     DDAT(JGG+ 1)   = K1                                              DEGV01    120
CD     DDAT(JGG+ 2)   = K2                                              DEGV01    121
CD     DDAT(JGG+ 3)   = V1                                              DEGV01    122
CD     DDAT(JGG+ 4)   = V2                                              DEGV01    123
CD     DDAT(JGG+ 5)   = V3                                              DEGV01    124
CD     DDAT(JGG+ 6)   = T1                                              DEGV01    125
CD     DDAT(JGG+ 7)   = T2                                              DEGV01    126
CD     DDAT(JGG+ 8)   = KR                                              DEGV01    127
CD     DDAT(JGG+ 9)   = TSR                                             DEGV01    128
CD     DDAT(JGG+10)   = L1                                              DEGV01    129
CD     DDAT(JGG+11)   = L2                                              DEGV01    130
CD     DDAT(JGG+12)   = TF1                                             DEGV01    131
CD     DDAT(JGG+13)   = TF2                                             DEGV01    132
CD     DDAT(JGG+14)   = XFV                                             DEGV01    133
CD     DDAT(JGG+15)   = TFCV2                                           DEGV01    134
CD     DDAT(JGG+16)   = XFCV                                            DEGV01    135
CD     DDAT(JGG+17)   = THP                                             DEGV01    136
CD     DDAT(JGG+18)   = TRH                                             DEGV01    137
CD     DDAT(JGG+19)   = TIP                                             DEGV01    138
CD     DDAT(JGG+20)   = TLP                                             DEGV01    139
CD     DDAT(JGG+21)   = KBR                                             DEGV01    140
CD     DDAT(JGG+22)   = FHP                                             DEGV01    141
CD     DDAT(JGG+23)   = FIP                                             DEGV01    142
CD     DDAT(JGG+24)   = PMAX                                            DEGV01    143
CD     DDAT(JGG+25)   = FBRPR                                           DEGV01    144
CD     DDAT(JGG+26)   = KA                                              DEGV01    145
CD     DDAT(JGG+27)   = PDROP                                           DEGV01    146
CD     DDAT(JGG+28)   = RLMT                                            DEGV01    147
CD     DDAT(JGG+29)   = TI1                                             DEGV01    148
CD     DDAT(JGG+30)   = TI2                                             DEGV01    149
CD     DDAT(JGG+31)   = TI3                                             DEGV01    150
CD     DDAT(JGG+32)   = TI4                                             DEGV01    151
CD     DDAT(JGG+33)   = TI5                                             DEGV01    152
CD     DDAT(JGG+34)   = LI1                                             DEGV01    153
CD     DDAT(JGG+35)   = LI2                                             DEGV01    154
CD     DDAT(JGG+36)   = IVOB                                            DEGV01    155
CD     DDAT(JGG+37)   = PI1                                             DEGV01    156
CD     DDAT(JGG+38)   = AI1                                             DEGV01    157
CD     DDAT(JGG+39)   = PI2                                             DEGV01    158
CD     DDAT(JGG+40)   = AI2                                             DEGV01    159
CD     DDAT(JGG+41)   = XI1                                             DEGV01    160
CD     DDAT(JGG+42)   = YI1                                             DEGV01    161
CD     DDAT(JGG+43)   = XI2                                             DEGV01    162
CD     DDAT(JGG+44)   = YI2                                             DEGV01    163
CD     DDAT(JGG+45)   = CIDB1                                           DEGV01    164
CD     DDAT(JGG+46)   = CIDB2                                           DEGV01    165
CD     DDAT(JGG+47)   = TC1                                             DEGV01    166
CD     DDAT(JGG+48)   = TC2                                             DEGV01    167
CD     DDAT(JGG+49)   = TC3                                             DEGV01    168
CD     DDAT(JGG+50)   = TC4                                             DEGV01    169
CD     DDAT(JGG+51)   = TC5                                             DEGV01    170
CD     DDAT(JGG+52)   = LC1                                             DEGV01    171
CD     DDAT(JGG+53)   = LC2                                             DEGV01    172
CD     DDAT(JGG+54)   = (reserved for future use)                       DEGV01    173
CD     DDAT(JGG+55)   = PC1                                             DEGV01    174
CD     DDAT(JGG+56)   = AC1                                             DEGV01    175
CD     DDAT(JGG+57)   = PC2                                             DEGV01    176
CD     DDAT(JGG+58)   = AC2                                             DEGV01    177
CD     DDAT(JGG+59)   = XC1                                             DEGV01    178
CD     DDAT(JGG+60)   = YC1                                             DEGV01    179
CD     DDAT(JGG+61)   = XC2                                             DEGV01    180
CD     DDAT(JGG+62)   = YC2                                             DEGV01    181
CD     DDAT(JGG+63)   = CDB1                                            DEGV01    182
CD     DDAT(JGG+64)   = CDB2                                            DEGV01    183
CD     IDDAT(JGG+65)  = ILN                                             DEGV01    184
CD     IDDAT(JGG+66)  = IFV                                             DEGV01    185
CD                                                                      DEGV01    186
CD     Governor states                                                  DEGV01    187
CD                                                                      DEGV01    188
CD     XSTATE(JPS+ 1) = THP block                   : compulsory        DEGV01    189
CD     XSTATE(JPS+ 2) = TRH block                   : compulsory        DEGV01    190
CD     XSTATE(JPS+ 3) = TIP block                   : compulsory        DEGV01    191
CD     XSTATE(JPS+ 4) = TLP block                   : compulsory        DEGV01    192
CD     XSTATE(JPS+ 5) = TC3 block                   : compulsory        DEGV01    193
CD     XSTATE(JPS+ 6) = TC1 block                   : compulsory        DEGV01    194
CD     XSTATE(JPS+ 7) = TC5 block                   : compulsory        DEGV01    195
CD     XSTATE(JPS+ 8) = TI3 block                   : compulsory        DEGV01    196
CD     XSTATE(JPS+ 9) = TI1 block                   : compulsory        DEGV01    197
CD     XSTATE(JPS+10) = TI5 block                   : compulsory        DEGV01    198
CD     XSTATE(JPS+11) = TR block                    : compulsory        DEGV01    199
CD                                                                      DEGV01    200
CD     Governor Y-variables                                             DEGV01    201
CD                                                                      DEGV01    202
CD     XLDREF(JYP+ 1) = load reference signal                           DEGV01    203
CD     CVP(JYP+ 2)    = control valve position                          DEGV01    204
CD     BLRPR(JYP+ 3)  = boiler/reactor pressure                         DEGV01    205
CD     PVP(JYP+ 4)    = pilot valve position                            DEGV01    206
CD     AIV(JYP+ 5)    = updated value of multiplier A                   DEGV01    207
CD     FAIV(JYP+ 6)   = intercept valve flow area                       DEGV01    208
CD     FACV(JYP+ 7)   = control valve flow area                         DEGV01    209
CD     INTL(JYP+ 8)   = integer for acceleration sensitive control      DEGV01    210
CD                      = 0    the control is not triggered             DEGV01    211
CD                      = 1    the control is triggered for the time    DEGV01    212
CD                             less than T1 seconds; no signal has been DEGV01    213
CD                             applied yet                              DEGV01    214
CD                      = 2    the control is triggered and the signal  DEGV01    215
CD                             is applied                               DEGV01    216
CD     TSNTL(JYP+ 9)  = acceleration sensitive control trigger time     DEGV01    217
CD     AKIV(JYP+10)   = steady-state value of multiplier A              DEGV01    218
CD     PDEM(JYP+11)   = power demand from AGC control                   DEGV01    219
CD     PSET(JYP+12)   = set point for boiler pressure control           DEGV01    220
CD                                                                      DEGV01    221
C                                                                       DEGV01    222
C     ARRAYS "CCVDB1,2;CIVDB1,2" HAVE BEEN FIXED, CALLED BY NEW "DBAND".DEGV01    223
C                                                                       DEGV01    224
      INCLUDE 'PARX.INS'                                                DEGV01    225
      INCLUDE 'CNB3.INS'                                                DEGV01    226
      INCLUDE 'CNB4.INS'                                                DEGV01    227
      INCLUDE 'CNB8.INS'                                                DEGV01    228
      INCLUDE 'CNB10.INS'                                               DEGV01    229
      INCLUDE 'CNB19.INS'                                               DEGV01    230
      INCLUDE 'CNG3.INS'                                                DEGV01    231
      INCLUDE 'CNPARX.INS'                                              DEGV01    232
      INCLUDE 'CNXSTA.INS'                                              DEGV01    233
      INCLUDE 'CNMDAT.INS'                                              DEGV01    234
      INCLUDE 'CNEXC.INS'                                               DEGV01    235
      INCLUDE 'CNPRGV.INS'                                              DEGV01    236
      INCLUDE 'CNMYVA.INS'                                              DEGV01    237
      INCLUDE 'CNYVAR.INS'                                              DEGV01    238
C                                                                       DEGV01    239
      JSGV=JSTATE                                                       DEGV01    240
C                                                                       DEGV01    241
      XRATE=0.0                                                         DEGV01    242
      XDIF=0.0                                                          DEGV01    243
      IVFDBK=0                                                          DEGV01    244
      GOVSP=0.0                                                         DEGV01    245
C                                                                       DEGV01    246
      ILNN=IDDAT(JGG+65)                                                DEGV01    247
      IFVN=IDDAT(JGG+66)                                                DEGV01    248
      IGSTAN=ICONTA(10,N)                                               DEGV01    249
      IF (IGSTAN.NE.0) JYPS=MYVAR(6,N)                                  DEGV01    250
C                                                                       DEGV01    251
C     THERMAL UNITS                                                     DEGV01    252
C                                                                       DEGV01    253
C   FAST VALVING SIGNAL                                                 DEGV01    254
      XSGFV=0.                                                          DEGV01    255
      IF (IFVN.EQ.0) GO TO 20                                           DEGV01    256
      IF (TS.LT.DDAT(JGG+12)) GO TO 20                                  DEGV01    257
      IF (TS.GE.DDAT(JGG+13)) GO TO 20                                  DEGV01    258
      XSGFV=DDAT(JGG+14)                                                DEGV01    259
20    CONTINUE                                                          DEGV01    260
C                                                                       DEGV01    261
C      TYPE 1,2 OR 3                                                    DEGV01    262
C                                                                       DEGV01    263
C   CHECK IVFEEDBACK                                                    DEGV01    264
C                                                                       DEGV01    265
      IF (ILNN.NE.1) GO TO 30                                           DEGV01    266
      IVFDBK=1                                                          DEGV01    267
      IF (DDAT(JGG+41).LE.1.E-6.AND.DDAT(JGG+42).LE.1.E-6.AND.          DEGV01    268
     + DDAT(JGG+43).LE.1.E-6.AND.DDAT(JGG+44).LE.1.E-6) IVFDBK=0        DEGV01    269
30    NDV=11                                                            DEGV01    270
      GO TO (40,70,60), IGVN                                            DEGV01    271
C      TYPE 1                                                           DEGV01    272
40    GAIN=DDAT(JGG+1)                                                  DEGV01    273
      OVSPD=XSPU-DDAT(JGG+3)                                            DEGV01    274
      IF (OVSPD.GT.0.) GOVSP=DDAT(JGG+2)                                DEGV01    275
      OVSPD1=DDAT(JGG+1)*XSPU                                           DEGV01    276
      OVSPD2=DDAT(JGG+2)*OVSPD                                          DEGV01    277
      IF (OVSPD1.GE.OVSPD2) GO TO 50                                    DEGV01    278
      GAIN=GOVSP                                                        DEGV01    279
      XLDREF(JYP+1)=0.                                                  DEGV01    280
50    XSG1=XLDREF(JYP+1)-GAIN*XSPU                                      DEGV01    281
      GO TO 80                                                          DEGV01    282
C TYPE 3                                                                DEGV01    283
60    DSTATE(LSTATE+11)=(XSPU*DDAT(JGG+1)-XSTATE(JSTATE+11))/DDAT(JGG+9)DEGV01    284
      XGVS=XLDREF(JYP+1)-XSTATE(JSTATE+11)                              DEGV01    285
      IF (IFVN.EQ.3) XGVS=XGVS-XSGFV                                    DEGV01    286
      XSUM=XGVS                                                         DEGV01    287
      GO TO 160                                                         DEGV01    288
C                                                                       DEGV01    289
C     TYPE 2                                                            DEGV01    290
C   TYPE 2 (WITH AUXLIARY GOVERNOR)                                     DEGV01    291
70    CONTINUE                                                          DEGV01    292
      XSG1=XLDREF(JYP+1)-(DDAT(JGG+1)*XSPU)                             DEGV01    293
      IF (XSPU.LE.DDAT(JGG+3)) GO TO 80                                 DEGV01    294
      XSG1=XSG1-(DDAT(JGG+2)*(XSPU-DDAT(JGG+3)))                        DEGV01    295
C                                                                       DEGV01    296
C    ACCELERATION SENSITIVE CONTROL                                     DEGV01    297
80    XSG2=0.                                                           DEGV01    298
      IF (DDAT(JGG+5).LT.1.E-6) GO TO 120                               DEGV01    299
      IF (XACPU.LE.DDAT(JGG+4)) GO TO 90                                DEGV01    300
      IF (INTL(JYP+8).NE.0) GO TO 100                                   DEGV01    301
      INTL(JYP+8)=1                                                     DEGV01    302
      TSNTL(JYP+9)=TS                                                   DEGV01    303
      GO TO 120                                                         DEGV01    304
90    IF (INTL(JYP+8).LT.2) GO TO 110                                   DEGV01    305
100   TSX=TS-TSNTL(JYP+9)                                               DEGV01    306
      T1P2=DDAT(JGG+6)+DDAT(JGG+7)                                      DEGV01    307
      IF (TSX.LE.DDAT(JGG+6)) GO TO 120                                 DEGV01    308
      INTL(JYP+8)=2                                                     DEGV01    309
      IF (TSX.GT.T1P2) GO TO 110                                        DEGV01    310
      XSG2=DDAT(JGG+5)                                                  DEGV01    311
      GO TO 120                                                         DEGV01    312
110   INTL(JYP+8)=0                                                     DEGV01    313
120   CONTINUE                                                          DEGV01    314
      XSUM=XSG1                                                         DEGV01    315
      IF (IGVN.EQ.2) GO TO 130                                          DEGV01    316
      XSUM=XSG1-XSG2                                                    DEGV01    317
C   FAST VALVING BOTH CV AND IV THROUGH A COMMON SIGNAL                 DEGV01    318
      IF (IFVN.EQ.3) XSUM=XSUM-XSGFV                                    DEGV01    319
130   CONTINUE                                                          DEGV01    320
      IF (IGSTAN.EQ.1) XSUM=XSUM+GSS(JYPS+1)                            DEGV01    321
      IF (DDAT(JGG+9).LT.1.E-6) GO TO 140                               DEGV01    322
      DSTATE(LSTATE+11)=(XSUM-XSTATE(JSTATE+11))/DDAT(JGG+9)            DEGV01    323
      GO TO 150                                                         DEGV01    324
140   DSTATE(LSTATE+11)=0.                                              DEGV01    325
      XSTATE(JSTATE+11)=XSUM                                            DEGV01    326
150   XGVS=XSTATE(JSTATE+11)                                            DEGV01    327
      IF (IGVN.NE.2) GO TO 160                                          DEGV01    328
C   TYPE 2                                                              DEGV01    329
      IF (XGVS.GT.DDAT(JGG+10)) XGVS=DDAT(JGG+10)                       DEGV01    330
      IF (XGVS.LT.DDAT(JGG+11)) XGVS=DDAT(JGG+11)                       DEGV01    331
      XGVS=XGVS-XSG2                                                    DEGV01    332
      IF (IFVN.EQ.3) XGVS=XGVS-XSGFV                                    DEGV01    333
      GO TO 170                                                         DEGV01    334
160   CONTINUE                                                          DEGV01    335
      IF (XGVS.GT.DDAT(JGG+10)) XGVS=DDAT(JGG+10)                       DEGV01    336
      IF (XGVS.LT.DDAT(JGG+11)) XGVS=DDAT(JGG+11)                       DEGV01    337
170   CONTINUE                                                          DEGV01    338
C                                                                       DEGV01    339
C     INTERCEPT VALVE CONTROL LOOP                                      DEGV01    340
C                                                                       DEGV01    341
      IF (DDAT(JGG+33).LT.1.E-6) GO TO 180                              DEGV01    342
      DSTATE(LSTATE+10)=(XGVS-XSTATE(JSTATE+10))/DDAT(JGG+33)           DEGV01    343
      XSIV=XSTATE(JSTATE+10)                                            DEGV01    344
      IF (DSTATE(LSTATE+10).LE.0.0.OR.DDAT(JGG+32).LE.1.0) XSIV=XSIV+   DEGV01    345
     + DDAT(JGG+32)*DSTATE(LSTATE+10)                                   DEGV01    346
      GO TO 190                                                         DEGV01    347
180   DSTATE(LSTATE+10)=0.                                              DEGV01    348
      XSTATE(JSTATE+10)=XGVS                                            DEGV01    349
      XSIV=XGVS                                                         DEGV01    350
190   CONTINUE                                                          DEGV01    351
C  IV POSITION DEMAND                                                   DEGV01    352
      XIVPD=DDAT(JGG+8)*(XSIV+DDAT(JGG+36))                             DEGV01    353
      IF(IVFDBK.NE.1)THEN                                               DEGV01    354
        IF (XIVPD.GE.1.) XIVPD=1.                                       DEGV01    355
      ENDIF                                                             DEGV01    356
      IF (IGVN.NE.3) GO TO 220                                          DEGV01    357
C   TYPE 3 DIFFERENTIAL FEEDING LOOP                                    DEGV01    358
      XDIF=DSTATE(LSTATE+11)                                            DEGV01    359
      IF (XSUM.GT.DDAT(JGG+10).OR.XSUM.LT.DDAT(JGG+11)) XDIF=0.0        DEGV01    360
      IF (DDAT(JGG+33).GT.1.E-6) GO TO 200                              DEGV01    361
      XILP=-XDIF                                                        DEGV01    362
      GO TO 210                                                         DEGV01    363
200   XILP=(DDAT(JGG+32)-DDAT(JGG+33))*DSTATE(LSTATE+10)-DDAT(JGG+32)*  DEGV01    364
     +XDIF                                                              DEGV01    365
      XILP=XILP/DDAT(JGG+33)                                            DEGV01    366
210   IF (XILP.LT.DDAT(JGG+41)) XILP=0.0                                DEGV01    367
      XIVPD=XIVPD-XILP*DDAT(JGG+42)                                     DEGV01    368
220   CONTINUE                                                          DEGV01    369
C  IV POSITION                                                          DEGV01    370
      PNIV=XSTATE(JSTATE+8)                                             DEGV01    371
      IF (PNIV.GT.1.0) PNIV=1.0                                         DEGV01    372
      IF (PNIV.LT.0.0) PNIV=0.0                                         DEGV01    373
      IF (IDDAT(JGG+46).EQ.0) GO TO 230                                 DEGV01    374
      DBDX=DDAT(JGG+46)                                                 DEGV01    375
      IF (ABS(DBDX).GT.1.E-6) CALL DBAND (PNIV,DBDX,DDAT,JGG,NDAT,75)   DEGV01    376
230   XFEED=PNIV                                                        DEGV01    377
      IF (ILNN.EQ.0) GO TO 270                                          DEGV01    378
C  IV LINEARITY COMPENSATION                                            DEGV01    379
      XPN1=DDAT(JGG+41)                                                 DEGV01    380
      YFA1=DDAT(JGG+42)                                                 DEGV01    381
      XPN2=DDAT(JGG+43)                                                 DEGV01    382
      YFA2=DDAT(JGG+44)                                                 DEGV01    383
      IF (ILNN.EQ.1) GO TO 250                                          DEGV01    384
C   FEED FORWARD COMPENSATION                                           DEGV01    385
      XPIN=XIVPD                                                        DEGV01    386
      IF (ILNN.NE.2) GO TO 240                                          DEGV01    387
      IF (XPIN.GT.1.0) XPIN=1.0                                         DEGV01    388
      IF (XPIN.LT.0.0) XPIN=0.0                                         DEGV01    389
240   CONTINUE                                                          DEGV01    390
      CALL NLCHAR                                                       DEGV01    391
      XIVPD=YOUT                                                        DEGV01    392
      GO TO 270                                                         DEGV01    393
C   FEEDBACK COMPENSATION                                               DEGV01    394
250   IF (IVFDBK.EQ.0) GO TO 260                                        DEGV01    395
      XPIN=XFEED                                                        DEGV01    396
      CALL NLCHAR                                                       DEGV01    397
      XFEED=YOUT                                                        DEGV01    398
      GO TO 270                                                         DEGV01    399
260   XFEED=0.                                                          DEGV01    400
270   CONTINUE                                                          DEGV01    401
      XSUM=XIVPD-XFEED                                                  DEGV01    402
      IF (IDDAT(JGG+45).EQ.0) GO TO 280                                 DEGV01    403
      DBDX=DDAT(JGG+45)                                                 DEGV01    404
      IF (ABS(DBDX).GT.1.E-6) CALL DBAND (XSUM,DBDX,DDAT,JGG,NDAT,72)   DEGV01    405
280   XSUM=XSUM/DDAT(JGG+30)                                            DEGV01    406
      IF (DDAT(JGG+29).LT.1.E-6) GO TO 290                              DEGV01    407
      DSTATE(LSTATE+9)=(XSUM-XSTATE(JSTATE+9))/DDAT(JGG+29)             DEGV01    408
      GO TO 300                                                         DEGV01    409
290   DSTATE(LSTATE+9)=0.                                               DEGV01    410
      XSTATE(JSTATE+9)=XSUM                                             DEGV01    411
      XRATE=XSTATE(JSTATE+9)                                            DEGV01    412
300   IF (XRATE.LE.DDAT(JGG+34)) GO TO 310                              DEGV01    413
      XSTATE(JSTATE+9)=DDAT(JGG+34)                                     DEGV01    414
      IF (DSTATE(LSTATE+9).GE.0.) DSTATE(LSTATE+9)=0.                   DEGV01    415
310   IF (XRATE.GE.DDAT(JGG+35)) GO TO 320                              DEGV01    416
      XSTATE(JSTATE+9)=DDAT(JGG+35)                                     DEGV01    417
      IF (DSTATE(LSTATE+9).LE.0.) DSTATE(LSTATE+9)=0.                   DEGV01    418
320   CONTINUE                                                          DEGV01    419
      XRATE=XSTATE(JSTATE+9)                                            DEGV01    420
C                                                                       DEGV01    421
      IF (IFVN.NE.1.AND.IFVN.NE.2) GO TO 330                            DEGV01    422
C   FAST VALVING THROUGH IV RATE SIGNAL                                 DEGV01    423
      XRATE=XRATE-XSGFV                                                 DEGV01    424
330   CONTINUE                                                          DEGV01    425
      DSTATE(LSTATE+8)=XRATE/DDAT(JGG+31)                               DEGV01    426
      IF (XSTATE(JSTATE+8).GE.1.0.AND.DSTATE(LSTATE+8).GT.0.0) DSTATE   DEGV01    427
     +(LSTATE+8)=0.0                                                    DEGV01    428
      IF (XSTATE(JSTATE+8).LE.0.0.AND.DSTATE(LSTATE+8).LT.0.0) DSTATE   DEGV01    429
     +(LSTATE+8)=0.0                                                    DEGV01    430
      XPN1=DDAT(JGG+37)                                                 DEGV01    431
      YFA1=DDAT(JGG+38)                                                 DEGV01    432
      XPN2=DDAT(JGG+39)                                                 DEGV01    433
      YFA2=DDAT(JGG+40)                                                 DEGV01    434
      XPIN=PNIV                                                         DEGV01    435
      CALL NLCHAR                                                       DEGV01    436
C   IV FLOW AREA                                                        DEGV01    437
      FAIV(JYP+6)=YOUT                                                  DEGV01    438
C                                                                       DEGV01    439
C      CONTROL VALVE LOOP                                               DEGV01    440
C                                                                       DEGV01    441
      IF (DDAT(JGG+51).LT.1.E-6) GO TO 340                              DEGV01    442
      DSTATE(LSTATE+7)=(XGVS-XSTATE(JSTATE+7))/DDAT(JGG+51)             DEGV01    443
      XCVPD=XSTATE(JSTATE+7)+(DDAT(JGG+50)*DSTATE(LSTATE+7))            DEGV01    444
      GO TO 350                                                         DEGV01    445
340   DSTATE(LSTATE+7)=0.0                                              DEGV01    446
      XSTATE(JSTATE+7)=XGVS                                             DEGV01    447
      XCVPD=XGVS                                                        DEGV01    448
350   CONTINUE                                                          DEGV01    449
C   XCVPD= CV POSITION DEMAND                                           DEGV01    450
C   CV POSITION                                                         DEGV01    451
      PNCV=XSTATE(JSTATE+5)                                             DEGV01    452
      IF (PNCV.GT.1.0) PNCV=1.0                                         DEGV01    453
      IF (PNCV.LT.0.0) PNCV=0.0                                         DEGV01    454
      IF (IDDAT(JGG+64).EQ.0) GO TO 360                                 DEGV01    455
      DBDX=DDAT(JGG+64)                                                 DEGV01    456
      IF (ABS(DBDX).GT.1.E-6) CALL DBAND (PNCV,DBDX,DDAT,JGG,NDAT,69)   DEGV01    457
360   XFEED=PNCV                                                        DEGV01    458
      IF (ILNN.EQ.0) GO TO 390                                          DEGV01    459
C  CV LINEARITY XCOMPENSATION                                           DEGV01    460
      XPN1=DDAT(JGG+59)                                                 DEGV01    461
      YFA1=DDAT(JGG+60)                                                 DEGV01    462
      XPN2=DDAT(JGG+61)                                                 DEGV01    463
      YFA2=DDAT(JGG+62)                                                 DEGV01    464
      IF (ILNN.EQ.1) GO TO 380                                          DEGV01    465
C   FEED FORWARD COMPENSATION                                           DEGV01    466
      XPIN=XCVPD                                                        DEGV01    467
      IF (ILNN.NE.2) GO TO 370                                          DEGV01    468
      IF (XPIN.GT.1.0) XPIN=1.0                                         DEGV01    469
      IF (XPIN.LT.0.0) XPIN=0.0                                         DEGV01    470
370   CONTINUE                                                          DEGV01    471
      CALL NLCHAR                                                       DEGV01    472
      XCVPD=YOUT                                                        DEGV01    473
      GO TO 390                                                         DEGV01    474
C   FEED BACK COMPENSATION                                              DEGV01    475
380   XPIN=XFEED                                                        DEGV01    476
      CALL NLCHAR                                                       DEGV01    477
      XFEED=YOUT                                                        DEGV01    478
390   CONTINUE                                                          DEGV01    479
      XSUM=XCVPD-XFEED                                                  DEGV01    480
      IF (IDDAT(JGG+63).EQ.0) GO TO 400                                 DEGV01    481
      DBDX=DDAT(JGG+63)                                                 DEGV01    482
      IF (ABS(DBDX).GT.1.E-6) CALL DBAND (XSUM,DBDX,DDAT,JGG,NDAT,66)   DEGV01    483
400   XSUM=XSUM/DDAT(JGG+48)                                            DEGV01    484
      IF (DDAT(JGG+47).LT.1.E-6) GO TO 410                              DEGV01    485
      DSTATE(LSTATE+6)=(XSUM-XSTATE(JSTATE+6))/DDAT(JGG+47)             DEGV01    486
      GO TO 420                                                         DEGV01    487
410   DSTATE(LSTATE+6)=0.0                                              DEGV01    488
      XSTATE(JSTATE+6)=XSUM                                             DEGV01    489
420   XRATE=XSTATE(JSTATE+6)                                            DEGV01    490
      IF (XRATE.LE.DDAT(JGG+52)) GO TO 430                              DEGV01    491
      XSTATE(JSTATE+6)=DDAT(JGG+52)                                     DEGV01    492
      IF (DSTATE(LSTATE+6).GE.0.) DSTATE(LSTATE+6)=0.                   DEGV01    493
430   IF (XRATE.GE.DDAT(JGG+53)) GO TO 440                              DEGV01    494
      XSTATE(JSTATE+6)=DDAT(JGG+53)                                     DEGV01    495
      IF (DSTATE(LSTATE+6).LE.0.) DSTATE(LSTATE+6)=0.                   DEGV01    496
440   CONTINUE                                                          DEGV01    497
      XRATE=XSTATE(JSTATE+6)                                            DEGV01    498
      IF (IGVN.NE.3) GO TO 470                                          DEGV01    499
C   TYPE 3 DIFFERENTIAL FEEDING LOOP                                    DEGV01    500
      IF (DDAT(JGG+51).GT.1.E-6) GO TO 450                              DEGV01    501
      XCLP=-XDIF                                                        DEGV01    502
      GO TO 460                                                         DEGV01    503
450   XCLP=(DDAT(JGG+50)-DDAT(JGG+51))*DSTATE(LSTATE+7)-DDAT(JGG+50)*   DEGV01    504
     +XDIF                                                              DEGV01    505
      XCLP=XCLP/DDAT(JGG+51)                                            DEGV01    506
460   IF (XCLP.LT.DDAT(JGG+59)) XCLP=0.0                                DEGV01    507
      XRATE=XRATE-XCLP*DDAT(JGG+60)                                     DEGV01    508
470   CONTINUE                                                          DEGV01    509
C                                                                       DEGV01    510
      IF (IFVN.NE.2) GO TO 480                                          DEGV01    511
C   FAST VALVING THROUGH CV RATE SIGNAL                                 DEGV01    512
      IF (TS.LT.DDAT(JGG+12).OR.TS.GE.DDAT(JGG+15)) GO TO 480           DEGV01    513
      XRATE=XRATE-DDAT(JGG+16)                                          DEGV01    514
480   CONTINUE                                                          DEGV01    515
      DSTATE(LSTATE+5)=XRATE/DDAT(JGG+49)                               DEGV01    516
      IF (XSTATE(JSTATE+5).GE.1.0.AND.DSTATE(LSTATE+5).GT.0.0) DSTATE   DEGV01    517
     +(LSTATE+5)=0.0                                                    DEGV01    518
      IF (XSTATE(JSTATE+5).LE.0.0.AND.DSTATE(LSTATE+5).LT.0.0) DSTATE   DEGV01    519
     +(LSTATE+5)=0.0                                                    DEGV01    520
      XPN1=DDAT(JGG+55)                                                 DEGV01    521
      YFA1=DDAT(JGG+56)                                                 DEGV01    522
      XPN2=DDAT(JGG+57)                                                 DEGV01    523
      YFA2=DDAT(JGG+58)                                                 DEGV01    524
      XPIN=PNCV                                                         DEGV01    525
      CALL NLCHAR                                                       DEGV01    526
C   CV FLOW AREA                                                        DEGV01    527
      FACV(JYP+7)=YOUT                                                  DEGV01    528
C                                                                       DEGV01    529
C     TURBIN STEAM SYSTEM DYNAMICS                                      DEGV01    530
C                                                                       DEGV01    531
C     HP FLOW-XSTATE(JSTATE+1)                                          DEGV01    532
      XHPN1=FACV(JYP+7)*BLRPR(JYP+3)*DDAT(JGG+21)                       DEGV01    533
      XHPN2=(DDAT(JGG+21)-1.0)*XSTATE(JSTATE+2)                         DEGV01    534
      XHPN=XHPN1-XHPN2                                                  DEGV01    535
      IF (XHPN.LT.0.0.AND.DDAT(JGG+25).GT.0.0) XHPN=0.0                 DEGV01    536
      DSTATE(LSTATE+1)=(XHPN-XSTATE(JSTATE+1))/DDAT(JGG+17)             DEGV01    537
C      A - FACTOR FOR IV FLOW                                           DEGV01    538
      RIPRH=(1.0-(DDAT(JGG+27)/100.0))*(XSTATE(JSTATE+3)/XSTATE         DEGV01    539
     + (JSTATE+2))                                                      DEGV01    540
      IF (RIPRH.LT.DDAT(JGG+28)) RIPRH=DDAT(JGG+28)                     DEGV01    541
      IF (RIPRH.GT.1.) RIPRH=1.                                         DEGV01    542
      XK1=2.0/DDAT(JGG+26)                                              DEGV01    543
      XK2=(DDAT(JGG+26)+1.0)/DDAT(JGG+26)                               DEGV01    544
      XEKK=(RIPRH**XK1)-(RIPRH**XK2)                                    DEGV01    545
      IF (XEKK.LE.0.0) XEKK=1.E-7                                       DEGV01    546
      XEKK=SQRT(XEKK)                                                   DEGV01    547
      AIV(JYP+5)=AKIV(JYP+10)*XEKK                                      DEGV01    548
      IF (IVFDBK.EQ.0) AIV(JYP+5)=1.0                                   DEGV01    549
C                                                                       DEGV01    550
C     IV FLOW                                                           DEGV01    551
      FLWIV=FAIV(JYP+6)*XSTATE(JSTATE+2)*AIV(JYP+5)                     DEGV01    552
C     RH PRESSURE- XSTATE(JSTATE+2)                                     DEGV01    553
      DSTATE(LSTATE+2)=(XSTATE(JSTATE+1)-FLWIV)/DDAT(JGG+18)            DEGV01    554
C      IP(OR INLET PIPING) FLOW- XSTATE(JSTATE+3)                       DEGV01    555
      IF (DDAT(JGG+19).LT.1.E-6) GO TO 490                              DEGV01    556
      DSTATE(LSTATE+3)=(FLWIV-XSTATE(JSTATE+3))/DDAT(JGG+19)            DEGV01    557
      GO TO 500                                                         DEGV01    558
490   DSTATE(LSTATE+3)=0.0                                              DEGV01    559
      XSTATE(JSTATE+3)=FLWIV                                            DEGV01    560
500   CONTINUE                                                          DEGV01    561
C     LP FLOW - XSTATE(JSTATE+4)                                        DEGV01    562
      DSTATE(LSTATE+4)=(XSTATE(JSTATE+3)-XSTATE(JSTATE+4))/DDAT(JGG+20) DEGV01    563
C                                                                       DEGV01    564
      LSTATE=LSTATE+11                                                  DEGV01    565
C                                                                       DEGV01    566
C   GOVERNOR STABILIZER                                                 DEGV01    567
C                                                                       DEGV01    568
      IF (IGSTAN.EQ.0) GO TO 690                                        DEGV01    569
      XSUM=DDAT(JGS+1)*XSTATE(IDOMG)+PDGN*DDAT(JGS+2)+DDAT(JGS+3)*      DEGV01    570
     $CVP(JYP+2)                                                        DEGV01    571
      NDVS=12                                                           DEGV01    572
      DSTATE(LSTATE+NDVS)=XSUM-XSTATE(JSTATE+NDVS)*DDAT(JGS+4)          DEGV01    573
      GSS(JYPS+1)=DSTATE(LSTATE+NDVS)                                   DEGV01    574
      IF (GSS(JYPS+1).GT.DDAT(JGS+5)) GSS(JYPS+1)=DDAT(JGS+5)           DEGV01    575
      IF (GSS(JYPS+1).LT.DDAT(JGS+6)) GSS(JYPS+1)=DDAT(JGS+6)           DEGV01    576
      LSTATE=LSTATE+1                                                   DEGV01    577
690   CONTINUE                                                          DEGV01    578
C                                                                       DEGV01    579
      PVP(JYP+4)=XGVS                                                   DEGV01    580
C                                                                       DEGV01    581
      RETURN                                                            DEGV01    582
C                                                                       DEGV01    583
      END                                                               DEGV01    584
