CFPRIME INE4                                                            INE4        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 INE4                                                   INE4        3
CD                                                                      INE4        4
CD    TO PERFORM INITIALIZATION AND DATA CHECK FOR EXCITER TYPE 4.      INE4        5
CD                                                                      INE4        6
CD    THE DATA STRUCTURE AFTER THE INITIALIZATION IS GIVEN BELOW.       INE4        7
CD                                                                      INE4        8
CD   3.3 Exciter type 4                                                 INE4        9
CD                                                                      INE4       10
CD     Exciter data                                                     INE4       11
CD                                                                      INE4       12
CD     IDDAT(JE+ 1)   = IVTN         : sensing bus number               INE4       13
CD     DDAT(JE+ 2)    = KA                                              INE4       14
CD     DDAT(JE+ 3)    = TA                                              INE4       15
CD     DDAT(JE+ 4)    = KE                                              INE4       16
CD     DDAT(JE+ 5)    = TE                                              INE4       17
CD     DDAT(JE+ 6)    = SE(VSAT) or AEX                                 INE4       18
CD     DDAT(JE+ 7)    = SE(0.75VSAT) or BEX                             INE4       19
CD     DDAT(JE+ 8)    = VSAT                                            INE4       20
CD     DDAT(JE+ 9)    = KC                                              INE4       21
CD     DDAT(JE+10)    = KF                                              INE4       22
CD     DDAT(JE+11)    = TF                                              INE4       23
CD     DDAT(JE+12)    = TC                                              INE4       24
CD     DDAT(JE+13)    = TB                                              INE4       25
CD     DDAT(JE+14)    = VAMAX                                           INE4       26
CD     DDAT(JE+15)    = VAMIN                                           INE4       27
CD     DDAT(JE+16)    = VEMIN                                           INE4       28
CD     DDAT(JE+17)    = KR                                              INE4       29
CD     DDAT(JE+18)    = TR                                              INE4       30
CD     DDAT(JE+19)    = RC                                              INE4       31
CD     DDAT(JE+20)    = XC                                              INE4       32
CD     DDAT(JE+21)    = XDE                                             INE4       33
CD     DDAT(JE+22)    = X'DE                                            INE4       34
CD     DDAT(JE+23)    = KN                                              INE4       35
CD     DDAT(JE+24)    = EFDN                                            INE4       36
CD     DDAT(JE+25)    = KLN                                             INE4       37
CD     DDAT(JE+26)    = VLN                                             INE4       38
CD     DDAT(JE+27)    = VFEMAX                                          INE4       39
CD     DDAT(JE+28)    = LVF                                             INE4       40
CD                                                                      INE4       41
CD     Exciter states                                                   INE4       42
CD                                                                      INE4       43
CD     XSTATE(JES+1)  = TR block     : compulsory                       INE4       44
CD     XSTATE(JES+2)  = TF block     : compulsory                       INE4       45
CD     XSTATE(JES+3)  = TB block     : compulsory                       INE4       46
CD     XSTATE(JES+4)  = TA block     : compulsory                       INE4       47
CD     XSTATE(JES+5)  = TE block     : compulsory                       INE4       48
CD                                                                      INE4       49
CD     Exciter Y-variables                                              INE4       50
CD                                                                      INE4       51
CD     VREG(JYE+1)    = VC (input to the TR block)                      INE4       52
CD     VREF(JYE+2)    = reference value                                 INE4       53
CD                                                                      INE4       54
      INCLUDE 'PARX.INS'                                                INE4       55
      INCLUDE 'CNMDAT.INS'                                              INE4       56
      INCLUDE 'CNSTN.INS'                                               INE4       57
      INCLUDE 'CNB1.INS'                                                INE4       58
      INCLUDE 'CNB4.INS'                                                INE4       59
      INCLUDE 'CNMSTA.INS'                                              INE4       60
      INCLUDE 'CNXSTA.INS'                                              INE4       61
      INCLUDE 'CNB8.INS'                                                INE4       62
      INCLUDE 'CNEXC.INS'                                               INE4       63
      INCLUDE 'CNMYVA.INS'                                              INE4       64
      INCLUDE 'CNYVAR.INS'                                              INE4       65
      INCLUDE 'CNUNIT.INS'                                              INE4       66
      INCLUDE 'CNMSG.INS'                                               INE4       67
      INCLUDE 'CNXDOT.INS'                                              INE4       68
C                                                                       INE4       69
      DATA BIG/99.9/                                                    INE4       70
C                                                                       INE4       71
C   IEXN = 4                                                            INE4       72
C                                                                       INE4       73
C                                                                       INE4       74
C  INPUT TIME CONSTANTS CHECK AND RESET                                 INE4       75
C                                                                       INE4       76
      IF(DDAT(JE+3).LT.TMIN.AND.IDDAT(JE+3).NE.0)THEN                   INE4       77
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE4       78
     *                     ,NDGC(N)                                     INE4       79
         WRITE(MSG(2),9020)                                             INE4       80
         IF(MTFLAG.EQ.0) THEN                                           INE4       81
            WRITE(MSG(3),9030) 'TA',DDAT(JE+3),TMIN                     INE4       82
         ELSE                                                           INE4       83
            WRITE(MSG(3),9030) 'TA',DDAT(JE+3),TMIN,'TA',0.0            INE4       84
            DDAT(JE+3)=0.0                                              INE4       85
         ENDIF                                                          INE4       86
         CALL PRTMSG(3)                                                 INE4       87
      ENDIF                                                             INE4       88
C                                                                       INE4       89
      IF (DDAT(JE+5).LE.0.0) THEN                                       INE4       90
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE4       91
     *                     ,NDGC(N)                                     INE4       92
         WRITE(MSG(2),9020)                                             INE4       93
         WRITE(MSG(3),9050) DDAT(JE+5)                                  INE4       94
         CALL PRTMSG(3)                                                 INE4       95
         CALL ASTOP('INE4: FATAL ERROR',17)                             INE4       96
      ELSE IF (DDAT(JE+5).LT.10.0*TMIN) THEN                            INE4       97
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE4       98
     *                     ,NDGC(N)                                     INE4       99
         WRITE(MSG(2),9020)                                             INE4      100
         IF(MTFLAG.EQ.0) THEN                                           INE4      101
            WRITE(MSG(3),9030) 'TE',DDAT(JE+5),10.0*TMIN                INE4      102
         ELSE                                                           INE4      103
            WRITE(MSG(3),9030) 'TE',DDAT(JE+5),10.0*TMIN,'TE',10.0*TMIN INE4      104
            DDAT(JE+5)=10.0*TMIN                                        INE4      105
         ENDIF                                                          INE4      106
         CALL PRTMSG(3)                                                 INE4      107
      ENDIF                                                             INE4      108
C                                                                       INE4      109
      IF(DDAT(JE+11).LT.TMIN.AND.IDDAT(JE+11).NE.0)THEN                 INE4      110
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE4      111
     *                     ,NDGC(N)                                     INE4      112
         WRITE(MSG(2),9020)                                             INE4      113
         IF(MTFLAG.EQ.0) THEN                                           INE4      114
            WRITE(MSG(3),9030) 'TF',DDAT(JE+11),TMIN                    INE4      115
            CALL PRTMSG(2)                                              INE4      116
         ELSE                                                           INE4      117
            WRITE(MSG(3),9030) 'TF',DDAT(JE+11),TMIN,'TF',0.0           INE4      118
            DDAT(JE+11)=0.0                                             INE4      119
         ENDIF                                                          INE4      120
         CALL PRTMSG(3)                                                 INE4      121
      ENDIF                                                             INE4      122
C                                                                       INE4      123
      IF(DDAT(JE+13).LT.TMIN.AND.IDDAT(JE+13).NE.0)THEN                 INE4      124
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE4      125
     *                     ,NDGC(N)                                     INE4      126
         WRITE(MSG(2),9020)                                             INE4      127
         IF(MTFLAG.EQ.0) THEN                                           INE4      128
            WRITE(MSG(3),9030) 'TB',DDAT(JE+13),TMIN                    INE4      129
         ELSE                                                           INE4      130
            WRITE(MSG(3),9030) 'TB',DDAT(JE+13),TMIN,'TB',0.0           INE4      131
            DDAT(JE+13)=0.0                                             INE4      132
         ENDIF                                                          INE4      133
         CALL PRTMSG(3)                                                 INE4      134
      ENDIF                                                             INE4      135
C                                                                       INE4      136
      IF(DDAT(JE+18).LT.TMIN.AND.IDDAT(JE+18).NE.0)THEN                 INE4      137
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE4      138
     *                     ,NDGC(N)                                     INE4      139
         WRITE(MSG(2),9020)                                             INE4      140
         IF(MTFLAG.EQ.0) THEN                                           INE4      141
            WRITE(MSG(3),9030) 'TR',DDAT(JE+18),TMIN                    INE4      142
         ELSE                                                           INE4      143
            WRITE(MSG(3),9030) 'TR',DDAT(JE+18),TMIN,'TR',0.0           INE4      144
            DDAT(JE+18)=0.0                                             INE4      145
         ENDIF                                                          INE4      146
         CALL PRTMSG(3)                                                 INE4      147
      ENDIF                                                             INE4      148
C                                                                       INE4      149
C   DATA PREPARATION AND INPUT DATA PRINTOUT                            INE4      150
C                                                                       INE4      151
      IF (IDDAT(JE+14).EQ.0.AND.IDDAT(JE+15).EQ.0) THEN                 INE4      152
         DDAT(JE+14)=BIG                                                INE4      153
         DDAT(JE+15)=-BIG                                               INE4      154
      ENDIF                                                             INE4      155
      IF (IDDAT(JE+27).EQ.0) DDAT(JE+27)=BIG                            INE4      156
      IF(IDDAT(JE+8).NE.0)CALL EXSATF                                   INE4      157
C                                                                       INE4      158
      VE=EFDN                                                           INE4      159
C                                                                       INE4      160
C  RECTIFIER REGULATION                                                 INE4      161
C                                                                       INE4      162
      IF (IDDAT(JE+9).EQ.0)THEN                                         INE4      163
C                                                                       INE4      164
C   KC=0                                                                INE4      165
C                                                                       INE4      166
      VTH=EFDN                                                          INE4      167
C                                                                       INE4      168
C   KC NE 0                                                             INE4      169
C                                                                       INE4      170
      ELSE                                                              INE4      171
      CFKC=CFDN*DDAT(JE+9)                                              INE4      172
      VTH=EFDN+0.577*CFKC                                               INE4      173
      FACT=CFKC/VTH                                                     INE4      174
      IF (FACT.LT.0.433) GO TO 90                                       INE4      175
      VTH=EFDN/1.732+CFKC                                               INE4      176
      FACT=CFKC/VTH                                                     INE4      177
      IF (FACT.GT.0.75) GO TO 90                                        INE4      178
      VTH=(EFDN*EFDN+CFKC*CFKC)/0.75                                    INE4      179
      VTH=SQRT(VTH)                                                     INE4      180
      FACT=CFKC/VTH                                                     INE4      181
      IF (FACT.LE.0.75.AND.FACT.GE.0.433) GO TO 90                      INE4      182
C                                                                       INE4      183
      WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)          INE4      184
     *                  ,NDGC(N)                                        INE4      185
      WRITE(MSG(2),9010)                                                INE4      186
      CALL PRTMSG(2)                                                    INE4      187
      IEEXIN=1                                                          INE4      188
C                                                                       INE4      189
C    ENDIF KC.NE.0                                                      INE4      190
C                                                                       INE4      191
      ENDIF                                                             INE4      192
C                                                                       INE4      193
 90   VE=VTH+EFDN*DDAT(JE+22)                                           INE4      194
C                                                                       INE4      195
C   EXCITER SATURATION BLOCK                                            INE4      196
C                                                                       INE4      197
      SE=DDAT(JE+6)*EXP(DDAT(JE+7)*VE)/VE                               INE4      198
      SEKX=VE*(SE+DDAT(JE+4))                                           INE4      199
      VEMAX=(DDAT(JE+27)-(DDAT(JE+21)-DDAT(JE+22))*CFDN)*VE/SEKX        INE4      200
      SEKX=SEKX+EFDN*(DDAT(JE+21)-DDAT(JE+22))                          INE4      201
C                                                                       INE4      202
C   RATE FEEDBACK BLOCK                                                 INE4      203
C                                                                       INE4      204
      XRATE=EFDN                                                        INE4      205
      IF(XRATE.GT.DDAT(JE+24)) THEN                                     INE4      206
      XRATE=DDAT(JE+24)*DDAT(JE+10)+(XRATE-DDAT(JE+24))*                INE4      207
     +      DDAT(JE+23)                                                 INE4      208
      ELSE                                                              INE4      209
      XRATE=XRATE*DDAT(JE+10)                                           INE4      210
      END IF                                                            INE4      211
      XSTATE(JSTATE+2)=XRATE                                            INE4      212
C                                                                       INE4      213
      VR=SEKX                                                           INE4      214
C                                                                       INE4      215
      VR=VR/(DDAT(JE+17)*EFDN)                                          INE4      216
C                                                                       INE4      217
      XSTATE(JSTATE+3)=VR/DDAT(JE+2)                                    INE4      218
      XSTATE(JSTATE+4)=VR                                               INE4      219
C                                                                       INE4      220
      XDFACT(JSTATE+4)=DDAT(JE+2)                                       INE4      221
C                                                                       INE4      222
      XSTATE(JSTATE+5)=VE                                               INE4      223
      VREF(JYE+2)=XSTATE(JSTATE+1)+XSTATE(JSTATE+3)                     INE4      224
C                                                                       INE4      225
C     SET INITIAL CASE NUMBER USED IN ETMSP/IMP (DEFAULT=1)             INE4      226
C                                                                       INE4      227
      IDDAT(JE+29)=1                                                    INE4      228
C                                                                       INE4      229
      JSTATE=JSTATE+5                                                   INE4      230
      JY=JY+2                                                           INE4      231
C                                                                       INE4      232
C     DETERMINE IF A SUBDIVISION OF THE NORMAL INTEGRATION STEP         INE4      233
C     SHOULD BE USED. IF SO, CALCULATE THE LARGEST STEP SIZE PERMITTED  INE4      234
C                                                                       INE4      235
      IF (IDDAT(JE+10).NE.0.AND.IDDAT(JE+11).NE.0) THEN                 INE4      236
         IDDAT(JE+30)=1                                                 INE4      237
         DDAT(JE+31)=DDAT(JE+11)*DDAT(JE+5)                             INE4      238
     *               /DDAT(JE+2)                                        INE4      239
         IF (DDAT(JE+10).GT.DDAT(JE+23)) THEN                           INE4      240
            DDAT(JE+31)=DDAT(JE+31)/DDAT(JE+10)                         INE4      241
         ELSE                                                           INE4      242
            DDAT(JE+31)=DDAT(JE+31)/DDAT(JE+23)                         INE4      243
         END IF                                                         INE4      244
         IF (DDAT(JE+28).GT.0.5.AND.IDDAT(JE+13).NE.0) THEN             INE4      245
            DDAT(JE+31)=DDAT(JE+31)*DDAT(JE+13)                         INE4      246
            IF (IDDAT(JE+12).NE.0) DDAT(JE+31)=DDAT(JE+31)              INE4      247
     *                                         /(1.0+DDAT(JE+12))       INE4      248
         END IF                                                         INE4      249
         IF (IDDAT(JE+3).NE.0) DDAT(JE+31)=DDAT(JE+31)*DDAT(JE+3)       INE4      250
         IF (DDAT(JE+31).LT.DTMIN) DDAT(JE+31)=DTMIN                    INE4      251
      ELSE                                                              INE4      252
         IDDAT(JE+30)=0                                                 INE4      253
      END IF                                                            INE4      254
C                                                                       INE4      255
      IF(VR.GT.DDAT(JE+14).OR.VR.LT.DDAT(JE+15)) THEN                   INE4      256
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE4      257
     *                     ,NDGC(N)                                     INE4      258
         WRITE(MSG(2),9020)                                             INE4      259
         WRITE(MSG(3),9100)                                             INE4      260
         WRITE(MSG(4),9110) VR,DDAT(JE+14),DDAT(JE+15)                  INE4      261
         CALL PRTMSG(4)                                                 INE4      262
      ENDIF                                                             INE4      263
      IF(VE.GT.VEMAX.OR.VE.LT.DDAT(JE+16))THEN                          INE4      264
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE4      265
     *                     ,NDGC(N)                                     INE4      266
         WRITE(MSG(2),9020)                                             INE4      267
         WRITE(MSG(3),9200)                                             INE4      268
         WRITE(MSG(4),9210) VE,VEMAX,DDAT(JE+16)                        INE4      269
         CALL PRTMSG(4)                                                 INE4      270
      ENDIF                                                             INE4      271
C                                                                       INE4      272
      RETURN                                                            INE4      273
C                                                                       INE4      274
 9000 FORMAT(' *** WARNING GENERATOR AT BUS:',I5,' STATION: ',3A4       INE4      275
     *,' GID',A4)                                                       INE4      276
 9010 FORMAT(5X,'TYPE 4 EXCITER (WSCC TYPE FH, IEEE TYPE AC3A) FEX'     INE4      277
     *,' FUNCTION OUT OF RANGE')                                        INE4      278
 9020 FORMAT(5X,'TYPE 4 EXCITER (WSCC TYPE FH, IEEE TYPE AC3A)')        INE4      279
 9030 FORMAT(5X,A,'=',F8.6,' IS BELOW THE LIMIT VALUE OF',F5.2,:,2X,A   INE4      280
     *,' HAS BEEN SET TO',F5.2)                                         INE4      281
 9050 FORMAT(5X,'TE=',F8.6,' IS LESS THAN OR EQUAL TO ZERO.')           INE4      282
 9100 FORMAT(5X,'VA-X4 VIOLATES LIMITS:')                               INE4      283
 9110 FORMAT(5X,'VA = ',G12.5,' VAMAX = ',G12.5,' VAMIN = ',G12.5)      INE4      284
 9200 FORMAT(5X,'VE-X5 VIOLATES LIMITS:')                               INE4      285
 9210 FORMAT(5X,'VE = ',G12.5,' VEMAX = ',G12.5,' VEMIN = ',G12.5)      INE4      286
C                                                                       INE4      287
      END                                                               INE4      288
