CFPRIME BINJCT                                                          BINJCT      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  BINJCT                                                BINJCT      3
CD -------------------------------------------------------------------  BINJCT      4
CD                                                                      BINJCT      5
CD              *****     BINJCT  ROUTINE   *****                       BINJCT      6
CD                                                                      BINJCT      7
CD -------------------------------------------------------------------  BINJCT      8
CD                                                                      BINJCT      9
CD       PURPOSE:  Calculates total current injection at each           BINJCT     10
CD                 converter ac bus, from all converters on bus.        BINJCT     11
CD                                                                      BINJCT     12
CD                                                                      BINJCT     13
CD       DEFINITION OF LOCAL VARIABLES:                                 BINJCT     14
CD                 XIP     -  part of real power.                       BINJCT     15
CD                 XIQ     -  part of imaginary power.                  BINJCT     16
CD                 K      - 'do' loop index.                            BINJCT     17
CD                 NUM    -  pointer to location of voltage in dCD      BINJCT     18
CD                           arrays from converter reference.           BINJCT     19
CD                 JPOSN   -  storage position for dc information.      BINJCT     20
CD                 RP     -  part of imaginary power.                   BINJCT     21
CD                 RQ     -  part of real power.                        BINJCT     22
CD                                                                      BINJCT     23
CD -------------------------------------------------------------------  BINJCT     24
      INCLUDE 'PARX.INS'                                                BINJCT     25
      INCLUDE 'CNPT.INS'                                                BINJCT     26
      INCLUDE 'GRDC01.INS'                                              BINJCT     27
      INCLUDE 'GRDC02.INS'                                              BINJCT     28
      INCLUDE 'GRPDCS.INS'                                              BINJCT     29
      INCLUDE 'UDCF.INS'                                                BINJCT     30
      INCLUDE 'UDCJ.INS'                                                BINJCT     31
C                                                                       BINJCT     32
      DO 20 NUM = 1, NACBUS                                             BINJCT     33
         PASUM(NUM) = 0.0                                               BINJCT     34
         QASUM(NUM) = 0.0                                               BINJCT     35
 20   CONTINUE                                                          BINJCT     36
C                                                                       BINJCT     37
C     For each line commutated dc converter, add the current injection  BINJCT     38
C     to the corresponding ac bus.                                      BINJCT     39
C                                                                       BINJCT     40
C     NOTE:  PASUM and QASUM are the summation of currents NOT          BINJCT     41
C            powers for line commutated converters only.                BINJCT     42
C                                                                       BINJCT     43
      DO 40 K = 1, LCDC                                                 BINJCT     44
         IF(IDC(K) .NE. 0)THEN                                          BINJCT     45
            JPOSN = IDC(K)                                              BINJCT     46
            NUM = IDCBNU(JPOSN)                                         BINJCT     47
            IF(NUM .EQ. 0) GO TO 40                                     BINJCT     48
            PASUM(NUM) = PASUM(NUM) + REALI(JPOSN)                      BINJCT     49
            QASUM(NUM) = QASUM(NUM) + XIMAGI(JPOSN)                     BINJCT     50
         ENDIF                                                          BINJCT     51
 40   CONTINUE                                                          BINJCT     52
C                                                                       BINJCT     53
C     Calculate real power injection and add to total injection         BINJCT     54
C     since last major ac solution.                                     BINJCT     55
C                                                                       BINJCT     56
      DO 60 NUM = 1, NACBUS                                             BINJCT     57
         XIP = DCEA(NUM) * PASUM(NUM)                                   BINJCT     58
         XIQ = DCEB(NUM) * PASUM(NUM)                                   BINJCT     59
         RQ = DCEA(NUM) * QASUM(NUM)                                    BINJCT     60
         RP = DCEB(NUM) * QASUM(NUM)                                    BINJCT     61
         PTHVDC(NUM) = PTHVDC(NUM) + (RP + XIP)                         BINJCT     62
         QTHVDC(NUM) = XIQ - RQ                                         BINJCT     63
60    CONTINUE                                                          BINJCT     64
C                                                                       BINJCT     65
C---------------------------------------------------------------------  BINJCT     66
C                                                                       BINJCT     67
      RETURN                                                            BINJCT     68
C                                                                       BINJCT     69
      END                                                               BINJCT     70
