CFPRIME INE31                                                           INE31       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 INE31                                                  INE31       3
CD                                                                      INE31       4
CD    TO PERFORM INITIALIZATION AND DATA CHECK FOR EXCITER TYPE 31.     INE31       5
CD                                                                      INE31       6
CD    THE DATA STRUCTURE AFTER THE INITIALIZATION IS GIVEN BELOW.       INE31       7
CD                                                                      INE31       8
CD   3.13 Exciter type 31                                               INE31       9
CD                                                                      INE31      10
CD     Exciter data                                                     INE31      11
CD                                                                      INE31      12
CD     IDDAT(JE+ 1)   = IVTN         : sensing bus number               INE31      13
CD     DDAT(JE+ 2)    = KA                                              INE31      14
CD     DDAT(JE+ 3)    = VAMAX                                           INE31      15
CD     DDAT(JE+ 4)    = TC                                              INE31      16
CD     DDAT(JE+ 5)    = TB                                              INE31      17
CD     DDAT(JE+ 6)    = PHIMAX                                          INE31      18
CD     DDAT(JE+ 7)    = PHIMIN                                          INE31      19
CD     DDAT(JE+ 8)    = VSMAX                                           INE31      20
CD     DDAT(JE+ 9)    = VSMIN                                           INE31      21
CD     DDAT(JE+10)    = VRMAX                                           INE31      22
CD     DDAT(JE+11)    = VRMIN                                           INE31      23
CD     DDAT(JE+12)    = (reserved for future use)                       INE31      24
CD     DDAT(JE+13)    = KVF                                             INE31      25
CD     DDAT(JE+14)    = ETMIN                                           INE31      26
CD     DDAT(JE+15)    = KIFL                                            INE31      27
CD     DDAT(JE+16)    = IFLMT                                           INE31      28
CD     DDAT(JE+17)    = (reserved for future use)                       INE31      29
CD     DDAT(JE+18)    = TR                                              INE31      30
CD     DDAT(JE+19)    = RC                                              INE31      31
CD     DDAT(JE+20)    = XC                                              INE31      32
CD     DDAT(JE+21)    = KETL                                            INE31      33
CD     DDAT(JE+22)    = TL1                                             INE31      34
CD     DDAT(JE+23)    = TL2                                             INE31      35
CD     DDAT(JE+24)    = ETLMT                                           INE31      36
CD     DDAT(JE+25)    = VOMX                                            INE31      37
CD                                                                      INE31      38
CD     Exciter states                                                   INE31      39
CD                                                                      INE31      40
CD     XSTATE(JES+1)  = TR block     : compulsory                       INE31      41
CD     XSTATE(JES+2)  = TL2 block    : optional                         INE31      42
CD     XSTATE(JES+3)  = TB block     : optional                         INE31      43
CD                                                                      INE31      44
CD     Exciter Y-variables                                              INE31      45
CD                                                                      INE31      46
CD     VREG(JYE+1)    = VC (input to the TR block)                      INE31      47
CD     VREF(JYE+2)    = reference value                                 INE31      48
CD                                                                      INE31      49
      INCLUDE 'PARX.INS'                                                INE31      50
      INCLUDE 'CNMDAT.INS'                                              INE31      51
      INCLUDE 'CNSTN.INS'                                               INE31      52
      INCLUDE 'CNVOLT.INS'                                              INE31      53
      INCLUDE 'CNMSTA.INS'                                              INE31      54
      INCLUDE 'CNXSTA.INS'                                              INE31      55
      INCLUDE 'CNB8.INS'                                                INE31      56
      INCLUDE 'CNEXC.INS'                                               INE31      57
      INCLUDE 'CNMYVA.INS'                                              INE31      58
      INCLUDE 'CNYVAR.INS'                                              INE31      59
      INCLUDE 'CNUNIT.INS'                                              INE31      60
      INCLUDE 'CNB1.INS'                                                INE31      61
      INCLUDE 'CNB4.INS'                                                INE31      62
      INCLUDE 'CNIMPR.INS'                                              INE31      63
      INCLUDE 'CNMSG.INS'                                               INE31      64
C                                                                       INE31      65
      DATA BIG/99.9/                                                    INE31      66
C                                                                       INE31      67
C  IEX = 31                                                             INE31      68
C                                                                       INE31      69
C  INPUT TIME CONSTANTS CHECK AND RESET                                 INE31      70
C                                                                       INE31      71
      IF(DDAT(JE+5).LT.TMIN.AND.IDDAT(JE+5).NE.0)THEN                   INE31      72
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE31      73
     *                     ,NDGC(N)                                     INE31      74
         WRITE(MSG(2),9030) 'TB',DDAT(JE+5),TMIN                        INE31      75
         IF(MTFLAG.EQ.0) THEN                                           INE31      76
            CALL PRTMSG(2)                                              INE31      77
         ELSE                                                           INE31      78
         WRITE(MSG(3),9040) 'TB',0.0                                    INE31      79
         CALL PRTMSG(3)                                                 INE31      80
         DDAT(JE+5)=0.0                                                 INE31      81
         ENDIF                                                          INE31      82
      ENDIF                                                             INE31      83
C                                                                       INE31      84
      IF(DDAT(JE+18).LT.TMIN.AND.IDDAT(JE+18).NE.0)THEN                 INE31      85
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE31      86
     *                     ,NDGC(N)                                     INE31      87
         WRITE(MSG(2),9030) 'TR',DDAT(JE+18),TMIN                       INE31      88
         IF(MTFLAG.EQ.0) THEN                                           INE31      89
            CALL PRTMSG(2)                                              INE31      90
         ELSE                                                           INE31      91
         WRITE(MSG(3),9040) 'TR',0.0                                    INE31      92
         CALL PRTMSG(3)                                                 INE31      93
         DDAT(JE+18)=0.0                                                INE31      94
         ENDIF                                                          INE31      95
      ENDIF                                                             INE31      96
C                                                                       INE31      97
      IF(DDAT(JE+23).LT.TMIN.AND.IDDAT(JE+23).NE.0)THEN                 INE31      98
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE31      99
     *                     ,NDGC(N)                                     INE31     100
         WRITE(MSG(2),9030) 'TL2',DDAT(JE+23),TMIN                      INE31     101
         IF(MTFLAG.EQ.0) THEN                                           INE31     102
            CALL PRTMSG(2)                                              INE31     103
         ELSE                                                           INE31     104
         WRITE(MSG(3),9040) 'TL2',0.0                                   INE31     105
         CALL PRTMSG(3)                                                 INE31     106
         DDAT(JE+23)=0.0                                                INE31     107
         ENDIF                                                          INE31     108
      ENDIF                                                             INE31     109
C                                                                       INE31     110
C  DATA PREPARATION AND INPUT DATA PRINTOUT                             INE31     111
C                                                                       INE31     112
      IF (IDDAT(JE+8).EQ.0.AND.IDDAT(JE+9).EQ.0)THEN                    INE31     113
      DDAT(JE+8)=BIG                                                    INE31     114
      DDAT(JE+9)=-BIG                                                   INE31     115
      ENDIF                                                             INE31     116
      IF (IDDAT(JE+25).EQ.0)DDAT(JE+25)=BIG                             INE31     117
      IF (IDDAT(JE+10).EQ.0.AND.IDDAT(JE+11).EQ.0)THEN                  INE31     118
      DDAT(JE+10)=BIG                                                   INE31     119
      DDAT(JE+11)=-BIG                                                  INE31     120
      ENDIF                                                             INE31     121
C                                                                       INE31     122
      IDDAT(JE+26)=0                                                    INE31     123
      IDDAT(JE+27)=0                                                    INE31     124
C                                                                       INE31     125
      KSTATE=1                                                          INE31     126
C                                                                       INE31     127
C  TERMINAL VOLTAGE LIMITER BLOCK                                       INE31     128
C                                                                       INE31     129
      IF (IDDAT(JE+21).EQ.0) THEN                                       INE31     130
         DDAT(JE+21)=0.0                                                INE31     131
         DDAT(JE+22)=0.0                                                INE31     132
         DDAT(JE+23)=0.0                                                INE31     133
         DDAT(JE+24)=99.0                                               INE31     134
      END IF                                                            INE31     135
C                                                                       INE31     136
      IF (IDDAT(JE+21).NE.0) THEN                                       INE31     137
      IF(ET.GT.DDAT(JE+24))THEN                                         INE31     138
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE31     139
     *                     ,NDGC(N)                                     INE31     140
         WRITE(MSG(2),9010)                                             INE31     141
         WRITE(MSG(3),9020) ET,DDAT(JE+24)                              INE31     142
         CALL PRTMSG(3)                                                 INE31     143
      ENDIF                                                             INE31     144
C                                                                       INE31     145
C  V2 PRIME - OPTIONAL                                                  INE31     146
C                                                                       INE31     147
      KSTATE=KSTATE+1                                                   INE31     148
      XSTATE(JSTATE+KSTATE)=0.                                          INE31     149
      IDDAT(JE+26)=JSTATE+KSTATE-NSTATE                                 INE31     150
C                                                                       INE31     151
      END IF                                                            INE31     152
C                                                                       INE31     153
      SPHI=EFDN/(DDAT(JE+3)*ET-DDAT(JE+13)*EFDN)                        INE31     154
      PHI=ASIN(SPHI)                                                    INE31     155
      VSUM=PHI*DDAT(JE+3)/DDAT(JE+2)                                    INE31     156
      VREF(JYE+2)=XSTATE(JSTATE+1)+VSUM                                 INE31     157
      IF (IDDAT(JE+5).NE.0) THEN                                        INE31     158
         KSTATE=KSTATE+1                                                INE31     159
         XSTATE(JSTATE+KSTATE)=VSUM                                     INE31     160
         IDDAT(JE+27)=JSTATE+KSTATE-NSTATE                              INE31     161
      END IF                                                            INE31     162
C                                                                       INE31     163
      JSTATE=JSTATE+KSTATE                                              INE31     164
      JY=JY+2                                                           INE31     165
C                                                                       INE31     166
      IDDAT(JE+28)=0                                                    INE31     167
      IF (IDDAT(JE+15).NE.0) THEN                                       INE31     168
         IF (EFDN.GT.DDAT(JE+16))THEN                                   INE31     169
            IDDAT(JE+28)=1                                              INE31     170
            WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)    INE31     171
     *                        ,NDGC(N)                                  INE31     172
            WRITE(MSG(2),9100)                                          INE31     173
            WRITE(MSG(3),9110) EFDN,DDAT(JE+16)                         INE31     174
            CALL PRTMSG(3)                                              INE31     175
         ENDIF                                                          INE31     176
      ENDIF                                                             INE31     177
      IF (VSUM.GT.DDAT(JE+10).OR.VSUM.LT.DDAT(JE+11)) THEN              INE31     178
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE31     179
     *                     ,NDGC(N)                                     INE31     180
         WRITE(MSG(2),9200)                                             INE31     181
         WRITE(MSG(3),9210) VSUM,DDAT(JE+10),DDAT(JE+11)                INE31     182
         CALL PRTMSG(3)                                                 INE31     183
      ENDIF                                                             INE31     184
      IF (PHI.GT.DDAT(JE+6).OR.PHI.LT.DDAT(JE+7)) THEN                  INE31     185
         WRITE(MSG(1),9000) NLF,INAME(KN-2),INAME(KN-1),INAME(KN)       INE31     186
     *                     ,NDGC(N)                                     INE31     187
         WRITE(MSG(2),9010)                                             INE31     188
         WRITE(MSG(3),9020) PHI,DDAT(JE+6),DDAT(JE+7)                   INE31     189
         CALL PRTMSG(3)                                                 INE31     190
      ENDIF                                                             INE31     191
C                                                                       INE31     192
      RETURN                                                            INE31     193
C                                                                       INE31     194
 9000 FORMAT(' *** WARNING GENERATOR AT BUS: ',I5,' STATION: ',3A4      INE31     195
     *,' GID:',A4)                                                      INE31     196
 9010 FORMAT(5X,'TYPE 31 EXCITER  ET GREATER THAN REF SIGNAL:')         INE31     197
 9020 FORMAT(5X,'ET = ',G12.5,' ETLMT = ',G12.5)                        INE31     198
 9030 FORMAT(5X,'TYPE 31 EXCITER ',A,'=',F8.6                           INE31     199
     *,' IS BELOW THE LIMIT VALUE OF ',F4.2)                            INE31     200
 9040 FORMAT(5X,A,' HAS BEEN SET TO ',F4.2)                             INE31     201
 9100 FORMAT(5X,'TYPE 31 EXCITER  IFDN GREATER THENA REF SIGNAL:')      INE31     202
 9110 FORMAT(5X,'IFDN = ',G12.5,' IFLMT = ',G12.5)                      INE31     203
 9200 FORMAT(5X,'TYPE 31 EXCITER  VSUM VIOLATES LIMITS: ')              INE31     204
 9210 FORMAT(5X,'VSUM = ',G12.5,' VRMAX = ',G12.5,' VRMIN = ',G12.5)    INE31     205
C                                                                       INE31     206
      END                                                               INE31     207
