CFPRIME MXDOT                                                           MXDOT       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 MXDOT                                                  MXDOT       3
CD                                                                      MXDOT       4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF INDUCTION MOTOR FOR MXDOT       5
CD    USE IN THE TRAPEZOIDAL METHOD. THIS SUBROUTINE IS SIMILAR TO      MXDOT       6
CD    SUBROUTINE DEMOTL. THE DIFFERENCES ARE                            MXDOT       7
CD                                                                      MXDOT       8
CD    1. THE PARTS RELATED TO THE RUNGE-KUTTA METHOD ARE DELETED        MXDOT       9
CD                                                                      MXDOT      10
CD    2. THE JACOBIAN CLACULATION PATH IS ADDED                         MXDOT      11
CD                                                                      MXDOT      12
CD    3. THE STATE DERIVATIVE ARRAY, XDOT, IS HERE A GLOBAL ARRAY       MXDOT      13
CD                                                                      MXDOT      14
      INCLUDE 'PARX.INS'                                                MXDOT      15
      INCLUDE 'CNPT.INS'                                                MXDOT      16
      INCLUDE 'CNB4.INS'                                                MXDOT      17
      INCLUDE 'CNB9.INS'                                                MXDOT      18
      INCLUDE 'CNB19.INS'                                               MXDOT      19
      INCLUDE 'CNMPAR.INS'                                              MXDOT      20
      INCLUDE 'CNPARX.INS'                                              MXDOT      21
      INCLUDE 'CNIPTR.INS'                                              MXDOT      22
C      INCLUDE 'CNMNEW.INS/LIST'                                        MXDOT      23
      INCLUDE 'CNXSTA.INS'                                              MXDOT      24
      INCLUDE 'CNQSTA.INS'                                              MXDOT      25
      INCLUDE 'CNZSTA.INS'                                              MXDOT      26
      INCLUDE 'CNMDAT.INS'                                              MXDOT      27
      INCLUDE 'CNVOLT.INS'                                              MXDOT      28
      INCLUDE 'CNMYVA.INS'                                              MXDOT      29
      INCLUDE 'CNYVAR.INS'                                              MXDOT      30
      INCLUDE 'CNFLAG.INS'                                              MXDOT      31
      INCLUDE 'CNUNIT.INS'                                              MXDOT      32
      INCLUDE 'CNXDOT.INS'                                              MXDOT      33
      INCLUDE 'CNJCOB.INS'                                              MXDOT      34
      INCLUDE 'CNIMPR.INS'                                              MXDOT      35
C                                                                       MXDOT      36
C      INTEGER*2 NMTNLD                                                 MXDOT      37
C      COMPLEX VOLBAR                                                   MXDOT      38
C      COMMON/MOTVOL/VOLBAR(NZL),NMTNLD(2*NZL)                          MXDOT      39
C                                                                       MXDOT      40
      COMPLEX VOLMOT                                                    MXDOT      41
C                                                                       MXDOT      42
      LDEB=.FALSE.                                                      MXDOT      43
C                                                                       MXDOT      44
      XS=0.0                                                            MXDOT      45
C                                                                       MXDOT      46
      DO 120 K=1,NMOTL                                                  MXDOT      47
      I=NMOLD(K)                                                        MXDOT      48
      IF (NTHM(2,I).EQ.0) GO TO 120                                     MXDOT      49
      JM=JMDAT(K)                                                       MXDOT      50
      JZT=JXIMO(K)                                                      MXDOT      51
      JY=JVIMO(K)                                                       MXDOT      52
      MOTYPK=IDDAT(JM+1)                                                MXDOT      53
C                                                                       MXDOT      54
      IF (MOTYPK.LT.10) THEN                                            MXDOT      55
         VOLMOT=VOLT(I)                                                 MXDOT      56
      ELSE                                                              MXDOT      57
         VOLMOT=CMPLX(DDAT(JM+37),DDAT(JM+38))                          MXDOT      58
         MOTYPK=MOTYPK-10                                               MXDOT      59
      END IF                                                            MXDOT      60
      IF (DDAT(JM+15).LT.0.0) GOTO 130                                  MXDOT      61
      XSO=DDAT(JM+24)                                                   MXDOT      62
      XRO=DDAT(JM+25)                                                   MXDOT      63
      XMMK=DDAT(JM+16)/DXM(JY+1)                                        MXDOT      64
      IF (MOTYPK.LE.3) THEN                                             MXDOT      65
         V1D=XSTATE(JZT+1)                                              MXDOT      66
         V1Q=XSTATE(JZT+2)                                              MXDOT      67
         SLIP=XSTATE(JZT+3)                                             MXDOT      68
         SA=ABS(SLIP)                                                   MXDOT      69
      ELSE                                                              MXDOT      70
         V1D=VC1D(JY+10)                                                MXDOT      71
         V1Q=VC1Q(JY+11)                                                MXDOT      72
         SLIP=XSTATE(JZT+1)                                             MXDOT      73
         SA=ABS(SLIP)                                                   MXDOT      74
      END IF                                                            MXDOT      75
      IF (MOTYPK.EQ.2.OR.MOTYPK.EQ.7) THEN                              MXDOT      76
         IF (SA.LT.1.E-04) THEN                                         MXDOT      77
            XR=DDAT(JM+20)*DDAT(JM+19)*DDAT(JM+19)/6.                   MXDOT      78
            RR=DDAT(JM+20)                                              MXDOT      79
         ELSE                                                           MXDOT      80
            B2=DDAT(JM+18)*SQRT(SA)                                     MXDOT      81
            DEM=COSH(B2)-COS(B2)                                        MXDOT      82
            XR=DDAT(JM+20)*B2*.5/SA*(SINH(B2)-SIN(B2))/DEM              MXDOT      83
            RR=DDAT(JM+20)*B2*.5*(SINH(B2)+SIN(B2))/DEM                 MXDOT      84
         END IF                                                         MXDOT      85
C         XB=XMMK+XRO+XR*DDAT(JM+22)                                    MXDOT      86
         XB=XMMK+2.0*XRO+XR*DDAT(JM+22)                                 MXDOT      87
      ELSE IF (MOTYPK.EQ.3.OR.MOTYPK.EQ.8) THEN                         MXDOT      88
         RRO=DDAT(JM+20)*DDAT(JM+33)/(DDAT(JM+20)+DDAT(JM+33))          MXDOT      89
         QM=(DDAT(JM+20)+DDAT(JM+33))/DDAT(JM+32)                       MXDOT      90
         RX=QM*RRO/(QM*QM+SA*SA)                                        MXDOT      91
         XR=DDAT(JM+20)/DDAT(JM+33)*RX                                  MXDOT      92
         RR=RX*(QM+SA*SA*DDAT(JM+20)/RRO)                               MXDOT      93
         XB=XMMK+XRO+DDAT(JM+19)*DDAT(JM+22)+XR                         MXDOT      94
      ELSE                                                              MXDOT      95
         XR=DDAT(JM+19)                                                 MXDOT      96
         RR=DDAT(JM+20)                                                 MXDOT      97
         XB=XMMK+XRO+XR*DDAT(JM+22)                                     MXDOT      98
      END IF                                                            MXDOT      99
C                                                                       MXDOT     100
C     SATURATION                                                        MXDOT     101
C                                                                       MXDOT     102
      IF (IDDAT(JM+4).EQ.0) THEN                                        MXDOT     103
         IF (MOTYPK.EQ.2.OR.MOTYPK.EQ.7) THEN                           MXDOT     104
           XR=XR+2.0*XRO                                                MXDOT     105
         ELSE                                                           MXDOT     106
           XR=XR+XRO                                                    MXDOT     107
         ENDIF                                                          MXDOT     108
         XS=XSO+DDAT(JM+17)                                             MXDOT     109
         AJCOB(IAIDEX+1)=1.0                                            MXDOT     110
      ELSE                                                              MXDOT     111
         IF (SA.LT.1.E-04) GO TO 110                                    MXDOT     112
         CROMK=DDAT(JM+27)                                              MXDOT     113
         CSOMK=DDAT(JM+26)                                              MXDOT     114
         XS1=DDAT(JM+21)                                                MXDOT     115
         RS=DDAT(JM+18)                                                 MXDOT     116
         CRD=V1Q/XMMK-XMMK/XB*CDM(JY+8)                                 MXDOT     117
         CRQ=-V1D/XMMK-XMMK/XB*CQM(JY+9)                                MXDOT     118
         CR=SQRT(CRD*CRD+CRQ*CRQ)                                       MXDOT     119
         CS=SQRT(CDM(JY+8)*CDM(JY+8)+CQM(JY+9)*CQM(JY+9))               MXDOT     120
         D=1.0                                                          MXDOT     121
         IF (CR.LE.CROMK) GO TO 70                                      MXDOT     122
         RATIO=CROMK/CR                                                 MXDOT     123
         FACT=SQRT(1.0-RATIO*RATIO)                                     MXDOT     124
         ANGX=ATAN(RATIO/FACT)                                          MXDOT     125
         D=(ANGX+RATIO*FACT)*PI                                         MXDOT     126
70       CONTINUE                                                       MXDOT     127
         IF (MOTYPK.EQ.3.OR.MOTYPK.EQ.8) THEN                           MXDOT     128
            XR=XRO+XRO*D+XR                                             MXDOT     129
         ELSEIF (MOTYPK.EQ.3.OR.MOTYPK.EQ.8) THEN                       MXDOT     130
            XR=XRO+XR+DDAT(JM+19)*D                                     MXDOT     131
         ELSE                                                           MXDOT     132
            XR=XRO+XR*D                                                 MXDOT     133
         END IF                                                         MXDOT     134
         DDAT(JM+22)=D                                                  MXDOT     135
         D=1.0                                                          MXDOT     136
         IF (CS.LE.CSOMK) GO TO 100                                     MXDOT     137
         RATIO=CSOMK/CS                                                 MXDOT     138
         FACT=SQRT(1.0-RATIO*RATIO)                                     MXDOT     139
         ANGX=ATAN(RATIO/FACT)                                          MXDOT     140
         D=(ANGX+RATIO*FACT)*PI                                         MXDOT     141
100      CONTINUE                                                       MXDOT     142
         XS=XSO+DDAT(JM+17)*D                                           MXDOT     143
         DDAT(JM+23)=D                                                  MXDOT     144
         VMR=REAL(VOLMOT)-RS*CDM(JY+8)+XS*CQM(JY+9)                     MXDOT     145
         VMI=AIMAG(VOLMOT)-RS*CQM(JY+9)-XS*CDM(JY+8)                    MXDOT     146
         VM=SQRT(VMR*VMR+VMI*VMI)                                       MXDOT     147
         V1=DDAT(JM+28)                                                 MXDOT     148
         V2=DDAT(JM+29)                                                 MXDOT     149
         G1=DDAT(JM+30)                                                 MXDOT     150
         G2=DDAT(JM+31)                                                 MXDOT     151
         CALL SATFU (VM,V1,V2,G1,G2,D)                                  MXDOT     152
         CALL ISATFU (VM,V1,V2,G1,G2,DDI)                               MXDOT     153
         AJCOB(IAIDEX+1)=DDI                                            MXDOT     154
         DXM(JY+1)=D                                                    MXDOT     155
         XMMK=DDAT(JM+16)/D                                             MXDOT     156
         XA=XMMK+XR                                                     MXDOT     157
         XS1K=XS+XMMK*XR/XA                                             MXDOT     158
         DDAT(JM+21)=XS1K                                               MXDOT     159
C                                                                       MXDOT     160
C     CALCULATE BSM & GSM                                               MXDOT     161
C                                                                       MXDOT     162
         IF (MOTYPK.LE.3) THEN                                          MXDOT     163
            RSK=DDAT(JM+18)                                             MXDOT     164
            YS1=1.0/(RSK**2+XS1K**2)                                    MXDOT     165
            RSK=RSK*YS1                                                 MXDOT     166
            XS1K=XS1K*YS1                                               MXDOT     167
            GSM(JY+4)=RSK                                               MXDOT     168
            BSM(JY+5)=XS1K                                              MXDOT     169
         END IF                                                         MXDOT     170
      END IF                                                            MXDOT     171
110   CONTINUE                                                          MXDOT     172
C                                                                       MXDOT     173
      WXBASE=DDAT(JM+13)                                                MXDOT     174
      AR=RR*WXBASE/(XMMK+XR)                                            MXDOT     175
      XSD=XMMK+XS-DDAT(JM+21)                                           MXDOT     176
      SA1=1.0-SLIP                                                      MXDOT     177
C                                                                       MXDOT     178
      ILTYPE=IDDAT(JM+5)                                                MXDOT     179
      IF (ILTYPE.EQ.1) THEN                                             MXDOT     180
         IF (SA.LT.1.0) THEN                                            MXDOT     181
            EXPN=DDAT(JM+7)                                             MXDOT     182
            EXPM=DDAT(JM+8)                                             MXDOT     183
            COFK1=DDAT(JM+9)                                            MXDOT     184
            COFK2=DDAT(JM+10)                                           MXDOT     185
            TLOAD=COFK1*SA1**EXPN+COFK2*SA**EXPM                        MXDOT     186
         ELSE                                                           MXDOT     187
            TLOAD=0.0                                                   MXDOT     188
         END IF                                                         MXDOT     189
      ELSE IF (ILTYPE.EQ.2) THEN                                        MXDOT     190
         IF (SA.LT.1.0) THEN                                            MXDOT     191
            ALL=DDAT(JM+7)                                              MXDOT     192
            BLL=DDAT(JM+8)                                              MXDOT     193
            CLL=DDAT(JM+9)                                              MXDOT     194
            TLOAD=ALL*SA1**2+BLL*SA1+CLL                                MXDOT     195
         ELSE                                                           MXDOT     196
            TLOAD=0.0                                                   MXDOT     197
         END IF                                                         MXDOT     198
      ELSE IF (ILTYPE.EQ.3)THEN                                         MXDOT     199
         TLOAD=TLM(JY+2)                                                MXDOT     200
      ELSE IF (ILTYPE.GT.3)THEN                                         MXDOT     201
C                                                                       MXDOT     202
         IF (SA.LT.1.0) THEN                                            MXDOT     203
            NR=IDDAT(JM+36)                                             MXDOT     204
            ITQN=IDDAT(JM+37)                                           MXDOT     205
            ISPN=IDDAT(JM+38)                                           MXDOT     206
            DDAT(NR+ISPN)=1.0-SA                                        MXDOT     207
            TLOAD=DDAT(NR+ITQN)*DDAT(JM+11)/BASPC                       MXDOT     208
         ELSE                                                           MXDOT     209
            TLOAD=0.0                                                   MXDOT     210
         END IF                                                         MXDOT     211
C                                                                       MXDOT     212
      END IF                                                            MXDOT     213
C                                                                       MXDOT     214
      IF (MOTYPK.LE.3) THEN                                             MXDOT     215
C                                                                       MXDOT     216
         SW=WXBASE*SLIP                                                 MXDOT     217
         XDOT(JZT+1)=-AR*(XSD*CQM(JY+9)+V1D)+SW*V1Q                     MXDOT     218
         XDOT(JZT+2)=AR*(XSD*CDM(JY+8)-V1Q)-SW*V1D                      MXDOT     219
         XDOT(JZT+3)=-DDAT(JM+6)*(V1Q*CQM(JY+9)+V1D*CDM(JY+8)-TLOAD)    MXDOT     220
C                                                                       MXDOT     221
      ELSE                                                              MXDOT     222
C                                                                       MXDOT     223
         TRSW=WXBASE*SLIP/AR                                            MXDOT     224
         Z12=XSD/(TRSW*TRSW+1.0)                                        MXDOT     225
         Z11=Z12*TRSW                                                   MXDOT     226
         V1D=Z11*CDM(JY+8)-Z12*CQM(JY+9)                                MXDOT     227
         V1Q=Z12*CDM(JY+8)+Z11*CQM(JY+9)                                MXDOT     228
         VC1D(JY+10)=V1D                                                MXDOT     229
         VC1Q(JY+11)=V1Q                                                MXDOT     230
         RSK=DDAT(JM+18)                                                MXDOT     231
         XS1K=DDAT(JM+21)                                               MXDOT     232
         Z11=RSK+Z11                                                    MXDOT     233
         Z12=XS1K+Z12                                                   MXDOT     234
         YS1=1.0/(Z11**2+Z12**2)                                        MXDOT     235
         Z11=Z11*YS1                                                    MXDOT     236
         Z12=Z12*YS1                                                    MXDOT     237
         GSM(JY+4)=Z11                                                  MXDOT     238
         BSM(JY+5)=Z12                                                  MXDOT     239
C                                                                       MXDOT     240
         XDOT(JZT+1)=-DDAT(JM+6)*(V1Q*CQM(JY+9)+V1D*CDM(JY+8)-TLOAD)    MXDOT     241
C                                                                       MXDOT     242
      END IF                                                            MXDOT     243
C                                                                       MXDOT     244
C     UPDATE JACOBIAN MATRICES                                          MXDOT     245
C                                                                       MXDOT     246
      IF (JMUPDT) THEN                                                  MXDOT     247
C                                                                       MXDOT     248
         CALL MOTOLN(1,K)                                               MXDOT     249
C                                                                       MXDOT     250
      END IF                                                            MXDOT     251
 130  CONTINUE                                                          MXDOT     252
C                                                                       MXDOT     253
C     UPDATE COUNTERS                                                   MXDOT     254
C                                                                       MXDOT     255
      IF (MOTYPK.LE.3) THEN                                             MXDOT     256
         IAIDEX=IAIDEX+10                                               MXDOT     257
         ICIDEX=ICIDEX+6                                                MXDOT     258
         IBIDEX=IBIDEX+8                                                MXDOT     259
      ELSE                                                              MXDOT     260
         IAIDEX=IAIDEX+2                                                MXDOT     261
         ICIDEX=ICIDEX+2                                                MXDOT     262
         IBIDEX=IBIDEX+4                                                MXDOT     263
      END IF                                                            MXDOT     264
C                                                                       MXDOT     265
 120  CONTINUE                                                          MXDOT     266
C                                                                       MXDOT     267
      RETURN                                                            MXDOT     268
C                                                                       MXDOT     269
      END                                                               MXDOT     270
