CFPRIME LOSECT                                                          LOSECT      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 LOSECT(ICODE,NPBNOI,NPBNOJ,CID,SID                     LOSECT      3
     &,PFLINE,PLEFT,PSLINE)                                             LOSECT      4
CD                                                                      LOSECT      5
CD    TO CALCULATE THE EQUIVALENT PI CIRCUIT WHEN A CAPACTOR FLASH OR   LOSECT      6
CD    BEING REINSERT.                                                   LOSECT      7
CD                                                                      LOSECT      8
CD    INPUT OF THE ROUTINE ARE:                                         LOSECT      9
CD                                                                      LOSECT     10
CD    1. NPBNOI AND NPBNOJ ARE THE FROM- AND TO-BUS NUMBER              LOSECT     11
CD    2. ICID AND ISID ARE 4 BYTE INTEGERS THAT CONTAINS                LOSECT     12
CD       THE CIRCUIT AND SECTION IDENTITIES OF THE LINE                 LOSECT     13
CD                                                                      LOSECT     14
      INCLUDE 'PARX.INS'                                                LOSECT     15
      INCLUDE 'CNFLAG.INS'                                              LOSECT     16
      INCLUDE 'CNPT.INS'                                                LOSECT     17
      INCLUDE 'CNB19.INS'                                               LOSECT     18
      INCLUDE 'CNLFDA.INS'                                              LOSECT     19
      INCLUDE 'CNSELI.INS'                                              LOSECT     20
      INCLUDE 'CNMSG.INS'                                               LOSECT     21
C                                                                       LOSECT     22
      CHARACTER*2 CID,SID,CKT                                           LOSECT     23
      INTEGER LISMON(NPL)                                               LOSECT     24
      EQUIVALENCE (BUDAT(1),LISMON(1))                                  LOSECT     25
C                                                                       LOSECT     26
      DIMENSION PFLINE(6),PLEFT(6),PSLINE(6)                            LOSECT     27
C                                                                       LOSECT     28
      COMPLEX ZCX(20),Y1CX(20),Y2CX(20)                                 LOSECT     29
C                                                                       LOSECT     30
      LDEB=(JDEB(22).NE.0)                                              LOSECT     31
C                                                                       LOSECT     32
C                                                                       LOSECT     33
      CALL LOLINE(NPBNOI,NPBNOJ,CID,JNL)                                LOSECT     34
C                                                                       LOSECT     35
      IF(JNL.NE.0)THEN                                                  LOSECT     36
C                                                                       LOSECT     37
C   BRANCH FOUND                                                        LOSECT     38
C                                                                       LOSECT     39
      JNL5=IABS(JNL)                                                    LOSECT     40
      ITFK=LISMON(JNL5)                                                 LOSECT     41
      CALL UPACKI(JJJ,NMLINE,ITFK)                                      LOSECT     42
      JTRF=LTRANC(JNL5)                                                 LOSECT     43
      JNL5=JNL5*5                                                       LOSECT     44
      ITFK=LFTB(JNL5-4)                                                 LOSECT     45
      CALL UNPACK(CKT,NJSELI,ITFK)                                      LOSECT     46
C                                                                       LOSECT     47
      ELSE                                                              LOSECT     48
C                                                                       LOSECT     49
C     STORE NOT FOUND LOGIC                                             LOSECT     50
C                                                                       LOSECT     51
      GOTO 600                                                          LOSECT     52
C                                                                       LOSECT     53
      ENDIF                                                             LOSECT     54
C                                                                       LOSECT     55
      IPOS=LCONE(5,NJSELI)                                              LOSECT     56
      IPOS1=IPOS+LCONE(6,NJSELI)-1                                      LOSECT     57
      ISECT=1                                                           LOSECT     58
      KSECT=0                                                           LOSECT     59
C                                                                       LOSECT     60
C   STORE THE PI EQUIVALENT INCLUDE THE CAPACITOR GAP                   LOSECT     61
C                                                                       LOSECT     62
      PFLINE(1)=EQPI(1,NJSELI)                                          LOSECT     63
      PFLINE(2)=EQPI(2,NJSELI)                                          LOSECT     64
      PFLINE(3)=EQPI(3,NJSELI)                                          LOSECT     65
      PFLINE(4)=EQPI(4,NJSELI)                                          LOSECT     66
      PFLINE(5)=EQPI(5,NJSELI)                                          LOSECT     67
      PFLINE(6)=EQPI(6,NJSELI)                                          LOSECT     68
C                                                                       LOSECT     69
C   FOR LINE WITH ONE SECTION ONLY                                      LOSECT     70
C                                                                       LOSECT     71
      IF(IPOS.EQ.IPOS1)THEN                                             LOSECT     72
          IF(PSELIN(2,IPOS).GE.0.0)THEN                                 LOSECT     73
             IEBK=1                                                     LOSECT     74
             WRITE(MSG(1),1120) NPBNOI,NPBNOJ,CID,SID                   LOSECT     75
             WRITE(MSG(2),1130)                                         LOSECT     76
             CALL PRTMSG(2)                                             LOSECT     77
             GOTO 600                                                   LOSECT     78
          ENDIF                                                         LOSECT     79
          PSLINE(1)=1000.                                               LOSECT     80
          PSLINE(2)=0.0                                                 LOSECT     81
          PSLINE(3)=EQPI(3,NJSELI)                                      LOSECT     82
          PSLINE(4)=EQPI(4,NJSELI)                                      LOSECT     83
          PSLINE(5)=EQPI(5,NJSELI)                                      LOSECT     84
          PSLINE(6)=EQPI(6,NJSELI)                                      LOSECT     85
          PLEFT(1)=0.0                                                  LOSECT     86
          PLEFT(2)=0.0                                                  LOSECT     87
          PLEFT(3)=0.0                                                  LOSECT     88
          PLEFT(4)=0.0                                                  LOSECT     89
          PLEFT(5)=0.0                                                  LOSECT     90
          PLEFT(6)=0.0                                                  LOSECT     91
          GOTO 500                                                      LOSECT     92
      ENDIF                                                             LOSECT     93
C                                                                       LOSECT     94
      DO 100 II=IPOS,IPOS1                                              LOSECT     95
          IF(CNEXTS(2,II).EQ.SID)THEN                                   LOSECT     96
          KSECT=1                                                       LOSECT     97
          IF(PSELIN(2,II).LT.0.0)THEN                                   LOSECT     98
          IF(NEXTSL(3,II).NE.0)THEN                                     LOSECT     99
             IEBK=1                                                     LOSECT    100
             WRITE(MSG(1),1120) NPBNOI,NPBNOJ,CID,SID                   LOSECT    101
             WRITE(MSG(2),1130)                                         LOSECT    102
             CALL PRTMSG(2)                                             LOSECT    103
             GOTO 600                                                   LOSECT    104
           ELSE                                                         LOSECT    105
           ISECT=ISECT-1                                                LOSECT    106
C                                                                       LOSECT    107
C   CALCULATE THE PI EQUIVALENT LEFT TO THE CAPACITOR GAP               LOSECT    108
C                                                                       LOSECT    109
           CALL ABCD(ISECT,ZCX,Y1CX,Y2CX,REQ,XEQ,G1EQ,B1EQ,G2EQ,B2EQ)   LOSECT    110
           YMAG=REQ*REQ+XEQ*XEQ                                         LOSECT    111
           PLEFT(1)=REQ/YMAG                                            LOSECT    112
           PLEFT(2)=XEQ/YMAG                                            LOSECT    113
           PLEFT(3)=G1EQ                                                LOSECT    114
           PLEFT(4)=B1EQ                                                LOSECT    115
           PLEFT(5)=G2EQ                                                LOSECT    116
           PLEFT(6)=B2EQ                                                LOSECT    117
C                                                                       LOSECT    118
           ENDIF                                                        LOSECT    119
          ENDIF                                                         LOSECT    120
          ELSE                                                          LOSECT    121
          YMAG=PSELIN(1,II)*PSELIN(1,II)+PSELIN(2,II)*PSELIN(2,II)      LOSECT    122
          ZREAL=PSELIN(1,II)/YMAG                                       LOSECT    123
          ZIMAG=PSELIN(2,II)/YMAG                                       LOSECT    124
          ZCX(ISECT)=CMPLX(ZREAL,ZIMAG)                                 LOSECT    125
          Y1CX(ISECT)=CMPLX(PSELIN(3,II),PSELIN(4,II))                  LOSECT    126
          Y2CX(ISECT)=CMPLX(PSELIN(5,II),PSELIN(6,II))                  LOSECT    127
          ENDIF                                                         LOSECT    128
  100  ISECT=ISECT+1                                                    LOSECT    129
       IF(KSECT.EQ.0)THEN                                               LOSECT    130
       IEBK=1                                                           LOSECT    131
       WRITE(MSG(1),1120) NPBNOI,NPBNOJ,CID,SID                         LOSECT    132
       WRITE(MSG(2),1130)                                               LOSECT    133
       CALL PRTMSG(2)                                                   LOSECT    134
       GOTO 600                                                         LOSECT    135
       ENDIF                                                            LOSECT    136
C                                                                       LOSECT    137
C   CALCULATE THE PI EQUIVALENT WITHOUT THE CAPACITOR GAP               LOSECT    138
C                                                                       LOSECT    139
       CALL ABCD(ISECT,ZCX,Y1CX,Y2CX,REQ,XEQ,G1EQ,B1EQ,G2EQ,B2EQ)       LOSECT    140
       YMAG=REQ*REQ+XEQ*XEQ                                             LOSECT    141
       PSLINE(1)=REQ/YMAG                                               LOSECT    142
       PSLINE(2)=XEQ/YMAG                                               LOSECT    143
       PSLINE(3)=G1EQ                                                   LOSECT    144
       PSLINE(4)=B1EQ                                                   LOSECT    145
       PSLINE(5)=G2EQ                                                   LOSECT    146
       PSLINE(6)=B2EQ                                                   LOSECT    147
C                                                                       LOSECT    148
 500   CONTINUE                                                         LOSECT    149
C                                                                       LOSECT    150
       IF(JNL.LT.0)THEN                                                 LOSECT    151
       NLFI=NPBNOJ                                                      LOSECT    152
       NLFJ=NPBNOI                                                      LOSECT    153
       ELSE                                                             LOSECT    154
       NLFI=NPBNOI                                                      LOSECT    155
       NLFJ=NPBNOJ                                                      LOSECT    156
       ENDIF                                                            LOSECT    157
C                                                                       LOSECT    158
 600  CONTINUE                                                          LOSECT    159
C                                                                       LOSECT    160
      RETURN                                                            LOSECT    161
C                                                                       LOSECT    162
 1120 FORMAT(' ** ERROR IN LOSECT- CAPACTOR',2I10,2A2,' DOES NOT EXIST')LOSECT    163
 1130 FORMAT(5X,'CHECK YOUR SCGR DATA DECK')                            LOSECT    164
      END                                                               LOSECT    165
