diff --git a/source/.gitattributes b/source/.gitattributes index e1ae61e..5536f79 100644 --- a/source/.gitattributes +++ b/source/.gitattributes @@ -1,5 +1,10 @@ # do not attempt any end-of-line conversion * -text +# Exclude files from archive +/.github export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore + # These files are in the GAMS language *.gms linguist-language=GAMS *.mod linguist-language=GAMS @@ -8,6 +13,7 @@ *.def linguist-language=GAMS *.dsc linguist-language=GAMS *.cli linguist-language=GAMS +*.ecb linguist-language=GAMS *.etl linguist-language=GAMS *.ier linguist-language=GAMS *.lin linguist-language=GAMS diff --git a/source/.github/ISSUE_TEMPLATE/bug_report.md b/source/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..4c3f387 --- /dev/null +++ b/source/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,34 @@ +--- +name: Bug report +about: Create a report to help us improve TIMES +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Provide information for reproducing the bug, as much in detail as possible: +- Which TIMES feature used in your model appears to be triggering the bad behavior? +- What exactly is the manifested incorrect or undesirable behaviour? +- Which steps would be needed to be able to reproduce the bad behavior? + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Test case** +If possible, attach a ZIP file containing the TIMES input files (*.DD, \*.RUN) and the listing file (\*.LST) for a test case reproducing the issue. + +**Versions (please complete the following information):** + - GAMS version used (e.g. GAMS 27.3) + - TIMES version used (see version info in QA_Check.log) + - Operating system (if not Windows) + +**Additional context** +Add any other context about the problem here. diff --git a/source/.github/ISSUE_TEMPLATE/feature_request.md b/source/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..5e7b89f --- /dev/null +++ b/source/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,22 @@ +--- +name: Feature request +about: Suggest an idea for ETSAP-TIMES +title: '' +labels: enhancement +assignees: '' + +--- + +**Is your feature request related to a modeling issue? Please describe.** +A clear and concise description of what the modeling issue is. Ex.: I'm always frustrated when [...] + +**Describe the solution you'd like to have implemented** +A clear and concise description of the new or improved functionality: +- If applicable, describe the new input attribute(s) needed for the new feature(s) +- Describe what should happen when the new or improved feature(s) are used + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/source/Version.log b/source/Version.log index fa9f5f3..f0405b9 100644 --- a/source/Version.log +++ b/source/Version.log @@ -2749,4 +2749,101 @@ Modified files: (reason) initsys.mod : Increased version number to 4.7.3 setglobs.gms : (1) coef_obj.mod : (1) -mod_vars.cli : (2) \ No newline at end of file +mod_vars.cli : (2) + +----------------------------------------------------------------------------------------- +TIMES Version 4.7.4 +----------------------------------------------------------------------------------------- +Date: 13-Oct-2023 [AL]: Maintenance release +1) Fixed bug related to zero new capacities when deriving logit market shares +2) Fixed bug related to zero SHAPE values for NCAP_CPX +3) Cosmetic improvements + +Modified files: (reason) +initsys.mod : Increased version number to 4.7.4 +ppmain.mod : (3) +coef_shp.mod : (2) +eqobjvar.mod : (3) +eqobjels.mod : (3) +eqobjvar.rpt : (3) +equ_ext.abs : (3) +rpt_ext.ecb : (1) + +----------------------------------------------------------------------------------------- +TIMES Version 4.7.5 +----------------------------------------------------------------------------------------- +Date: 28-Oct-2023 [AL]: Maintenance release +1) Fixed divide by zero error in certain condition of PASTI with ILED within active horizon +2) Added support for NCAP_ICOM for past investments +3) Cosmetic improvements + +Modified files: (reason) +initsys.mod : Increased version number to 4.7.5 +ppmain.mod : (1) +cal_cap.mod : (2) +bndmain.mod : (3) +bnd_stg.mod : (3) +initmty.vda : (3) +eqactups.vda : (3) + +----------------------------------------------------------------------------------------- +TIMES Version 4.7.6 +----------------------------------------------------------------------------------------- +Date: 15-Nov-2023 [AL]: Maintenance release +1) Fixed bug in ECB extension when defining multiple markets with Logit choices +2) Added stochastic support for flexible STS storage option (STSFLX) +3) Cosmetic improvements + +Modified files: (reason) +initsys.mod : Increased version number to 4.7.6 +maindrv.mod : (3) +setglobs.gms : (3) +eqstgtss.mod : (2) +eqdamage.mod : (3) +preshape.gms : (3) +solve.stp : (3) +prepret.dsc : (3) +recurrin.stc : (3) +ppm_ext.ecb : (1) + +----------------------------------------------------------------------------------------- +TIMES Version 4.7.7 +----------------------------------------------------------------------------------------- +Date: 27-Dec-2023 [AL]: Maintenance release +1) Fixed divide by zero issue in the ECB extension +2) Performance improvement for EQ_PEAK in large models +3) Added optional output attribute for process units +4) Cosmetic improvements + +Modified files: (reason) +initsys.mod : Increased version number to 4.7.7 +initmty.mod : (4) +units.def : (3) +setglobs.gms : (2) +pp_lvlpk.mod : (2) +pp_shapr.mod : (2) +pp_reduce.red : (2) +eqpeak.mod : (2) +cal_ire.mod : (2) +err_stat.mod : (4) +rpt_ext.ecb : (1) +solsetv.v3 : (3) + +----------------------------------------------------------------------------------------- +TIMES Version 4.7.8 +----------------------------------------------------------------------------------------- +Date: 19-Jan-2024 [AL]: Maintenance QA release +1) Added QA checks against invalid attributes +2) Improved topology check for auxiliary IRE flows +3) Small performance/cosmetic improvements + +Modified files: (reason) +initsys.mod : Increased version number to 4.7.8 +ppmain.mod : (1),(2) +setglobs.gms : (1) +pp_lvlpk.mod : (3) +eqpeak.mod : (3) +cal_fflo.mod : (3) +pp_qack.mod : (1) +init_ext.vda : (2) +pp_prelv.vda : (3) \ No newline at end of file diff --git a/source/bnd_stg.mod b/source/bnd_stg.mod index 863f7c2..bf45d7c 100644 --- a/source/bnd_stg.mod +++ b/source/bnd_stg.mod @@ -15,12 +15,13 @@ * set bounds at process activity level TRACKP(RP(R,P))$((NOT PRC_VINT(R,P))$PRC_MAP(R,'STG',P)) = YES; + STG%2_BND(R,T,P,C,S,BD)$((NOT TOP(R,P,C,'%2'))$RP_STG(R,P)) = 0; $IF %STAGES% == YES LOOP(SW_T(T%SWD%), - %VAR%_%1.LO(RTP_VINTYR(R,T,T,P),C,S%SWD%)$(RPCS_VAR(R,P,C,S)$TRACKP(R,P)) $= %2_BND(R,T,P,C,S,'LO'); - %VAR%_%1.UP(RTP_VINTYR(R,T,T,P),C,S%SWD%)$(RPCS_VAR(R,P,C,S)$TRACKP(R,P)) $= %2_BND(R,T,P,C,S,'UP'); - %VAR%_%1.FX(RTP_VINTYR(R,T,T,P),C,S%SWD%)$(RPCS_VAR(R,P,C,S)$TRACKP(R,P)) $= %2_BND(R,T,P,C,S,'FX'); + %VAR%_%1.LO(RTP_VINTYR(R,T,T,P),C,S%SWD%)$(RPCS_VAR(R,P,C,S)$TRACKP(R,P)) $= STG%2_BND(R,T,P,C,S,'LO'); + %VAR%_%1.UP(RTP_VINTYR(R,T,T,P),C,S%SWD%)$(RPCS_VAR(R,P,C,S)$TRACKP(R,P)) $= STG%2_BND(R,T,P,C,S,'UP'); + %VAR%_%1.FX(RTP_VINTYR(R,T,T,P),C,S%SWD%)$(RPCS_VAR(R,P,C,S)$TRACKP(R,P)) $= STG%2_BND(R,T,P,C,S,'FX'); $IF %STAGES% == YES ); OPTION CLEAR=TRACKP; \ No newline at end of file diff --git a/source/bndmain.mod b/source/bndmain.mod index 700f743..0685ed4 100644 --- a/source/bndmain.mod +++ b/source/bndmain.mod @@ -33,8 +33,8 @@ $ BATINCLUDE bnd_flo.%1 *----------------------------------------------------------------------------- * limit on storage *----------------------------------------------------------------------------- -$ BATINCLUDE bnd_stg.%1 SIN STGIN 0 -$ BATINCLUDE bnd_stg.%1 SOUT STGOUT -INF +$ BATINCLUDE bnd_stg.%1 SIN IN 0 +$ BATINCLUDE bnd_stg.%1 SOUT OUT -INF *----------------------------------------------------------------------------- * limit on total installation of new capacity diff --git a/source/cal_cap.mod b/source/cal_cap.mod index e15da47..ac9e4b2 100644 --- a/source/cal_cap.mod +++ b/source/cal_cap.mod @@ -23,8 +23,6 @@ * CAL_NCOM: the term associated with invest/decommission commodities in the EQ_COMxxx SUM(RPC_CAPFLO(R,V,P,C)$COEF_%2COM(R,V,T,P,C), COEF_%2COM(R,V,T,P,C) * %3 - G_YRFR(R,S) * (%VARV%_NCAP%4(R,V,P %SWS%)$T(V) -$ IF '%2'=='O' + NCAP_PASTI(R,V,P)$PASTYEAR(V) - ) + G_YRFR(R,S) * (%VARV%_NCAP%4(R,V,P %SWS%)$T(V)+NCAP_PASTI(R,V,P)$PASTYEAR(V)) ) *$OFFLISTING \ No newline at end of file diff --git a/source/cal_fflo.mod b/source/cal_fflo.mod index a75d6e0..cf91b39 100644 --- a/source/cal_fflo.mod +++ b/source/cal_fflo.mod @@ -1,30 +1,30 @@ *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -* Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) +* Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) * This file is part of the IEA-ETSAP TIMES model generator, licensed * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). *=============================================================================* * CAL_FFLO the code associated with the flow variable in the EQ_COMxxx * %1 - 'IN/OUT' for consumption/production -** %2 - 'I/O' for for invest/decommission checks (for now - NO LONGER USED) +** %2 - 'I/O' for invest/decommission checks (no longer used) * %3 - * Peak multiplier +* %4 - Peak by flow contribution *=============================================================================* *GaG Questions/Comments: * - VAR_FLOs according to whether c-in-PCG otherwise RPS_S1 *----------------------------------------------------------------------------- -$IF %REDUCE% == 'YES' $GOTO REDUCE +$IF %REDUCE% == YES $GOTO REDUCE $SET SHP1 "" SET SHG ",P,CG3,C" $IF DEFINED RTP_FFCS $SET SHP1 "*(%SHFF%S(R,V%SHG%%SOW%))" $SET SHP1 "*(%SHFF%X(R,V,T%SHG%)$PRC_VINT(R,P))%SHP1%" *----------------------------------------------------------------------------- *V05c 980923 - check that commodity not just capacity related SUM(TOP(RP_FLO(R,P),C,'%1')$(NOT RPC_EMIS(R,P,C)), - SUM(RTPCS_VARF(R,T,P,C,TS), - SUM(RTP_VINTYR(R,V,T,P), %VAR%_FLO(R,V,T,P,C,TS %SOW%) + SUM((RTP_VINTYR(R,V,T,P),RTPCS_VARF(R,T,P,C,TS)), * equation coarser than variable or equation finer than variable -*M2T* consider COM_TS shape too, so both TS_MAP and TS_BELOW both embedded - %3) * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS))) +* consider COM_TS shape too, so both TS_MAP and RS_BELOW embedded + %VAR%_FLO(R,V,T,P,C,TS %SOW%) * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)) %3) ) + -* [AL] Handle RPC_EMIS flows separately; They cannot be NOFLO +* Handle RPC_EMIS flows separately; They cannot be NOFLO SUM(TOP(RPC_EMIS(RP_FLO(R,P),C),'%1'), SUM((FS_EMIS(R,P,CG3,COM2,C),RTPCS_VARF(R,T,P,COM2,TS))$RS_TREE(R,S,TS), SUM(RTP_VINTYR(R,V,T,P),%VAR%_FLO(R,V,T,P,COM2,TS %SOW%) * @@ -35,18 +35,17 @@ $EXIT *----------------------------------------------------------------------------- $LABEL REDUCE * [UR] model reduction %REDUCE% is set in *.run -*[AL] Sum over non-vintaged processes +* Sum over non-vintaged processes SUM(TOP(RP_FLO(R,P),C,'%1')$(NOT PRC_VINT(R,P)), SUM((RTP_VINTYR(R,V(T),T,P),RTPCS_VARF(R,T,P,C,TS)), $ BATINCLUDE cal_red.red C COM TS P T '' T * equation coarser than variable or equation finer than variable - %3 * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS))) + * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)) %3)%4 ) + -*[AL] Sum over vintaged processes - SUM((TOP(PRC_VINT(RP_FLO(R,P)),C,'%1'),RTPCS_VARF(R,T,P,C,TS)), +* Sum over vintaged processes + SUM((TOP(PRC_VINT(RP_FLO(R,P)),C,'%1'),RTPCS_VARF(R,T,P,C,TS))%4, $ BATINCLUDE cal_red.red C COM TS P T '' V SUM 'RTP_VINTYR(R,V,T,P),' %3 * equation coarser than variable or equation finer than variable * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)) ) + - diff --git a/source/cal_ire.mod b/source/cal_ire.mod index 2f2eaa4..b22b517 100644 --- a/source/cal_ire.mod +++ b/source/cal_ire.mod @@ -17,32 +17,27 @@ $IF DEFINED RTP_FFCS $SET MX "(%SHFF%S(R,V,P,C,C%SOW%))*" *V0.9 022100 - handle the fact that called 2x for aux $SET IE '%3' $IF '%IE%'=='' $SET IE "'%1'" -$IF '%1' == 'EXP' -$IF '%2' == 'OUT' $GOTO AUXONLY -$IF '%1' == 'IMP' -$IF '%2' == 'IN' $GOTO AUXONLY +$IF '%1%2' == 'EXPOUT' $GOTO AUXONLY +$IF '%1%2' == 'IMPIN' $GOTO AUXONLY * actual exchange -*V05c 980923 - check that commodity not just capacity related *V05c 981016 - change RTPCS_VARFs to ts - SUM((RPC_IRE(%6R,P%7,C,'%1'),RTPCS_VARF(R,T,P,C,TS)), + SUM((RPC_IRE(%6R,P%7,C,'%1'),RTPCS_VARF(R,T,P,C,TS))$RS_FR(R,S,TS), SUM(RTP_VINTYR(R,V,T,P), (%VAR%_IRE(R,V,T,P,C,TS,'%1'%SOW%)$(NOT RPC_AIRE(R,P,C))+(%VAR%_ACT(R,V,T,P,TS%SOW%)*PRC_ACTFLO(R,V,P,C))$RPC_AIRE(R,P,C) )%4 - ) * - RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)) + ) * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)) ) + $IF SET IREAUXBAL %IREAUXBAL% %2 %5 $LABEL AUXONLY -*V0.5b handle auxillary commodity flows too -*** NOTE: assumes that attribute at the same level as the variable!!! +*V0.5b handle auxiliary commodity flows too +*** NOTE: assumes that attribute at the same level as the variable!! *V0.9 022100 - do IN/OUT explicitly - SUM((RPC_IRE(%6R,P%7,COM,%IE%),RTPCS_VARF(R,T,P,COM,TS))$IRE_FLOSUM(R,T,P,COM,TS,%IE%,C,'%2'), + SUM((RPC_IRE(%6R,P%7,COM,%IE%),RTPCS_VARF(R,T,P,COM,TS))$(IRE_FLOSUM(R,T,P,COM,TS,%IE%,C,'%2')$RS_FR(R,S,TS)), IRE_FLOSUM(R,T,P,COM,TS,%IE%,C,'%2') * SUM(RTP_VINTYR(R,V,T,P), %MX% (%VAR%_IRE(R,V,T,P,COM,TS,%IE%%SOW%)$(NOT RPC_AIRE(R,P,COM))+(%VAR%_ACT(R,V,T,P,TS%SOW%)*PRC_ACTFLO(R,V,P,COM))$RPC_AIRE(R,P,COM) )%4 - ) * - RS_FR(R,S,TS)*(1+RTCS_FR(R,T,COM,S,TS)) + ) * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,COM,S,TS)) ) + *$OFFLISTING diff --git a/source/coef_shp.mod b/source/coef_shp.mod index 6ce868b..b1a4ab5 100644 --- a/source/coef_shp.mod +++ b/source/coef_shp.mod @@ -68,7 +68,7 @@ RVPRL(RTP)$((COEF_RPTI(RTP)>1)$NCAP_CPX(RTP)) = ROUND(NCAP_TLIFE(RTP)-1)+EPS; COEF_CAP(RTP_CPTYR(R,V(TT),T,P))$RVPRL(R,V,P) = SUM(OPYEAR(AGE+RVPRL(R,V,P),LIFE),SHAPE(J+(NCAP_CPX(R,V,P)-1),LIFE)) / (RVPRL(R,V,P)+1); - COEF_CAP(R,V,T,P)$COEF_CAP(R,V,T,P) = 1/MAX(1,COEF_CPT(R,V,T,P)/COEF_CAP(R,V,T,P))-1; + COEF_CAP(RTP_CPTYR(R,V,T,P))$NCAP_CPX(R,V,P) = (1/MAX(1,COEF_CPT(R,V,T,P)/COEF_CAP(R,V,T,P)))$COEF_CAP(R,V,T,P)-1; ); OPTION RTP_CPX <= COEF_CAP; COEF_CPT(R,V,T,P)$COEF_CAP(R,V,T,P) = COEF_CPT(R,V,T,P)*(COEF_CAP(R,V,T,P)+1); diff --git a/source/eqactups.vda b/source/eqactups.vda index a82791d..282635a 100644 --- a/source/eqactups.vda +++ b/source/eqactups.vda @@ -135,7 +135,7 @@ $IFI %OBMAC%==YES $macro var_sift(v,s,l) %var%_udp(r,v,t,p,s,l%sow%)*prc_capact( SUM(PRC_TS(R,P,TS)$RS_BELOW1(R,S,TS),%VAR%_ACT(R,V,T,P,TS%SOW%))$STG_SIFT(RTP,%PGPRIM%,S) + SUM((TOP(RPC_STG(R,P,C),'OUT'),RPCS_VAR(R,P,C,TS)),%VAR%_SOUT(R,V,T,P,C,TS%SOW%))$ANNUAL(S)$ACTCG(COM) + (%VAR%_SIN(R,V,T,P,COM,S%SOW%) + %VAR%_ACT(R,V,T,P,S%SOW%))$PRC_TS(R,P,S) + %VAR%_SOUT(R,T,T,P,%PGPRIM%,S%SOW%) - - SUM((TOP(RPC_STG(R,P,C),'OUT'),RTCS_VARC(RTC(R,T,C),TS))$RS_FR(R,S,TS),(STG_SIFT(RTP,C,TS)$(PRC_TS(R,P,S)+ANNUAL(S)$ACTCG(COM))+STG_SIFT(RTP,%PGPRIM%,S))*%VAR%_COMPRD(RTC,TS%SOW%)/COM_IE(RTC,TS)*RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)))) - + SUM((TOP(RPC_STG(R,P,C),'OUT'),RTCS_VARC(RTC(R,T,C),TS))$RS_FR(R,S,TS),(STG_SIFT(RTP,C,TS)$(PRC_TS(R,P,S)+ANNUAL(S)$ACTCG(COM))+STG_SIFT(RTP,%PGPRIM%,S))*%VAR%_COMPRD(R,T,C,TS%SOW%)/COM_IE(RTC,TS)*RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)))) - * Get net sifting, force zero shifting at seasonal level SUM(BD(L)$LNX(L), (SUM((TOP(RPC_STG(R,P,C),'OUT'),RPCS_VAR(R,P,C,TS))$RS_FR(R,S,TS),%VAR%_SOUT(R,V,T,P,C,TS%SOW%)*RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS))) - diff --git a/source/eqdamage.mod b/source/eqdamage.mod index a06bc31..2552a26 100644 --- a/source/eqdamage.mod +++ b/source/eqdamage.mod @@ -14,7 +14,7 @@ $ IF NOT DEFINED DAM_ELAST PARAMETER DAM_ELAST //; SET JSUBJ(J,J) 'All steps up to J' //; SET DAM_NUM(R,C,J,BD); SET DAMOBJ / DAM, DAS, DAM-EXT /; - SET WWDAM /DELTA-ATM/, RTDAM(R,T,C%SWD%), SWW(ALLSOW,ALLSOW); + SET WWDAM /DELTA-ATM/, RTDAM(R,T,C,ALLSOW), SWW(ALLSOW,ALLSOW); PARAMETER DAM_SIZE(REG,T,COM,LIM) 'Size of emission steps' //; *----------------------------------------------------------------------------- OPTION CLEAR=RXX; @@ -66,23 +66,27 @@ $IFI %STAGES%==YES OPTION SWW<=SW_TSW; LOOP(SOW,DAM_COST(R,T,C,CUR)$S_DAM_COST(R * Set number of FX steps (any non-zero DAM_STEP(R,C,'N') disables endogenous damage) DAM_STEP(TRACKC(R,C),'FX')$(DAM_STEP(R,C,'N') EQ 0) = 1+1$SUM(T$(DAM_SIZE(R,T,C,'N') GT 0),YES); IF(CARD(DAM_COST)=0,SUM_OBJ('OBJDAM',ITEM)=0); - RTDAM(RXX(R,T,C)%SOW%)$(%SWTX%YES+WWDAM(C)) = YES; + RTDAM(RXX(R,T,C)%SWX%)$(%SWTX%YES+WWDAM(C)) = YES; *----------------------------------------------------------------------------- SET OBV / OBJDAM /; $IF %DAMAGE%==NO SUM_OBJ('OBJDAM',ITEM)=0; -$IFI %SPINES%==YES $%SW_TAGS% +$IF %VARMAC% $SET VAR %VAS% $IF %DAMAGE%==NO $GOTO FINISH -$IF %DAMAGE%==NLP $GOTO NLPDAM *----------------------------------------------------------------------------- -* Set bounds for damage variables: - LOOP(SAMEAS(J,'1'),DAM_NUM(TRACKC(R,C),J+(DAM_STEP(R,C,BD)-1),BD) = YES); - %VAR%_DAM.UP(R,T,C,BD,J %SWD%) = INF; - %VAR%_DAM.UP(RTC(R,T,C),'LO',J%SOW%)$((ORD(J) LE DAM_STEP(R,C,'LO'))$RTDAM(RTC%SOW%)) = DAM_SIZE(RTC,'LO'); - %VAR%_DAM.UP(RTC(R,T,C),'LO','1'%SOW%)$(DAM_ELAST(R,C,'N')$RTDAM(RTC%SOW%)) = DAM_SIZE(RTC,'LO')+DAM_TQTY(RTC)-DAM_TVOC(RTC,'LO'); - %VAR%_DAM.UP(RTC(R,T,C),'UP',J%SOW%)$((ORD(J) LT DAM_STEP(R,C,'UP'))$RTDAM(RTC%SOW%)) = DAM_SIZE(RTC,'UP'); - %VAR%_DAM.UP(RTC(R,T,C),'FX','1'%SOW%)$(DAM_TVOC(R,T,C,'UP')$RTDAM(RTC%SOW%)) = DAM_SIZE(RTC,'FX'); - %VAR%_DAM.UP(RTC(R,T,C),'FX','2'%SOW%)$RTDAM(RTC%SOW%) = DAM_SIZE(RTC,'N')$(NOT DAM_ELAST(R,C,'N')); +* Emission balance equation + + %EQ%_DAMAGE(RTC(%R_T%,C) %SOW%)$(SUM(RDCUR(R,CUR)$DAM_COST(R,T,C,CUR),1)$RTDAM(RTC%SWX%)).. + + SUM(DAM_NUM(R,C,JJ,BD),SUM(JSUBJ(JJ,J),%VAR%_DAM(R,T,C,BD,J %SOW%))) + + =E= ( +$IF %CLI%==YES SUM(CM_VAR(C),%VART%_CLITOT(CM_VAR,T%SWS%)$CM_KIND(CM_VAR)+%VAR%_CLIBOX(CM_VAR,T%SOW%)$(NOT CM_KIND(CM_VAR)))$(NOT RC(R,C)) + + SUM(COM_TS(RC(R,C),S),DAM_COEF(R,T,C,S)*%VAR%_COMNET(R,T,C,S %SOW%)$(NOT DAM_ELAST(R,C,'N')) + + DAM_COEF(R,T,C,S)*%VAR%_COMPRD(R,T,C,S %SOW%)$DAM_ELAST(R,C,'N')) + )$DAM_STEP(R,C,'FX'); + +$IF %DAMAGE%==NLP $GOTO NLPDAM *----------------------------------------------------------------------------- $LABEL LPDAM * Damage cost equation @@ -105,18 +109,9 @@ $IFI %STAGES%==YES S_DAM_COST(R,T,C,CUR,'1',WW)) %3 =E= SUM(OBV,SUM_OBJ('OBJDAM',OBV)*%VAR%_OBJ(R,OBV,CUR %SOW%)); -$GOTO FINISH +$GOTO BOUND *============================================================================= $LABEL NLPDAM -* Set bounds for damage variables: - DAM_STEP(TRACKC(R,C),'LO') = 1; - DAM_STEP(TRACKC(R,C),'UP') = 1; - LOOP(SAMEAS(J,'1'),DAM_NUM(TRACKC(R,C),J+(DAM_STEP(R,C,BD)-1),BD) = YES); - %VAR%_DAM.UP(R,T,C,BD,J %SWD%) = INF; - %VAR%_DAM.UP(RTC(R,T,C),'LO','1'%SOW%)$RTDAM(RTC%SOW%) = (DAM_TQTY(RTC)-DAM_SIZE(RTC,'N'))$DAM_STEP(R,C,'LO'); - %VAR%_DAM.UP(RTC(R,T,C),'FX','1'%SOW%)$RTDAM(RTC%SOW%) = EPS; - %VAR%_DAM.UP(RTC(R,T,C),'FX','2'%SOW%)$RTDAM(RTC%SOW%) = DAM_SIZE(RTC,'N'); -*----------------------------------------------------------------------------- * Damage cost equation %EQ%_OBJDAM(RDCUR(R,CUR)%SOW%).. SUM(RTC(R,T,C)$(DAM_STEP(R,C,'FX')$DAM_COST(R,T,C,CUR)), @@ -138,21 +133,29 @@ $IFI %STAGES%==YES S_DAM_COST(R,T,C,CUR,'1',WW)) ) =E= SUM(OBV,SUM_OBJ('OBJDAM',OBV)*%VAR%_OBJ(R,OBV,CUR %SOW%)); - *----------------------------------------------------------------------------- -$LABEL FINISH +$LABEL BOUND +$IF %DAMAGE%==NLP $GOTO BDNLP +* Set bounds for damage variables: + LOOP(SAMEAS(J,'1'),DAM_NUM(TRACKC(R,C),J+(DAM_STEP(R,C,BD)-1),BD) = YES); + %VAR%_DAM.UP(R,T,C,BD,J %SWD%) = INF; + %VAR%_DAM.UP(RTC(R,T,C),'LO',J%SOW%)$((ORD(J) LE DAM_STEP(R,C,'LO'))$RTDAM(RTC%SWX%)) = DAM_SIZE(RTC,'LO'); + %VAR%_DAM.UP(RTC(R,T,C),'LO','1'%SOW%)$(DAM_ELAST(R,C,'N')$RTDAM(RTC%SWX%)) = DAM_SIZE(RTC,'LO')+DAM_TQTY(RTC)-DAM_TVOC(RTC,'LO'); + %VAR%_DAM.UP(RTC(R,T,C),'UP',J%SOW%)$((ORD(J) LT DAM_STEP(R,C,'UP'))$RTDAM(RTC%SWX%)) = DAM_SIZE(RTC,'UP'); + %VAR%_DAM.UP(RTC(R,T,C),'FX','1'%SOW%)$(DAM_TVOC(RTC,'UP')$RTDAM(RTC%SWX%)) = DAM_SIZE(RTC,'FX'); + %VAR%_DAM.UP(RTC(R,T,C),'FX','2'%SOW%)$RTDAM(RTC%SWX%) = DAM_SIZE(RTC,'N')$(NOT DAM_ELAST(R,C,'N')); +$GOTO FINISH *----------------------------------------------------------------------------- -* Emission balance equation - - %EQ%_DAMAGE(RTC(%R_T%,C) %SOW%)$(SUM(RDCUR(R,CUR)$DAM_COST(R,T,C,CUR),1)$RTDAM(RTC%SOW%)).. - - SUM(DAM_NUM(R,C,JJ,BD),SUM(JSUBJ(JJ,J),%VAR%_DAM(R,T,C,BD,J %SOW%))) - - =E= ( -$IF %CLI%==YES SUM(CM_VAR(C),%VART%_CLITOT(CM_VAR,T%SWS%)$CM_KIND(CM_VAR)+%VAR%_CLIBOX(CM_VAR,T%SOW%)$(NOT CM_KIND(CM_VAR)))$(NOT RC(R,C)) + - SUM(COM_TS(RC(R,C),S),DAM_COEF(R,T,C,S)*%VAR%_COMNET(R,T,C,S %SOW%)$(NOT DAM_ELAST(R,C,'N')) + - DAM_COEF(R,T,C,S)*%VAR%_COMPRD(R,T,C,S %SOW%)$DAM_ELAST(R,C,'N')) - )$DAM_STEP(R,C,'FX'); +$LABEL BDNLP +* Set bounds for damage variables: + DAM_STEP(TRACKC,BDNEQ) = 1; + LOOP(SAMEAS(J,'1'),DAM_NUM(TRACKC(R,C),J+(DAM_STEP(R,C,BD)-1),BD) = YES); + %VAR%_DAM.UP(R,T,C,BD,J %SWD%) = INF; + %VAR%_DAM.UP(RTC(R,T,C),'LO','1'%SOW%)$RTDAM(RTC%SWX%) = (DAM_TQTY(RTC)-DAM_SIZE(RTC,'N'))$DAM_STEP(R,C,'LO'); + %VAR%_DAM.UP(RTC(R,T,C),'FX','1'%SOW%)$RTDAM(RTC%SWX%) = EPS; + %VAR%_DAM.UP(RTC(R,T,C),'FX','2'%SOW%)$RTDAM(RTC%SWX%) = DAM_SIZE(RTC,'N'); +*----------------------------------------------------------------------------- +$LABEL FINISH *----------------------------------------------------------------------------- OPTION CLEAR=TRACKC,CLEAR=RXX,CLEAR=DAM_TVOC; DAM_TVOC(R,T,C,'N')$DAM_SIZE(R,T,C,'N') = ((DAM_SIZE(R,T,C,'N')/DAM_TQTY(R,T,C))**DAM_ELAST(R,C,'LO'))$DAM_ELAST(R,C,'N'); \ No newline at end of file diff --git a/source/eqobjels.mod b/source/eqobjels.mod index d88b7d8..ab5315f 100644 --- a/source/eqobjels.mod +++ b/source/eqobjels.mod @@ -46,6 +46,6 @@ $LABEL RHS *------------------------------------------------------------------------------ * Step bounds for linear CES demand functions - %EQ%L_COMCES(RTC(R,T,COM),C,S%SWT%)$(RTCS_VARC(R,T,C,S)$MI_DOPE(R,T,C)$MI_DMAS(R,COM,C)).. + %EQ%L_COMCES(RTC(%R_T%,COM),C,S%SWT%)$(RTCS_VARC(R,T,C,S)$MI_DOPE(R,T,C)$MI_DMAS(R,COM,C)).. SUM(RCJ(R,C,J,BDNEQ(BD))$COM_ELAST(R,T,C,S,BD),%VAR%_ELAST(R,T,C,S,J,BD%SOW%)*COM_STEP(R,C,BD)/ORD(J)/(DDF_QREF(R,T,C)*COM_FR%MX%(R,T,C,S)*COM_VOC(R,T,C,BD))) =L= %VAR%_COMPRD(R,T,COM,'ANNUAL'%SOW%)/DDF_QREF(R,T,COM); diff --git a/source/eqobjvar.mod b/source/eqobjvar.mod index 79cd0fb..ec1e334 100644 --- a/source/eqobjvar.mod +++ b/source/eqobjvar.mod @@ -45,7 +45,7 @@ $IF %STAGES% == YES $SETLOCAL SWTD 'SUM(SW_TSW(SOW,T,WW),' SET SOW ',WW' SUM(%TPULSE% * SUM(COSTYPE,OBJ_COMNT(R,Y_EOH,C,S,COSTYPE,CUR)))) + SUM(RHS_COMPRD(R,T,C,S), %VAR%_COMPRD(R,T,C,S %SOW%) * SUM(%TPULSE% * SUM(COSTYPE,OBJ_COMPD(R,Y_EOH,C,S,COSTYPE,CUR)))) + -$IFI %STAGES%==YES SUM((RTCS_VARC(R,T,C,S),COM_VAR,W(WW))$S_COM_TAX(R,T,C,S,COM_VAR,CUR,'1',W),SUM(Y_EOH(Y)$OBJ_LINT(R,T,Y,CUR),OBJ_LINT(R,T,Y,CUR)*S_COM_TAX(R,Y,C,S,COM_VAR,CUR,'1',W))*(%VAR%_COMPRD(R,T,C,S%SOW%)$(ORD(COM_VAR)=2)+%VAR%_COMNET(R,T,C,S%SOW%)$UC_NAME(COM_VAR))) + +$IFI %STAGES%==YES SUM((RTCS_VARC(R,T,C,S),COM_VAR,W(WW))$S_COM_TAX(R,T,C,S,COM_VAR,CUR,'1',W),SUM(Y_EOH(Y)$OBJ_LINT(R,T,Y,CUR),OBJ_LINT(R,T,Y,CUR)*S_COM_TAX(R,Y,C,S,COM_VAR,CUR,'1',W))*(%VAR%_COMPRD(R,T,C,S%SOW%)$DIAG('PRD',COM_VAR)+%VAR%_COMNET(R,T,C,S%SOW%)$DIAG('NET',COM_VAR))) + *------------------------------------------------------------------------------ * Commodity costs/tax/sub associated with imports/exports from outside study area diff --git a/source/eqobjvar.rpt b/source/eqobjvar.rpt index 98d86aa..b5b8bf6 100644 --- a/source/eqobjvar.rpt +++ b/source/eqobjvar.rpt @@ -37,7 +37,7 @@ $IFI %STAGES%==YES Z=SUM(W(SOW),SW_PROB(W)); SUM(RHS_COMBAL(R,T,C,S), VAR_COMNET.L(R,T,C,S) * %5(%TPULSE% (OBJ_COMNT(R,%4,C,S,'TAX',CUR)+OBJ_COMNT(R,%4,C,S,'SUB',CUR)))) + SUM(RHS_COMPRD(R,T,C,S), VAR_COMPRD.L(R,T,C,S) * %5(%TPULSE% (OBJ_COMPD(R,%4,C,S,'TAX',CUR)+OBJ_COMPD(R,%4,C,S,'SUB',CUR)))); $IFI %STAGES%==YES - %1_COMC(%3RTC(R,T,C),CUR)$RDCUR(R,CUR) $= SUM((RTCS_VARC(RTC,S),COM_VAR,SW_TSW(SOW,T,W))$S_COM_TAX(RTC,S,COM_VAR,CUR,'1',W),(%5(%TMP%S_COM_TAX(R,%4,C,S,COM_VAR,CUR,'1',W))*(VAR_COMPRD.L(RTC,S)$(ORD(COM_VAR)=2)+VAR_COMNET.L(RTC,S)$UC_NAME(COM_VAR))+%1_COMC(J,RTC,CUR)*G_YRFR(R,S))*SW_PROB(W)/Z); + %1_COMC(%3RTC(R,T,C),CUR)$RDCUR(R,CUR) $= SUM((RTCS_VARC(RTC,S),COM_VAR,SW_TSW(SOW,T,W))$S_COM_TAX(RTC,S,COM_VAR,CUR,'1',W),(%5(%TMP%S_COM_TAX(R,%4,C,S,COM_VAR,CUR,'1',W))*(VAR_COMPRD.L(RTC,S)$DIAG('PRD',COM_VAR)+VAR_COMNET.L(RTC,S)$DIAG('NET',COM_VAR))+%1_COMC(J,RTC,CUR)*G_YRFR(R,S))*SW_PROB(W)/Z); *------------------------------------------------------------------------------ * Commodity costs associated with imports/exports from outside study area diff --git a/source/eqpeak.mod b/source/eqpeak.mod index f4e67b4..3d470fc 100644 --- a/source/eqpeak.mod +++ b/source/eqpeak.mod @@ -1,5 +1,5 @@ *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -* Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) +* Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) * This file is part of the IEA-ETSAP TIMES model generator, licensed * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). *=============================================================================* @@ -15,14 +15,14 @@ %EQ%_PEAK(%R_T%,CG2,RTS(SL)%SWT%)$(SUM(COM_GMAP(R,CG2,C)$RTC(R,T,C),1)$COM_PKTS(R,CG2,SL)) .. SUM((COM_GMAP(R,CG2,C),COM_TS(R,C,S))$RS_FR(R,SL,S), - RS_FR(R,SL,S) * + RS_FR(R,SL,S) * +* Apply maximum reserve among CG2 and C + (1/(1+MAX(SUM(COM(CG2),COM_PKRSV(R,T,COM)),COM_PKRSV(R,T,C))))*COM_IE(R,T,C,S)* - (1/(1+MAX(SMAX(COM(CG2),COM_PKRSV(R,T,COM)),COM_PKRSV(R,T,C))))*COM_IE(R,T,C,S)* - - (SUM(RPC_PKC(PRC_CAP(R,P),C), G_YRFR(R,S) * PRC_CAPACT(R,P) * + (SUM(RPC_PKC(R,P,C), G_YRFR(R,S) * PRC_CAPACT(R,P) * SUM(V$COEF_CPT(R,V,T,P),COEF_CPT(R,V,T,P)*PRC_ACTFLO(R,V,P,C)*NCAP_PKCNT(R,V,P,S)* (%VARV%_NCAP(R,V,P %SWS%)$MILESTONYR(V)+NCAP_PASTI(R,V,P)$PASTYEAR(V) %RCAPSUB%)) - ) + + ) + * * production @@ -34,15 +34,14 @@ $ BATINCLUDE cal_ire.%1 EXP IN IE '*(-NCAP_PKCNT(R,V,P,S)/COM_IE(R,T,C,S))$ ( *GG*PK no multiplier -*[UR] 25.04.2003 added NCAP_PKCNT multiplier to turn off contribution by setting NCAP_PKCNT to zero -*[AL] 25.01.2007 allow using PKNO to switch process to production-based peak contribution -*[AL] When PKNO=YES no default PKCNT is assigned -> process contributes only if PKCNT set by user +* [UR] 25.04.2003 added NCAP_PKCNT multiplier to turn off contribution by setting NCAP_PKCNT to zero +* allow using PKNO to switch process to production-based peak contribution (contributes only if PKCNT set by user) * storage $ BATINCLUDE cal_stgn.%1 OUT IN '*STG_EFF(R,V,P)' '' "(NOT PRC_NSTTS(R,P,TS))" '*(NCAP_PKCNT(R,V,P,S)**RPC_PKF(R,P,C))$RPC_PKF(R,P,C)' * individual flows -$ BATINCLUDE cal_fflo.%1 OUT O '*(NCAP_PKCNT(R,V,P,S)**RPC_PKF(R,P,C))$RPC_PKF(R,P,C)' +$ BATINCLUDE cal_fflo.%1 OUT O '*(NCAP_PKCNT(R,V,P,S)**RPC_PKF(R,P,C))' '$RPC_PKF(R,P,C)' 0) @@ -54,27 +53,26 @@ $IF SET PEAKCHP $BATINCLUDE %PEAKCHP% SUM((COM_GMAP(R,CG2,C),COM_TS(R,C,S))$RS_FR(R,SL,S), RS_FR(R,SL,S) * -* Apply the maximum of flexibilities among CG2 an C +* Apply maximum flexibility among CG2 and C (1+MAX(SUM(COM(CG2),COM_PKFLX(R,T,COM,SL)),COM_PKFLX(R,T,C,S)))* ( - ( * * consumption * *GG*PK pass TS as timeslice * individual flows -$ BATINCLUDE cal_fflo.%1 IN I '*FLO_PKCOI(R,T,P,C,TS)' +$ BATINCLUDE cal_fflo.%1 IN I '*FLO_PKCOI(R,T,P,C,TS)' * inter-regional trade from region -$ BATINCLUDE cal_ire.%1 EXP IN IE '*FLO_PKCOI(R,T,P,C,TS)' - +$ BATINCLUDE cal_ire.%1 EXP IN IE '*FLO_PKCOI(R,T,P,C,TS)' - * capacity related commodity flows * fixed commodity associated with installed capacity or investment -$ BATINCLUDE cal_cap.%1 IN I '1$(NOT PRC_PKNO(R,P))*' - ) + +$ BATINCLUDE cal_cap.%1 IN I '1$(NOT PRC_PKNO(R,P))*' + + * storage -$ BATINCLUDE cal_stgn.%1 IN OUT '' 'STG_EFF(R,V,P)*(NCAP_PKCNT(R,V,P,S)**RPC_PKF(R,P,C))*' "((NOT PRC_MAP(R,'NST',P))+PRC_NSTTS(R,P,TS))" "$(NOT RPC_PKC(R,P,C)*PRC_CAP(R,P))" +$ BATINCLUDE cal_stgn.%1 IN OUT '' 'STG_EFF(R,V,P)*(NCAP_PKCNT(R,V,P,S)**RPC_PKF(R,P,C))*' "((NOT PRC_MAP(R,'NST',P))+PRC_NSTTS(R,P,TS))" "$RPC_PKF(R,P,C)" * blending SUM(BLE_OPR(R,BLE,OPR)$(BLE_INP(R,BLE,C)*BLE_TP(R,T,BLE)),G_YRFR(R,S)*(1+RTCS_FR(R,T,C,S,'ANNUAL'))*BL_INP(R,BLE,C)*PEAKDA_BL(R,BLE,T)*%VAR%_BLND(R,T,BLE,OPR %SOW%)) + diff --git a/source/eqstgtss.mod b/source/eqstgtss.mod index 24b7a91..88188fc 100644 --- a/source/eqstgtss.mod +++ b/source/eqstgtss.mod @@ -45,9 +45,7 @@ ((STG_LOSS(R,V,P,ALL_TS))/(EXP(STG_LOSS(R,V,P,ALL_TS))-1)-1))$STG_LOSS(R,V,P,ALL_TS) ) * storage charge - + STG_CHRG(R,T,P,S--RS_STG(R,S)) - - ; + + STG_CHRG(R,T,P,S--RS_STG(R,S)); *--- Balancer Equation --- @@ -82,14 +80,12 @@ SUM(TOP(PRC_STGIPS(R,P,C),IO), 1 / PRC_ACTFLO(R,V,P,C) * %VAR%_SIN(R,V,T,P,C,S %SOW%)$IPS(IO) - %VAR%_SOUT(R,V,T,P,C,S %SOW%)$(NOT IPS(IO))) - * balancer flow - %VAR%_SOUT(R,V,T,P,%PGPRIM%,S%SOW%)) - - ; + %VAR%_SOUT(R,V,T,P,%PGPRIM%,S%SOW%)); *--- Levelizer Equation --- - EQ_STSLEV(RTP_VINTYR(%R_V_T%,P),TSL,RTS(S)%SWX%)$((STOAL(R,S)=PRC_SGL(R,P))$TS_GROUP(R,TSL,S)$RP_STL(R,P,TSL,'UP')).. + EQ_STSLEV(RTP_VINTYR(%R_V_T%,P),TSL,RTS(S)%SWX%)$(%SWTX%(STOAL(R,S)=PRC_SGL(R,P))$TS_GROUP(R,TSL,S)$RP_STL(R,P,TSL,'UP')).. * Sum of levelizers must be less than average variation over S SUM(TS_MAP(R,TS,S)$STOA(TS),(%VAR%_SIN(R,V,T,P,%PGPRIM%,TS%SOW%)+%VAR%_UDP(R,V,T,P,TS,'LO'%SOW%)+VAR_STS(R,V,T,P,TS,'N'))/RS_STGPRD(R,TS)) diff --git a/source/equ_ext.abs b/source/equ_ext.abs index 03612e8..ed29a42 100644 --- a/source/equ_ext.abs +++ b/source/equ_ext.abs @@ -40,6 +40,7 @@ $ macro var_bsfnsp(r,v,t,p,c,s) %var%_bsprs(r,v,t,p,c,s,'FX'%SOW%) $ macro var_bsupsr(r,v,t,p,s,bd) %var%_bsprs(r,v,t,p,%PGPRIM%,s,bd%SOW%) $ macro var_bslack(r,t,p,c,s) %var%_bsprs(r,t,t,p,c,s,'UP'%SOW%) * Capacity-CPT expression +$IF %STAGES%==YES $%SW_STVARS% $SET TMP SUM(MODLYEAR(K)$(COEF_CPT(R,K,T,P)$(DIAG(V,K)>=1$PRC_VINT(R,P))),COEF_CPT(R,K,T,P)*(%VARM%_NCAP(R,K,P%SWS%)$T(K)+NCAP_PASTI(R,K,P)%RCAPSBM%)) *----------------------------------------------------------------------------- diff --git a/source/err_stat.mod b/source/err_stat.mod index 9099a88..44516f3 100644 --- a/source/err_stat.mod +++ b/source/err_stat.mod @@ -29,8 +29,15 @@ SET SOLVESTAT(J) / 8 "Integer solution" 9 "Intermediate non-integer" 10 "Integer infeasible" + 11 "Lic problem" 12 "Error unknown" 13 "Error no solution" + 14 "No solution returned" + 15 "Solved unique" + 16 "Solved locally unique" + 17 "Solved singular" + 18 "Unbnd no solution" + 19 "Infes no solution" /; FILE SCREEN / '' /; FILE END_GAMS / %TMP% /; @@ -46,7 +53,7 @@ $IF NOT ERRORFREE $ECHO %3%5 > %TMP% $GOTO DONE $LABEL SOLVE - Z = MIN(14,%MODEL_NAME%.MODELSTAT)-1; IF(Z > 12, Z=11); + Z = MIN(14,%MODEL_NAME%.MODELSTAT)-1; IF(Z > 18, Z=11); IF(Z>=0,PUT SCREEN /"--- TIMES Solve status: "; LOOP(SAMEAS(J,'1'), PUT SOLVESTAT.TE(J+Z)); PUTCLOSE; diff --git a/source/init_ext.vda b/source/init_ext.vda index 5940707..d200f00 100644 --- a/source/init_ext.vda +++ b/source/init_ext.vda @@ -1,5 +1,5 @@ *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -* Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) +* Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) * This file is part of the IEA-ETSAP TIMES model generator, licensed * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). *=============================================================================* @@ -86,29 +86,26 @@ $IF NOT %OBMAC%==YES PARAMETER VAR_SIFT(LL,S,L) //; PRC_RESID(R,LL--ORD(LL),P)$((PRC_RESID(R,LL,P)>0)$PRC_RESID(R,LL,P)) = PRC_RESID(R,'0',P)+EPS; NCAP_PASTI(R,PYR_S,P)$PRC_RESID(R,'0',P) = 1; *----------------------------------------------------------------------------- -* Initial Preprocessing of VDA_EMCB and FLO_EMIS +* Initial Preprocessing of VDA_EMCB, FLO_EMIS and IRE_FLOSUM FLO_EMIS(R,LL,P,CG,C,S) $= FLO_EFF(R,LL,P,CG,C,S); OPTION CLEAR=RXX,CLEAR=FLO_EFF; - VDA_EMCB(R,DATAYEAR,C,COM)$COM_TMAP(R,'ENV',C) = 0; - LOOP((R,DATAYEAR,C,COM)$VDA_EMCB(R,DATAYEAR,C,COM),RXX(R,C,COM) = YES;); + VDA_EMCB(R,YEAR,C,COM)$COM_TMAP(R,'ENV',C) = 0; + LOOP((R,DATAYEAR,C,COM)$VDA_EMCB(R,DATAYEAR,C,COM),RXX(R,C,COM) = YES); RXX(R,C,COM)$(NOT COM_TMAP(R,'ENV',COM)) = NO; LOOP((TOP(R,P,C,'IN'),RXX(R,C,COM)),FS_EMCB(R,P,COM,C)=YES); FS_EMCB(R,P,COM,C)$TOP(R,P,COM,'IN') = NO; OPTION TRACKPC <= FS_EMCB; TOP(TRACKPC,'OUT') = YES; - OPTION CLEAR=RXX, CLEAR=TRACKPC, PRC_ACT < PRC_ACTUNT; + OPTION CLEAR=RXX, CLEAR=TRACKPC; LOOP((R,DATAYEAR,P,CG,C,S)$FLO_EMIS(R,DATAYEAR,P,CG,C,S),RPC_EMIS(R,P,C) = YES); - TOP(RPC_EMIS(PRC_ACT(R,P),C),'OUT')$(COM_TMAP(R,'ENV',C)*(NOT TOP(R,P,C,'IN'))) = YES; + RPG_RED(RPC_EMIS(R,P,C),'OUT')$(NOT TOP(R,P,C,'IN')) = YES; + LOOP((R,DATAYEAR,P,C,S,IE,COM,IO)$(PRC_MAP(R,'IRE',P)$IRE_FLOSUM(R,DATAYEAR,P,C,S,IE,COM,IO)),RPG_RED(R,P,COM,IO) = YES); *----------------------------------------------------------------------------- * Initial Preprocessing of COM_AGG and VDA_FLOP COM_AGG(R,LL,C,C)$COM_AGG(R,LL,C,C) = 0; VDA_FLOP(R,LL,P,CG,S) $= ACT_FLO(R,LL,P,CG,S); KEEP_FLOF(R,P,C)$VDA_FLOP(R,'%DFLBL%',P,C,'ANNUAL') = YES; $IFI %SHELL%==ANSWER KEEP_FLOF(R,P,C)$PRC_ACTFLO(R,'%DFLBL%',P,C) = YES; -*----------------------------------------------------------------------------- -* Initial Preprocessing of IRE_FLOSUM - LOOP((R,DATAYEAR,P,C,S,IE,COM,IO)$IRE_FLOSUM(R,DATAYEAR,P,C,S,IE,COM,IO),RPG_ACE(R,P,COM,IO) = YES); - TOP(RPG_ACE(PRC_ACT,C,IO)) = YES; - OPTION CLEAR=PRC_ACT,CLEAR=ACT_FLO,CLEAR=RPG_ACE; + OPTION CLEAR=ACT_FLO; *----------------------------------------------------------------------------- * Handle Updatable OFF-ranges & REG_BDNCAP process-based bounds NCAP_START(R,P)$(NCAP_START(R,P)<=MIYR_BOH)=0; diff --git a/source/initmty.mod b/source/initmty.mod index 8838443..20dd5e5 100644 --- a/source/initmty.mod +++ b/source/initmty.mod @@ -13,7 +13,7 @@ * - consider PRC_MAP(PRC_GRP,PRC_SUBGRP,PRC) where PRC_SUBGRP = PRC_RSOURC + any user-provided sub-groupings * - SOW/COM/PRC/CUR master sets (merged) == entire list, that is not REG * - lists (eg, DEM_SECT) for _MAP sets not REG (but individual mappings are) -* - HAVE THE USER *.SET/DD files OMIT the declarations to ease maintenance changes +* - HAVE THE USER *.DD files OMIT the declarations to ease maintenance changes *----------------------------------------------------------------------------- * Version control $IF NOT FUNTYPE rpower $ABORT TIMES Version 4.0 and above Requires GAMS 22.0 or above! @@ -23,6 +23,7 @@ $IF gamsversion 230 $SETGLOBAL OBMAC YES $IF gamsversion 236 $SETGLOBAL G2X6 YES $LABEL DECL $ONEMPTY + *----------------------------------------------------------------------------- * SET SECTION *----------------------------------------------------------------------------- @@ -455,7 +456,7 @@ $IF %PGPRIM%==ACT $SETGLOBAL RETIRE 'YES' SETGLOBAL DSCAUTO Yes $IFI %DSC%==YES $KILL RCAP_BLK * Initialize list of standard extensions to be loaded -$SETGLOBAL EXTEND +$SET VDA 'YES' SETGLOBAL EXTEND * Add recognized extensions if defined $IFI '%ECB%'==YES $SETGLOBAL EXTEND '%EXTEND% ECB' @@ -473,7 +474,7 @@ $IFI '%MCA%' == YES $SETGLOBAL EXTEND '%EXTEND% MCA' $SETGLOBAL EXTEND %EXTEND% %1 %2 %3 %4 %5 %6 * Load all extension declarations -$IF NOT '%EXTEND%' == '' $BATINCLUDE main_ext.mod initmty %EXTEND% +$BATINCLUDE main_ext.mod initmty %EXTEND% $IF ERRORFREE $BATINCLUDE err_stat.mod '$IF NOT ERRORFREE' ABORT 'Errors in Compile' 'VARIABLE OBJz' ': Required _TIMES.g00 Restart File Missing' diff --git a/source/initmty.vda b/source/initmty.vda index 68f80d7..0be626e 100644 --- a/source/initmty.vda +++ b/source/initmty.vda @@ -1,66 +1,66 @@ -*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -* Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) -* This file is part of the IEA-ETSAP TIMES model generator, licensed -* under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). -*=============================================================================* -* INITMTY.VDA has all the EMPTY declarations for system & user data * -*=============================================================================* -$ SETGLOBAL VDA YES -*============================================================================= -* User Input attributes in the VDA extension -*----------------------------------------------------------------------------- -* Process transformation parameters: - PARAMETERS - VDA_FLOP(REG,ALLYEAR,PRC,CG,S) 'General process transformation parameter' - VDA_EMCB(REG,ALLYEAR,COM,COM) 'Combustion emission parameter (aka EMI_comb)' // - VDA_CEH(REG,ALLYEAR,PRC) 'The slope of pass-out turbine (alias NCAP_CEH)' // - FLO_EMIS(REG,ALLYEAR,PRC,CG,COM,S) 'General process emission parameter' // - FLO_EFF(REG,ALLYEAR,PRC,CG,COM,S) 'General process flow-relation parameter' //; -*----------------------------------------------------------------------------- -* Commodity-dependent availabilities: -$ SET MX ,SEASON, WEEKLY, DAYNITE - SET STL / SET.S%MX% /; - PARAMETERS - NCAP_AFAC(REG,ALLYEAR,PRC,CG) 'Annual availability of capacity for commodity group CG' // - NCAP_AFC(REG,ALLYEAR,PRC,CG,STL) 'Availability of capacity for commodity group CG' - NCAP_AFCS(REG,ALLYEAR,PRC,CG,TS) 'Availability of capacity for commodity group CG'//; -*----------------------------------------------------------------------------- -* Dynamic UC variable bounds (UC_DYNBND user-defined) - SET UC_DYNBND(UC_N,LIM) 'Dynamic process-wise UC bounds' //; -*----------------------------------------------------------------------------- -* Activity efficiency and dispatching options - PARAMETERS - ACT_EFF(REG,YEAR,PRC,CG,TS) 'Activity efficiency for process' // - ACT_UPS(R,ALLYEAR,P,S,L) 'Max. ramp rate, fraction of capacity per hour' - ACT_MINLD(R,ALLYEAR,P) 'Minimum stable operation level' // - ACT_LOSPL(R,ALLYEAR,P,L) 'Fuel consumption increase at minimum load' // - ACT_CSTPL(R,ALLYEAR,P,CUR) 'Partial load cost penalty' // - ACT_MAXNON(R,LL,P,UPT) 'Max. non-operational time before transition to next stand-by condition, by start-up type, in hours' // - ACT_SDTIME(R,LL,P,UPT,BD) 'Duration of start-up (BD=UP) and shut-down BD=LO) phases, by start-up type, in hours' // - ACT_LOSSD(R,LL,P,UPT,BD) 'Efficiency at one hour from start-up (BD=UP) or at one hour to end of shut-down (BD=LO)' // - STG_MAXCYC(R,YEAR,P) 'Maximum number of storage cycles over lifetime' //; -*----------------------------------------------------------------------------- -* Special: Risk parameters & reporting options - PARAMETER UC_ACTBET(UC_N,ALL_REG,ALLYEAR,PRC); - PARAMETER UC_FLOBET(UC_N,ALL_REG,ALLYEAR,PRC,CG); - PARAMETER PRC_REACT(R,ALLYEAR,P) 'Reactance of transmission line'; - PARAMETER COM_CSTBAL(R,ALLYEAR,C,S,ITEM,CUR) 'Cost on specific component of node balance'; - PARAMETER GR_GENLEV(R,C) 'Grid connection category for electricity generation commodity'//; - PARAMETER GR_DEMFR(R,ALLYEAR,C,S) 'Fraction of total electricity demand allocated to grid node' //; - PARAMETER GR_ENDFR(R,ALLYEAR,C,CG) 'Fraction of sectoral electricity demand allocated to grid node' //; - PARAMETER GR_GENFR(R,ALLYEAR,C,ITEM) 'Fraction of electricity generation type allocated to grid node'//; - PARAMETER GR_GENMAP(R,P,ITEM) 'Mapping of technology to generation type' //; - PARAMETER GR_XBND(R,ALLYEAR) 'Maximum level of net imports to / exports from region' //; - PARAMETER GR_THMIN(R,LL,P) 'Thermal minimum level' //; - PARAMETER GR_VARGEN(R,S,ITEM,BD) 'Variance in type of generation'; -*----------------------------------------------------------------------------- -* Attributes for experimental ECB extension - PARAMETER COM_MSHGV(R,YEAR,C) 'Choices heterogeneity parameter' //; - PARAMETER NCAP_MSPRF(R,YEAR,C,P,LIM) 'Preference parameters in choice' //; -*----------------------------------------------------------------------------- -* Predefined items - SET ALL_REG / IMPEXP /; - SET COM_GRP / IMP, EXP /; - SET ITEM / OBJ /, UC_NAME / ANNUAL %MX% /; - SET UC_N /%SYSPREFIX%SOLVE_STATUS 'Model solution status code'/; +*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +* Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) +* This file is part of the IEA-ETSAP TIMES model generator, licensed +* under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). +*=============================================================================* +* INITMTY.VDA has all the EMPTY declarations for system & user data * +*=============================================================================* +$ SETGLOBAL VDA YES +*============================================================================= +* User Input attributes in the VDA extension +*----------------------------------------------------------------------------- +* Process transformation parameters: + PARAMETERS + VDA_FLOP(REG,ALLYEAR,PRC,CG,S) 'General process transformation parameter' + VDA_EMCB(REG,ALLYEAR,COM,COM) 'Combustion emission parameter (aka EMI_comb)' // + VDA_CEH(REG,ALLYEAR,PRC) 'The slope of pass-out turbine (alias NCAP_CEH)' // + FLO_EMIS(REG,ALLYEAR,PRC,CG,COM,S) 'General process emission parameter' // + FLO_EFF(REG,ALLYEAR,PRC,CG,COM,S) 'General process flow-relation parameter' //; +*----------------------------------------------------------------------------- +* Commodity-dependent availabilities: +$ SET MX ,SEASON, WEEKLY, DAYNITE + SET STL / SET.S%MX% /; + PARAMETERS + NCAP_AFAC(REG,ALLYEAR,PRC,CG) 'Annual availability of capacity for commodity group CG' // + NCAP_AFC(REG,ALLYEAR,PRC,CG,STL) 'Availability of capacity for commodity group CG'// + NCAP_AFCS(REG,ALLYEAR,PRC,CG,TS) 'Availability of capacity for commodity group CG'//; +*----------------------------------------------------------------------------- +* Dynamic UC variable bounds (UC_DYNBND user-defined) + SET UC_DYNBND(UC_N,LIM) 'Dynamic process-wise UC bounds' //; +*----------------------------------------------------------------------------- +* Activity efficiency and dispatching options + PARAMETERS + ACT_EFF(REG,YEAR,PRC,CG,TS) 'Activity efficiency for process' // + ACT_UPS(R,ALLYEAR,P,S,L) 'Max. ramp rate, fraction of capacity per hour' + ACT_MINLD(R,ALLYEAR,P) 'Minimum stable operation level' // + ACT_LOSPL(R,ALLYEAR,P,L) 'Fuel consumption increase at minimum load' // + ACT_CSTPL(R,ALLYEAR,P,CUR) 'Partial load cost penalty' // + ACT_MAXNON(R,LL,P,UPT) 'Max. non-operational time before transition to next stand-by condition, by start-up type, in hours' // + ACT_SDTIME(R,LL,P,UPT,BD) 'Duration of start-up (BD=UP) and shut-down BD=LO) phases, by start-up type, in hours' // + ACT_LOSSD(R,LL,P,UPT,BD) 'Efficiency at one hour from start-up (BD=UP) or at one hour to end of shut-down (BD=LO)' // + STG_MAXCYC(R,YEAR,P) 'Maximum number of storage cycles over lifetime' //; +*----------------------------------------------------------------------------- +* Special: Risk parameters & reporting options + PARAMETER UC_ACTBET(UC_N,ALL_REG,ALLYEAR,PRC); + PARAMETER UC_FLOBET(UC_N,ALL_REG,ALLYEAR,PRC,CG); + PARAMETER PRC_REACT(R,ALLYEAR,P) 'Reactance of transmission line'; + PARAMETER COM_CSTBAL(R,ALLYEAR,C,S,ITEM,CUR) 'Cost on specific component of node balance'; + PARAMETER GR_GENLEV(R,C) 'Grid connection category for electricity generation commodity'//; + PARAMETER GR_DEMFR(R,ALLYEAR,C,S) 'Fraction of total electricity demand allocated to grid node' //; + PARAMETER GR_ENDFR(R,ALLYEAR,C,CG) 'Fraction of sectoral electricity demand allocated to grid node' //; + PARAMETER GR_GENFR(R,ALLYEAR,C,ITEM) 'Fraction of electricity generation type allocated to grid node'//; + PARAMETER GR_GENMAP(R,P,ITEM) 'Mapping of technology to generation type' //; + PARAMETER GR_XBND(R,ALLYEAR) 'Maximum level of net imports to / exports from region' //; + PARAMETER GR_THMIN(R,LL,P) 'Thermal minimum level' //; + PARAMETER GR_VARGEN(R,S,ITEM,BD) 'Variance in type of generation'; +*----------------------------------------------------------------------------- +* Attributes for experimental ECB extension + PARAMETER COM_MSHGV(R,YEAR,C) 'Choices heterogeneity parameter' //; + PARAMETER NCAP_MSPRF(R,YEAR,C,P,LIM) 'Preference parameters in choice' //; +*----------------------------------------------------------------------------- +* Predefined items + SET ALL_REG / IMPEXP /; + SET COM_GRP / IMP, EXP /; + SET ITEM / OBJ /, UC_NAME / ANNUAL %MX% /; + SET UC_N /%SYSPREFIX%SOLVE_STATUS 'Model solution status code'/; *----------------------------------------------------------------------------- \ No newline at end of file diff --git a/source/initsys.mod b/source/initsys.mod index 231e5af..161986a 100644 --- a/source/initsys.mod +++ b/source/initsys.mod @@ -1,10 +1,10 @@ -$TITLE TIMES -- VERSION 4.7.3 +$TITLE TIMES -- VERSION 4.7.8 *==========================================================================================* * INITSYS.MOD has all the fixed system declarations for ETSAP TIMES * *==========================================================================================* $ onlisting ontext *=========================================================================================== -* Copyright (C) 2000-2023 IEA Energy Technology Systems Analysis Programme (IEA-ETSAP). +* Copyright (C) 2000-2024 IEA Energy Technology Systems Analysis Programme (IEA-ETSAP). * This software (ETSAP TIMES) is open source: you can redistribute it and/or modify it * under the terms of the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). * For further information, visit: . diff --git a/source/maindrv.mod b/source/maindrv.mod index 2037fc9..e211c30 100644 --- a/source/maindrv.mod +++ b/source/maindrv.mod @@ -38,7 +38,6 @@ $ IF %STAGES% == YES $SET SENSIS 'NO' SET OBJANN NO $ IF SET TIMESTEP $SETGLOBAL STEPPED + $ SET R_T 'R,T' SET TX 'T' SET R_V_T 'R,V,T' SET RTPX '' $ IF SET STEPPED $SET R_T 'R,SUBT(T)' SET TX 'SUBT(T)' SET R_V_T 'R,V,SUBT(T)' -$ IF SET FIXBOH $ IF DEFINED REG_FIXT $SET R_T 'RT_PP(%R_T%)' SET R_V_T 'RVT(%R_V_T%)' SET RTPX X *----------------------------------------------------------------------------- * do a check on user data diff --git a/source/pp_lvlpk.mod b/source/pp_lvlpk.mod index 8b25f78..463a419 100644 --- a/source/pp_lvlpk.mod +++ b/source/pp_lvlpk.mod @@ -1,5 +1,5 @@ *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -* Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) +* Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) * This file is part of the IEA-ETSAP TIMES model generator, licensed * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). *=============================================================================* @@ -9,25 +9,27 @@ * Questions/Comments: * - *----------------------------------------------------------------------------- -SET RPC_PKC(R,P,C); -PARAMETER RPC_PKF(R,P,C) //; + SET RPC_PKC(R,P,C); + PARAMETER RPC_PKF(R,P,C) //; *----------------------------------------------------------------------------- * Collect PKTS for all COM_PEAK commodities -LOOP(COM_PKTS(R,CG,S), RCS(COM_TS(R,C,TS))$(RS_TREE(R,S,TS)$COM_GMAP(R,CG,C)) = YES); -TRACKC(R,C) $= SUM(RCS(R,C,S),1); + LOOP(COM_PKTS(R,CG,S), RCS(COM_TS(R,C,TS))$(RS_TREE(R,S,TS)$COM_GMAP(R,CG,C)) = YES); + TRACKC(R,C) $= SUM(RCS(R,C,S),1); *----------------------------------------------------------------------------- * Levelization of NCAP_PKCNT -LOOP((RTP(R,V,P),S)$NCAP_PKCNT(R,V,P,S), - RTP_GRP(R,V,P,C,IO('OUT'))$(SUM(RCS(R,C,TS)$(NOT NCAP_PKCNT(R,V,P,TS)),1)$RPC(R,P,C)) = YES); + OPTION RTP_ISHPR < NCAP_PKCNT; + FLO_PKCOI(RTP(R,T,P),C,S)$(TRACKC(R,C)$PRC_PKNO(R,P)) = 0; + TRACKPC(RPC(R,P,C))$((TOP(RPC,'OUT')+RPC_IRE(RPC,'IMP'))$TRACKC(R,C)) = YES; + RTP_GRP(RTP_ISHPR(RTP(R,V,P)),C,IO(IPS))$(SUM(RCS(R,C,S)$(NOT NCAP_PKCNT(R,V,P,S)),1)$TRACKPC(R,P,C)) = YES; *----------------------------------------------------------------------------- * Aggregation/inheritance to target timeslices *----------------------------------------------------------------------------- -LOOP(RTP_GRP(R,V,P,C,IO), TS_ARRAY(S) = NCAP_PKCNT(R,V,P,S); - IF((NOT SUM(RS_BELOW(R,'ANNUAL',S)$TS_ARRAY(S),1))$TS_ARRAY('ANNUAL'), - NCAP_PKCNT(R,V,P,S)$RCS(R,C,S) = TS_ARRAY('ANNUAL'); - ELSE + LOOP(RTP_GRP(R,V,P,C,IO), TS_ARRAY(S) = NCAP_PKCNT(R,V,P,S); + F = TS_ARRAY('ANNUAL'); + IF((NOT SUM(RS_BELOW(R,ANNUAL,S)$TS_ARRAY(S),1))$F,NCAP_PKCNT(R,V,P,S)$RCS(R,C,S) = F; + ELSE * Set leveling default = %1; - TS_ARRAY('ANNUAL')$(NOT TS_ARRAY('ANNUAL')) = %1; + IF(NOT F,TS_ARRAY(ANNUAL) = %1); * Simultaneous inheritance/aggregation; but only if target level value is not present LOOP(RCS(R,C,TS)$(NOT TS_ARRAY(TS)), NCAP_PKCNT(R,V,P,TS) $= @@ -36,18 +38,17 @@ LOOP(RTP_GRP(R,V,P,C,IO), TS_ARRAY(S) = NCAP_PKCNT(R,V,P,S); TS_ARRAY(ALL_TS))))))); *----------------------------------------------------------------------------- * Peak contribution - TRACKPC(R,P,C)$((TOP(R,P,C,'OUT')+RPC_IRE(R,P,C,'IMP'))$TRACKC(R,C)) = YES; * If PRC_PKAF, apply PKCNT only for capacity - TRACKP(PRC_PKAF(RP))=NOT PRC_PKNO(RP); RPC_PKF(TRACKPC(RP,C))=EPS**1$TRACKP(RP); - TRACKPC(PRC_PKNO(RP),C)=NO; -* If no PKCNT provided, Copy NCAP_AF if PRC_PKAF; Otherwise set default 1 - LOOP(TRACKPC(R,P,C),PRC_TS2(R,P,S)$((NOT SUM(RTP(R,V,P),NCAP_PKCNT(RTP,S)))$RCS(R,C,S)) = YES); - NCAP_PKCNT(RTP(R,V,P),S)$PRC_TS2(R,P,S) = 1$(NOT PRC_PKAF(R,P)) + - SUM(PRC_TS(R,P,TS)$RS_TREE(R,S,TS),SMAX(BD,NCAP_AF(RTP,TS,BD))*(1+(G_YRFR(R,TS)/G_YRFR(R,S)-1)$RS_BELOW(R,S,TS)))$PRC_PKAF(R,P); + TRACKP(PRC_PKAF(RP))=NOT PRC_PKNO(RP); TRACKPC(PRC_PKNO(RP),C) = NO; + RPC_PKF(RPC(RP_FLO(R,P),C))$TRACKC(R,C) = EPS**1$TRACKP(R,P); +* If no PKCNT provided, copy NCAP_AF if PRC_PKAF; otherwise set default 1 + LOOP(TRACKPC(R,P,C),PRC_TS2(R,P,S)$((NOT SUM(RTP(R,V,P),NCAP_PKCNT(RTP,S)))$RCS(R,C,S)) = YES); + NCAP_PKCNT(RTP(R,V,P),S)$PRC_TS2(R,P,S) = 1$(NOT PRC_PKAF(R,P)) + + SUM(PRC_TS(R,P,TS)$RS_TREE(R,S,TS),SMAX(BD,NCAP_AF(RTP,TS,BD))*(1+(G_YRFR(R,TS)/G_YRFR(R,S)-1)$RS_BELOW(R,S,TS)))$PRC_PKAF(R,P); *----------------------------------------------------------------------------- * RPC_PKC indicator for peak contribution by capacity RPC_PKC(TRACKPC(RPC_ACT(TRACKP(RP_STD),C)))=YES; TRACKPC(RP,C)$(NOT RPC_PG(RP,C)*RP_FLO(RP))=NO; RPC_PKC(TRACKPC(RP_PGACT(RP),C))$(RP_PG(RP,C)+TRACKP(RP))=YES; LOOP(NRG_TMAP(R,'ELC',C)$TRACKC(R,C),RPC_PKC(TRACKPC(TRACKP(R,P),C))=YES;TRACKP(R,P)$TRACKPC(R,P,C)=NO); - OPTION CLEAR=TRACKP,CLEAR=TRACKC,CLEAR=TRACKPC,CLEAR=RTP_GRP,CLEAR=RCS,CLEAR=PRC_TS2; + OPTION CLEAR=TRACKP,CLEAR=TRACKC,CLEAR=TRACKPC,CLEAR=RTP_GRP,CLEAR=RCS,CLEAR=RTP_ISHPR,CLEAR=PRC_TS2; diff --git a/source/pp_prelv.vda b/source/pp_prelv.vda index fd281b5..57ac323 100644 --- a/source/pp_prelv.vda +++ b/source/pp_prelv.vda @@ -1,11 +1,11 @@ *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -* Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) +* Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) * This file is part of the IEA-ETSAP TIMES model generator, licensed * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). *=============================================================================* * pp_prelvl.vda - Auxiliary preprocessing before levelizing *=============================================================================* -* To be called AFTER establishing RTCS_VARC and RPCS_VAR. +* Called AFTER establishing RTCS_VARC and RPCS_VAR. *----------------------------------------------------------------------------- * Restore NCAP_TLIFE for RESID LOOP(PYR_S(V),NCAP_TLIFE(R,V,P)$PRC_RESID(R,'%DFLBL%',P) = PRC_RESID(R,'%DFLBL%',P)); @@ -74,7 +74,8 @@ $IFI %SHELL%==ANSWER PRC_ACTFLO(R,LL,P,C)$((NOT KEEP_FLOF(R,P,C))$TRACKPC(R,P,C) RPC_EMIS(R,P,C)$SUM(RPCC_FFUNC(R,P,COM,C),1) = NO; * Add groups of source commodities FSCK(RP_CGC(R,P,CG,COM),C)$(COM_GMAP(R,CG,C)$RPC(R,P,C)) = YES; - LOOP(FSCK(R,P,CG,COM,C), FLO_SUM(R,V,P,COM,C,COM,S) $= FLO_EMIS(R,V,P,CG,COM,S); RPC_EMIS(R,P,COM) = NO); + LOOP(FSCK(R,P,CG,COM,C), FLO_SUM(R,V,P,COM,C,COM,S) $= FLO_EMIS(R,V,P,CG,COM,S)); + RPC_EMIS(R,P,COM)$SUM(FSCK(R,P,CG,COM,C),1) = NO; * Add activity sources FLO_SUM(RTP(R,V,P),COM,C,COM,S)$(RPC_PG(R,P,C)$RP_CGC(R,P,%PGPRIM%,COM)) = FLO_EMIS(RTP,%PGPRIM%,COM,S)/PRC_ACTFLO(RTP,C); RP_CGC(R,P,%PGPRIM%,C) = NO; PUTGRP=0; diff --git a/source/pp_qack.mod b/source/pp_qack.mod index e8a1148..3059505 100644 --- a/source/pp_qack.mod +++ b/source/pp_qack.mod @@ -1,5 +1,5 @@ *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -* Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) +* Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) * This file is part of the IEA-ETSAP TIMES model generator, licensed * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). *=============================================================================* @@ -220,12 +220,21 @@ $ BATINCLUDE pp_qaput.%1 PUTOUT PUTGRP 01 'IRE Process with invalid Paramet IF(Z = 3, PUT QLOG ' WARNING - IRE with FLO_SHAR: R=',%RL%,' P=',%PL%,' C=',CG.TL); IF(Z = 4, PUT QLOG ' WARNING - IRE with ACT_EFF: R=',%RL%,' P=',%PL%,' CG=',CG.TL); ); - OPTION CLEAR=UNCD7; - UNCD7(UC_N,SIDE--ORD(SIDE),R,LL--ORD(LL),P,C,S--ORD(S)) $= UC_FLO(UC_N,SIDE,R,LL,P,C,S)$RP_IRE(R,P); - LOOP(UNCD7(UC_N,SIDE,R,LL,P,C,S), + OPTION CLEAR=RXX; + LOOP(UC_QAFLO('1',UCN,SIDE,R,P,C)$(NOT UC_CAPFLO(UCN,SIDE,R,P,C)),RXX(R,P,UCN)=YES); + LOOP(RXX(R,P,UC_N), $ BATINCLUDE pp_qaput.%1 PUTOUT PUTGRP 01 'IRE Process with invalid Parameters' PUT QLOG ' WARNING - IRE with UC_FLO: R=',%RL%,' P=',%PL%,' UC_N=',UC_N.TL; ); + OPTION CLEAR=RXX; PUTGRP=0; + LOOP(PRC_MAP(R,'IRE',P)$(RP(R,P)$(NOT RP_IRE(R,P))), +$ BATINCLUDE pp_qaput.%1 PUTOUT PUTGRP 09 'Standard Flow Process with invalid Attributes' + PUT QLOG ' SEVERE ERROR - Process Group is IRE: R=',%RL%,' P=',%PL%; + ); + LOOP(UC_QAFLO('2',UC_N,SIDE,RPC(R,P,C)), +$ BATINCLUDE pp_qaput.%1 PUTOUT PUTGRP 01 'Standard Flow Process with invalid Parameters' + PUT QLOG ' WARNING - FLO flow with UC_IRE: R=',%RL%,' P=',%PL%,' C=',%CL%,' UC_N=',UC_N.TL; + ); *----------------------------------------------------------------------------- PUTGRP = 0; * ACT_EFF quality tests diff --git a/source/pp_qafs.mod b/source/pp_qafs.mod index f8aec94..cd20f0b 100644 --- a/source/pp_qafs.mod +++ b/source/pp_qafs.mod @@ -1,5 +1,5 @@ *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -* Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) +* Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) * This file is part of the IEA-ETSAP TIMES model generator, licensed * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). *============================================================================= @@ -10,7 +10,6 @@ SET RTP_CG(R,ALLYEAR,P,CG,IO) //; SET RTP_GRP(R,ALLYEAR,P,CG,IO) //; SET RP_GIC(R,P,CG,IO,C) //; - SET RPG_RED(R,P,CG,IO) //; *----------------------------------------------------------------------------- * Collect the Groups involved OPTION RP_CCG <= FLO_SHAR; PUTGRP=0; diff --git a/source/pp_reduce.red b/source/pp_reduce.red index e881a9c..b3b9dce 100644 --- a/source/pp_reduce.red +++ b/source/pp_reduce.red @@ -177,7 +177,8 @@ $LABEL REDDONE LOOP(FS_EMIS(R,P,CG,C,COM), RPCC_FFUNC(R,P,CG,COM) = YES); OPTION CLEAR=TRACKPC,CLEAR=FSCK; PRC_TS2(PRC_TS(RP_PGACT(RP_STD),S)) = YES; - RPC_PKF(RPC_PKC(PRC_CAP,C)) = 0; + RPC_PKC(RP,C)$(NOT PRC_CAP(RP)) = NO; + RPC_PKF(RPC_PKC) = 0; * Remove timeslices turned off if DYNTS enabled $IF NOT %RTS%==S $BATINCLUDE dynslite.vda REDUCE diff --git a/source/pp_shapr.mod b/source/pp_shapr.mod index 5057c69..5691f3f 100644 --- a/source/pp_shapr.mod +++ b/source/pp_shapr.mod @@ -12,26 +12,24 @@ *=============================================================================* *AL Comments: *----------------------------------------------------------------------------- + SET RTP_SHAPI(REG,ALLYEAR,PRC,BD,J,J,LL,LL); +$ SETLOCAL PASS %3 +$ IF %3=='' $SETLOCAL PASS YES -SET RTP_SHAPI(REG,ALLYEAR,PRC,BD,J,J,LL,LL); -SET RTP_ISHPR(REG,ALLYEAR,PRC) //; -$SETLOCAL PASS %3 -$IF %3 == '' $SETLOCAL PASS YES - -LOOP(BD,RTP_ISHPR(RTP(R,V,P))$((%1%6X(RTP,BD) GE 1.5)$%1%6X(RTP,BD)) = YES); -RTP_ISHPR(RTP(R,V,P))$((%5 GE 1.5)$%5) = YES; + LOOP(BD,RTP_ISHPR(RTP(R,V,P))$((%1%6X(RTP,BD) GE 1.5)$%1%6X(RTP,BD)) = YES); + RTP_ISHPR(RTP(R,V,P))$((%5 GE 1.5)$%5) = YES; * Prepare for start and end years -OPTION CLEAR=FIL2; FIL2(V) = B(V)-YEARVAL(V); -PASTSUM(RTP_ISHPR(R,V,P)) = FIL2(V)+NCAP_ILED(R,V,P)+NCAP_TLIFE(R,V,P)-1; + OPTION CLEAR=FIL2; FIL2(V) = B(V)-YEARVAL(V); + PASTSUM(RTP_ISHPR(R,V,P)) = FIL2(V)+NCAP_ILED(R,V,P)+NCAP_TLIFE(R,V,P)-1; * Shape attributes only for processes around for > 1 period -%1%6X(RTP_ISHPR(R,V,P),BD)$(PASTSUM(R,V,P)-FIL2(V)+1 < D(V)) = 0; + %1%6X(RTP_ISHPR(R,V,P),BD)$(PASTSUM(R,V,P)-FIL2(V)+1 < D(V)) = 0; * Get hold of the shape and multi index J,JJ for each RVP, as well as start and end years -LOOP(SAMEAS(J,'1'), - RTP_SHAPI(RTP_ISHPR(R,V(LL),P),BD,J+MAX(0,%1%6X(R,V,P,BD)-1),J+MAX(0,%5-1),LL+(FIL2(V)+NCAP_ILED(R,V,P)),LL+PASTSUM(R,V,P)) = YES; -); + LOOP(SAMEAS(J,'1'), + RTP_SHAPI(RTP_ISHPR(R,V(LL),P),BD,J+MAX(0,%1%6X(R,V,P,BD)-1),J+MAX(0,%5-1),LL+(FIL2(V)+NCAP_ILED(R,V,P)),LL+PASTSUM(R,V,P)) = YES; + ); LOOP(SAMEAS(AGE,'1'), * Calculate average SHAPE for plants still operating in each period: @@ -41,8 +39,8 @@ LOOP(SAMEAS(J,'1'), SHAPE(J,AGE+(MIN(YEARVAL(EOHYEARS),YEARVAL(YEAR))-YEARVAL(LL)))) / (MAX(1,MIN(E(T),YEARVAL(YEAR))-MAX(B(T),YEARVAL(LL))+1)))); -* If no shape index is pecified, set the BASE value for the attribute -RTP_ISHPR(RTP(R,V,P)) = (NOT RTP_ISHPR(R,V,P)); -%4$(RTP_ISHPR(R,V,P)$(%PASS%)) = %1%2; +* If no shape index is specified, set the BASE value for the attribute + RTP_ISHPR(RTP(R,V,P)) = (NOT RTP_ISHPR(RTP)); + %4$(RTP_ISHPR(R,V,P)$(%PASS%)) = %1%2; * Clear the temporary sets -OPTION CLEAR=RTP_SHAPI,CLEAR=RTP_ISHPR,CLEAR=PASTSUM; + OPTION CLEAR=RTP_SHAPI,CLEAR=RTP_ISHPR,CLEAR=PASTSUM; diff --git a/source/ppm_ext.ecb b/source/ppm_ext.ecb index 58112d1..099ce21 100644 --- a/source/ppm_ext.ecb +++ b/source/ppm_ext.ecb @@ -27,7 +27,8 @@ $ BATINCLUDE fillparm NCAP_MSPRF R 'C,P,L' ",'','',''" T 'RTP(R,T,P)' 'GE 0' * Initialize probing shares RTC_MS(RTC(R,T,C))$(SUM(TOP(RPC_PG(R,P,C),'OUT')$(NOT RTP_OFF(R,T,P)),ORD(T)>1)$COM_MSHGV(R,T,C)) = YES; - LOOP(RTC_MS(R,T,C),PRC_YMAX(RP_FLO(PRC_CAP(R,P)))$TOP(R,P,C,'OUT') = RPC_PG(R,P,C)$(NOT RTP_OFF(R,T,P)); + LOOP(RTC_MS(R,T,C), OPTION CLEAR=PRC_YMAX; + PRC_YMAX(RP_FLO(PRC_CAP(R,P)))$TOP(R,P,C,'OUT') = RPC_PG(R,P,C)$(NOT RTP_OFF(R,T,P)); Z=SUM(P$PRC_YMAX(R,P),1); IF(Z, COEF_LMS(R,T,C,P)$PRC_YMAX(R,P) = -0.05 / Z)); * Complete flow controls for dummy diff --git a/source/ppmain.mod b/source/ppmain.mod index c125396..2b2eec7 100644 --- a/source/ppmain.mod +++ b/source/ppmain.mod @@ -41,12 +41,14 @@ $ IF WARNINGS $BATINCLUDE pp_qaput.%1 PUTOUT 0 * 'GAMS Warnings Detected%TMP%' * establish initial primary looping control sets indicating what region/process/commodities *----------------------------------------------------------------------------- * process/commodities in each region, including inter-regional exchanges + PRC_ACTUNT(R,P,%PGPRIM%,UNITS_ACT) = NO; OPTION RPC_AIRE < TOP_IRE; RPC_IRE(RPC_AIRE,'IMP') = YES; OPTION RPC_AIRE <= TOP_IRE; RPC_IRE(RPC_AIRE,'EXP') = YES; - OPTION CLEAR=RPC_AIRE; + OPTION CLEAR=RPC_AIRE, PRC_ACT < PRC_ACTUNT; RP_IRE(ALL_R,P)$SUM(RPC_IRE(ALL_R,P,C,IE),1) = YES; TOP(RP_IRE(R,P),C,'IN')$RPC_IRE(R,P,C,'EXP') = NO; TOP(RP_IRE(R,P),C,'OUT')$RPC_IRE(R,P,C,'IMP') = NO; + TOP(RPG_RED(PRC_ACT(R,P),C,IO))$(COM_TMAP(R,'ENV',C)+RP_IRE(R,P)) = YES; * process/commodities in each region RPC(R,P,C)$(SUM(TOP(R,P,C,IO),1) + SUM(RPC_IRE(R,P,C,IE),1)) = YES; RC(R,C)$SUM(RPC(R,P,C),1) = YES; @@ -54,8 +56,8 @@ $ IF WARNINGS $BATINCLUDE pp_qaput.%1 PUTOUT 0 * 'GAMS Warnings Detected%TMP%' RP_FLO(RP)$(NOT RP_IRE(RP)) = YES; * establish PCG, checking for missing ones - PRC_ACTUNT(R,P,%PGPRIM%,UNITS_ACT) = NO; - OPTION RP_PG < PRC_ACTUNT; PRC_ACT(RP)$(NOT SUM(RP_PG(RP,CG),1))=YES; + OPTION RP_PG < PRC_ACTUNT, CLEAR=RPG_RED, CLEAR=PRC_ACT; + PRC_ACT(RP)$(NOT SUM(RP_PG(RP,CG),1))=YES; IF(CARD(PRC_ACT), TRACKPC(PRC_ACT(R,P),C)$((NOT COM_TMAP(R,'ENV',C)+COM_TMAP(R,'FIN',C))$TOP(R,P,C,'OUT'))=YES; PRC_ACT(RP)$(SUM(TRACKPC(RP,C),1) NE 1)=NO; RP_PG(TRACKPC(PRC_ACT,C))=YES; @@ -145,7 +147,7 @@ $IFI %OBJ%==MOD M(T) = 0; IF(ALTOBJ=1,ALTOBJ=1$SUM(T,M(T) NE YEARVAL(T))); * establish 1st/last run year - MIYR_1(MILESTONYR)$(ORD(MILESTONYR) = 1) = YES; + MIYR_1(T)$(ORD(T) = 1) = YES; IF(ALTOBJ, * If alternate objective, set B and E, D and M: E(T(TT-1)) = FLOOR((YEARVAL(T)+YEARVAL(TT))/2); B(T(TT+1)) = E(TT)+1; @@ -154,7 +156,7 @@ $IFI %OBJ%==MOD M(T) = 0; D(T)=E(T)-B(T)+1; M(T) = YEARVAL(T)); *V0.5c 980904 - set 1st value to B not milestone itself MIYR_V1 = SMIN(MIYR_1, B(MIYR_1)); - MIYR_VL = SMAX(MILESTONYR$(ORD(MILESTONYR) = CARD(MILESTONYR)), E(MILESTONYR)); + MIYR_VL = SMAX(T$(ORD(T) = CARD(T)), E(T)); $IFI '%OBLONG%'==YES IF(MIYR_V1+SUM(T,E(T)+1-B(T))-MIYR_VL NE 1,ABORT "Inconsistent periods - cannot use OBLONG."); LOOP(MIYR_1(LL),PASTYEAR(LL-(YEARVAL(LL)-MIYR_V1+1)) = YES); * Set LEADs and LAGs for periods @@ -480,9 +482,9 @@ $ BATINCLUDE pp_qaput.%1 PUTOUT PUTGRP 01 'NCAP_TLIFE out of feasible range * Checks for host processes of refits SET PRC_RCAP //; PARAMETER PRC_REFIT //; PRC_REFIT(R,P,PRC)$PRC_REFIT(R,P,PRC)=MAX(ABS(ROUND(PRC_REFIT(R,P,PRC))),MIN(6,ABS(MAX(ROUND(PRC_REFIT(R,P,P)),-1)*2)))*MOD(ROUND(PRC_REFIT(R,P,PRC)),2); - LOOP((RP(R,PRC),P)$PRC_REFIT(RP,P),IF(PRC_REFIT(RP,P)<-4,NCAP_ELIFE(RTP(R,T,P))$(NCAP_ELIFE(RTP)<1)=NCAP_TLIFE(RTP); - NCAP_TLIFE(RTP(R,T,P))=MAX(NCAP_TLIFE(R,T,PRC)+NCAP_ILED(R,T,PRC)-1,NCAP_TLIFE(RTP)))); - LOOP((RP(R,PRC),P)$((NOT PRC_RCAP(RP))$PRC_REFIT(RP,P)),RTP_OFF(R,T,P)=YES); + LOOP((RP(R,PRC),P)$PRC_REFIT(RP,P),IF(NOT PRC_RCAP(RP),RTP_OFF(R,T,P)=YES); + IF(PRC_REFIT(RP,P)<-4,NCAP_ELIFE(RTP(R,T,P))$(NCAP_ELIFE(RTP)<1)=NCAP_TLIFE(RTP); + NCAP_TLIFE(RTP(R,T,P))=MAX(NCAP_TLIFE(R,T,PRC)+NCAP_ILED(R,T,PRC)-1,NCAP_TLIFE(RTP)))); *----------------------------------------------------------------------------- * capacity transfer v = year of installation and thus data values where @@ -541,7 +543,7 @@ $ BATINCLUDE pp_qaput.mod PUTOUT PUTGRP 1 'Inconsistent CAP_BND(UP/LO/FX) def *----------------------------------------------------------------------------- * turn off RTP/CPTYR if no new investment & installed capacity no longer available LOOP(BDUPX(BD),RTP_OFF(RTP)$((NCAP_BND(RTP,BD)=0)$NCAP_BND(RTP,BD)) = YES); - NO_RVP(RTP_OFF(R,T,P)) = YES; + NO_RVP(RTP_OFF(R,T,P))$(NOT NCAP_PASTI(R,T,P)) = YES; LOOP(T, NO_RVP(R,TT,P)$(RTP_CPTYR(R,T,TT,P)$(NOT RTP_OFF(R,T,P))) = NO); LOOP(PYR(V), NO_RVP(R,T,P)$(RTP_CPTYR(R,V,T,P)$NCAP_PASTI(R,V,P)) = NO); RTP(NO_RVP) = NO; @@ -1166,8 +1168,9 @@ $ BATINCLUDE prepxtra.mod UCINT * Remove RHS from DYNDIR if LHS present: UC_DYNDIR(R,UC_N,'RHS')$UC_DYNDIR(R,UC_N,'LHS') = NO; UC_TSL(UC_DYNDIR(R_UC,'RHS'),TSL)$UC_TSL(R_UC,'LHS',TSL)=YES; UC_DYNDIR(R_UC,SIDE)=NO; -* Add implicit T_SUCC and remove T_EACH whenever T_SUCC: - LOOP(SIDE, UC_T_SUCC(UC_T_EACH(R,UC_N,T))$UC_DYNDIR(R,UC_N,SIDE) = YES); +* Add implicit T_SUCC and remove T_EACH whenever T_SUCC + UC_T_SUCC(UC_T_EACH(R,UCN,T)) $= SUM(UC_DYNDIR(R,UCN,SIDE),1); + UC_T_SUCC(UC_T_EACH(R,UCN,T))$UC_R_SUM(R,UCN) $= SUM(UC_T_SUCC(UC_R_SUM(REG,UCN),T),1); UC_T_EACH(UC_T_SUCC) = NO; * Remove last MILESTONYR from UC_T_SUCC unless GROWTH constraint is RHS-based: UC_T_SUCC(UC_T_SUCC(R,UC_N,T))$(ORD(T) EQ CARD(T)) = UC_DYNDIR(R,UC_N,'RHS'); @@ -1175,15 +1178,16 @@ $ BATINCLUDE prepxtra.mod UCINT *----------------------------------------------------------------------------- * Assigning commodities and processes to UC group map sets - SET UC_MAP_FLO(UC_N,SIDE,ALL_REG,PRC,COM) 'Assigning processes to UC_GRP'; SET UC_MAP_IRE(UC_N,ALL_REG,PRC,COM,IE) 'Assigning processes to UC_GRP'; * FLO / IRE / COM OPTION UC_MAP_FLO < UC_FLO; + UC_QAFLO('1',UC_MAP_FLO(UCN,SIDE,RP_IRE(R,P),C))=YES; UC_CAPFLO(UC_N,SIDE,R,P,C)$(NOT UC_MAP_FLO(UC_N,SIDE,R,P,C)) = NO; UC_MAP_FLO(UC_N,SIDE,RP_IRE,C) = NO; OPTION UC_MAP_IRE < UC_IRE; + UC_QAFLO('2',UCN,'LHS',RP_FLO,C)$=SUM(UC_MAP_IRE(UCN,RP_FLO,C,IE),1); UC_MAP_IRE(UC_N,R,P,C,IE)$(NOT RPC_IRE(R,P,C,IE)) = NO; OPTION UC_GMAP_C < UC_COM; UC_ATTR(R,UCN,SIDE,UC_GRPTYPE,UC_DYNT)$UC_ATTR(R,UCN,SIDE,'COMCON',UC_DYNT)$=SUM(UC_GMAP_C(R,UCN,COM_VAR,C,'COMCON')$COV_MAP(COM_VAR,UC_GRPTYPE),1); diff --git a/source/prepret.dsc b/source/prepret.dsc index 4242bee..c5b3e09 100644 --- a/source/prepret.dsc +++ b/source/prepret.dsc @@ -50,16 +50,33 @@ $IF %MIP% INTEGER IF(CNT,Z=(-1+2$(F=CNT))*MAX(1,MY_F); ELSE Z=-2); IF(NOT MAPVAL(CNT),RP_RTF(R,PRC) = Z); IF(F,RCAP_BND(RTP(R,T,PRC),'UP')$(NOT SUM(P$PRC_REFIT(R,PRC,P),RTP(R,T,P)$(ABS(PRC_REFIT(R,PRC,P))>2)))=EPS)); -$EXIT -*----------------------------------------------------------------------------- -$LABEL EQOBJ -$SETGLOBAL RCAPSUB -SUM(VNRET(V,T),%VART%_SCAP(R,V,T,P%SWS%))$PRC_RCAP(R,P) -$SETGLOBAL RCAPSBM -SUM(VNRET(MODLYEAR,T),%VART%_SCAP(R,MODLYEAR,T,P%SWS%))$PRC_RCAP(R,P) * Force obj type 2a/2b VNRET(VNT(V,T))$(NOT SAMEAS(V,T)) = YES; RVPRL(RTP(R,V,P))$PRC_RCAP(R,P)=MAX(0,SMAX(RTP_CPTYR(R,VNRET(V,T),P),YEARVAL(T))-YEARVAL(V)); RVP(RTP) $= RVPRL(RTP); NCAP_ILED(RVP) = NCAP_ILED(RVP)+EPS; +* Set bounds for continuous retirements + RCAP_BND(R,T,P,BDNEQ) $= RCAP_BND(R,T,P,'FX'); + PASTSUM(RVP(R,V,P))$RCAP_BND(RVP,'N') = -(B(V)+NCAP_ILED(RVP)+ABS(RCAP_BND(RVP,'N'))); + PASTSUM(RVP)$((RCAP_BND(RVP,'N')<0)+MAPVAL(RCAP_BLK(RVP))) = MAX(1,ABS(PASTSUM(RVP))); + LOOP(TT(T--1),Z=ORD(T)-1; + %VAR%_RCAP.LO(RTP_CPTYR(R,VNRET(V,T),P)%SOW%)$RVP(R,V,P) = RCAP_BND(R,T,P,'LO')$(NOT MAPVAL(RCAP_BLK(R,V,P)))+MIN(0,RTFORC(R,V,T,P)-RTFORC(R,V,TT,P)$Z); + %VAR%_RCAP.UP(RTP_CPTYR(R,VNRET(V,T),P)%SOW%)$RCAP_BND(R,T,P,'UP') = + MIN(SMIN(PASTMILE(V),NCAP_PASTI(R,V,P)),RCAP_BND(R,T,P,'UP')+MAX(0,RTFORC(R,V,T,P)-RTFORC(R,V,TT,P)$Z))); + %VAR%_SCAP.LO(RTP_CPTYR(R,VNRET(V,T),P)%SOW%)$RVP(R,V,P) = MAX(RCAP_BND(R,T,P,'LO'),RTFORC(R,V,T,P)); + %VAR%_SCAP.UP(RTP_CPTYR(R,PASTMILE(V),T,P)%SOW%)$RVP(R,V,P) = MAX(RTFORC(R,V,T,P),NCAP_PASTI(R,V,P)); + LOOP(RVP(R,V,P),Z=1;LOOP(RTP_CPTYR(R,VNRET(V,T),P)$Z,Z=0; %VAR%_SCAP.UP(R,V,T,P%SOW%)=MIN(%VAR%_RCAP.UP(R,V,T,P%SOW%),%VAR%_SCAP.UP(R,V,T,P%SOW%)))); + %VAR%_SCAP.FX(RTP_CPTYR(R,V,T,P)%SOW%)$(((M(T) LT ABS(PASTSUM(R,V,P)))+((M(T)-LEAD(T))/PASTSUM(R,V,P) GE 1))$PASTSUM(R,V,P)) = RTFORC(R,V,T,P); +* Force refits = retirements on request + PRC_YMAX(PRC_RCAP(RP)) = MIN(0,SUM(P$PRC_REFIT(RP,P),MAX(EPS,3-ABS(PRC_REFIT(RP,P))))); + RVPRL(R,'0',P) $= PRC_YMAX(R,P); + %VAR%_RCAP.UP(RTP_TT(R,T(TT++1),T,P)%SOW%)$((RP_RTF(R,P)<3)$PRC_YMAX(R,P))=MAX(0,SUM(RTP(R,PYR_S(V),P),RTFORC(R,V,T,P)-RTFORC(R,V,TT,P))$VNT(TT,T)$(MOD(RP_RTF(R,P),2)=0)); + OPTION CLEAR=PASTSUM,CLEAR=RVP; +$EXIT +*----------------------------------------------------------------------------- +$LABEL EQOBJ +$SETGLOBAL RCAPSUB -SUM(VNRET(V,T),%VART%_SCAP(R,V,T,P%SWS%))$PRC_RCAP(R,P) +$SETGLOBAL RCAPSBM -SUM(VNRET(MODLYEAR,T),%VART%_SCAP(R,MODLYEAR,T,P%SWS%))$PRC_RCAP(R,P) *------------------- * Allow retirements in integer multiples of a user-defined block-size or the full residual capacity @@ -69,9 +86,10 @@ $SETGLOBAL RCAPSBM -SUM(VNRET(MODLYEAR,T),%VART%_SCAP(R,MODLYEAR,T,P%SWS%))$PRC_ RCAP_BLK(R,V,P) * %VAR%_DRCAP(R,V,T,P%SOW%,'2') + (NCAP_PASTI(R,V,P)-RTFORC(R,V,T,P)) * %VAR%_DRCAP(R,V,T,P%SOW%,'1'); * Cumulative retirements - %EQ%_CUMRET(R,VNRET(V,K(T-1)),P%SWT%)$(RTP_CPTYR(R,V,T,P)$PRC_RCAP(R,P)).. + %EQ%_CUMRET(R,VNRET(V,K(T-(1-1$RP_RTF(R,P)))),P%SWT%)$(RTP_CPTYR(R,V,T,P)$PRC_RCAP(R,P)).. - SUM(RTP_CPTYR(R,V,MODLYEAR(K),P),%VAR%_SCAP(R,V,T,P%SOW%)-%VAR%_RCAP(R,V,T,P%SOW%)-%VARM%_SCAP(R,V,K,P%SWS%)) + SUM(RTP_CPTYR(R,V,K,P),%VAR%_SCAP(R,V,T,P%SOW%) - %VAR%_RCAP(R,V,T,P%SOW%)) - + SUM(RTP_CPTYR(R,V,MODLYEAR(Y(T-1)),P)$VNRET(V,Y),%VARM%_SCAP(R,V,Y,P%SWS%)) =E= 0; * Maximum salvage capacity @@ -86,26 +104,10 @@ $SETGLOBAL RCAPSBM -SUM(VNRET(MODLYEAR,T),%VART%_SCAP(R,MODLYEAR,T,P%SWS%))$PRC_ %EQ%L_REFIT(RTP_TT(R,TT,T,PRC),LNX(L)%SWT%)$((BD(L)+VNT(T,TT)$(RP_RTF(R,PRC)=3))$RT_PP(R,T)).. SUM((V(TT),P)$((VNT(T,V) OR PRC_REFIT(R,PRC,P)<0)$PRC_REFIT(R,PRC,P)),COEF_CPT(R,V,T,P)*(%VARV%_NCAP(R,V,P%SWS%)%RCAPSUB%))+%VAR%_RCAP(R,T,TT,PRC%SOW%)$(RP_RTF(R,PRC)$VNT(T,TT)$BD(L)<3) =E= - SUM(RTP_CPTYR(R,VNRET(V,TT),PRC),COEF_CPT(R,V,T,PRC) * (%VARTT%_SCAP(R,V,TT,PRC%SWS%)-SUM(MODLYEAR(K(TT-1))$VNRET(V,K),%VARM%_SCAP(R,V,K,PRC%SWS%)+MIN(INF$MOD(RP_RTF(R,PRC),2),RTFORC(R,V,TT,PRC)-RTFORC(R,V,K,PRC)))))+ + SUM(RTP_CPTYR(R,VNRET(V,TT),PRC),COEF_CPT(R,V,T,PRC) * (%VARTT%_RCAP(R,V,TT,PRC%SWS%)-SUM(MODLYEAR(K(TT-1))$VNT(V,K),MIN(INF$MOD(RP_RTF(R,PRC),2),RTFORC(R,V,TT,PRC)-RTFORC(R,V,K,PRC)))))+ SUM(K(TT-1)$RTP_TT(R,K,T,PRC),%VAR%_RCAP(R,T,K,PRC%SOW%))$(RP_RTF(R,PRC)$BD(L)>0); *----------------------------------------------------------------------------- -$IF %STAGES%==YES $%SW_TAGS% -* Set bounds for continuous retirements - RCAP_BND(R,T,P,BDNEQ) $= RCAP_BND(R,T,P,'FX'); - PASTSUM(RVP(R,V,P))$RCAP_BND(RVP,'N') = -(B(V)+NCAP_ILED(RVP)+ABS(RCAP_BND(RVP,'N'))); - PASTSUM(RVP)$((RCAP_BND(RVP,'N')<0)+MAPVAL(RCAP_BLK(RVP))) = MAX(1,ABS(PASTSUM(RVP))); - LOOP(TT(T--1),Z=ORD(T)-1; - %VAR%_RCAP.LO(RTP_CPTYR(R,VNRET(V,T),P)%SOW%)$RVP(R,V,P) = RCAP_BND(R,T,P,'LO')$(NOT MAPVAL(RCAP_BLK(R,V,P)))+MIN(0,RTFORC(R,V,T,P)-RTFORC(R,V,TT,P)$Z); - %VAR%_RCAP.UP(RTP_CPTYR(R,VNRET(V,T),P)%SOW%)$RCAP_BND(R,T,P,'UP') = - MIN(SMIN(PASTMILE(V),NCAP_PASTI(R,V,P)),RCAP_BND(R,T,P,'UP')+MAX(0,RTFORC(R,V,T,P)-RTFORC(R,V,TT,P)$Z))); - %VAR%_SCAP.LO(RTP_CPTYR(R,V,T,P)%SOW%)$RVP(R,V,P) = MAX(RCAP_BND(R,T,P,'LO'),RTFORC(R,V,T,P)); - %VAR%_SCAP.UP(RTP_CPTYR(R,PASTMILE(V),T,P)%SOW%)$RVP(R,V,P) = MAX(RTFORC(R,V,T,P),NCAP_PASTI(R,V,P)); - LOOP(RVP(R,V,P),Z=1;LOOP(RTP_CPTYR(R,VNRET(V,T),P)$Z,Z=0; %VAR%_SCAP.UP(R,V,T,P%SOW%)=MIN(%VAR%_RCAP.UP(R,V,T,P%SOW%),%VAR%_SCAP.UP(R,V,T,P%SOW%)))); - %VAR%_SCAP.FX(RTP_CPTYR(R,V,T,P)%SOW%)$(((M(T) LT ABS(PASTSUM(R,V,P)))+((M(T)-LEAD(T))/PASTSUM(R,V,P) GE 1))$PASTSUM(R,V,P)) = RTFORC(R,V,T,P); -* Force refits = retirements on request - PRC_YMAX(PRC_RCAP(RP)) = MIN(0,SUM(P$PRC_REFIT(RP,P),MAX(EPS,3-ABS(PRC_REFIT(RP,P))))); - RVPRL(R,'0',P) $= PRC_YMAX(R,P); - %VAR%_RCAP.UP(RTP_TT(R,T(TT++1),T,P)%SOW%)$((RP_RTF(R,P)<3)$PRC_YMAX(R,P))=MAX(0,SUM(RTP(R,PYR_S(V),P),RTFORC(R,V,T,P)-RTFORC(R,V,TT,P))$VNT(TT,T)$(MOD(RP_RTF(R,P),2)=0)); +$IF %VARMAC% $SET VAR %VAS% $IF NOT %MIP% OPTION CLEAR=RCAP_BLK; * Set bounds for integer retirements IF(CARD(RCAP_BLK), RCAP_BLK(RTP)$(RCAP_BLK(RTP) LE 0) = 0; @@ -116,7 +118,7 @@ $IF NOT %MIP% OPTION CLEAR=RCAP_BLK; %VAR%_DRCAP.UP(RTP_CPTYR(R,V,T,P)%SOW%,'2')$RCAP_BLK(R,V,P) = MIN(10,FLOOR(%VAR%_SCAP.UP(R,V,T,P%SOW%)/RCAP_BLK(R,V,P)+1E-8)); ); RVPRL(R,PYR_S,P)$PRC_RESID(R,'0',P)=NO; NCAP_OLIFE(R,T,P)$(NOT PRC_VINT(R,P))=NO; - OPTION CLEAR=COEF_CAP,CLEAR=PASTSUM,CLEAR=RVP; + OPTION CLEAR=COEF_CAP; $EXIT *----------------------------------------------------------------------------- $LABEL OBJFIX diff --git a/source/preshape.gms b/source/preshape.gms index 22c30e8..3da2d10 100644 --- a/source/preshape.gms +++ b/source/preshape.gms @@ -13,37 +13,37 @@ * %7 - P/C ******************************************************************************* *$ONLISTING -$EOLCOM ! -$SETLOCAL DEF 10 +$EOLCOM ! +$SETLOCAL TAIL ",%3" SETLOCAL DEF 10 +$IF '%3'=='' $SETLOCAL TAIL $IF NOT '%8'=='' $SETLOCAL DEF %8 OPTION CLEAR = %6; -%6(%2,LL--ORD(LL),%3%4) $= %1(%2,LL,%3); -LOOP(%6(%2,'%DFLBL%',%3%4), - DFUNC=%DEF%; DFUNC $= MOD(ROUND(%1(%2,'%DFLBL%',%3)),1000); - MY_ARRAY(DM_YEAR) = %1(%2,DM_YEAR,%3); +%6(%2,LL--ORD(LL)%TAIL%%4) $= %1(%2,LL%TAIL%); +LOOP(%6(%2,'%DFLBL%'%TAIL%%4), + DFUNC=%DEF%; DFUNC $= MOD(ROUND(%1(%2,'%DFLBL%'%TAIL%)),1000); + MY_ARRAY(DM_YEAR) = %1(%2,DM_YEAR%TAIL%); IF(DFUNC NE 10, F=0; LAST_VAL=0; * do interpolate LOOP(DM_YEAR$MY_ARRAY(DM_YEAR), ! check for nonzero (including EPS) - MY_F = MY_ARRAY(DM_YEAR); Z = YEARVAL(DM_YEAR); - IF(LAST_VAL, %1(%2,%5,%3)$((Z GT YEARVAL(%5))$(YEARVAL(%5) GT MY_FYEAR)) = LAST_VAL; + MY_F = MY_ARRAY(DM_YEAR); Z = YEARVAL(DM_YEAR); + IF(LAST_VAL, %1(%2,%5%TAIL%)$((Z>YEARVAL(%5))$(YEARVAL(%5)>MY_FYEAR)) = LAST_VAL; ELSE F = Z; FIRST_VAL = MY_F); LAST_VAL = ROUND(MY_F); MY_FYEAR=Z;); ! remember the value and year ELSE FIRST_VAL = 0; MY_FYEAR = 0; ! intra-period I/E LOOP(MY_FIL(LL)$MY_ARRAY(MY_FIL), ! check for data values MY_F = MY_ARRAY(LL); Z = YEARVAL(MY_FIL); F = FIL2(MY_FIL); - IF(MY_FYEAR LT F, IF(F GT MIN(FIRST_VAL,Z), LAST_VAL = MY_F; FIRST_VAL = F;); - %1(%2,%5(LL+(F-YEARVAL(LL))),%3)$(NOT MY_ARRAY(%5)) = LAST_VAL); + IF(MY_FYEARMIN(FIRST_VAL,Z), LAST_VAL = MY_F; FIRST_VAL = F;); + %1(%2,%5(LL+(F-YEARVAL(LL)))%TAIL%)$(NOT MY_ARRAY(%5)) = LAST_VAL); LAST_VAL = MY_F; MY_FYEAR=Z;); ! remember the value and year DFUNC=0; ); - IF(ROUND(DFUNC-5,-1) EQ 10, - %1(%2,%5,%3)$%7 $= FIRST_VAL$(YEARVAL(%5) LT F)$(E(%5) GE F) + LAST_VAL$(YEARVAL(%5) GT Z)$(B(%5) LE Z); + IF(ROUND(DFUNC-5,-1)=10, + %1(%2,%5%TAIL%)$%7 $= FIRST_VAL$(YEARVAL(%5)Z)$(B(%5) LE Z); DFUNC=DFUNC-10); IF(DFUNC GE 2, * Do back/forward extrapolate - IF(DFUNC EQ 4, Z = INF; ELSEIF DFUNC EQ 5, F = 0); - %1(%2,%5,%3)$%7 $= FIRST_VAL$(YEARVAL(%5) LT F) + LAST_VAL$(YEARVAL(%5) GT Z); + IF(DFUNC=4, Z = INF; ELSEIF DFUNC=5, F = 0); + %1(%2,%5%TAIL%)$%7 $= FIRST_VAL$(YEARVAL(%5)Z); ); ); $OFFLISTING - diff --git a/source/recurrin.stc b/source/recurrin.stc index ac12963..d7a9307 100644 --- a/source/recurrin.stc +++ b/source/recurrin.stc @@ -16,6 +16,7 @@ $IFI %OBMAC%==YES $SET TST YES $GOTO %1 *----------------------------------------------------------------------------- $LABEL MXPAR +$IF %STAGES%==YES $SETGLOBAL VARMAC '1==1' SETGLOBAL VAS VAS * Do we need MX parameter macroes? $SET NEED NO $IF DEFINED S_NCAP_AFS $SET NEED YES diff --git a/source/rpt_ext.ecb b/source/rpt_ext.ecb index d937117..b4ce936 100644 --- a/source/rpt_ext.ecb +++ b/source/rpt_ext.ecb @@ -11,13 +11,14 @@ $ IF NOT DEFINED RTC_MS $EXIT OBJ_SUMSI(RTP(R,T,P),V)$RVPT(R,V,P,T) = YES; OBJ_SUMSI(RTP(R,T,P),T)$(COEF_CPT(R,T,T,P)>0) = YES; * Existence flags - PAR_TOP(RVP(R,T,P),C,'OUT')$COEF_LMS(R,T,C,P) = SUM((OBJ_SUMSI(RVP,V),PRC_TS(R,P,S)),PAR_FLO(R,V,T,P,C,S)>0); - PAR_TOP(RVP(R,T,P),C,IO)$PAR_TOP(RVP,C,IO) = SUM(OBJ_SUMSI(RVP,V),VAR_NCAP.L(R,V,P)*PRC_CAPACT(R,P)*POWER(COEF_CPT(R,V,T,P),0.5$(DIAG(V,T)-1)))/VAR_XCAP.L(R,T,C)+EPS; + PAR_TOP(RVP(R,T,P),C,'OUT')$COEF_LMS(R,T,C,P) = SUM((OBJ_SUMSI(RVP,V),PRC_TS(R,P,S)),PAR_NCAPL(R,V,P)*PAR_FLO(R,V,T,P,C,S)>0); + PAR_TOP(RVP(R,T,P),C,IO)$PAR_TOP(RVP,C,IO) = SUM(OBJ_SUMSI(RVP,V),PAR_NCAPL(R,V,P)*PRC_CAPACT(R,P)*POWER(COEF_CPT(R,V,T,P),0.5$(DIAG(V,T)-1)))/VAR_XCAP.L(R,T,C)+EPS; * Implied utilization factors PASTSUM(RVP(R,T,P))$PAR_CAPL(RVP) = (PAR_CAPL(RVP)+SUM(PASTCV,PAR_PASTI(R,T,P,PASTCV)))*PRC_CAPACT(R,P)+1-1; PASTSUM(NCAP_YES(RVP(R,V,P))) = (SUM(RTP_CPTYR(R,V,T,P),COEF_PVT(R,T)*SUM(RPCS_VAR(RPC_PG(R,P,C),S),PAR_FLO(R,V,T,P,C,S))) / SUM(RTP_CPTYR(R,V,T,P),COEF_PVT(R,T)*VAR_NCAP.L(RVP)*COEF_CPT(R,V,T,P)*PRC_CAPACT(R,P)))$PRC_VINT(R,P) + (SUM(RTP_CPTYR(R,V,T,P)$PASTSUM(R,T,P),COEF_PVT(R,T)*COEF_CPT(R,V,T,P)/PASTSUM(R,T,P)*SUM(RPCS_VAR(RPC_PG(R,P,C),S),PAR_FLO(R,T,T,P,C,S))) / SUM(RTP_CPTYR(R,V,T,P),COEF_PVT(R,T)*COEF_CPT(R,V,T,P)))$(NOT PRC_VINT(R,P)); + PASTSUM(RVP)$((PASTSUM(RVP)=0)$PASTSUM(RVP)) = 0; * Calculate INV unit cost annuity and intangibles COEF_RTP(RVP(R,T,P)) = SUM(OBJ_ICUR(RVP,CUR),SUM(OBJ_SUMII(RVP,LIFE,K_EOH,JOT),%CAPJD% OBJ_CRF(RVP,CUR) / OBJ_DIVI(RVP) * SUM(INVSPRED(K_EOH,JOT,Y,K),OBJ_ICOST(R,K,P,CUR)))); @@ -41,7 +42,7 @@ $ IF NOT DEFINED RTC_MS $EXIT * Adjust shares, normalize, and get sum over cutoff PRC_YMIN(R,P)$((PRC_YMIN(R,P)>.05)$PRC_YMIN(R,P)) = MAX(PRC_YMIN(R,P),PAR_TOP(R,T,P,C,'OUT')/MY_F*F); F = SUM(P$PRC_YMIN(R,P),PRC_YMIN(R,P)); - PRC_YMIN(R,P)$PRC_YMIN(R,P)=(PRC_YMIN(R,P)/F)$(PRC_YMIN(R,P)/F>.01); + PRC_YMIN(R,P)$PRC_YMIN(R,P)=(PRC_YMIN(R,P)/F)$(PRC_YMIN(R,P)/F>.005); F = SUM(P$PRC_YMIN(R,P),PRC_YMIN(R,P))*.9999; * Get MY_F = Max share, and Z = sum of differences from max MY_F = SMAX(P$PRC_YMIN(R,P),PRC_YMIN(R,P)); Z = SUM(P$PRC_YMIN(R,P),MY_F-PRC_YMIN(R,P)); diff --git a/source/setglobs.gms b/source/setglobs.gms index b909d11..6eb849d 100644 --- a/source/setglobs.gms +++ b/source/setglobs.gms @@ -1,5 +1,5 @@ *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -* Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) +* Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) * This file is part of the IEA-ETSAP TIMES model generator, licensed * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). *========================================================================= @@ -7,6 +7,8 @@ * %1 - optional variable label to jump *========================================================================= $ SETARGS X1 X2 +* --- FIXT Dump --- +$ IF NOT SET FIXBOH $KILL REG_FIXT * --- DATA Dump --- $ IF NOT %DATAGDX%==YES $GOTO SYSD $ IF NOT ERRORFREE $GOTO SYSD @@ -75,7 +77,7 @@ $ LABEL SYSD SET RPC_MARKET(R,P,C,IE) 'Market exchange process indicator' //; SET RPC_PG(R,P,C) 'Commodities in the primary group' //; SET RPC_SPG(R,P,C) 'Commodities in the shadow primary group'//; - SET RPCS_VAR(R,P,C,ALL_TS) 'The timeslices at which VAR_FLOs are to be created'//; + SET RPCS_VAR(R,P,C,ALL_TS) 'Timeslices at which VAR_FLOs are to be created'//; SET RPS_S1(R,P,ALL_TS) 'All timeslices at the PRC_TSL/COM_TSLspg'//; SET RPS_S2(R,P,ALL_TS) 'All timeslices at/above PRC_TSL/COM_TSLspg'//; SET RPS_PRCTS(R,P,ALL_TS) 'All timeslices at/above the PRC_TSL' //; @@ -89,10 +91,11 @@ $ LABEL SYSD SET RTPCS_VARF(ALL_REG,ALLYEAR,P,C,ALL_TS) 'The VAR_FLOs control set' //; SET RTP_VARA(R,ALLYEAR,P) 'The VAR_ACT control set' //; SET RTP_VARP(R,T,P) 'RTPs that have a VAR_CAP' //; - SET RTP_VINTYR(ALL_REG,ALLYEAR,ALLYEAR,PRC) 'v/t years when vintaging involved'//; + SET RTP_VINTYR(REG,ALLYEAR,ALLYEAR,PRC) 'v/t years according to vintaging'//; SET RTP_TT(R,YEAR,T,PRC) 'Retrofit control periods' //; SET RVP(R,ALLYEAR,P) 'ALIAS(RTP) for Process/time' //; SET RTP_CAPYR(R,YEAR,YEAR,P) 'Capacity vintage years' //; + SET RTP_ISHPR(REG,ALLYEAR,PRC)'Attribute existence indicator' //; SET RTP_CGC(REG,YEAR,P,CG,CG) 'Multi-purpose work set' //; SET RTPS_BD(R,ALLYEAR,P,S,BD) 'Multi-purpose work set' //; SET CG_GRP(REG,PRC,CG,CG) 'Multi-purpose work set' //; @@ -115,6 +118,7 @@ $ LABEL SYSD SET UC_GMAP_P(REG,UC_N,UC_GRPTYPE,PRC) 'Assigning processes to UC_GRP'; SET UC_GMAP_U(ALL_R,UC_N,UC_N) 'Assigning constraints to UC_GRP' //; SET UC_DYNBND(UC_N,LIM) 'Dynamic process-wise UC bounds' //; + SET UC_QAFLO(J,UC_N,SIDE,R,P,C) 'QA_checks for UC FLO/IRE tuples' SET RC_CUMCOM(REG,COM_VAR,ALLYEAR,ALLYEAR,COM) 'Cumulative commodity PRD/NET'; SET RPC_CUMFLO(REG,PRC,COM,ALLYEAR,ALLYEAR) 'Cumulative process flows'; @@ -140,6 +144,7 @@ $ LABEL SYSD SET BDLOX(BD) / LO, FX /; SET BDNEQ(BD) / LO, UP /; SET RP_PRC(R,P); + SET RPG_RED(R,P,CG,IO) //; SET RP_GRP(REG,PRC,CG); SET RP_CCG(REG,PRC,C,CG); SET RP_CGG(REG,PRC,C,CG,CG); @@ -339,8 +344,8 @@ $IF NOT "%MX%%SCUM%%SW_STVARS%"=='%X1%%X1%%X1%' $%ControlAbort%: MX / SW_STVARS $SETGLOBAL CAPJD '%X1%' SETGLOBAL CAPWD %X1% $IF NOT '%CAPJD%%CAPWD%'=='%X1%%X1%' $%ControlAbort%: CAPxD * -$SETGLOBAL SWX '%X1%' SETGLOBAL SWTX %X1% -$IF NOT "%SWX%%SWTX%"=='%X1%%X1%' $%ControlAbort%: SWX +$SETGLOBAL SWX '%X1%' SETGLOBAL SWTX '%X1%' SETGLOBAL VARMAC %X1% +$IF NOT "%SWX%%SWTX%%VARMAC%"=='%X1%%X1%%X1%' $%ControlAbort%: SWX $SETGLOBAL SWX ,'1' * $SET TMP '%CTST%' SETGLOBAL CTST %X1% @@ -351,4 +356,5 @@ $SETGLOBAL CTST %TMP% $SETGLOBAL SW_TAGS %X1% $IF NOT "%SW_TAGS%"=='%X1%' $%ControlAbort%: SW_TAGS $IF NOT '%X1%'=='' $SETLOCAL X1 '' GOTO RESET +$SETGLOBAL VARMAC 0==1 *------------------------------------------------------------------------- diff --git a/source/solsetv.v3 b/source/solsetv.v3 index cb7b796..080f146 100644 --- a/source/solsetv.v3 +++ b/source/solsetv.v3 @@ -173,7 +173,17 @@ SETS REG_ACT(NONSET,%PGPRIM%) = YES; OTHCOM(CG) $= SUM(COM_PEAK(R,CG),1); OTHCOM(CUR) $= SUM(RDCUR(R,CUR),1); - +*--------------------------------------------------------------------- +$ IFI NOT %PUNITS%==YES $EXIT + SET PRC_UNITS(R,P,UC_GRPTYPE,UNITS); +* Add default capacity unit and conversion if missing + G_UNCA(UNITS_ACT,UNITS_ACT)$(NOT SUM(UNITS$(G_UNCA(UNITS,UNITS_ACT)=1),1)) = 1; + PRC_UNITS(RP,'ACT',UNITS_ACT)$SUM(PRC_ACTUNT(RP,CG,UNITS_ACT),1) = YES; + LOOP(UNITS_ACT, + PRC_UNITS(PRC_CAP(RP),'CAP',UNITS)$((ABS(G_UNCA(UNITS,UNITS_ACT)-PRC_CAPACT(RP))