CFPRIME INE1N2                                                          INE1N2      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 INE1N2                                                 INE1N2      3
CD                                                                      INE1N2      4
CD    TO PERFORM INITIALIZATION AND DATA CHECK FOR EXCITER TYPES 1 AND 2INE1N2      5
CD                                                                      INE1N2      6
CD    THE DATA STRUCTURE AFTER THE INITIALIZATION IS GIVEN BELOW.       INE1N2      7
CD                                                                      INE1N2      8
CD   3.1 Exciter types 1 and 2                                          INE1N2      9
CD                                                                      INE1N2     10
CD     Exciter data                                                     INE1N2     11
CD                                                                      INE1N2     12
CD     IDDAT(JE+1)    = IVTN         : sensing bus number               INE1N2     13
CD     DDAT(JE+ 2)    = KA                                              INE1N2     14
CD     DDAT(JE+ 3)    = TA                                              INE1N2     15
CD     DDAT(JE+ 4)    = KE                                              INE1N2     16
CD     DDAT(JE+ 5)    = TE                                              INE1N2     17
CD     DDAT(JE+ 6)    = SE(VSAT) or AEX                                 INE1N2     18
CD     DDAT(JE+ 7)    = SE(0.75VSAT) or BEX                             INE1N2     19
CD     DDAT(JE+ 8)    = VSAT                                            INE1N2     20
CD     DDAT(JE+ 9)    = (reserved for future use)                       INE1N2     21
CD     DDAT(JE+10)    = KF                                              INE1N2     22
CD     DDAT(JE+11)    = TF                                              INE1N2     23
CD     DDAT(JE+12)    = TC                                              INE1N2     24
CD     DDAT(JE+13)    = TB                                              INE1N2     25
CD     DDAT(JE+14)    = VRMAX                                           INE1N2     26
CD     DDAT(JE+15)    = VRMIN                                           INE1N2     27
CD     DDAT(JE+16)    = ETV                                             INE1N2     28
CD     DDAT(JE+17)    = ETMIN                                           INE1N2     29
CD     DDAT(JE+18)    = TR                                              INE1N2     30
CD     DDAT(JE+19)    = RC                                              INE1N2     31
CD     DDAT(JE+20)    = XC                                              INE1N2     32
CD                                                                      INE1N2     33
CD     Exciter states                                                   INE1N2     34
CD                                                                      INE1N2     35
CD     XSTATE(JES+1)  = TR block     : compulsory                       INE1N2     36
CD     XSTATE(JES+2)  = TF block     : compulsory                       INE1N2     37
CD     XSTATE(JES+3)  = TB block     : compulsory                       INE1N2     38
CD     XSTATE(JES+4)  = TA block     : compulsory                       INE1N2     39
CD     XSTATE(JES+5)  = TE block     : compulsory                       INE1N2     40
CD                                                                      INE1N2     41
CD     Exciter Y-variables                                              INE1N2     42
CD                                                                      INE1N2     43
CD     VREG(JYE+1)    = VC (input to the TR block)                      INE1N2     44
CD     VREF(JYE+2)    = reference value                                 INE1N2     45
CD                                                                      INE1N2     46
      INCLUDE 'PARX.INS'                                                INE1N2     47
      INCLUDE 'CNMDAT.INS'                                              INE1N2     48
      INCLUDE 'CNMSTA.INS'                                              INE1N2     49
      INCLUDE 'CNXSTA.INS'                                              INE1N2     50
      INCLUDE 'CNEXC.INS'                                               INE1N2     51
      INCLUDE 'CNSTN.INS'                                               INE1N2     52
      INCLUDE 'CNB1.INS'                                                INE1N2     53
      INCLUDE 'CNB4.INS'                                                INE1N2     54
      INCLUDE 'CNMYVA.INS'                                              INE1N2     55
      INCLUDE 'CNYVAR.INS'                                              INE1N2     56
      INCLUDE 'CNUNIT.INS'                                              INE1N2     57
      INCLUDE 'CNMSG.INS'                                               INE1N2     58
      INCLUDE 'CNXDOT.INS'                                              INE1N2     59
C                                                                       INE1N2     60
C                                                                       INE1N2     61
C  IEX=1 & 2                                                            INE1N2     62
C                                                                       INE1N2     63
C                                                                       INE1N2     64
C  INPUT TIME CONSTANTS CHECK AND RESET                                 INE1N2     65
C                                                                       INE1N2     66
      IF(DDAT(JE+3).LT.TMIN.AND.IDDAT(JE+3).NE.0)THEN                   INE1N2     67
         WRITE(MSG(1),9020) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE1N2     68
     *            ,NDGC(N)                                              INE1N2     69
         WRITE(MSG(2),9000)                                             INE1N2     70
         IF(MTFLAG.EQ.0) THEN                                           INE1N2     71
            WRITE(MSG(3),9040) 'TA',DDAT(JE+3),TMIN                     INE1N2     72
            CALL PRTMSG(3)                                              INE1N2     73
         ELSE                                                           INE1N2     74
            WRITE(MSG(3),9040) 'TA',DDAT(JE+3),TMIN,'TA',0.0            INE1N2     75
            CALL PRTMSG(3)                                              INE1N2     76
            DDAT(JE+3)=0.0                                              INE1N2     77
         ENDIF                                                          INE1N2     78
      ENDIF                                                             INE1N2     79
C                                                                       INE1N2     80
      IF (DDAT(JE+5).LE.0.0) THEN                                       INE1N2     81
         WRITE(MSG(1),9020) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE1N2     82
     *                     ,NDGC(N)                                     INE1N2     83
         WRITE(MSG(2),9000)                                             INE1N2     84
         WRITE(MSG(3),9050) DDAT(JE+5)                                  INE1N2     85
         CALL PRTMSG(3)                                                 INE1N2     86
         CALL ASTOP('INE1N2: FATAL ERROR',19)                           INE1N2     87
      ELSE IF (DDAT(JE+5).LT.10.0*TMIN) THEN                            INE1N2     88
         WRITE(MSG(1),9020) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE1N2     89
     *            ,NDGC(N)                                              INE1N2     90
         WRITE(MSG(2),9000)                                             INE1N2     91
         IF(MTFLAG.EQ.0) THEN                                           INE1N2     92
            WRITE(MSG(3),9040) 'TE',DDAT(JE+5),10.0*TMIN                INE1N2     93
            CALL PRTMSG(3)                                              INE1N2     94
         ELSE                                                           INE1N2     95
            WRITE(MSG(3),9040) 'TE',DDAT(JE+5),10.0*TMIN,'TE',10.0*TMIN INE1N2     96
            CALL PRTMSG(3)                                              INE1N2     97
            DDAT(JE+5)=10.0*TMIN                                        INE1N2     98
         ENDIF                                                          INE1N2     99
      END IF                                                            INE1N2    100
C                                                                       INE1N2    101
      IF(DDAT(JE+11).LT.TMIN.AND.IDDAT(JE+11).NE.0)THEN                 INE1N2    102
         WRITE(MSG(1),9020) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE1N2    103
     *            ,NDGC(N)                                              INE1N2    104
         WRITE(MSG(2),9000)                                             INE1N2    105
         IF(MTFLAG.EQ.0) THEN                                           INE1N2    106
            WRITE(MSG(3),9040) 'TF',DDAT(JE+11),TMIN                    INE1N2    107
            CALL PRTMSG(3)                                              INE1N2    108
         ELSE                                                           INE1N2    109
            WRITE(MSG(3),9040) 'TF',DDAT(JE+11),TMIN,'TF',0.0           INE1N2    110
            CALL PRTMSG(3)                                              INE1N2    111
            DDAT(JE+11)=0.0                                             INE1N2    112
         ENDIF                                                          INE1N2    113
      ENDIF                                                             INE1N2    114
C                                                                       INE1N2    115
      IF(DDAT(JE+13).LT.TMIN.AND.IDDAT(JE+13).NE.0)THEN                 INE1N2    116
         WRITE(MSG(1),9020) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE1N2    117
     *            ,NDGC(N)                                              INE1N2    118
         WRITE(MSG(2),9000)                                             INE1N2    119
         IF(MTFLAG.EQ.0) THEN                                           INE1N2    120
            WRITE(MSG(3),9040) 'TB',DDAT(JE+13),TMIN                    INE1N2    121
            CALL PRTMSG(3)                                              INE1N2    122
         ELSE                                                           INE1N2    123
            WRITE(MSG(3),9040) 'TB',DDAT(JE+13),TMIN,'TB',0.0           INE1N2    124
            CALL PRTMSG(3)                                              INE1N2    125
            DDAT(JE+13)=0.0                                             INE1N2    126
         ENDIF                                                          INE1N2    127
      ENDIF                                                             INE1N2    128
C                                                                       INE1N2    129
      IF(DDAT(JE+18).LT.TMIN.AND.IDDAT(JE+18).NE.0)THEN                 INE1N2    130
         WRITE(MSG(1),9020) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE1N2    131
     *            ,NDGC(N)                                              INE1N2    132
         WRITE(MSG(2),9000)                                             INE1N2    133
         IF(MTFLAG.EQ.0) THEN                                           INE1N2    134
            WRITE(MSG(3),9040) 'TR',DDAT(JE+18),TMIN                    INE1N2    135
            CALL PRTMSG(3)                                              INE1N2    136
         ELSE                                                           INE1N2    137
            WRITE(MSG(3),9040) 'TR',DDAT(JE+18),TMIN,'TR',0.0           INE1N2    138
            CALL PRTMSG(3)                                              INE1N2    139
            DDAT(JE+18)=0.0                                             INE1N2    140
         ENDIF                                                          INE1N2    141
      ENDIF                                                             INE1N2    142
C                                                                       INE1N2    143
C  DATA PREPARATIONS AND INPUT DATA PRINTOUT                            INE1N2    144
C                                                                       INE1N2    145
      IF (IDDAT(JE+14).EQ.0.AND.IDDAT(JE+15).EQ.0) THEN                 INE1N2    146
         DDAT(JE+14)=99.0                                               INE1N2    147
         DDAT(JE+15)=-99.0                                              INE1N2    148
      END IF                                                            INE1N2    149
      IF(IDDAT(JE+8).NE.0)CALL EXSATF                                   INE1N2    150
C                                                                       INE1N2    151
      IF(IEXN.EQ.2)CALL CALKE (SE0)                                     INE1N2    152
C                                                                       INE1N2    153
      VE=EFDN                                                           INE1N2    154
C                                                                       INE1N2    155
C   EXCITER SATURATION BLOCK FOR TYEP 1 & 2                             INE1N2    156
C                                                                       INE1N2    157
      IF (IEXN.EQ.1) THEN                                               INE1N2    158
         IF (IDDAT(JE+4).EQ.0) THEN                                     INE1N2    159
            CALL CALKE1(SE)                                             INE1N2    160
            WRITE(MSG(1),9020) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),   INE1N2    161
     *                       NDGC(N)                                    INE1N2    162
            WRITE(MSG(2),9110)                                          INE1N2    163
            WRITE(MSG(3),9120)                                          INE1N2    164
            CALL PRTMSG(3)                                              INE1N2    165
         ELSE                                                           INE1N2    166
            SE=DDAT(JE+6)*EXP(DDAT(JE+7)*VE)/VE                         INE1N2    167
         END IF                                                         INE1N2    168
      ELSE                                                              INE1N2    169
         SE=SE0                                                         INE1N2    170
      ENDIF                                                             INE1N2    171
      SEKX=VE*(SE+DDAT(JE+4))                                           INE1N2    172
      XSTATE(JSTATE+2)=EFDN                                             INE1N2    173
C                                                                       INE1N2    174
      VR=SEKX                                                           INE1N2    175
C                                                                       INE1N2    176
      XSTATE(JSTATE+3)=VR/DDAT(JE+2)                                    INE1N2    177
      XSTATE(JSTATE+4)=VR                                               INE1N2    178
C                                                                       INE1N2    179
      XDFACT(JSTATE+4)=DDAT(JE+2)                                       INE1N2    180
C                                                                       INE1N2    181
      XSTATE(JSTATE+5)=VE                                               INE1N2    182
      VREF(JYE+2)=XSTATE(JSTATE+1)+XSTATE(JSTATE+3)                     INE1N2    183
C                                                                       INE1N2    184
      JSTATE=JSTATE+5                                                   INE1N2    185
      JY=JY+2                                                           INE1N2    186
C                                                                       INE1N2    187
C     DETERMINE IF A SUBDIVISION OF THE NORMAL INTEGRATION STEP         INE1N2    188
C     SHOULD BE USED. IF SO, CALCULATE THE LARGEST STEP SIZE PERMITTED  INE1N2    189
C                                                                       INE1N2    190
      IF (IDDAT(JE+10).NE.0.AND.IDDAT(JE+11).NE.0) THEN                 INE1N2    191
         IDDAT(JE+21)=1                                                 INE1N2    192
         DDAT(JE+22)=DDAT(JE+11)*DDAT(JE+5)                             INE1N2    193
     *               /DDAT(JE+2)                                        INE1N2    194
         DDAT(JE+22)=DDAT(JE+22)/DDAT(JE+10)                            INE1N2    195
         IF (IDDAT(JE+13).NE.0) THEN                                    INE1N2    196
            DDAT(JE+22)=DDAT(JE+22)*DDAT(JE+13)                         INE1N2    197
            IF (IDDAT(JE+12).NE.0) DDAT(JE+22)=DDAT(JE+22)              INE1N2    198
     *                                         /(1.0+DDAT(JE+12))       INE1N2    199
         END IF                                                         INE1N2    200
         IF (IDDAT(JE+3).NE.0) DDAT(JE+22)=DDAT(JE+22)*DDAT(JE+3)       INE1N2    201
         IF (DDAT(JE+22).LT.DTMIN) DDAT(JE+22)=DTMIN                    INE1N2    202
      ELSE                                                              INE1N2    203
         IDDAT(JE+21)=0                                                 INE1N2    204
      END IF                                                            INE1N2    205
C                                                                       INE1N2    206
      IF (VR.GT.DDAT(JE+14)+0.00001.OR.                                 INE1N2    207
     +    VR.LT.DDAT(JE+15)-0.00001)THEN                                INE1N2    208
      WRITE(MSG(1),9020) NLF,INAME(KN-2),INAME(KN-1),INAME(KN),NDGC(N)  INE1N2    209
      WRITE(MSG(2),9000)                                                INE1N2    210
      WRITE(MSG(3),9010) VR,DDAT(JE+14),DDAT(JE+15)                     INE1N2    211
      CALL PRTMSG(3)                                                    INE1N2    212
      ENDIF                                                             INE1N2    213
C                                                                       INE1N2    214
      RETURN                                                            INE1N2    215
 9020 FORMAT(' *** WARNING GENERATOR AT BUS:',I5,' STATION: '           INE1N2    216
     *,3A4,' GID:',A4)                                                  INE1N2    217
 9000 FORMAT(5X,'TYPE 1 OR 2 EXCITER (WSCC TYPE FA OR FB, IEEE TYPE'    INE1N2    218
     *,' DC1A OR DC2A)')                                                INE1N2    219
 9010 FORMAT(5X,'VR-X4 VIOLATES LIMITS:   VR=',F9.4,' VRMAX=',F9.4      INE1N2    220
     *,' VRMIN=',F9.4)                                                  INE1N2    221
 9040 FORMAT(5X,A,'=',F8.6,' IS BELOW THE LIMIT VALUE OF',F5.2,:,2X,A   INE1N2    222
     *,' HAS BEEN SET TO',F5.2)                                         INE1N2    223
 9110 FORMAT(5X,'KE IS ZERO FOR TYPE 1 EXCITER.'                        INE1N2    224
     *,' IT IS INTERNALLY CALCULATED.')                                 INE1N2    225
 9120 FORMAT(5X,'THE EXCITER IS CHANGED TO TYPE 2')                     INE1N2    226
 9050 FORMAT(5X,'TE=',F8.6,' IS LESS THAN OR EQUAL TO ZERO.')           INE1N2    227
C                                                                       INE1N2    228
      END                                                               INE1N2    229
