CFPRIME ISTA12                                                          ISTA12      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 ISTA12(ISMAX,ISMIN)                                    ISTA12      3
CD                                                                      ISTA12      4
CD    TO PERFORM INITIALIZATION AND DATA CHECK FOR STABILIZER TYPE 12.  ISTA12      5
CD                                                                      ISTA12      6
CD    THE DATA STRUCTURE AFTER THE INITIALIZATION IS GIVEN BELOW.       ISTA12      7
CD                                                                      ISTA12      8
CD   4.11 Stabilizer type 12                                            ISTA12      9
CD                                                                      ISTA12     10
CD     Stabilizer data                                                  ISTA12     11
CD                                                                      ISTA12     12
CD     IDDAT(JS+ 1)   = BUSR1        : sensing bus number for signal #1 ISTA12     13
CD     IDDAT(JS+ 2)   = TYPE1        : type of input for signal #1:     ISTA12     14
CD                                     = 1 rotor speed                  ISTA12     15
CD                                     = 2 acceleration power           ISTA12     16
CD                                     = 3 bus frequency                ISTA12     17
CD                                     = 4 electrical power             ISTA12     18
CD                                     = 5 bus voltage magnitude        ISTA12     19
CD                                     = 6 voltage deviation from steadyISTA12     20
CD                                        state value                   ISTA12     21
CD     IDDAT(JS+3)    = BUSR2        : sensing bus number for input #2  ISTA12     22
CD     IDDAT(JS+4)    = TYPE2        : type of input for signal #2:     ISTA12     23
CD                                     = 1 rotor speed                  ISTA12     24
CD                                     = 2 acceleration power           ISTA12     25
CD                                     = 3 bus frequency                ISTA12     26
CD                                     = 4 electrical power             ISTA12     27
CD                                     = 5 bus voltage magnitude        ISTA12     28
CD                                     = 6 voltage deviation from steadyISTA12     29
CD                                        state value                   ISTA12     30
CD     DDAT(JS+ 5)    = K1                                              ISTA12     31
CD     DDAT(JS+ 6)    = T1                                              ISTA12     32
CD     DDAT(JS+ 7)    = K2                                              ISTA12     33
CD     DDAT(JS+ 8)    = T2                                              ISTA12     34
CD     DDAT(JS+ 9)    = T'Q0                                            ISTA12     35
CD     DDAT(JS+10)    = TQ0                                             ISTA12     36
CD     DDAT(JS+11)    = T'Q1                                            ISTA12     37
CD     DDAT(JS+12)    = TQ1                                             ISTA12     38
CD     DDAT(JS+13)    = T'Q2                                            ISTA12     39
CD     DDAT(JS+14)    = TQ2                                             ISTA12     40
CD     DDAT(JS+15)    = T'Q3                                            ISTA12     41
CD     DDAT(JS+16)    = TQ3                                             ISTA12     42
CD     DDAT(JS+17)    = VSMAX                                           ISTA12     43
CD     DDAT(JS+18)    = VSMIN                                           ISTA12     44
CD     DDAT(JS+19)    = TF                                              ISTA12     45
CD     DDAT(JS+20)    = RC                                              ISTA12     46
CD     DDAT(JS+21)    = XC                                              ISTA12     47
CD     DDAT(JS+22)    = VCU                                             ISTA12     48
CD     DDAT(JS+23)    = VCL                                             ISTA12     49
CD     DDAT(JS+24)    = PTHR                                            ISTA12     50
CD                                                                      ISTA12     51
CD     Stabilizer states                                                ISTA12     52
CD                                                                      ISTA12     53
CD     XSTATE(JSS+1)  = TF block if input is bus frequency              ISTA12     54
CD                                                  : optional          ISTA12     55
CD     XSTATE(JSS+2)  = T1 block                    : optional          ISTA12     56
CD     XSTATE(JSS+3)  = T2 block                    : optional          ISTA12     57
CD     XSTATE(JSS+4)  = TQ0 block                   : optional          ISTA12     58
CD     XSTATE(JSS+5)  = TQ1 block                   : optional          ISTA12     59
CD     XSTATE(JSS+6)  = TQ2 block                   : optional          ISTA12     60
CD     XSTATE(JSS+7)  = TQ3 block                   : optional          ISTA12     61
CD                                                                      ISTA12     62
CD     Stabilizer Y-variables                                           ISTA12     63
CD                                                                      ISTA12     64
CD     VSS(JYS+1)     = stabilizer output                               ISTA12     65
CD                                                                      ISTA12     66
      INCLUDE 'PARX.INS'                                                ISTA12     67
      INCLUDE 'CNMDAT.INS'                                              ISTA12     68
      INCLUDE 'CNB1.INS'                                                ISTA12     69
      INCLUDE 'CNB4.INS'                                                ISTA12     70
      INCLUDE 'CNSTN.INS'                                               ISTA12     71
      INCLUDE 'CNEXC.INS'                                               ISTA12     72
      INCLUDE 'CNXSTA.INS'                                              ISTA12     73
      INCLUDE 'CNIMPR.INS'                                              ISTA12     74
      INCLUDE 'CNUNIT.INS'                                              ISTA12     75
      INCLUDE 'CNMSG.INS'                                               ISTA12     76
C                                                                       ISTA12     77
      DATA BIG/99.9/                                                    ISTA12     78
C                                                                       ISTA12     79
C  INPUT TIME CONSTANTS CHECK AND RESET                                 ISTA12     80
C                                                                       ISTA12     81
      IF(DDAT(JS+6).LT.TMIN.AND.IDDAT(JS+6).NE.0)THEN                   ISTA12     82
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTA12     83
     *            ,NDGC(N)                                              ISTA12     84
         WRITE(MSG(2),9020) 'T1',DDAT(JS+6),TMIN                        ISTA12     85
         IF(MTFLAG.EQ.0) THEN                                           ISTA12     86
            CALL PRTMSG(2)                                              ISTA12     87
         ELSE                                                           ISTA12     88
            WRITE(MSG(3),9030) 'T1',0.0                                 ISTA12     89
            CALL PRTMSG(3)                                              ISTA12     90
            DDAT(JS+6)=0.0                                              ISTA12     91
         ENDIF                                                          ISTA12     92
      ENDIF                                                             ISTA12     93
C                                                                       ISTA12     94
      IF(DDAT(JS+8).LT.TMIN.AND.IDDAT(JS+8).NE.0)THEN                   ISTA12     95
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTA12     96
     *            ,NDGC(N)                                              ISTA12     97
         WRITE(MSG(2),9020) 'T2',DDAT(JS+8),TMIN                        ISTA12     98
         IF(MTFLAG.EQ.0) THEN                                           ISTA12     99
            CALL PRTMSG(2)                                              ISTA12    100
         ELSE                                                           ISTA12    101
            WRITE(MSG(3),9030) 'T2',0.0                                 ISTA12    102
            CALL PRTMSG(3)                                              ISTA12    103
            DDAT(JS+8)=0.0                                              ISTA12    104
         ENDIF                                                          ISTA12    105
      ENDIF                                                             ISTA12    106
C                                                                       ISTA12    107
      IF(DDAT(JS+10).LT.TMIN.AND.IDDAT(JS+10).NE.0)THEN                 ISTA12    108
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTA12    109
     *            ,NDGC(N)                                              ISTA12    110
         WRITE(MSG(2),9020) 'TQ0',DDAT(JS+10),TMIN                      ISTA12    111
         IF(MTFLAG.EQ.0) THEN                                           ISTA12    112
            CALL PRTMSG(2)                                              ISTA12    113
         ELSE                                                           ISTA12    114
            WRITE(MSG(3),9030) 'TQ0',0.0                                ISTA12    115
            CALL PRTMSG(3)                                              ISTA12    116
            DDAT(JS+10)=0.0                                             ISTA12    117
         ENDIF                                                          ISTA12    118
      ENDIF                                                             ISTA12    119
C                                                                       ISTA12    120
      IF(DDAT(JS+12).LT.TMIN.AND.IDDAT(JS+12).NE.0)THEN                 ISTA12    121
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTA12    122
     *            ,NDGC(N)                                              ISTA12    123
         WRITE(MSG(2),9020) 'TQ1',DDAT(JS+12),TMIN                      ISTA12    124
         IF(MTFLAG.EQ.0) THEN                                           ISTA12    125
            CALL PRTMSG(2)                                              ISTA12    126
         ELSE                                                           ISTA12    127
            WRITE(MSG(3),9030) 'TQ1',0.0                                ISTA12    128
            CALL PRTMSG(3)                                              ISTA12    129
            DDAT(JS+12)=0.0                                             ISTA12    130
         ENDIF                                                          ISTA12    131
      ENDIF                                                             ISTA12    132
C                                                                       ISTA12    133
      IF(DDAT(JS+14).LT.TMIN.AND.IDDAT(JS+14).NE.0)THEN                 ISTA12    134
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTA12    135
     *            ,NDGC(N)                                              ISTA12    136
         WRITE(MSG(2),9020) 'TQ2',DDAT(JS+14),TMIN                      ISTA12    137
         IF(MTFLAG.EQ.0) THEN                                           ISTA12    138
            CALL PRTMSG(2)                                              ISTA12    139
         ELSE                                                           ISTA12    140
            WRITE(MSG(3),9030) 'TQ2',0.0                                ISTA12    141
            CALL PRTMSG(3)                                              ISTA12    142
            DDAT(JS+14)=0.0                                             ISTA12    143
         ENDIF                                                          ISTA12    144
      ENDIF                                                             ISTA12    145
C                                                                       ISTA12    146
      IF(DDAT(JS+16).LT.TMIN.AND.IDDAT(JS+16).NE.0)THEN                 ISTA12    147
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTA12    148
     *            ,NDGC(N)                                              ISTA12    149
         WRITE(MSG(2),9020) 'TQ3',DDAT(JS+16),TMIN                      ISTA12    150
         IF(MTFLAG.EQ.0) THEN                                           ISTA12    151
            CALL PRTMSG(2)                                              ISTA12    152
         ELSE                                                           ISTA12    153
            WRITE(MSG(3),9030) 'TQ3',0.0                                ISTA12    154
            CALL PRTMSG(3)                                              ISTA12    155
            DDAT(JS+16)=0.0                                             ISTA12    156
         ENDIF                                                          ISTA12    157
      ENDIF                                                             ISTA12    158
C                                                                       ISTA12    159
      IF (IDDAT(JS+2).EQ.0) IDDAT(JS+2)=1                               ISTA12    160
      IF (IDDAT(JS+4).EQ.0) IDDAT(JS+4)=1                               ISTA12    161
C                                                                       ISTA12    162
C     DDAT(JS+25) THROUGH DDAT(JS+30) ARE USED TO STORE THE             ISTA12    163
C     SUBSCRIPTS OF OPTIONAL BLOCKS. IF ZERO, THE CORRESPONDING         ISTA12    164
C     BLOCK IS NOT PRESENT.                                             ISTA12    165
C                                                                       ISTA12    166
      IDDAT(JS+25)=0                                                    ISTA12    167
      IDDAT(JS+26)=0                                                    ISTA12    168
      IDDAT(JS+27)=0                                                    ISTA12    169
      IDDAT(JS+28)=0                                                    ISTA12    170
      IDDAT(JS+29)=0                                                    ISTA12    171
      IDDAT(JS+30)=0                                                    ISTA12    172
C                                                                       ISTA12    173
      IF (IDDAT(JS+17).EQ.0.AND.IDDAT(JS+18).EQ.0) THEN                 ISTA12    174
         DDAT(JS+17)=BIG                                                ISTA12    175
         DDAT(JS+18)=-BIG                                               ISTA12    176
      END IF                                                            ISTA12    177
        IF (DDAT(JS+17).LT.0.0.OR.DDAT(JS+18).GT.0.0) THEN              ISTA12    178
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       ISTA12    179
     *                     ,NDGC(N)                                     ISTA12    180
         WRITE(MSG(2),9060) DDAT(JS+17),DDAT(JS+18)                     ISTA12    181
         CALL PRTMSG(2)                                                 ISTA12    182
        END IF                                                          ISTA12    183
      ISMAX=JS+17                                                       ISTA12    184
      ISMIN=JS+18                                                       ISTA12    185
C                                                                       ISTA12    186
      IF (IDDAT(JS+22).EQ.0.AND.IDDAT(JS+23).EQ.0) THEN                 ISTA12    187
         DDAT(JS+22)=BIG                                                ISTA12    188
         DDAT(JS+23)=-BIG                                               ISTA12    189
      END IF                                                            ISTA12    190
C                                                                       ISTA12    191
      IF (IDDAT(JS+6).NE.0) THEN                                        ISTA12    192
         KSTATE=KSTATE+1                                                ISTA12    193
         XSTATE(JSTATE+KSTATE)=DDAT(JS+5)*VSI1                          ISTA12    194
         IDDAT(JS+25)=JSTATE+KSTATE-NSTATE                              ISTA12    195
      END IF                                                            ISTA12    196
      IF (IDDAT(JS+8).NE.0) THEN                                        ISTA12    197
         KSTATE=KSTATE+1                                                ISTA12    198
         XSTATE(JSTATE+KSTATE)=DDAT(JS+7)*VSI2                          ISTA12    199
         IDDAT(JS+26)=JSTATE+KSTATE-NSTATE                              ISTA12    200
      END IF                                                            ISTA12    201
      VSUM=DDAT(JS+5)*VSI1+DDAT(JS+7)*VSI2                              ISTA12    202
      IF (IDDAT(JS+10).NE.0) THEN                                       ISTA12    203
         KSTATE=KSTATE+1                                                ISTA12    204
         XSTATE(JSTATE+KSTATE)=VSUM                                     ISTA12    205
         IDDAT(JS+27)=JSTATE+KSTATE-NSTATE                              ISTA12    206
         VSUM=0.0                                                       ISTA12    207
      END IF                                                            ISTA12    208
      IF (IDDAT(JS+12).NE.0) THEN                                       ISTA12    209
         KSTATE=KSTATE+1                                                ISTA12    210
         XSTATE(JSTATE+KSTATE)=VSUM                                     ISTA12    211
         IDDAT(JS+28)=JSTATE+KSTATE-NSTATE                              ISTA12    212
      END IF                                                            ISTA12    213
      IF (IDDAT(JS+14).NE.0) THEN                                       ISTA12    214
         KSTATE=KSTATE+1                                                ISTA12    215
         XSTATE(JSTATE+KSTATE)=VSUM                                     ISTA12    216
         IDDAT(JS+29)=JSTATE+KSTATE-NSTATE                              ISTA12    217
      END IF                                                            ISTA12    218
      IF (IDDAT(JS+16).NE.0) THEN                                       ISTA12    219
         KSTATE=KSTATE+1                                                ISTA12    220
         XSTATE(JSTATE+KSTATE)=VSUM                                     ISTA12    221
         IDDAT(JS+30)=JSTATE+KSTATE-NSTATE                              ISTA12    222
      END IF                                                            ISTA12    223
C                                                                       ISTA12    224
C     IDDAT(JS+31) = 1 -- NORMAL CASE WITH OUTPUT SWITCH                ISTA12    225
C                         AT "ON" POSITION                              ISTA12    226
C     IDDAT(JS+31) = 0 -- CASE WITH OUTPUT SWITCH AT "OFF" POSITION     ISTA12    227
C                                                                       ISTA12    228
C     THIS FLAG IS USED ONLY IN IMPLICIT INTEGRATION METHOD             ISTA12    229
C                                                                       ISTA12    230
      IDDAT(JS+31)=1                                                    ISTA12    231
C                                                                       ISTA12    232
      JSTATE=JSTATE+KSTATE                                              ISTA12    233
C                                                                       ISTA12    234
      RETURN                                                            ISTA12    235
C                                                                       ISTA12    236
 9000 FORMAT(' *** WARNING GENERATOR AT BUS: ',I5,' STATION: ',3A4      ISTA12    237
     *,' GID:',A4)                                                      ISTA12    238
 9020 FORMAT(5X,'TYPE 12 STABILIZER ',A,'=',F8.6                        ISTA12    239
     *,' IS BELOW THE LIMIT VALUE OF ',F4.2)                            ISTA12    240
 9030 FORMAT(5X,A,' HAS BEEN SET TO ',F4.2)                             ISTA12    241
 9060 FORMAT(5X,'TYPE 12 STABILIZER DATA ERROR. VSMAX=',F10.5           ISTA12    242
     *,' VSMIN=',F10.5)                                                 ISTA12    243
      END                                                               ISTA12    244
