CFPRIME MOMDAT                                                          MOMDAT      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 MOMDAT(CARD,IKEY,JTYP,IEBK)                            MOMDAT      3
CD                                                                      MOMDAT      4
CD    TO PERFORMS THE SWITCHING ACTIVITIES OF INDUCTION MOTORS:         MOMDAT      5
CD                                                                      MOMDAT      6
      INCLUDE 'PARX.INS'                                                MOMDAT      7
      INCLUDE 'CNPT.INS'                                                MOMDAT      8
      INCLUDE 'CNFLAG.INS'                                              MOMDAT      9
      INCLUDE 'CNIPTR.INS'                                              MOMDAT     10
      INCLUDE 'CNSTN.INS'                                               MOMDAT     11
      INCLUDE 'CNMPAR.INS'                                              MOMDAT     12
      INCLUDE 'CNUNIT.INS'                                              MOMDAT     13
      INCLUDE 'CNMDAT.INS'                                              MOMDAT     14
      INCLUDE 'CNXSTA.INS'                                              MOMDAT     15
      INCLUDE 'CNNNEW.INS'                                              MOMDAT     16
      INCLUDE 'CNMSTA.INS'                                              MOMDAT     17
      INCLUDE 'CNMYVA.INS'                                              MOMDAT     18
      INCLUDE 'CNYVAR.INS'                                              MOMDAT     19
C                                                                       MOMDAT     20
      CHARACTER*2 CID                                                   MOMDAT     21
      CHARACTER*132 CARD                                                MOMDAT     22
C                                                                       MOMDAT     23
      LOGICAL LIMFLT                                                    MOMDAT     24
      COMMON /MOTVF/ VOLDRE(NMT), VOLDIM(NMT), BUSFRQ(NMT), TSPREV,     MOMDAT     25
     &               GSMOLD, BSMOLD, LIMFLT                             MOMDAT     26
C                                                                       MOMDAT     27
      LDEB=(JDEB(44).NE.0)                                              MOMDAT     28
C                                                                       MOMDAT     29
      JM=0                                                              MOMDAT     30
      MOTYPK=0                                                          MOMDAT     31
      NTHMK=0                                                           MOMDAT     32
C                                                                       MOMDAT     33
      READ(CARD,1370) ITYP,NLFI,NTHMK,CID,PULOAD                        MOMDAT     34
C                                                                       MOMDAT     35
      IF(IKEY.EQ.1)THEN                                                 MOMDAT     36
      IKEY=2                                                            MOMDAT     37
C      WRITE(IU17,1420)                                                 MOMDAT     38
      WRITE(IU6,1420)                                                   MOMDAT     39
      ENDIF                                                             MOMDAT     40
      IPBNO=NLFI                                                        MOMDAT     41
      IN3=IPBNO*3                                                       MOMDAT     42
      NLFI=NOLD(IPBNO)                                                  MOMDAT     43
      IMOT=NLFI                                                         MOMDAT     44
C                                                                       MOMDAT     45
      JM=JMDAT(NTHMK)                                                   MOMDAT     46
      JSTATE=JXIMO(NTHMK)                                               MOMDAT     47
      JY=JVIMO(NTHMK)                                                   MOMDAT     48
C                                                                       MOMDAT     49
      MOTYPK=IABS(IDDAT(JM+1))                                          MOMDAT     50
C                                                                       MOMDAT     51
      GOTO (360,370,380), JTYP                                          MOMDAT     52
C                                                                       MOMDAT     53
 360  CONTINUE                                                          MOMDAT     54
CD                                                                      MOMDAT     55
CD    1. DISCONNECTING INDUCTION MOTOR                                  MOMDAT     56
C                                                                       MOMDAT     57
C      DDAT(JM+22)=1.0                                                  MOMDAT     58
C      DDAT(JM+23)=1.0                                                  MOMDAT     59
C      GSM(JY+4)=0.0                                                    MOMDAT     60
C      GSMO(JY+6)=0.0                                                   MOMDAT     61
C      BSM(JY+5)=0.0                                                    MOMDAT     62
C      BSMO(JY+7)=0.0                                                   MOMDAT     63
C      IF (MOTYPK.LE.3) THEN                                            MOMDAT     64
C         XSTATE(JSTATE+1)=0.0                                          MOMDAT     65
C         XSTATE(JSTATE+2)=0.0                                          MOMDAT     66
C         XSTATE(JSTATE+3)=1.0                                          MOMDAT     67
C      ELSE                                                             MOMDAT     68
C         VC1D(JY+10)=0.0                                               MOMDAT     69
C         VC1Q(JY+11)=0.0                                               MOMDAT     70
C         XSTATE(JSTATE+1)=1.0                                          MOMDAT     71
C      END IF                                                           MOMDAT     72
C      NTHM(2,IPBNO)=0                                                  MOMDAT     73
      DDAT(JM+35)=-1.0                                                  MOMDAT     74
      LIMFLT = .TRUE.                                                   MOMDAT     75
C      WRITE(IU17,1510) ITYP,IMOT,INAME(IN3-2),INAME(IN3-1),INAME(IN3), MOMDAT     76
C     +                  CID                                            MOMDAT     77
      WRITE(IU6,1510) ITYP,IMOT,INAME(IN3-2),INAME(IN3-1),INAME(IN3),   MOMDAT     78
     +                CID                                               MOMDAT     79
      GOTO 410                                                          MOMDAT     80
 370  CONTINUE                                                          MOMDAT     81
CD                                                                      MOMDAT     82
CD    2. RECONNECTING INDUCTION MOTOR                                   MOMDAT     83
C                                                                       MOMDAT     84
      IF (DDAT(JM+35) .EQ. -1.0) THEN                                   MOMDAT     85
        DDAT(JM+35)=0.0                                                 MOMDAT     86
        WRITE(IU6,1520) ITYP,IMOT,INAME(IN3-2),INAME(IN3-1),INAME(IN3), MOMDAT     87
     +                  CID                                             MOMDAT     88
        LIMFLT = .TRUE.                                                 MOMDAT     89
      ENDIF                                                             MOMDAT     90
      GOTO 410                                                          MOMDAT     91
 380  CONTINUE                                                          MOMDAT     92
CD                                                                      MOMDAT     93
CD    3. STARTING INDUCTION MOTOR FROM STANDSTILL                       MOMDAT     94
C                                                                       MOMDAT     95
      IDDAT(JM+1)=IABS(IDDAT(JM+1))                                     MOMDAT     96
      NTHM(2,IPBNO)=NTHMK                                               MOMDAT     97
      IF (MOTYPK.LE.3) THEN                                             MOMDAT     98
         XSTATE(JSTATE+1)=0.0                                           MOMDAT     99
         XSTATE(JSTATE+2)=0.0                                           MOMDAT    100
         XSTATE(JSTATE+3)=1.0                                           MOMDAT    101
      ELSE                                                              MOMDAT    102
         VC1D(JY+10)=0.0                                                MOMDAT    103
         VC1Q(JY+11)=0.0                                                MOMDAT    104
         XSTATE(JSTATE+1)=1.0                                           MOMDAT    105
      END IF                                                            MOMDAT    106
      DDAT(JM+22)=1.0                                                   MOMDAT    107
      DDAT(JM+23)=1.0                                                   MOMDAT    108
      SA=1.0                                                            MOMDAT    109
      XS=DDAT(JM+17)                                                    MOMDAT    110
      XR=DDAT(JM+19)                                                    MOMDAT    111
      XS=XS+DDAT(JM+24)                                                 MOMDAT    112
      XR=XR+DDAT(JM+25)                                                 MOMDAT    113
      RR=DDAT(JM+20)                                                    MOMDAT    114
      IF (MOTYPK.EQ.2.OR.MOTYPK.EQ.7) THEN                              MOMDAT    115
C         X6=DDAT(JM+19)**2*RR/6.0                                      MOMDAT    116
C         XR=DDAT(JM+25)+X6                                             MOMDAT    117
         DDAT(JM+25)=DDAT(JM+25)/2.0                                    MOMDAT    118
         X6=DDAT(JM+25)                                                 MOMDAT    119
         X7=DDAT(JM+19)**2*RR/6.0                                       MOMDAT    120
      ELSE IF (MOTYPK.EQ.3.OR.MOTYPK.EQ.8) THEN                         MOMDAT    121
         X6=DDAT(JM+19)                                                 MOMDAT    122
         X7=RR*RR*DDAT(JM+32)/(RR+DDAT(JM+33))**2                       MOMDAT    123
         RR=RR*DDAT(JM+33)/(RR+DDAT(JM+33))                             MOMDAT    124
C         XR=DDAT(JM+25)+DDAT(JM+19)+X7                                 MOMDAT    125
      ELSE                                                              MOMDAT    126
         X6=DDAT(JM+19)                                                 MOMDAT    127
         X7=0.0                                                         MOMDAT    128
      END IF                                                            MOMDAT    129
      XR=DDAT(JM+25)+X6+X7                                              MOMDAT    130
      XM=DDAT(JM+16)                                                    MOMDAT    131
      XA=XM+XR                                                          MOMDAT    132
      XS1K=XS+XM*XR/XA                                                  MOMDAT    133
      DDAT(JM+21)=XS1K                                                  MOMDAT    134
C                                                                       MOMDAT    135
C   CALCULATE BSM & GSM                                                 MOMDAT    136
C                                                                       MOMDAT    137
      RSK=DDAT(JM+18)                                                   MOMDAT    138
      IF (MOTYPK.LE.3) THEN                                             MOMDAT    139
         YS1=1.0/(RSK**2+XS1K**2)                                       MOMDAT    140
         RSK=RSK*YS1                                                    MOMDAT    141
         XS1K=XS1K*YS1                                                  MOMDAT    142
      ELSE                                                              MOMDAT    143
         WXBASE=DDAT(JM+13)                                             MOMDAT    144
         AR=RR*WXBASE/(XM+XR)                                           MOMDAT    145
         XSD=XM+XS-XS1K                                                 MOMDAT    146
         TRSW=WXBASE*SA/AR                                              MOMDAT    147
         Z12=XSD/(TRSW*TRSW+1.0)                                        MOMDAT    148
         Z11=Z12*TRSW                                                   MOMDAT    149
         Z11=RSK+Z11                                                    MOMDAT    150
         Z12=XS1K+Z12                                                   MOMDAT    151
         YS1=1.0/(Z11**2+Z12**2)                                        MOMDAT    152
         RSK=Z11*YS1                                                    MOMDAT    153
         XS1K=Z12*YS1                                                   MOMDAT    154
      END IF                                                            MOMDAT    155
      GSM(JY+4)=RSK                                                     MOMDAT    156
      BSM(JY+5)=XS1K                                                    MOMDAT    157
      GSMO(JY+6)=RSK                                                    MOMDAT    158
      BSMO(JY+7)=XS1K                                                   MOMDAT    159
C      WRITE(IU17,1530) ITYP,IMOT,INAME(IN3-2),INAME(IN3-1),INAME(IN3), MOMDAT    160
C     +                 CID                                             MOMDAT    161
      WRITE(IU6,1530) ITYP,IMOT,INAME(IN3-2),INAME(IN3-1),INAME(IN3)  , MOMDAT    162
     +                CID                                               MOMDAT    163
 410  CONTINUE                                                          MOMDAT    164
C                                                                       MOMDAT    165
      RETURN                                                            MOMDAT    166
C                                                                       MOMDAT    167
 1370 FORMAT (A3,1X,2I5,3X,A2)                                          MOMDAT    168
 1420 FORMAT (///10X,'SWITCHING OF INDUCTION MOTOR :-',/,10X,28('-'),/10MOMDAT    169
     1X,'TYPE',1X,'BUS#   BUS NAME',T43,'ID',T47,'DESCRIPTION'/)        MOMDAT    170
 1510 FORMAT (T11,A2,3X,I4,1X,3A4,T43,A2,T47,'INDUCTION MOTOR REMOVAL') MOMDAT    171
 1520 FORMAT (T11,A2,3X,I4,1X,3A4,T43,A2,T47,                           MOMDAT    172
     +        'RESTARTING INDUCTION MOTOR')                             MOMDAT    173
 1530 FORMAT (T11,A2,3X,I4,1X,3A4,T43,A2,T47,                           MOMDAT    174
     &        'STARTING INDUCTION MOTOR FROM STANDSTILL')               MOMDAT    175
C                                                                       MOMDAT    176
      END                                                               MOMDAT    177
