View the file

Other files

File Type Posted
Sol_89303020REI000050.pdf PDF
SOW_ EMM to AIMMS migration_final_revised.pdf PDF

On GovTribe

Work with this file

  • Download the original file
  • Contacts named in this file
  • Similar government files
  • Ask GovTribe AI about this file

Text version

Appendix 1: AIMMS Conversion Sample

Following FORTRAN EFD subroutine ED$GAS and a set of corresponding AIMMS parameters are used to illustrate the EIA’s EFD AIMMS conversion process. Subroutine ED$GAS found in uefd.f is to set up the natural gas supply curves for the EFD to simulate the corresponding curves in the ECP.

FORTRAN subroutine containing OML calls to create EFD LP model

SUBROUTINE ED$GAS

use efd_row_col

IMPLICIT NONE

include'parametr' include'ncntrl' include'qblk' include'omlall.fi' include'emmparm' include'control' include'ecpcntl' include'uefdout include'convfact' include'angtdm' include'ngtdmrep' include'emission' include'emeblk' include'emablk' include'emoblk' include'cdsparms' include'csapr' include'emmemis'

INTEGER FRG,GRG,STP,SSN

INTEGER IRET

REAL*4 STSIZE,QTY,TOTSTP

REAL*4 ELNGSCRV

REAL*8 COEFF

CHARACTER*1 SSNCD(3)

CHARACTER*2 ST,GR

CHARACTER*16 ROW_G,ROW_S,COLUMN,ROWCAR

efdsub='ED$GAS'

! Assign codes for Seasons

SSNCD(1) = '1'

SSNCD(2) = '2'

SSNCD(3) = '3'

! Determine Utility Consumption from Last Iteration for Center Point

QTY = 0.0

DO FRG = 1 , UNRGNS

QTY = QTY + &

(UFLGFNR(1,FRG,CURIYR) + UFLGFNR(2,FRG,CURIYR)) + &

(UFLGINR(1,FRG,CURIYR) + UFLGINR(2,FRG,CURIYR)) + &

(UFLGCNR(1,FRG,CURIYR) + UFLGCNR(2,FRG,CURIYR)) + &

(UFLDGNR(1,FRG,CURIYR) + UFLDGNR(2,FRG,CURIYR))

end do

! If Gas Consumption = 0 (Probably because of infeasibility) use previous year

IF (QTY .LE. 0.0)THEN

QTY = 0.0

DO FRG = 1 , UNRGNS

QTY = QTY + &

(UFLGFNR(1,FRG,CURIYR-1) + UFLGFNR(2,FRG,CURIYR-1)) + &

(UFLGINR(1,FRG,CURIYR-1) + UFLGINR(2,FRG,CURIYR-1)) + &

(UFLGCNR(1,FRG,CURIYR-1) + UFLGCNR(2,FRG,CURIYR-1)) + &

(UFLDGNR(1,FRG,CURIYR-1) + UFLDGNR(2,FRG,CURIYR-1))

end do end if

!DKG PATCH

if (QTY .LE. 0.0) THEN

QTY = 2000.0

Endif

! Obtain Step Size (Used percent of total consumption from emmcntl and is consistent with ECP)

STSIZE = UPCRVSIZ * QTY

! Declare Row Type and Assign RHS

ROW_S = 'S_NGUS';call makmsk(ROW_S_mask,':S_NGUS:')

IF (EFDMAT .EQ. 0)THEN

! Production Row

CALL DROWTYPE(ROW_S,'L ',ROW_S_mask)

COEFF = DBLE(0.0)

CALL DRHS(EFDRHS,ROW_S,COEFF,ROW_S_mask,'ED$GAS,1')

END IF

! Production Vectors (Supply Steps) -- eventually use step variable from ECP

DO STP = 1 , 2 * UPCRVSTP + 1

WRITE(ST,'(I2.2)') STP

COLUMN = 'GPUS' // ST; call makmsk(COLUMN_mask,':GPUS:' , ST)

! Step Sizes (Center Point is Reference QTY)

IF (STP .EQ. 1)THEN

COEFF = DBLE(QTY - FLOAT(UPCRVSTP) * STSIZE)

TOTSTP = QTY - FLOAT(UPCRVSTP) * STSIZE

ELSE

COEFF = DBLE(STSIZE)

TOTSTP = TOTSTP + STSIZE

END IF

CALL DBND(EFDBND,COLUMN,0.0D0,COEFF,COLUMN_mask,'ED$GAS,2')

! Objective Function - Use Supply Curve Function from NGTDM

COEFF = DBLE(ELNGSCRV(CURIYR,FLOAT((STP - 1) - UPCRVSTP) * STSIZE))

IF (COEFF .LE. DBLE(0.001)) COEFF = FLOAT(STP) * COEFF

CALL DVAL(COLUMN,EFDOBJ,COEFF,COLUMN_mask,EFDOBJ,'ED$GAS,3')

! Put in Production Row

IF (EFDMAT .EQ. 0)THEN

COEFF = DBLE(-1.0)

CALL DVAL(COLUMN,ROW_S,COEFF,COLUMN_mask,ROW_S_mask,'ED$GAS,4')

END IF

END DO

! Transportation Row

DO GRG = 1 , NNGEM

DO SSN = 1, 3

WRITE(GR,'(I2.2)') GRG

ROW_G = 'NG' // GR // SSNCD(SSN); call makmsk(ROW_G_mask,':NG:' , GR , SSNCD(SSN))

IF (EFDMAT .EQ. 0)THEN

CALL DROWTYPE(ROW_G,'L ',ROW_G_mask)

COEFF = DBLE(0.0)

CALL DRHS(EFDRHS,ROW_G,COEFF,ROW_G_mask,'ED$GAS,5')

! Set Up Transportation Vectors

COLUMN = 'GTUS' // GR // SSNCD(SSN); call makmsk(COLUMN_mask,':GTUS:' , GR , SSNCD(SSN))

IF (EFDMAT .EQ. 0)THEN

COEFF = DBLE(1.0)

CALL DVAL(COLUMN,ROW_S,COEFF,COLUMN_mask,ROW_S_mask,'ED$GAS,6')

COEFF = DBLE(-1.0)

CALL DVAL(COLUMN,ROW_G,COEFF,COLUMN_mask,ROW_G_mask,'ED$GAS,7')

END IF

! Put in carbon row

ROWCAR = 'CARBONXX';ROWCAR_MASK='CARBON(**)'

COEFF = EGFEL(CURIYR) * 0.001

IF (COEFF .GT. EFD_MIN) CALL DVAL(COLUMN,ROWCAR,COEFF,COLUMN_mask,ROWCAR_mask)

! Objective Function (Markup)

COEFF = DBLE(SPNGELGR(GRG,CURIYR,SSN) - (OGWPRNG(MNUMOR,CURIYR) / CFNGC(CURIYR)))

! Remove carbon cost, if EFD constraint included

IF ((USW_CAR .EQ. 2 .OR. USW_CAR .EQ. 3) .AND. (CURIYR + UHBSYR) .GE. UYR_CAR)THEN

IF (TAX_FLAG .OR. PERMIT_FLAG)THEN

COEFF = COEFF - DBLE(JGFELGR(CURIYR))

END IF

CALL DVAL(COLUMN,EFDOBJ,COEFF,COLUMN_mask,EFDOBJ,'ED$GAS,8')

RETURN

END

AIMMS section containing ED$GAS related LP coefficient definitions as its parameters

DeclarationSection ED_GAS_Completed {

Parameter GASQTY {

Text: "trillion BTU";

Definition: { sum(SupplyRegion_Sub, (UFLGFNR('1',SupplyRegion_Sub,cyr)+(UFLGFNR('2',SupplyRegion_Sub,cyr))) +

(UFLGINR('1',SupplyRegion_Sub,cyr)+(UFLGINR('2',SupplyRegion_Sub,cyr))) +

(UFLGCNR('1',SupplyRegion_Sub,cyr)+(UFLGCNR('2',SupplyRegion_Sub,cyr))) +

(UFLDGNR('1',SupplyRegion_Sub,cyr)+(UFLDGNR('2',SupplyRegion_Sub,cyr))) )

Parameter ccalc_cGTUS_rS_NGUSle {

IndexDomain: (GasRegion,GasSeason);

Text: "OML Columns: GTUS(**)(*) and OML Rows: S_NGUS";

Definition: { if (EFDMAT('1') = 0.0) then

1.0 endif

Parameter ccalc_cGTUS_rNGle {

IndexDomain: (GasRegion,GasSeason);

Text: "OML Columns: GTUS(**)(*) and OML Rows: NG(**)(*)";

Definition: { if (EFDMAT('1') = 0.0) then

-1.0 endif

Parameter ccalc_cGPUS_rS_NGUSle {

IndexDomain: (GasProductionStep);

Text: "OML Columns: GPUS(**) and OML Rows: S_NGUS";

Definition: { if (EFDMAT('1') = 0.0) then

-1.0 endif

Parameter ccalc_cGPUS_UBOUND {

IndexDomain: (GasProductionStep);

Text: "OML Columns: GPUS(**) and OML Rows: UBOUND";

Definition: {

IF (GasProductionStep = '01') THEN

GASQTY - UPCRVSTP('1') * (UPCRVSIZ('1')*GASQTY)

ELSE

UPCRVSIZ('1') * GASQTY

ENDIF

Parameter ccalc_cGTUS_EFDCOSTS {

IndexDomain: (GasRegion,GasSeason);

Text: "OML Columns: GTUS(**)(*) and OML Rows: EFDCOSTS";

Definition: {

! Remove carbon cost, if EFD constraint included

IF ((USW_CAR('1') = 2 OR USW_CAR('1') = 3) AND (CURIYR('1') + UHBSYR('1')) >= UYR_CAR('1') and

(TAX_FLAG('1')=1 OR PERMIT_FLAG('1')=1) ) THEN

SPNGELGR(GasRegion,cyr,Three_element(GasSeason)) - (OGWPRNG('13',cyr) / CFNGC(cyr))-

JGFELGR(cyr)

ELSE

SPNGELGR(GasRegion,cyr,Three_element(GasSeason)) - (OGWPRNG('13',cyr) / CFNGC(cyr))

ENDIF

! 13 = max number of OGSM regions, replace with some identifier not hardwired

Parameter ccalc_cGTUS_rCARBONn {

IndexDomain: (CarbonRegion,GasRegion,GasSeason);

Text: "OML Columns: GTUS(**)(*) and OML Rows: CARBON(**)";

Definition: EGFEL(cyr) * 0.001;

AIMMS parameter conversion examples

Fortran code:

Converted AIMMS code:

File details come from the government source that posted it. Updated .