CFPRIME ISTAB1                                                          ISTAB1      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 ISTAB1(ISMAX,ISMIN)                                    ISTAB1      3
CD                                                                      ISTAB1      4
CD    TO PERFORM INITIALIZATION AND DATA CHECK FOR STABILIZER TYPES     ISTAB1      5
CD    1, 2 AND 3.                                                       ISTAB1      6
CD                                                                      ISTAB1      7
CD    THE DATA STRUCTURE AFTER THE INITIALIZATION IS GIVEN BELOW.       ISTAB1      8
CD                                                                      ISTAB1      9
CD   4.1 Stabilizer type 1                                              ISTAB1     10
CD                                                                      ISTAB1     11
CD     Stabilizer data                                                  ISTAB1     12
CD                                                                      ISTAB1     13
CD     IDDAT(JS+1)    = BUSR         : sensing bus number               ISTAB1     14
CD     IDDAT(JS+2)    = TYPE         : type of input signal:            ISTAB1     15
CD                                     = 1 rotor speed                  ISTAB1     16
CD                                     = 2 acceleration power           ISTAB1     17
CD                                     = 3 bus frequency                ISTAB1     18
CD                                     = 4 electrical power             ISTAB1     19
CD                                     = 5 bus voltage magnitude        ISTAB1     20
CD                                     = 6 voltage deviation from steadyISTAB1     21
CD                                        state value                   ISTAB1     22
CD     DDAT(JS+ 3)    = KS                                              ISTAB1     23
CD     DDAT(JS+ 4)    = T5                                              ISTAB1     24
CD     DDAT(JS+ 5)    = T1                                              ISTAB1     25
CD     DDAT(JS+ 6)    = T2                                              ISTAB1     26
CD     DDAT(JS+ 7)    = T3                                              ISTAB1     27
CD     DDAT(JS+ 8)    = T4                                              ISTAB1     28
CD     DDAT(JS+ 9)    = VSMAX                                           ISTAB1     29
CD     DDAT(JS+10)    = VSMIN                                           ISTAB1     30
CD     DDAT(JS+11)    = TF                                              ISTAB1     31
CD     DDAT(JS+12)    = RC                                              ISTAB1     32
CD     DDAT(JS+13)    = XC                                              ISTAB1     33
CD     DDAT(JS+14)    = PTHR                                            ISTAB1     34
CD                                                                      ISTAB1     35
CD     Stabilizer states                                                ISTAB1     36
CD                                                                      ISTAB1     37
CD     XSTATE(JSS+1)  = TF block if input is bus frequency              ISTAB1     38
CD                                   : optional                         ISTAB1     39
CD     XSTATE(JSS+2)  = T5 block     : compulsory                       ISTAB1     40
CD     XSTATE(JSS+3)  = T2 block     : optional                         ISTAB1     41
CD     XSTATE(JSS+4)  = T4 block     : optional                         ISTAB1     42
CD                                                                      ISTAB1     43
CD     Stabilizer Y-variables                                           ISTAB1     44
CD                                                                      ISTAB1     45
CD     VSS(JYS+1)     = stabilizer output                               ISTAB1     46
CD                                                                      ISTAB1     47
CD   4.2 Stabilizer type 2                                              ISTAB1     48
CD                                                                      ISTAB1     49
CD     Stabilizer data                                                  ISTAB1     50
CD                                                                      ISTAB1     51
CD     IDDAT(JS+1)    = BUSR         : sensing bus number               ISTAB1     52
CD     IDDAT(JS+2)    = TYPE         : type of input signal:            ISTAB1     53
CD                                     = 1 rotor speed                  ISTAB1     54
CD                                     = 2 acceleration power           ISTAB1     55
CD                                     = 3 bus frequency                ISTAB1     56
CD                                     = 4 electrical power             ISTAB1     57
CD                                     = 5 bus voltage magnitude        ISTAB1     58
CD                                     = 6 voltage deviation from steadyISTAB1     59
CD                                        state value                   ISTAB1     60
CD     DDAT(JS+ 3)    = KS                                              ISTAB1     61
CD     DDAT(JS+ 4)    = T5                                              ISTAB1     62
CD     DDAT(JS+ 5)    = T1                                              ISTAB1     63
CD     DDAT(JS+ 6)    = T2                                              ISTAB1     64
CD     DDAT(JS+ 7)    = T3                                              ISTAB1     65
CD     DDAT(JS+ 8)    = T4                                              ISTAB1     66
CD     DDAT(JS+ 9)    = VSMAX                                           ISTAB1     67
CD     DDAT(JS+10)    = VSMIN                                           ISTAB1     68
CD     DDAT(JS+11)    = TF                                              ISTAB1     69
CD     DDAT(JS+12)    = RC                                              ISTAB1     70
CD     DDAT(JS+13)    = XC                                              ISTAB1     71
CD     DDAT(JS+14)    = PTHR                                            ISTAB1     72
CD     DDAT(JS+15)    = KANG                                            ISTAB1     73
CD     DDAT(JS+16)    = TANG                                            ISTAB1     74
CD     DDAT(JS+17)    = DWTHR                                           ISTAB1     75
CD     DDAT(JS+18)    = ETHR                                            ISTAB1     76
CD     DDAT(JS+19)    = VS3MX                                           ISTAB1     77
CD     DDAT(JS+20)    = VS3MN                                           ISTAB1     78
CD     DDAT(JS+21)    = VANGM                                           ISTAB1     79
CD     DDAT(JS+22)    = VANGMX                                          ISTAB1     80
CD                                                                      ISTAB1     81
CD     Stabilizer states                                                ISTAB1     82
CD                                                                      ISTAB1     83
CD     XSTATE(JSS+1)  = TF block if input is bus frequency              ISTAB1     84
CD                                   : optional                         ISTAB1     85
CD     XSTATE(JSS+2)  = T5 block     : compulsory                       ISTAB1     86
CD     XSTATE(JSS+3)  = T2 block     : compulsory                       ISTAB1     87
CD     XSTATE(JSS+4)  = T4 block     : optional                         ISTAB1     88
CD     XSTATE(JSS+5)  = TANG block        : compulsory                  ISTAB1     89
CD                                                                      ISTAB1     90
CD     Stabilizer Y-variables                                           ISTAB1     91
CD                                                                      ISTAB1     92
CD     VSS(JYS+1)     = stabilizer output                               ISTAB1     93
CD                                                                      ISTAB1     94
CD   4.3 Stabilizer type 3                                              ISTAB1     95
CD                                                                      ISTAB1     96
CD     Stabilizer data                                                  ISTAB1     97
CD                                                                      ISTAB1     98
CD     IDDAT(JS+1)    = BUSR         : sensing bus number               ISTAB1     99
CD     IDDAT(JS+2)    = TYPE         : type of input signal:            ISTAB1    100
CD                                     = 1 rotor speed                  ISTAB1    101
CD                                     = 2 acceleration power           ISTAB1    102
CD                                     = 3 bus frequency                ISTAB1    103
CD                                     = 4 electrical power             ISTAB1    104
CD                                     = 5 bus voltage magnitude        ISTAB1    105
CD                                     = 6 voltage deviation from steadyISTAB1    106
CD                                        state value                   ISTAB1    107
CD     DDAT(JS+ 3)    = KS                                              ISTAB1    108
CD     DDAT(JS+ 4)    = T5                                              ISTAB1    109
CD     DDAT(JS+ 5)    = T1                                              ISTAB1    110
CD     DDAT(JS+ 6)    = T2                                              ISTAB1    111
CD     DDAT(JS+ 7)    = T3                                              ISTAB1    112
CD     DDAT(JS+ 8)    = T4                                              ISTAB1    113
CD     DDAT(JS+ 9)    = VSMAX                                           ISTAB1    114
CD     DDAT(JS+10)    = VSMIN                                           ISTAB1    115
CD     DDAT(JS+11)    = TF                                              ISTAB1    116
CD     DDAT(JS+12)    = RC                                              ISTAB1    117
CD     DDAT(JS+13)    = XC                                              ISTAB1    118
CD     DDAT(JS+14)    = PTHR                                            ISTAB1    119
CD     DDAT(JS+15)    = KANG                                            ISTAB1    120
CD     DDAT(JS+16)    = TANG                                            ISTAB1    121
CD     DDAT(JS+17)    = DWTHR                                           ISTAB1    122
CD     DDAT(JS+18)    = EIHR                                            ISTAB1    123
CD     DDAT(JS+19)    = VS3MX                                           ISTAB1    124
CD     DDAT(JS+20)    = VS3MN                                           ISTAB1    125
CD     DDAT(JS+21)    = VANGM                                           ISTAB1    126
CD     DDAT(JS+22)    = VANGMX                                          ISTAB1    127
CD                                                                      ISTAB1    128
CD     Stabilizer states                                                ISTAB1    129
CD                                                                      ISTAB1    130
CD     XSTATE(JSS+1)  = TF block if input is bus frequency              ISTAB1    131
CD                                   : optional                         ISTAB1    132
CD     XSTATE(JSS+2)  = T5 block     : compulsory                       ISTAB1    133
CD     XSTATE(JSS+3)  = T2 block     : compulsory                       ISTAB1    134
CD     XSTATE(JSS+4)  = T4 block     : optional                         ISTAB1    135
CD     XSTATE(JSS+5)  = TANG block        : compulsory                  ISTAB1    136
CD                                                                      ISTAB1    137
CD     Stabilizer Y-variables                                           ISTAB1    138
CD                                                                      ISTAB1    139
CD     VSS(JYS+1)     = stabilizer output                               ISTAB1    140
CD                                                                      ISTAB1    141
      INCLUDE 'PARX.INS'                                                ISTAB1    142
      INCLUDE 'CNMDAT.INS'                                              ISTAB1    143
      INCLUDE 'CNB1.INS'                                                ISTAB1    144
      INCLUDE 'CNB4.INS'                                                ISTAB1    145
      INCLUDE 'CNSTN.INS'                                               ISTAB1    146
      INCLUDE 'CNXSTA.INS'                                              ISTAB1    147
      INCLUDE 'CNEXC.INS'                                               ISTAB1    148
      INCLUDE 'CNIMPR.INS'                                              ISTAB1    149
      INCLUDE 'CNUNIT.INS'                                              ISTAB1    150
      INCLUDE 'CNMSG.INS'                                               ISTAB1    151
C                                                                       ISTAB1    152
      ISMAX=JS+9                                                        ISTAB1    153
      ISMIN=JS+10                                                       ISTAB1    154
      IF (IDDAT(JS+2).EQ.0) IDDAT(JS+2)=1                               ISTAB1    155
C                                                                       ISTAB1    156
C   TYPE 1 STABILIZER                                                   ISTAB1    157
C                                                                       ISTAB1    158
C                                                                       ISTAB1    159
C  INPUT TIME CONSTANTS CHECK AND RESET                                 ISTAB1    160
C                                                                       ISTAB1    161
      IF(DDAT(JS+4).LT.TMIN)THEN                                        ISTAB1    162
         WRITE(MSG(1),9040) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB1    163
     *                     ,NDGC(N)                                     ISTAB1    164
         WRITE(MSG(2),9020) 'T5',DDAT(JS+4),TMIN                        ISTAB1    165
         CALL PRTMSG(2)                                                 ISTAB1    166
         MSG(1)='STABILIZER DATA ERROR'                                 ISTAB1    167
         CALL ASTOP(MSG(1),21)                                          ISTAB1    168
      ENDIF                                                             ISTAB1    169
C                                                                       ISTAB1    170
      IF(DDAT(JS+6).LT.TMIN.AND.IDDAT(JS+6).NE.0)THEN                   ISTAB1    171
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB1    172
     *                     ,NDGC(N)                                     ISTAB1    173
         WRITE(MSG(2),9020) 'T2',DDAT(JS+6),TMIN                        ISTAB1    174
         IF(MTFLAG.EQ.0) THEN                                           ISTAB1    175
            CALL PRTMSG(2)                                              ISTAB1    176
         ELSE                                                           ISTAB1    177
         WRITE(MSG(3),9030) 'T2',0.                                     ISTAB1    178
         CALL PRTMSG(3)                                                 ISTAB1    179
         DDAT(JS+6)=0.0                                                 ISTAB1    180
         ENDIF                                                          ISTAB1    181
      ENDIF                                                             ISTAB1    182
C                                                                       ISTAB1    183
      IF(DDAT(JS+8).LT.TMIN.AND.IDDAT(JS+8).NE.0)THEN                   ISTAB1    184
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB1    185
     *                     ,NDGC(N)                                     ISTAB1    186
         WRITE(MSG(2),9020) 'T4',DDAT(JS+8),TMIN                        ISTAB1    187
         IF(MTFLAG.EQ.0) THEN                                           ISTAB1    188
            CALL PRTMSG(2)                                              ISTAB1    189
         ELSE                                                           ISTAB1    190
         WRITE(MSG(3),9030) 'T4',0.                                     ISTAB1    191
         CALL PRTMSG(3)                                                 ISTAB1    192
         DDAT(JS+8)=0.0                                                 ISTAB1    193
         ENDIF                                                          ISTAB1    194
      ENDIF                                                             ISTAB1    195
C                                                                       ISTAB1    196
      IF(DDAT(JS+16).LT.TMIN.AND.IDDAT(JS+16).NE.0.AND.                 ISTAB1    197
     *        ISTABN.NE.1)THEN                                          ISTAB1    198
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTAB1    199
     *                     ,NDGC(N)                                     ISTAB1    200
         WRITE(MSG(2),9020) 'TANG',DDAT(JS+16),TMIN                     ISTAB1    201
         IF(MTFLAG.EQ.0) THEN                                           ISTAB1    202
            CALL PRTMSG(2)                                              ISTAB1    203
         ELSE                                                           ISTAB1    204
         WRITE(MSG(3),9030) 'TANG',0.                                   ISTAB1    205
         CALL PRTMSG(3)                                                 ISTAB1    206
         DDAT(JS+16)=0.0                                                ISTAB1    207
         ENDIF                                                          ISTAB1    208
      ENDIF                                                             ISTAB1    209
C                                                                       ISTAB1    210
      IF (ISTABN.EQ.1) THEN                                             ISTAB1    211
         IDDAT(JS+15)=0                                                 ISTAB1    212
         IDDAT(JS+16)=0                                                 ISTAB1    213
         KSTATE=KSTATE+1                                                ISTAB1    214
         XSTATE(JSTATE+KSTATE)=DDAT(JS+3)*VSI1                          ISTAB1    215
C                                                                       ISTAB1    216
         IF (IDDAT(JS+6).NE.0) THEN                                     ISTAB1    217
            KSTATE=KSTATE+1                                             ISTAB1    218
            XSTATE(JSTATE+KSTATE)=0.0                                   ISTAB1    219
            IDDAT(JS+15)=JSTATE+KSTATE-NSTATE                           ISTAB1    220
         END IF                                                         ISTAB1    221
         IF (IDDAT(JS+8).NE.0) THEN                                     ISTAB1    222
            KSTATE=KSTATE+1                                             ISTAB1    223
            XSTATE(JSTATE+KSTATE)=0.0                                   ISTAB1    224
            IDDAT(JS+16)=JSTATE+KSTATE-NSTATE                           ISTAB1    225
         END IF                                                         ISTAB1    226
C                                                                       ISTAB1    227
      ELSE                                                              ISTAB1    228
C                                                                       ISTAB1    229
C   TYPE 2,3 STABILIZER                                                 ISTAB1    230
C                                                                       ISTAB1    231
         IDDAT(JS+25)=0                                                 ISTAB1    232
         KSTATE=KSTATE+1                                                ISTAB1    233
         XSTATE(JSTATE+KSTATE)=DDAT(JS+3)*VSI1                          ISTAB1    234
C                                                                       ISTAB1    235
         IF (IDDAT(JS+6).NE.0.AND.IDDAT(JS+8).NE.0) THEN                ISTAB1    236
            KSTATE=KSTATE+2                                             ISTAB1    237
            XSTATE(JSTATE+KSTATE-1)=0.0                                 ISTAB1    238
            XSTATE(JSTATE+KSTATE)=0.0                                   ISTAB1    239
            IDDAT(JS+25)=JSTATE+KSTATE-NSTATE                           ISTAB1    240
         ELSE IF (IDDAT(JS+6).NE.0) THEN                                ISTAB1    241
            KSTATE=KSTATE+1                                             ISTAB1    242
            XSTATE(JSTATE+KSTATE)=0.0                                   ISTAB1    243
         ELSE IF (IDDAT(JS+8).NE.0) THEN                                ISTAB1    244
            DDAT(JS+6)=DDAT(JS+8)                                       ISTAB1    245
            DDAT(JS+5)=DDAT(JS+7)                                       ISTAB1    246
            DDAT(JS+7)=0.0                                              ISTAB1    247
            DDAT(JS+8)=0.0                                              ISTAB1    248
            KSTATE=KSTATE+1                                             ISTAB1    249
            XSTATE(JSTATE+KSTATE)=0.0                                   ISTAB1    250
         ELSE                                                           ISTAB1    251
            DDAT(JS+5)=1.0                                              ISTAB1    252
            DDAT(JS+6)=1.0                                              ISTAB1    253
            KSTATE=KSTATE+1                                             ISTAB1    254
            XSTATE(JSTATE+KSTATE)=0.0                                   ISTAB1    255
         END IF                                                         ISTAB1    256
C                                                                       ISTAB1    257
         KSTATE=KSTATE+1                                                ISTAB1    258
         XSTATE(JSTATE+KSTATE)=0.0                                      ISTAB1    259
         IDDAT(JS+26)=JSTATE+KSTATE-NSTATE                              ISTAB1    260
C                                                                       ISTAB1    261
         IDDAT(JS+23)=0                                                 ISTAB1    262
         IDDAT(JS+24)=0                                                 ISTAB1    263
C                                                                       ISTAB1    264
      END IF                                                            ISTAB1    265
C                                                                       ISTAB1    266
      JSTATE=JSTATE+KSTATE                                              ISTAB1    267
C                                                                       ISTAB1    268
      RETURN                                                            ISTAB1    269
C                                                                       ISTAB1    270
 9000 FORMAT(' *** WARNING GENERATOR AT BUS: ',I5,' STATION: ',3A4      ISTAB1    271
     *,' GID:',A4)                                                      ISTAB1    272
 9020 FORMAT(5X,'TYPE 1, 2 OR 3 STABILIZER ',A,'=',F8.6                 ISTAB1    273
     *,' IS BELOW THE LIMIT VALUE OF ',F4.2)                            ISTAB1    274
 9030 FORMAT(5X,A,' HAS BEEN SET TO ',F4.2)                             ISTAB1    275
 9040 FORMAT(' *** DATA ERROR GENERATOR AT BUS: ',I5,' STATION: ',3A4   ISTAB1    276
     *,' GID:',A4)                                                      ISTAB1    277
      END                                                               ISTAB1    278
