Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Thank you for your response... I have assumed that they are initial values that we need to give. please correct me if I am wrong.

Please find the below code

C[PSS_EDB] SIMPLIFIED EXCITATION SYSTEM MODEL C (Version Independent Form) C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * C * * C * THIS PROGRAM AND ITS DOCUMENTATION ARE TRADE SECRETS OF POWER TECHNO- * C * LOGIES, A DIVISION OF S&W CONSULTANTS, INC. THEY HAVE BEEN LEASED TO * C * YOU, OUR CLIENT, * C * SUBJECT TO TERMS WHICH PROHIBIT YOU FROM DISCLOSING OR TRANSFERRING * C * THE PROGRAM OR ITS DOCUMENTATION, WHETHER IN ITS ORIGINAL OR MODIFIED * C * FORM, TO A THIRD PARTY, OR FROM USING THE PROGRAM FOR ANY PURPOSE * C * OTHER THAN COMPUTATION RELATING TO YOUR OWN SYSTEM. ANY SUCH * C * TRANSFER OR USE BY YOU OR YOUR EMPLOYEES WILL CONSTITUTE A BREACH OF * C * CONFIDENCE AND OF THE CONTRACT UNDER WHICH RIGHTS OF USE HAVE BEEN * C * GRANTED. * C * * C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  SUBROUTINE PSS_EDN(MC,SLOT)

C++ C define the local variables and global variables that are going to be used C in the model C--
USE PSSDM ! this is the global declaration

  IMPLICIT NONE

C++ C Now add all the local variable declarations that will be used in this C model C--
INTEGER IB ! bus index INTEGER IERR ! error code INTEGER J ! starting CON index INTEGER K ! starting state index INTEGER L ! starting VAR index INTEGER M ! starting ICON index INTEGER MC ! this is the machine index INTEGER SLOT ! used to get starting indices J, K, L & M

  REAL VINP   ! block input
  REAL VOUT   ! block output

  LOGICAL ERRFLG ! used in docu,check functionality

  IF (GET_MODE() == 8) THEN

C++ C Add the logic here for whatever the model is expected to do when MODE is C 8. C-- J=1 CALL SETCONDSCRPT('KVT (pu), VTGain onstant', J) CALL SETCONDSCRPT('TR (s), lead time constant', J+1) CALL SETCONDSCRPT('TC2 (s), lag time constant', J+2) CALL SETCONDSCRPT('TB2 (s), lag time constant', J+3) CALL SETCONDSCRPT('TC1 (s), lag time constant', J+4) CALL SETCONDSCRPT('TB1 (s), lag time constant', J+5) CALL SETCONDSCRPT('KR (pu), exciter gain', J+6) CALL SETCONDSCRPT('KS (pu), exciter gain', J+7) CALL SETCONDSCRPT('TS (s), exciter time constant', J+8) CALL SETCONDSCRPT('KC (pu), exciter gain', J+9) CALL SETCONDSCRPT('EMIN (pu), exciter minimum', J+10) CALL SETCONDSCRPT('EMAX (pu), exciter maximum', J+11)

     K=1
     CALL SET_STATE_DSCRPT('First state of the block', K)
     CALL SET_STATE_DSCRPT('Second state of the block', K+1)
     CALL SET_STATE_DSCRPT('Third state of the block', K+2)
     CALL SET_STATE_DSCRPT('Fourth state of the block', K+3)

     RETURN
  ENDIF

C++ C At this point in the code, MODE is any value 1 through 7 C-- J = GETSTRTIN(1,SLOT) ! starting CON index K = GETSTRTIN(2,SLOT) ! starting state index L = GETSTRTIN(3,SLOT) ! since this model does not use VAR, L will be 0 M = GETSTRTIN(4,SLOT) ! since this model does not use ICON, M will be 0 C++ C Get the value of IB which is the bus index. IB is the index of the bus C at which the machie is connected C-- IB = GETNUMTRM(MC) ! bus sequence number C++ C If NUMTRM(MC) is negative (which means that IB has a negative value) C it means machine is not in-service C-- IF (GETMODE() > 4) GO TO 100 ! MODE 5 to 7, we jump to statement 100 C++ C At this point in the code, MODE is any value 1 through 4 C-- IF (GETMODE() == 2) THEN C++ C Add the logic here for whatever the model is expected to do when MODE is C 2. C-- IF (GETMIDTRM()) RETURN ! model is not ready for Mid-term simulation C++ C At this point we know that we are running the normal stat-space C simulation C--

     VINP = GET_ETERM(MC)  ! Take the Terminal Voltage VT

     VOUT = NWLAG_MODE2(GET_CON(J), ! K_VT exciter gain
 &                      GET_CON(J+1), ! TR exciter time constant
 &                      GET_CON(J+11), ! Emax
 &                      GET_CON(J+10), ! Emin
 &                      VINP,         ! block input
 &                      K)          ! state index of this block

C V_Error Input to the next stage Blocks

     VINP = GET_VREF(MC) - VOUT + GET_VOTHSG(MC) + GET_VUEL(MC) + 
 &          GET_VOEL(MC)


     VOUT = LDLG_MODE2(1.0,          ! lead-lag block gain
 &                     GET_CON(J+2), ! TC2
 &                     GET_CON(J+3), ! TB2
 &                     VINP,         ! block input
 &                     K+1)            ! state index of this block
 &

C Linit Checking for the LDLG Block

     IF ((VOUT > GET_CON(J+11)) .OR. (VOUT < GET_CON(J+10))) THEN
        IF (VOUT > GET_CON(J+11)) THEN
           WRITE(DBUF01,107) VOUT, ' is greater than Emax= ',GET_CON(J+11)
        ELSE
           WRITE(DBUF01,107) VOUT, ' is less than Emin= ',GET_CON(J+10)
        ENDIF
        CALL ShowModel(GET_W7PRG())
        CALL PROGRESS(DBUF01,1)
     ENDIF

C Multiplying With Gain KR

     VOUT = VOUT * GET_CON(J+6)

     VINP = VOUT

     VOUT = LDLG_MODE2(1.0,          ! lead-lag block gain
 &                     GET_CON(J+4), ! TC1
 &                     GET_CON(J+5), ! TB1
 &                     VINP,         ! block input
 &                     K+2)            ! state index of this block

C Linit Checking for the LDLG Block

     IF ((VOUT > GET_CON(J+11)) .OR. (VOUT < GET_CON(J+10))) THEN
        IF (VOUT > GET_CON(J+11)) THEN
           WRITE(DBUF01,107) VOUT, ' is greater than Emax= ',GET_CON(J+11)
        ELSE
           WRITE(DBUF01,107) VOUT, ' is less than Emin= ',GET_CON(J+10)
        ENDIF
        CALL ShowModel(GET_W7PRG())
        CALL PROGRESS(DBUF01,1)
     ENDIF

     VINP = VOUT

     VOUT = NWLAG_MODE2(GET_CON(J+9), ! KS exciter gain
 &                      GET_CON(J+8), ! TS exciter time constant
 &                      GET_CON(J+11), ! Emax
 &                      GET_CON(J+10), ! Emin
 &                      VINP,         ! block input
 &                      K+3)          ! state index of this block

     RETURN
  ENDIF

  IF (GET_MODE() == 3) THEN

C++ C Add the logic here for whatever the model is expected to do when MODE is C 3. C-- IF (GET_MIDTRM()) RETURN ! model is not ready for Mid-term simulation C++ C At this point we know that we are running the normal stat-space C simulation C--

     VOUT = NWLAG_MODE3(GET_CON(J), ! K_VT exciter gain
 &                      GET_CON(J+1), ! TR exciter time constant
 &                      GET_CON(J+11), ! Emax
 &                      GET_CON(J+10), ! Emin
 &                      VINP,         ! block input
 &                      K)          ! state index of this block

     VINP = VOUT

     VOUT = LDLG_MODE3(1.0,          ! lead-lag block gain
 &                     GET_CON(J+2), ! TC2
 &                     GET_CON(J+3), ! TB2
 &                     VINP,         ! block input
 &                     K+1)            ! state index of this block

     VOUT = VOUT * GET_CON(J+6)
     VINP = VOUT

     VOUT = LDLG_MODE3(1.0,          ! lead-lag block gain
 &                     GET_CON(J+4), ! TC1
 &                     GET_CON(J+5), ! TB1
 &                     VINP,         ! block input
 &                     K+2)            ! state index of this block

     VINP = VOUT 

     VOUT = NWLAG_MODE2(GET_CON(J+9), ! KS exciter gain
 &                      GET_CON(J+8), ! TS exciter time constant
 &                      GET_CON(J+11), ! Emax
 &                      GET_CON(J+10), ! Emin
 &                      VINP,         ! block input
 &                      K+3)          ! state index of this block

C++ C Set the model output C-- CALL SET_EFD(VOUT, MC)

     RETURN
  ENDIF

  IF (GET_MODE() == 4) THEN

C++ C Add the logic here for whatever the model is expected to do when MODE is C 4. C-- IF (GET_MIDTRM()) THEN C++ C MIDTRM is a logical global variable which is accessible via the include C of COMON4.INS. This variable will be TRUE if the user attempts to run C a mid-term type simulation. C C Put out a message that the model is not ready or not coded to be run in C mid-term type simulation C--
CALL NOTMID ! this function will put out the necessary message
RETURN

     ELSE     ! means MIDTRM is false

C++ C Check if the highest state number is greater than NINTEG, if it is then C set NINTEG equal to the highest state number of that model C-- IF (K+3 > GETNINTEG()) CALL SETNINTEG(K+3) ENDIF

     RETURN
  ENDIF

C IF (GETMODE() == 1) THEN C++ C Add the logic here for whatever the model is expected to do when MODE is C 1. C-- IF (GETMIDTRM()) RETURN ! model is not ready for Mid-term simulation

     VOUT = GET_EFD(MC)

     VOUT = VOUT - (GET_XADIFD(MC)/GET_CON(J+9))  ! IFD/KC

     IF ((VOUT > GET_CON(J+11)) .OR. (VOUT < GET_CON(J+10))) THEN
        IF (VOUT > GET_CON(J+11)) THEN
           WRITE(DBUF01,107) VOUT, ' is greater than Emax= ',GET_CON(J+11)
        ELSE
           WRITE(DBUF01,107) VOUT, ' is less than Emin= ',GET_CON(J+10)
        ENDIF
        CALL ShowModel(GET_W7PRG())
        CALL PROGRESS(DBUF01,1)
     ENDIF

     VINP = NWLAG_MODE1(GET_CON(J+7), ! exciter gain
 &                      GET_CON(J+8), ! exciter time constant
 &                      GET_CON(J+11), ! Emax
 &                      GET_CON(J+10), ! Emin
 &                      VOUT,         ! block input
 &                      K+3,          ! state index of this block
 &                      IERR)         ! erro code

     VOUT = VINP

     VINP = LDLG_MODE1(1.0,          ! lead-lag block gain
 &                     GET_CON(J+4), ! TC1
 &                     GET_CON(J+5), ! TB1
 &                     VINP,         ! block input
 &                     K+2,            ! state index of this block
 &                     IERR)         ! erro code

C Limit Checking for Lead Lag Block Above

     IF ((VINP > GET_CON(J+11)) .OR. (VINP < GET_CON(J+10))) THEN
        IF (VINP > GET_CON(J+11)) THEN
           WRITE(DBUF01,107) VINP, ' is greater than Emax= ',GET_CON(J+11)
        ELSE
           WRITE(DBUF01,107) VINP, ' is less than Emin= ',GET_CON(J+10)
        ENDIF
        CALL ShowModel(GET_W7PRG())
        CALL PROGRESS(DBUF01,1)
     ENDIF

     VINP = VINP/GET_CON(J+6)   ! ! Devided by KR

     VOUT = VINP

     VINP = LDLG_MODE1(1.0,          ! lead-lag block gain
 &                     GET_CON(J+2), ! TC1
 &                     GET_CON(J+3), ! TB1
 &                     VINP,         ! block input
 &                     K+1,            ! state index of this block
 &                     IERR)         ! erro code

C Limit Checking for Lead Lag Block Above

     IF ((VINP > GET_CON(J+11)) .OR. (VINP < GET_CON(J+10))) THEN
        IF (VINP > GET_CON(J+11)) THEN
           WRITE(DBUF01,107) VINP, ' is greater than Emax= ',GET_CON(J+11)
        ELSE
           WRITE(DBUF01,107) VINP, ' is less than Emin= ',GET_CON(J+10)
        ENDIF
        CALL ShowModel(GET_W7PRG())
        CALL PROGRESS(DBUF01,1)
     ENDIF

     VOUT = VINP

     CALL SET_VREF(VINP + GET_ETERM(MC) - GET_VOTHSG(MC) - GET_VUEL(MC) - 
 &                 GET_VOEL(MC), MC)

C VINP = NWLAGMODE1(GETCON(J), ! exciter gain C & GETCON(J+1), ! exciter time constant C & GETCON(J+11), ! Emax C & GET_CON(J+10), ! Emin C & VOUT, ! block input C & K, ! state index of this block C & IERR) ! erro code

C VOUT = VINP

     RETURN
  ENDIF

C++ C At this point, MODE can be any value 5 through 7 C-- 100 IB = ABS(IB) IF (GETMODE() == 6) THEN C++ C Add the logic here for whatever the model is expected to do when MODE is C 6. C-- WRITE(DBUF01,507) NUMBUS(IB), GETMACHID(MC), GETCON(J, J+11) CALL REPORTS(GETIPRT(),DBUF01,2)

     RETURN
  ENDIF

  IF ((GET_MODE()==5) .OR. (GET_MODE()==7)) THEN

C++ C Here MODE can be either 5 or 7 C--
IF (GET_MODE() == 5) THEN

        CALL docuHeading    ! this prints out the heading for DOCU

     ELSE   ! else here means MODE can only be 7

C++ C Here MODE has a value of 7. Do the data checking for the model C-- CALL DOCUCHK(3,'KVT',GETCONMSGWARN(), & GETDOCUCHKERREQUAL(),0.0,0.0,ERRFLG) CALL DOCUCHK(4,'TR',GETCONMSGWARN(), & GETDOCUCHKERREQUAL(),0.0,0.0,ERRFLG) IF (.NOT. ERRFLG) THEN ! means is Te is not zero CALL DOCUCHK(4,'TR',GETCONMSGWARN(), & GETDOCUCHKERRINCLUSIVERANGE(),0.1,0.5,ERRFLG) ENDIF C++ C After doing data checking: C a) if there are no errors, RETURN back to PSSE. C b) if there is one or more data error, proceed further down, C-- IF (.NOT. ErrorsFound()) RETURN

     ENDIF

C++ C When code comes in here it means either of the following: C a) MODE is 5 C b) MODE is 7 and there is at least one data error C We do the following here: C a) list the model CON, ICON indices C b) list out the CON data C-- CALL SHOWMODELINDICIES(0, ! starting ICON (0 means no ICONs) & 0, ! last ICON of the model & J, ! starting CON of the model & J+11, ! last CON of the model & K, ! starting state index of the model & K+3, ! last state index of the model & 0, ! starting VAR index (0 means no VARs) & 0, ! 1 VAR and hence specify this as 0 & 0, ! starting reserved ICON & 0) ! ending reserved ICON C++ C Now write out the CON value C-- WRITE(DBUF01,7) GETCON(J, J+11) CALL REPORTS(GETIPRT(),DBUF01,12) ! 6 is the number of lines of DBUF01

     RETURN
  ENDIF

C++ C All Format statements are placed in one place for ease of readig C-- 7 FORMAT(/' K_VT TR TC2'/5X,3(G11.4,3X)// & ' TB2 TC1 TB1'/5X,3(G11.4,3X)// & ' KR KS TS'/5X,3(G11.4,3X)// & ' KC EMIN EMAX'/5X,3(G11.4,3X))

107 FORMAT(1X,' Initial Efd= ', G12.5,A,G12.5) 507 FORMAT(I7,' ''USRMDL'' ',A,' ''PSSEDN'' 4 0 0 6 2 0 4 0 0 6 2 0'/ & 7X,12(G12.12,3X),' /') C ----------------------------------------------------------------------------- END SUBROUTINE PSSEDN

Please help me how to solve the issue