Adding Code to Define the Source

Instead of writing our own code to define the voltage source, we can use EMTDC internal subroutines to do it for us.  We simply need to ensure that all of the subroutine arguments are defined in the component before we call it.  The subroutines we will use are as follows:

Edit the component definition and in the Script section, navigate to the Fortran segment.

 

 

Add the following script to the segment (you may copy directly from here):

 

#BEGIN

      CALL E_BRANCH_CFG($BRN,$SS,1,0,0,$R,0.0,0.0)

      CALL E_1PVSRC_CFG(1,0,1,$Vrms,$f,0.0,$R,0.0,0.0,0.0,0.0,$tr)

#ENDBEGIN

#STORAGE LOGICAL:1 INTEGER:6 REAL:8 RTCF:4

#LOCAL REAL RVD1_1

#LOCAL REAL RVD1_2

#LOCAL REAL RVD1_3

#LOCAL REAL RVD1_4

! Single Phase AC source: Type: R

     RVD1_1 = RTCF(NRTCF)

     RVD1_2 = RTCF(NRTCF+1)

     RVD1_3 = RTCF(NRTCF+2)

     RVD1_4 = RTCF(NRTCF+3)

     NRTCF = NRTCF + 4

     CALL EMTDC_1PVSRC($SS,$BRN,RVD1_4,.TRUE.,RVD1_1,RVD1_2,RVD1_3)

The #BEGIN Block

The block of script between the #BEGIN and the #ENDBEGIN directives is runtime configurable code that will be inserted into the BEGIN section of the system dynamics in EMTDC.  Here, we are calling two EMTDC subroutines, which combined will initialize both the branch parameters and the source control.  Descriptions of the argument lists are given as follows:

 

E_BRANCH_CFG(NBR,M,ER,EL,EC,RO,HL,FC)

 

Argument List:

E_1PVSRC_CFG(AC,SPEC,TYP,VM,F,PH,R,L,RP_C,P,Q,TC)

 

Argument List:

Storage and Dynamics Script

The storage allocation (#STORAGE) is necessary as it provides memory usage information for dynamic memory dimensioning in EMTDC.  The LOGICAL, INTEGER and REAL allocations are the storage usage for the EMTDC_1PVSRC subroutine.  The RTCF allocation is used to dimension the runtime configurable storage.

 

Directly preceding the call to the EMTDC_1PVSRC subroutine is the extraction of initialized values from the RTCF storage array.  The values stored in this array are defined in the BEGIN section at the beginning of the simulation (within the E_1PVSRC_CFG subroutine) and remain constant.  Extracting this data from storage ensures that the initialized values are instance-dependent – that is they are specific to wherever this component code is placed in the system dynamics.

 

The last bit is the actual call to the subroutine that controls the source throughout the simulation:  EMTDC_1PVSRC.  

 

EMTDC_1PVSRC(M,NBR,RT,AC,VP, W, A)

 

Argument List:

Save the Project.