CFPRIME TSCINT                                                          TSCINT      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 TSCINT                                                 TSCINT      3
CD                                                                      TSCINT      4
CD     TO PERFORM INITIALIZATION FOR TSC LOAD.                          TSCINT      5
CD                                                                      TSCINT      6
      INCLUDE 'PARX.INS'                                                TSCINT      7
      INCLUDE 'CNB19.INS'                                               TSCINT      8
      INCLUDE 'CNFLAG.INS'                                              TSCINT      9
      INCLUDE 'CNIPTR.INS'                                              TSCINT     10
      INCLUDE 'CNPT.INS'                                                TSCINT     11
      INCLUDE 'CNB4.INS'                                                TSCINT     12
      INCLUDE 'CNB6.INS'                                                TSCINT     13
      INCLUDE 'CNMDAT.INS'                                              TSCINT     14
      INCLUDE 'CNVOLT.INS'                                              TSCINT     15
      INCLUDE 'CNSTN.INS'                                               TSCINT     16
      INCLUDE 'CNXSTA.INS'                                              TSCINT     17
      INCLUDE 'CNMSG.INS'                                               TSCINT     18
      INCLUDE 'CNREC1.INS'                                              TSCINT     19
C                                                                       TSCINT     20
      LDEB=(JDEB(29).NE.0)                                              TSCINT     21
C                                                                       TSCINT     22
      JTC=0                                                             TSCINT     23
      K31=0                                                             TSCINT     24
      CMAG1=0.0                                                         TSCINT     25
      G01=0.0                                                           TSCINT     26
      NLF1=0                                                            TSCINT     27
      P1=0.0                                                            TSCINT     28
      VMG21=0.0                                                         TSCINT     29
      MTCLST=JSTATE                                                     TSCINT     30
      MTCLNO=2*NTSCL                                                    TSCINT     31
C                                                                       TSCINT     32
      DO 210 K=1,NTSCL                                                  TSCINT     33
         JTSC=JTCDAT(K)                                                 TSCINT     34
         JXTSC(K)=JSTATE                                                TSCINT     35
         NLF=IDDAT(JTSC+1)                                              TSCINT     36
         NLFO=NOLD(NLF)                                                 TSCINT     37
C                                                                       TSCINT     38
C     INITIALIZATION                                                    TSCINT     39
C                                                                       TSCINT     40
      IF(DDAT(JTSC+4).LT.TMIN)THEN                                      TSCINT     41
         WRITE(MSG(1),1000) NLFO                                        TSCINT     42
         WRITE(MSG(2),9030) 'TC',DDAT(JTSC+4),TMIN                      TSCINT     43
         IF(MTFLAG.EQ.0) THEN                                           TSCINT     44
           CALL PRTMSG(2)                                               TSCINT     45
         ELSE                                                           TSCINT     46
           WRITE(MSG(3),9040) 'TC',1.0                                  TSCINT     47
           CALL PRTMSG(3)                                               TSCINT     48
           DDAT(JTSC+4)=1.0                                             TSCINT     49
         ENDIF                                                          TSCINT     50
      ENDIF                                                             TSCINT     51
         IF (IDDAT(JTSC+7).EQ.0) THEN                                   TSCINT     52
            DDAT(JTSC+7)=2.0*DDAT(JTSC+10)                              TSCINT     53
         ELSE IF (DDAT(JTSC+7).LT.1.0) THEN                             TSCINT     54
            WRITE(MSG(1),1000) NLFO                                     TSCINT     55
            WRITE(MSG(2),1001) DDAT(JTSC+7)                             TSCINT     56
            CALL PRTMSG(2)                                              TSCINT     57
            DDAT(JTSC+7)=2.0*DDAT(JTSC+10)                              TSCINT     58
         ELSE                                                           TSCINT     59
            DDAT(JTSC+7)=DDAT(JTSC+7)*DDAT(JTSC+10)                     TSCINT     60
         END IF                                                         TSCINT     61
C                                                                       TSCINT     62
         VREAL=REAL(VOLT(NLF))                                          TSCINT     63
         VIMAG=AIMAG(VOLT(NLF))                                         TSCINT     64
         VMG2=VREAL**2+VIMAG**2                                         TSCINT     65
C                                                                       TSCINT     66
         GTSC0=DDAT(JTSC+10)                                            TSCINT     67
         IF (IDDAT(JTSC+8).EQ.0) DDAT(JTSC+8)=10.0                      TSCINT     68
         IF (IDDAT(JTSC+5).EQ.0)                                        TSCINT     69
     *      DDAT(JTSC+5)=(65.0-DDAT(JTSC+8))/(VMG2*GTSC0)               TSCINT     70
         IF (IDDAT(JTSC+6).EQ.0) DDAT(JTSC+6)=1200.0                    TSCINT     71
C                                                                       TSCINT     72
         TINIT=DDAT(JTSC+5)*GTSC0*VMG2+DDAT(JTSC+8)                     TSCINT     73
         DDAT(JTSC+9)=TINIT                                             TSCINT     74
         XSTATE(JSTATE+1)=TINIT                                         TSCINT     75
         XSTATE(JSTATE+2)=GTSC0                                         TSCINT     76
         VMG=SQRT(VMG2)                                                 TSCINT     77
         IF (VMG.GT.VTHZL) THEN                                         TSCINT     78
            IDDAT(JTSC+15)=0                                            TSCINT     79
         ELSE                                                           TSCINT     80
            IDDAT(JTSC+15)=1                                            TSCINT     81
         END IF                                                         TSCINT     82
         JSTATE=JSTATE+2                                                TSCINT     83
C                                                                       TSCINT     84
  210 CONTINUE                                                          TSCINT     85
C                                                                       TSCINT     86
1000  FORMAT(1X,'*** WARNING TSC LOAD AT BUS ',I5)                      TSCINT     87
1001  FORMAT(14X,'KL = ',F6.4,' IS LESS THAN 1.0. DEFAULT VALUE ',      TSCINT     88
     *'OF 2.0 IS USED.')                                                TSCINT     89
 9030 FORMAT(14X,A,'=',F8.6,' IS BELOW THE LIMIT VALUE OF ',F4.2)       TSCINT     90
 9040 FORMAT(14X,A,' HAS BEEN SET TO ',F4.2)                            TSCINT     91
C                                                                       TSCINT     92
      RETURN                                                            TSCINT     93
C------------------------------------------------------------           TSCINT     94
      ENTRY TTSCDA(IUX)                                                 TSCINT     95
CD                                                                      TSCINT     96
CD    TO TABULATE TSC LOAD DATA.                                        TSCINT     97
CD                                                                      TSCINT     98
      LENTER=-1                                                         TSCINT     99
C                                                                       TSCINT    100
 300  IF(NTSCL.EQ.0) RETURN                                             TSCINT    101
      IIL=61                                                            TSCINT    102
      NLFL=0                                                            TSCINT    103
C                                                                       TSCINT    104
 310  CONTINUE                                                          TSCINT    105
      NLF=LBUSNO+1                                                      TSCINT    106
      DO 350 N=1,NTSCL                                                  TSCINT    107
      JTC=JTCDAT(N)                                                     TSCINT    108
      KC=IDDAT(JTC+1)                                                   TSCINT    109
      NLFC=NOLD(KC)                                                     TSCINT    110
      IF(NLFC.GE.NLF.OR.NLFC.LE.NLFL) GOTO 350                          TSCINT    111
      NLF=NLFC                                                          TSCINT    112
      K=KC                                                              TSCINT    113
 350  CONTINUE                                                          TSCINT    114
      N=NTSCL                                                           TSCINT    115
C                                                                       TSCINT    116
      IF(NLF.EQ.LBUSNO+1) RETURN                                        TSCINT    117
      NLFL=NLF                                                          TSCINT    118
      K3=K*3                                                            TSCINT    119
      VREAL=REAL(VOLT(K))                                               TSCINT    120
      VIMAG=AIMAG(VOLT(K))                                              TSCINT    121
      VMG2=VREAL**2+VIMAG**2                                            TSCINT    122
      P=VMG2*DDAT(JTC+10)                                               TSCINT    123
C                                                                       TSCINT    124
      IF(IIL.GE.60)THEN                                                 TSCINT    125
         IF(LENTER.EQ.-1)THEN                                           TSCINT    126
            WRITE(IUX,1010)                                             TSCINT    127
         ELSE                                                           TSCINT    128
            WRITE(IUX,1020)                                             TSCINT    129
         ENDIF                                                          TSCINT    130
         IIL=5                                                          TSCINT    131
      ENDIF                                                             TSCINT    132
      IF(LENTER.EQ.-1)THEN                                              TSCINT    133
        WRITE(IUX,1030) NLF,INAME(K3-2),INAME(K3-1),INAME(K3),P         TSCINT    134
     *                 ,(DDAT(JTC+JL),JL=2,8)                           TSCINT    135
        IIL=IIL+1                                                       TSCINT    136
      ELSEIF(LENTER.EQ.0.AND.N.NE.NTSCL)THEN                            TSCINT    137
        NLF1=NLF                                                        TSCINT    138
        K31=K3                                                          TSCINT    139
        P1=P                                                            TSCINT    140
        G01=DDAT(JTC+10)                                                TSCINT    141
        VMG21=VMG2                                                      TSCINT    142
        CMAG1=SQRT(DDAT(JTC+12)*DDAT(JTC+12)+DDAT(JTC+13)*DDAT(JTC+13)) TSCINT    143
        LENTER=1                                                        TSCINT    144
      ELSEIF(LENTER.EQ.1)THEN                                           TSCINT    145
        CMAG=SQRT(DDAT(JTC+12)*DDAT(JTC+12)+DDAT(JTC+13)*DDAT(JTC+13))  TSCINT    146
        WRITE(IUX,1040) NLF1,INAME(K31-2),INAME(K31-1),INAME(K31)       TSCINT    147
     *                 ,P1,G01,SQRT(VMG21),CMAG1                        TSCINT    148
     *                 ,NLF,INAME(K3-2),INAME(K3-1),INAME(K3)           TSCINT    149
     *                 ,P,DDAT(JTC+10),SQRT(VMG2),CMAG                  TSCINT    150
        LENTER=0                                                        TSCINT    151
        IIL=IIL+1                                                       TSCINT    152
      ELSE                                                              TSCINT    153
        CMAG=SQRT(DDAT(JTC+12)*DDAT(JTC+12)+DDAT(JTC+13)*DDAT(JTC+13))  TSCINT    154
        WRITE(IUX,1040) NLF,INAME(K3-2),INAME(K3-1),INAME(K3)           TSCINT    155
     *                 ,P,DDAT(JTC+10),SQRT(VMG2),CMAG                  TSCINT    156
        IIL=IIL+1                                                       TSCINT    157
      ENDIF                                                             TSCINT    158
      GOTO 310                                                          TSCINT    159
C ------------------------------------------------------------------    TSCINT    160
      ENTRY TTSCIN(IUX)                                                 TSCINT    161
CD                                                                      TSCINT    162
CD    TO TABULATE INITIAL CONDITIONS OF TSC LOAD.                       TSCINT    163
CD                                                                      TSCINT    164
      LENTER=0                                                          TSCINT    165
      GOTO 300                                                          TSCINT    166
C                                                                       TSCINT    167
 1010 FORMAT(1H1,28X,'THERMOSTATICALLY CONTROLLED (TSC) LOAD DATA',/    TSCINT    168
     *,29X,43('='),//,'  BUS#   BUS NAME           P        KP'         TSCINT    169
     *,'        KI        TC        K1        T1        KL        TA'   TSCINT    170
     *,/,' ----- ------------',8(1X,9('-')))                            TSCINT    171
 1020 FORMAT(1H1,33X                                                    TSCINT    172
     *,'THERMOSTATICALLY CONTROLLED (TSC) LOAD INITIAL CONDITIONS',/    TSCINT    173
     *,34X,57('='),//                                                   TSCINT    174
     *,'  BUS#   BUS NAME           P        G0      VMAG      IMAG',5X TSCINT    175
     *,'  BUS#   BUS NAME           P        G0      VMAG      IMAG',/  TSCINT    176
     *,2(' ----- ------------',4(1X,9('-')),5X))                        TSCINT    177
 1030 FORMAT(I6,1X,3A4,8F10.3)                                          TSCINT    178
 1040 FORMAT(2(I6,1X,3A4,2F10.3,2F10.5,5X))                             TSCINT    179
C                                                                       TSCINT    180
      END                                                               TSCINT    181
