CFPRIME TCXDOT                                                          TCXDOT      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 TCXDOT                                                 TCXDOT      3
CD                                                                      TCXDOT      4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF TSC LOAD FOR USE    TCXDOT      5
CD    IN THE TRAPEZOIDAL METHOD. THIS SUBROUTINE IS SIMILAR TO          TCXDOT      6
CD    SUBROUTINE DETSCL. THE DIFFERENCES ARE                            TCXDOT      7
CD                                                                      TCXDOT      8
CD    1. THE PARTS RELATED TO THE RUNGE-KUTTA METHOD ARE DELETED        TCXDOT      9
CD                                                                      TCXDOT     10
CD    2. THE JACOBIAN CLACULATION PATH IS ADDED                         TCXDOT     11
CD                                                                      TCXDOT     12
CD    3. THE STATE DERIVATIVE ARRAY, XDOT, IS HERE A GLOBAL ARRAY       TCXDOT     13
CD                                                                      TCXDOT     14
      INCLUDE 'PARX.INS'                                                TCXDOT     15
      INCLUDE 'CNPT.INS'                                                TCXDOT     16
      INCLUDE 'CNB4.INS'                                                TCXDOT     17
      INCLUDE 'CNB6.INS'                                                TCXDOT     18
      INCLUDE 'CNB9.INS'                                                TCXDOT     19
      INCLUDE 'CNB19.INS'                                               TCXDOT     20
      INCLUDE 'CNPARX.INS'                                              TCXDOT     21
      INCLUDE 'CNIPTR.INS'                                              TCXDOT     22
C      INCLUDE 'CNMNEW.INS/LIST'                                        TCXDOT     23
      INCLUDE 'CNXSTA.INS'                                              TCXDOT     24
      INCLUDE 'CNQSTA.INS'                                              TCXDOT     25
      INCLUDE 'CNZSTA.INS'                                              TCXDOT     26
      INCLUDE 'CNMDAT.INS'                                              TCXDOT     27
      INCLUDE 'CNVOLT.INS'                                              TCXDOT     28
      INCLUDE 'CNMYVA.INS'                                              TCXDOT     29
      INCLUDE 'CNXDOT.INS'                                              TCXDOT     30
      INCLUDE 'CNIMPR.INS'                                              TCXDOT     31
      INCLUDE 'CNJCOB.INS'                                              TCXDOT     32
      INCLUDE 'CNABAK.INS'                                              TCXDOT     33
C                                                                       TCXDOT     34
      IF (NTSCL.EQ.0) RETURN                                            TCXDOT     35
C                                                                       TCXDOT     36
      DO 120 K=1,NTSCL                                                  TCXDOT     37
         JTSC=JTCDAT(K)                                                 TCXDOT     38
         JSTATE=JXTSC(K)                                                TCXDOT     39
         NLF=IDDAT(JTSC+1)                                              TCXDOT     40
         IF (IDDAT(JTSC+15).EQ.1) THEN                                  TCXDOT     41
            XDOT(JSTATE+1)=0.0                                          TCXDOT     42
            XDOT(JSTATE+2)=0.0                                          TCXDOT     43
            IBJCOB(IBIDEX+1)=NLF                                        TCXDOT     44
            IBJCOB(IBIDEX+6)=0                                          TCXDOT     45
            GOTO 110                                                    TCXDOT     46
         END IF                                                         TCXDOT     47
C                                                                       TCXDOT     48
         VREAL=REAL(VOLT(NLF))                                          TCXDOT     49
         VIMAG=AIMAG(VOLT(NLF))                                         TCXDOT     50
         VMG=VREAL**2+VIMAG**2                                          TCXDOT     51
C                                                                       TCXDOT     52
         GTSC=DDAT(JTSC+11)                                             TCXDOT     53
         WS1=DDAT(JTSC+5)*GTSC*VMG+DDAT(JTSC+8)                         TCXDOT     54
         XDOT(JSTATE+1)=(WS1-XSTATE(JSTATE+1))/DDAT(JTSC+6)             TCXDOT     55
C                                                                       TCXDOT     56
         DELT=DDAT(JTSC+9)-XSTATE(JSTATE+1)                             TCXDOT     57
         XDOT(JSTATE+2)=DDAT(JTSC+3)*DELT/DDAT(JTSC+4)                  TCXDOT     58
C                                                                       TCXDOT     59
         IF (XSTATE(JSTATE+2).GE.DDAT(JTSC+7)) THEN                     TCXDOT     60
            XSTATE(JSTATE+2)=DDAT(JTSC+7)                               TCXDOT     61
            IF (XDOT(JSTATE+2).GT.0.0) XDOT(JSTATE+2)=0.0               TCXDOT     62
         ELSE IF (XSTATE(JSTATE+2).LE.0.0) THEN                         TCXDOT     63
            XSTATE(JSTATE+2)=0.0                                        TCXDOT     64
            IF (XDOT(JSTATE+2).LT.0.0) XDOT(JSTATE+2)=0.0               TCXDOT     65
         END IF                                                         TCXDOT     66
C                                                                       TCXDOT     67
         GTSC=XSTATE(JSTATE+2)+DDAT(JTSC+2)*DELT                        TCXDOT     68
C                                                                       TCXDOT     69
         IF (GTSC.GT.DDAT(JTSC+7)) THEN                                 TCXDOT     70
            GTSC=DDAT(JTSC+7)                                           TCXDOT     71
         ELSE IF (GTSC.LT.0.0) THEN                                     TCXDOT     72
            GTSC=0.0                                                    TCXDOT     73
         END IF                                                         TCXDOT     74
         DDAT(JTSC+11)=GTSC                                             TCXDOT     75
C                                                                       TCXDOT     76
C                                                                       TCXDOT     77
C     UPDATE JACOBIAN MATRICES                                          TCXDOT     78
C                                                                       TCXDOT     79
         IF (JMUPDT) THEN                                               TCXDOT     80
C                                                                       TCXDOT     81
            A(1,1)=-(1.0+DDAT(JTSC+5)*DDAT(JTSC+2)*VMG)/DDAT(JTSC+6)    TCXDOT     82
            A(1,2)=DDAT(JTSC+5)*VMG/DDAT(JTSC+6)                        TCXDOT     83
            A(2,1)=-DDAT(JTSC+3)/DDAT(JTSC+4)                           TCXDOT     84
            A(2,2)=0.0                                                  TCXDOT     85
C                                                                       TCXDOT     86
            WS1=2.0*DDAT(JTSC+5)*(-DDAT(JTSC+2)*XSTATE(JSTATE+1)+       TCXDOT     87
     *          XSTATE(JSTATE+2)+DDAT(JTSC+2)*DDAT(JTSC+9))/DDAT(JTSC+6)TCXDOT     88
            B(1,1)=WS1*VREAL                                            TCXDOT     89
            B(1,2)=WS1*VIMAG                                            TCXDOT     90
            B(2,1)=0.0                                                  TCXDOT     91
            B(2,2)=0.0                                                  TCXDOT     92
C                                                                       TCXDOT     93
            AK(1,1)=DDAT(JTSC+2)*VREAL                                  TCXDOT     94
            AK(1,2)=-VREAL                                              TCXDOT     95
            AK(2,1)=DDAT(JTSC+2)*VIMAG                                  TCXDOT     96
            AK(2,2)=-VIMAG                                              TCXDOT     97
C                                                                       TCXDOT     98
            ICOLBV=1                                                    TCXDOT     99
            NAIDEX=IAIDEX                                               TCXDOT    100
            NBIDEX=IBIDEX                                               TCXDOT    101
            NCIDEX=ICIDEX                                               TCXDOT    102
C                                                                       TCXDOT    103
            IPATH=1                                                     TCXDOT    104
            IF (IPATH.EQ.1) THEN                                        TCXDOT    105
C                                                                       TCXDOT    106
               A(1,1)=1.0-CEFJM*A(1,1)                                  TCXDOT    107
               A(1,2)=-CEFJM*A(1,2)                                     TCXDOT    108
               A(2,1)=-CEFJM*A(2,1)                                     TCXDOT    109
               A(2,2)=1.0-CEFJM*A(2,2)                                  TCXDOT    110
C                                                                       TCXDOT    111
               B(1,1)=-CEFJM*B(1,1)                                     TCXDOT    112
               B(1,2)=-CEFJM*B(1,2)                                     TCXDOT    113
C                                                                       TCXDOT    114
               CALL LUDCM(2)                                            TCXDOT    115
C                                                                       TCXDOT    116
               CALL FBSUBA(2)                                           TCXDOT    117
C                                                                       TCXDOT    118
               NCIDEX=NCIDEX+4                                          TCXDOT    119
               CJCOB(NCIDEX-3)=-AK(1,1)                                 TCXDOT    120
               CJCOB(NCIDEX-2)=-AK(1,2)                                 TCXDOT    121
               CJCOB(NCIDEX-1)=-AK(2,1)                                 TCXDOT    122
               CJCOB(NCIDEX)=-AK(2,2)                                   TCXDOT    123
C                                                                       TCXDOT    124
               NAIDEX=NAIDEX+4                                          TCXDOT    125
               AJCOB(NAIDEX-3)=A(1,1)                                   TCXDOT    126
               AJCOB(NAIDEX-2)=A(1,2)                                   TCXDOT    127
               AJCOB(NAIDEX-1)=A(2,1)                                   TCXDOT    128
               AJCOB(NAIDEX)=A(2,2)                                     TCXDOT    129
C                                                                       TCXDOT    130
C     STORE A-1*B                                                       TCXDOT    131
C                                                                       TCXDOT    132
               NBIDEX=NBIDEX+1                                          TCXDOT    133
               IBJCOB(NBIDEX)=NLF                                       TCXDOT    134
               NBIDEX=NBIDEX+4                                          TCXDOT    135
               BJCOB(NBIDEX-3)=B(1,1)                                   TCXDOT    136
               BJCOB(NBIDEX-2)=B(1,2)                                   TCXDOT    137
               BJCOB(NBIDEX-1)=B(2,1)                                   TCXDOT    138
               BJCOB(NBIDEX)=B(2,2)                                     TCXDOT    139
               NBIDEX=NBIDEX+1                                          TCXDOT    140
               IBJCOB(NBIDEX)=0                                         TCXDOT    141
C                                                                       TCXDOT    142
            END IF                                                      TCXDOT    143
C                                                                       TCXDOT    144
         END IF                                                         TCXDOT    145
C                                                                       TCXDOT    146
 110     CONTINUE                                                       TCXDOT    147
C                                                                       TCXDOT    148
C     UPDATE COUNTERS                                                   TCXDOT    149
C                                                                       TCXDOT    150
         IAIDEX=IAIDEX+4                                                TCXDOT    151
         ICIDEX=ICIDEX+4                                                TCXDOT    152
         IBIDEX=IBIDEX+6                                                TCXDOT    153
C                                                                       TCXDOT    154
 120  CONTINUE                                                          TCXDOT    155
C                                                                       TCXDOT    156
      RETURN                                                            TCXDOT    157
      END                                                               TCXDOT    158
