├── .zenodo.json ├── AUTHORS.md ├── COPYING.txt ├── Contributing.md ├── NOTICE-GPLv3.txt ├── README.md ├── Version-Old.rar ├── Version.log ├── _times.g00 ├── atlearn.etl ├── atlearn1.etl ├── atlearn8.etl ├── atlearn9.etl ├── atsc.etl ├── bnd_act.mod ├── bnd_cum.mod ├── bnd_elas.mod ├── bnd_flo.mod ├── bnd_ire.vda ├── bnd_macro.tm ├── bnd_set.mod ├── bnd_stg.mod ├── bnd_ucv.mod ├── bnd_ucw.mod ├── bndmain.mod ├── cal_cap.mod ├── cal_caps.mod ├── cal_fflo.mod ├── cal_ire.mod ├── cal_nored.red ├── cal_red.red ├── cal_stgn.mod ├── calibase.mlf ├── clearsol.stc ├── clearsol.stp ├── coef_alt.lin ├── coef_cpt.mod ├── coef_csv.mod ├── coef_ext.abs ├── coef_ext.cli ├── coef_ext.etl ├── coef_ext.vda ├── coef_nio.mod ├── coef_obj.mod ├── coef_ptr.mod ├── coef_shp.mod ├── coefmain.mod ├── cost_ann.rpt ├── curex.gms ├── ddfupd.msa ├── dumpsol.mod ├── dumpsol1.mod ├── dumpsolv.mod ├── dynslite.vda ├── eqactbnd.mod ├── eqactflo.mod ├── eqactups.vda ├── eqashar.vda ├── eqblnd.mod ├── eqbndcom.mod ├── eqbndcst.mod ├── eqcaflac.vda ├── eqcapact.mod ├── eqcapvac.mod ├── eqchpelc.ier ├── eqcombal.mod ├── eqcpt.mod ├── eqcumcom.mod ├── eqcumflo.mod ├── eqdamage.mod ├── eqdeclr.mod ├── eqdeclr.tm ├── eqflobnd.mod ├── eqflofr.mod ├── eqflomrk.mod ├── eqfloshr.mod ├── eqire.mod ├── eqirebnd.mod ├── eqlducs.vda ├── eqmacro.tm ├── eqmain.mod ├── eqmrkcom.ier ├── eqobj.mod ├── eqobj.tm ├── eqobjann.tm ├── eqobjcst.tm ├── eqobjels.mod ├── eqobjels.rpt ├── eqobjfix.mod ├── eqobjfix.rpt ├── eqobjinv.mod ├── eqobjinv.rpt ├── eqobjvar.mod ├── eqobjvar.rpt ├── eqobsalv.mod ├── eqobsalv.rpt ├── eqpeak.mod ├── eqpk_ect.ier ├── eqptrans.mod ├── eqstgaux.lin ├── eqstgaux.mod ├── eqstgflo.mod ├── eqstgips.lin ├── eqstgips.mod ├── eqstgtss.mod ├── equ_ext.abs ├── equ_ext.cli ├── equ_ext.dsc ├── equ_ext.ecb ├── equ_ext.etl ├── equ_ext.ier ├── equ_ext.mlf ├── equ_ext.msa ├── equ_ext.vda ├── equcrtp.vda ├── equcwrap.mod ├── equserco.mod ├── eqxbnd.mod ├── err_stat.mod ├── fillcost.gms ├── fillparm.gms ├── fillsow.stc ├── fillvint.gms ├── fillwave.gms ├── filparam.gms ├── filshape.gms ├── forcupd.cli ├── gasgrids.vda ├── gdxfilter.gms ├── globals.def ├── init_ext.abs ├── init_ext.dsc ├── init_ext.vda ├── initmty.abs ├── initmty.cli ├── initmty.dsc ├── initmty.etl ├── initmty.ier ├── initmty.mlf ├── initmty.mod ├── initmty.msa ├── initmty.stc ├── initmty.tm ├── initmty.vda ├── initsys.mod ├── main_ext.mod ├── maindrv.mod ├── maplists.def ├── mod_equa.mod ├── mod_equa.tm ├── mod_ext.abs ├── mod_ext.cli ├── mod_ext.dsc ├── mod_ext.etl ├── mod_ext.ier ├── mod_ext.vda ├── mod_vars.abs ├── mod_vars.cli ├── mod_vars.dsc ├── mod_vars.etl ├── mod_vars.mod ├── mod_vars.msa ├── mod_vars.tm ├── par_uc.rpt ├── pextlevs.stc ├── powerflo.vda ├── pp_actef.vda ├── pp_chp.ier ├── pp_chp.mod ├── pp_clean.mod ├── pp_lvlbd.mod ├── pp_lvlbr.mod ├── pp_lvlfc.mod ├── pp_lvlff.mod ├── pp_lvlfs.mod ├── pp_lvlif.mod ├── pp_lvlpk.mod ├── pp_lvlus.mod ├── pp_micro.mod ├── pp_off.mod ├── pp_prelv.vda ├── pp_qack.mod ├── pp_qafs.mod ├── pp_qaput.mod ├── pp_reduce.red ├── pp_shapr.mod ├── ppm_ext.dsc ├── ppm_ext.ecb ├── ppm_ext.mlf ├── ppm_ext.vda ├── ppmain.mod ├── ppmain.tm ├── prep_ext.abs ├── prep_ext.dsc ├── prep_ext.ier ├── prep_ext.mlf ├── prep_ext.stc ├── prep_ext.tm ├── prep_ext.vda ├── prepparm.gms ├── preppm.mod ├── preppm.msa ├── prepret.dsc ├── prepxtra.mod ├── preshape.gms ├── presolve.mlf ├── readbprice.mod ├── recurrin.stc ├── resloadc.vda ├── rpt_dam.mod ├── rpt_ext.cli ├── rpt_ext.ecb ├── rpt_ext.ier ├── rpt_ext.mlf ├── rpt_ext.msa ├── rpt_obj.rpt ├── rpt_objc.rpt ├── rpt_par.cli ├── rptlite.rpt ├── rptmain.mod ├── rptmain.rpt ├── rptmain.stc ├── rptmain.tm ├── rptmisc.rpt ├── sensis.stc ├── setglobs.gms ├── sol_flo.red ├── sol_ire.rpt ├── solprep.msa ├── solputta.ans ├── solsetv.v3 ├── solsubta.ans ├── solsysd.v3 ├── solvcoef.msa ├── solve.mod ├── solve.msa ├── solve.stc ├── solve.stp ├── spoint.mod ├── stages.stc ├── times2veda.vdd ├── times2veda_stc.vdd ├── times2veda_v3.vdd ├── timesrng.gms ├── timslice.mod ├── uc_act.mod ├── uc_cap.mod ├── uc_cli.mod ├── uc_com.mod ├── uc_flo.mod ├── uc_ire.mod ├── uc_ncap.mod ├── uc_pasti.mod ├── ucbet.vda ├── units.def ├── writeddf.msa └── wrtbprice.mod /.zenodo.json: -------------------------------------------------------------------------------- 1 | { 2 | "creators": [ 3 | { 4 | "name": "IEA-ETSAP" 5 | } 6 | ], 7 | 8 | "license": "GPL-3.0", 9 | 10 | "title": "TIMES Model Generator", 11 | 12 | "keywords": [ 13 | "TIMES", 14 | "optimisation", 15 | "energy system model", 16 | "bottom-up model", 17 | "open source" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # The Integrated Markal-EFOM System – TIMES 2 | #### The code owner is the IEA Energy Technology Systems Analysis Programme (ETSAP) 3 | # Original Authors of ETSAP TIMES (by contracting party) 4 | * Ken Noble (Australia) 5 | * Denise van Regemorter (Belgium) 6 | * Amit Kanudia (Canada) 7 | * Richard Loulou (Canada) 8 | * Uwe Remme (Germany) 9 | * Peter Schaumann (Germany) 10 | * Günter Schmid (Germany) 11 | * GianCarlo Tosato (Italy) 12 | * Tom Kram (Netherlands) 13 | * Tomas Larsson (Sweden) 14 | * Gary Goldstein (USA) 15 | 16 | # Other contributing authors (incomplete list) 17 | * Martin Baumann (Austria) 18 | * Wouter Nijs (Belgium) 19 | * Kathleen Vaillancourt (Canada) 20 | * Kenneth Karlsson (Denmark) 21 | * Raffaele Salvucci (Denmark) 22 | * Markus Blesl (Germany) 23 | * Justine Broihan (Germany) 24 | * George Giannakidis (Greece) 25 | * Kostas Tigas (Greece) 26 | * James Glynn (Ireland) 27 | * Maurizio Gargiulo (Italy) 28 | * Ad Seebregts (Netherlands) 29 | * Pernille Seljom (Norway) 30 | * Kristina Haaskjold (Norway) 31 | * Evangelos Panos (Switzerland) 32 | * Socrates Kypreos (Switzerland) 33 | * Paul Dodds (United Kingdom) 34 | * Evelyn Wright (USA) 35 | 36 | ### Many thanks to all individuals who have contributed to ETSAP TIMES. 37 | 38 | # Current maintainer 39 | * [@Antti-L](https://github.com/Antti-L) 40 | -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | ## Contributing to TIMES 2 | 3 | Contribution to TIMES is currently done through "Issues" in GitHub which can be used for: 4 | 1) filing bug reports, and 5 | 2) submitting feature and enhancement requests, 6 | 7 | and discussing all the necessary details about them. 8 | 9 | In "Issues", you can insert code snippets, links and attachments that demonstrate the issue or describe the proposed enhancement in detail. When a consensus is reached about an issue, the maintainer of TIMES will proceed by implementing the fix or the new feature, and integrate it in the next release of the ETSAP TIMES code. 10 | 11 | Currently the TIMES code is maintained by @Antti-L. 12 | 13 | This is the current approach of managing contributions to TIMES, without the need for "pull requests" for the Master branch. For eventual bigger projects a different workflow may be useful in separate branches. 14 | 15 | ## Resources: 16 | 17 | - The main ETSAP[website](https://iea-etsap.org/) is a good place to get started with TIMES. 18 | - Extended documentation for TIMES is available on the [website](https://iea-etsap.org/index.php/documentation). 19 | - The [forum](http://iea-etsap.org/forum/index.php) is the main place to ask questions and search for answers from the ETSAP community. 20 | 21 | ## Bugs 22 | 23 | If you find a programming error in TIMES, please submit an Issue in the repository. Follow the [issue template](https://github.com/etsap-TIMES/TIMES_model/issues/new) for submitting a bug. 24 | 25 | ## Errors in the documentation 26 | 27 | The documentation can be found in the [Documentation Repository](https://github.com/etsap-TIMES/TIMES_Documentation). Please report issues with the Documentation [here](https://github.com/etsap-TIMES/TIMES_Documentation/issues/new). 28 | 29 | ## Ideas and Suggestions 30 | 31 | If you have an idea on how TIMES could be improved, or to suggest useful additions, please submit a request using the Github issue [here](https://github.com/etsap-TIMES/TIMES_model/issues/new). 32 | -------------------------------------------------------------------------------- /NOTICE-GPLv3.txt: -------------------------------------------------------------------------------- 1 | *------------------------------------------------------------------------------ 2 | * Copyright (C) 2000-2025 IEA Energy Technology Systems Analysis Programme. 3 | *------------------------------------------------------------------------------ 4 | * This software "The Integrated MARKAL-EFOM System - TIMES" is open source: 5 | * you can redistribute it and/or modify it under the terms of the 6 | * GNU General Public License as published by the Free Software Foundation, 7 | * either version 3 of the License, or (at your option) any later version. 8 | * 9 | * This software is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along 15 | * with this program (see the file COPYING.txt). If not, please visit: 16 | * 17 | *------------------------------------------------------------------------------ 18 | -------------------------------------------------------------------------------- /Version-Old.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etsap-TIMES/TIMES_model/c1bc28d72d5b260e2ef2fd18bf1f0031e0311eea/Version-Old.rar -------------------------------------------------------------------------------- /_times.g00: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etsap-TIMES/TIMES_model/c1bc28d72d5b260e2ef2fd18bf1f0031e0311eea/_times.g00 -------------------------------------------------------------------------------- /atlearn1.etl: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * File : ATLEARN1.ML 7 | * Language : GAMS 8 | * Programmer: Ad Seebregts, adaped by Gary Goldstein for TIMES 9 | * Origin : 02-06-98 10 | * Last edit : 07-27-01 11 | * Warning : 12 | * Purpose : generic content of AT output 13 | * Location : TIMES directory 14 | * Called : at the end of ATLEARN.ETL 15 | * Output : .ETL 16 | *=============================================================================* 17 | * %1 IS VARIABLE TO BE OUTPUTTED 18 | * %2 is name of table 19 | * %3 is prefix of row 20 | * %4 is 1 if CCAPM is to be output 21 | * %5 is number of decimals 22 | 23 | PUT /"%2 %1"/; 24 | PUT @63, LOOP(T,PUT T.TL:10); 25 | IF (%4 GT 0, PUT "CCAPM % reached"; 26 | ); 27 | PUT /; 28 | 29 | LOOP((TEG,REG)$SEG(REG,TEG), 30 | PUT "k",".%3.",TEG.TL:0 '/r.'REG.TL:0, ' '; 31 | PUT @30, PRC.TE(TEG):30 @60; 32 | LOOP(T, 33 | IF (%1.L(REG,T,TEG) GT 0, 34 | PUT %1.L(REG,T,TEG):10:%5; 35 | ELSE PUT " 0"; 36 | ); 37 | IF ((ORD(T) EQ CARD(T)) AND (%4 GT 0), 38 | PUT " ",CCAPM(REG,TEG):10:2; PUT (100 - 100*(CCAPM(REG,TEG)-VAR_CCAP.L(REG,T,TEG))/ 39 | (CCAPM(REG,TEG)-CCAP0(REG,TEG))):10:2; 40 | ); 41 | ); 42 | PUT /; 43 | * print PRC in TEG cluster 44 | IF(%4 EQ 0, 45 | LOOP(PRC$(CLUSTER(REG,TEG,PRC) GT 0), 46 | PUT "c",".%3.",PRC.TL:0; 47 | PUT @30, PRC.TE(PRC):30 @60; 48 | LOOP(T, 49 | IF (%1.L(REG,T,PRC) GT 0, 50 | PUT %1.L(REG,T,PRC):10:%5; 51 | ELSE PUT " 0"; 52 | ); 53 | ); 54 | PUT /; 55 | ); 56 | ); 57 | ); 58 | -------------------------------------------------------------------------------- /atlearn8.etl: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * File : ATLEARN8.ETL 7 | * Language : GAMS 8 | * Programmer: Ad Seebregts, adaped by Gary Goldstein for TIMES 9 | * Origin : 04-02-00 10 | * Last edit : 07-27-01 11 | *=============================================================================* 12 | * loop over TEG, PRC for key and clusters 13 | * INV CAP 14 | * CAM : maximum capacity based on growth factors 15 | * GRP : growth in capacity in one period (CAP(TP)/CAP(TP-1)) 16 | * GRA : average annual growth in NYEARS of period TP 17 | * GRF : growth factor (input): TID and time-dependent 18 | 19 | LOOP((TEG,REG)$SEG(REG,TEG), 20 | * Investment levels 21 | PUT /; 22 | * first output for key, next its cluster PRC's 23 | $BATINCLUDE ATLEARN9.ETL k VAR_NCAP TEG 0 INV 24 | LOOP(PRC$CLUSTER(REG,TEG,PRC), 25 | $BATINCLUDE ATLEARN9.ETL c VAR_NCAP PRC 0 INV 26 | ); 27 | 28 | * Capacity levels and growth factors (input and resulting) 29 | PUT /; 30 | $BATINCLUDE ATLEARN9.ETL k VAR_CAP TEG 0 CAP 31 | $BATINCLUDE ATLEARN9.ETL k VAR_CAP TEG 1 CAM 32 | $BATINCLUDE ATLEARN9.ETL k VAR_CAP TEG 2 GRP 33 | $BATINCLUDE ATLEARN9.ETL k VAR_CAP TEG 3 GRA 34 | $BATINCLUDE ATLEARN9.ETL k VAR_CAP TEG 4 GRF 35 | 36 | LOOP(PRC$CLUSTER(REG,TEG,PRC), 37 | $BATINCLUDE ATLEARN9.ETL c VAR_CAP PRC 0 CAP 38 | $BATINCLUDE ATLEARN9.ETL c VAR_CAP PRC 1 CAM 39 | $BATINCLUDE ATLEARN9.ETL c VAR_CAP PRC 2 GRP 40 | $BATINCLUDE ATLEARN9.ETL c VAR_CAP PRC 3 GRA 41 | $BATINCLUDE ATLEARN9.ETL c VAR_CAP PRC 4 GRF 42 | ); 43 | 44 | ); 45 | -------------------------------------------------------------------------------- /atlearn9.etl: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * File : ATLEARN9.ETL 7 | * Language : GAMS 8 | * Programmer: Ad Seebregts, adaped by Gary Goldstein for TIMES 9 | * Origin : 04-02-00 10 | * Last edit : 07-27-01 11 | *=============================================================================* 12 | * %1 = k or c 13 | * %2 = VAR_NCAP or VAR_CAP 14 | * %3 = TEG or PRC 15 | * %4 = 0 1 2 3 4 16 | * 0 is for variable INV or CAP 17 | * 1 CAM; 2 GRP; 3 GRA; 4 GRF; 18 | * %5 = INV or CAP or CAM or GRP or GRA or GRF; 19 | 20 | 21 | PUT "%1",".%5.",%3.TL:0, '/r.', REG.TL:0, @30; 22 | PUT PRC.TE(%3):30 @74; 23 | LOOP(T, 24 | IF (%4 EQ 0, 25 | PUT %2.L(REG,T,%3):10:2; 26 | ); 27 | 28 | * maximum capacity based on growth factors 29 | * IF (%4 EQ 1, 30 | * 31 | * IF ((PRC_TGR(%3,T) + PRC_GRTI(%3)) GT 0, 32 | * PUT ((PRC_TGR(%3,T)**NYRSPER)*CAP.L(T-1,%3) + 33 | * PRC_GRTI(%3) 34 | * ):10:2; 35 | * ELSE PUT " -"; 36 | * ); 37 | * 38 | * ); 39 | 40 | * period growth factor CAP(T)/CAP(T-1) 41 | IF (%4 EQ 2, 42 | 43 | IF (VAR_CAP.L(REG,T-1,%3) GT 0, 44 | PUT (VAR_CAP.L(REG,T,%3)/(VAR_CAP.L(REG,T-1,%3))):10:2; 45 | ELSE PUT " -"; 46 | ); 47 | ); 48 | 49 | * average annual growth factor in period T compared to T-1 50 | IF (%4 EQ 3, 51 | IF (VAR_CAP.L(REG,T-1,%3) GT 0, 52 | PUT ((VAR_CAP.L(REG,T,%3)/VAR_CAP.L(REG,T-1,%3))**(1/D(T))):10:2; 53 | ELSE PUT " -"; 54 | ); 55 | 56 | ); 57 | * user-provided maximum growth factors: for the first T, the TID 58 | * growth factor is given, if provided 59 | * IF (%4 EQ 4, 60 | * 61 | * IF (ORD(T) EQ 1, 62 | * IF (PRC_GRTI(%3) GT 0, 63 | * PUT TCH_GRTI(%3):10:2; 64 | * ELSE PUT " -"; 65 | * ); 66 | * ELSE 67 | * IF (PRC_TGR(%3,T) GT 0, 68 | * PUT (TCH_TGR(%3,T)):10:2; 69 | * ELSE PUT " -"; 70 | * ); 71 | * ); 72 | * ); 73 | * 74 | * 75 | ); 76 | 77 | PUT /; 78 | 79 | -------------------------------------------------------------------------------- /bnd_act.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * BND_ACT.MOD set the actual bounds for non-vintage VAR_ACTs 7 | *=============================================================================* 8 | *GaG Questions/Comments: 9 | * - FX take precedence as is set last!!! 10 | *----------------------------------------------------------------------------- 11 | *$ONLISTING 12 | * reset any existing bounds 13 | %VAR%_ACT.LO(R,V,T,P,S%SWD%) = 0; 14 | %VAR%_ACT.UP(R,V,T,P,S%SWD%) = INF; 15 | 16 | * assign from user data - only set bounds directly at the PRC_TS level 17 | 18 | $IF %STAGES% == YES $SETLOCAL SWT SW_T(T%SWD%)$ 19 | 20 | %VAR%_ACT.LO(RTP_VINTYR(R,T,T,P),S%SWD%)$(%SWT% PRC_TS(R,P,S) * (NOT PRC_VINT(R,P))) $= ACT_BND(R,T,P,S,'LO'); 21 | %VAR%_ACT.UP(RTP_VINTYR(R,T,T,P),S%SWD%)$(%SWT% PRC_TS(R,P,S) * (NOT PRC_VINT(R,P))) $= ACT_BND(R,T,P,S,'UP'); 22 | %VAR%_ACT.FX(RTP_VINTYR(%R_T%,T,P),S%SWD%)$(%SWT%PRC_TS(R,P,S)* (NOT PRC_VINT(R,P))) $= ACT_BND(R,T,P,S,'FX'); 23 | * for upper bounds of zero, activity variables of all vintages can be bounded to zero 24 | %VAR%_ACT.UP(RTP_VINTYR(R,V,T,P),S%SWD%)$(%SWT% PRC_TS(R,P,S) * PRC_VINT(R,P)$RTPS_OFF(R,T,P,S)) = EPS; 25 | 26 | *$OFFLISTING 27 | -------------------------------------------------------------------------------- /bnd_elas.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * BND_ELAS.MOD establishes bounds on demand elasticity variables 7 | * %1 - LO/UP step limit 8 | *=============================================================================* 9 | * Questions/Comments: 10 | * - RCJ includes testing for COM_STEP 11 | * - May want elasticity without COM_PROJ - may use COM_BQTY 12 | *----------------------------------------------------------------------------- 13 | OPTION CLEAR=MI_DOPE; 14 | LOOP((ANNUAL(S),MI_DMAS(RD_AGG(R,C),COM)), 15 | RD_SHAR(R,T,COM,C)=COM_AGG(R,T,COM,C)*DDF_PREF(R,T,C); 16 | COM_AGG(R,T,COM,C)$(COM_ELAST(R,T,C,S,'N')>0)=0; 17 | COM_ELAST(R,T(MIYR_1),COM,TS,BD)=0; 18 | COM_VOC(RTC(R,T,COM),'LO')$MI_ESUB(R,T,C)=MIN(COM_VOC(RTC,'LO'),1-9E9**(-COM_ELAST(RTC,S,'FX'))); 19 | MI_DOPE(R,T,COM)$MI_ESUB(R,T,C)=MAX(ABS(COM_ELAST(R,T,COM,S,'FX')),MI_ESUB(R,T,C))$SUM(BDNEQ$COM_ELAST(R,T,C,S,BDNEQ),1)); 20 | 21 | $IF %STAGES% == YES LOOP(SW_T(T%SOW%), 22 | 23 | %VAR%_ELAST.UP(RTCS_VARC(R,T,C,S),J,BDNEQ(BD)%SOW%)$RCJ(R,C,J,BD) = INF$MI_DOPE(R,T,C) + 24 | (MAX(DDF_QREF(R,T,C) * COM_FR%MX%(R,T,C,S), COM_BQTY(R,C,S)) * COM_VOC(R,T,C,BD)) / COM_STEP(R,C,BD); 25 | 26 | $IF %STAGES% == YES ); 27 | 28 | * Price levels for CES (marginal / average) 29 | MI_RHO(RTC(R,T,C))$MI_DOPE(RTC) = ROUND(1-1/MI_DOPE(RTC),6); 30 | MI_AGC(R,T(TT+1),COM,C,J,BDNEQ(BD))$(RCJ(R,C,J,BD)$MI_DMAS(R,COM,C)$MI_ESUB(R,T,COM)) = (1-BDSIG(BD)*(ORD(J)-.5)*COM_VOC(R,T,C,BD)/COM_STEP(R,C,BD))**(-1/COM_ELAST(R,T,C,'ANNUAL','FX')); 31 | MI_AGC(R,T,COM,C,J,BD)$((COM_VOC(R,T,C,BD)>0)$MI_AGC(R,T,COM,C,J,BD)$MI_DOPE(R,T,C)) = 32 | BDSIG(BD)/(ORD(J)*COM_VOC(R,T,C,BD)/COM_STEP(R,C,BD)) * 33 | (((1-(1-BDSIG(BD)*ORD(J)*COM_VOC(R,T,C,BD)/COM_STEP(R,C,BD))**MI_RHO(R,T,C))/MI_RHO(R,T,C))$MI_RHO(R,T,C) - 34 | LOG(1-BDSIG(BD)*ORD(J)*COM_VOC(R,T,C,BD)/COM_STEP(R,C,BD))$(MI_RHO(R,T,C)=0)); 35 | 36 | * Fix redundancies 37 | LOOP(RD_AGG(R,COM),FIL(T)=NOT PROD(BDNEQ,SUM(COM_TS(R,C,S)$MI_DMAS(R,COM,C),COM_ELAST(R,T,C,S,BDNEQ))); 38 | COM_ELAST(RTCS_VARC(R,T(FIL),C,S),BD)$MI_DMAS(R,COM,C)=0; RCS_COMPRD(R,T(FIL),COM,S,BD)=NO); 39 | COM_ELASTX(R,T,C,BDNEQ)$MI_DOPE(R,T,C)=1; 40 | RTC_SHED(R,T,C,BD,JJ)$MI_DOPE(R,T,C)=NO; 41 | -------------------------------------------------------------------------------- /bnd_flo.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * BND_FLO.MOD set the actual bounds for non-vintage VAR_FLOs * 7 | *=============================================================================* 8 | *UR Questions/Comments: 9 | *----------------------------------------------------------------------------- 10 | *$ONLISTING 11 | * reset any existing bounds 12 | %VAR%_FLO.LO(R,V,T,P,C,S%SWD%) = 0; 13 | %VAR%_FLO.UP(R,V,T,P,C,S%SWD%) = INF; 14 | 15 | * assign from user data 16 | FLO_BND(R,T,P,C,S,'LO')$((NOT RPC_EMIS(R,P,C))$(FLO_BND(R,T,P,C,S,'LO')=0)$RP_FLO(R,P))=0; 17 | LOOP((RTPC(R,T,P,C),S,BD)$FLO_BND(RTPC,S,BD),TRACKPC(RP_FLO(R,P),C)=YES); 18 | TRACKPC(PRC_VINT(R,P),C) = NO; 19 | TRACKPC(RPC_FFUNC(R,P,C))= NO; 20 | TRACKPC(RPC_EMIS(R,P,C)) = NO; 21 | * Mark all tuples that definitely cannot be handled by VAR bounds 22 | LOOP(T,FLO_BND(R,'%DFLBL%',P,C,S,BD)$FLO_BND(R,T,P,C,S,BD) = EPS$(NOT TRACKPC(R,P,C)); 23 | FLO_BND(R,'%DFLBL%',P,CG,S,BD)$((NOT C(CG))$FLO_BND(R,T,P,CG,S,BD)) = EPS); 24 | TRACKPC(RPC_ACT(R,P,C)) = NO; 25 | 26 | $IF %STAGES% == YES LOOP(SW_T(T%SWD%), 27 | %VAR%_FLO.LO(RTP_VINTYR(R,T,T,P),C,S%SWD%)$((RTPCS_VARF(R,T,P,C,S)*TRACKPC(R,P,C))$FLO_BND(R,T,P,C,S,'LO')) = FLO_BND(R,T,P,C,S,'LO'); 28 | %VAR%_FLO.UP(RTP_VINTYR(R,T,T,P),C,S%SWD%)$((RTPCS_VARF(R,T,P,C,S)*TRACKPC(R,P,C))$FLO_BND(R,T,P,C,S,'UP')) = FLO_BND(R,T,P,C,S,'UP'); 29 | %VAR%_FLO.FX(RTP_VINTYR(R,T,T,P),C,S%SWD%)$((RTPCS_VARF(R,T,P,C,S)*TRACKPC(R,P,C))$FLO_BND(R,T,P,C,S,'FX')) = FLO_BND(R,T,P,C,S,'FX'); 30 | $IF %STAGES% == YES ); 31 | OPTION CLEAR=TRACKPC; 32 | 33 | *$OFFLISTING 34 | $IF NOT '%REDUCE%' == 'YES' $EXIT 35 | $IF %STAGES% == YES $SETLOCAL SWT "%SWD%)$SW_T(T%SWD%" 36 | * As BND_ACT has been set before this, MAX/MIN can be used; FX bound consistency cannot be guaranteed 37 | LOOP(RTPCS_VARF(R,T,P,C,S)$(((NOT PRC_VINT(R,P))*RPC_ACT(R,P,C))$FLO_BND(R,T,P,C,S,'LO')),%VAR%_ACT.LO(R,T,T,P,S%SWT%) = MAX(%VAR%_ACT.LO(R,T,T,P,S%SWT%),FLO_BND(R,T,P,C,S,'LO')/PRC_ACTFLO(R,T,P,C))); 38 | LOOP(RTPCS_VARF(R,T,P,C,S)$(((NOT PRC_VINT(R,P))*RPC_ACT(R,P,C))$FLO_BND(R,T,P,C,S,'UP')),%VAR%_ACT.UP(R,T,T,P,S%SWT%) = MIN(%VAR%_ACT.UP(R,T,T,P,S%SWT%),FLO_BND(R,T,P,C,S,'UP')/PRC_ACTFLO(R,T,P,C))); 39 | LOOP(RTPCS_VARF(R,T,P,C,S)$(((NOT PRC_VINT(R,P))*RPC_ACT(R,P,C))$FLO_BND(R,T,P,C,S,'FX')),%VAR%_ACT.FX(R,T,T,P,S%SWT%) = FLO_BND(R,T,P,C,S,'FX')/PRC_ACTFLO(R,T,P,C)); 40 | 41 | -------------------------------------------------------------------------------- /bnd_ire.vda: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * BND_IRE.VDA bounds IRE flows and set prices from previous run if requested 7 | *=============================================================================* 8 | $IF NOT DEFINED PREMILE $EXIT 9 | RPC_IREIN(RPC_IREIO) = NO; 10 | PAR_IRE(R,V,T,P,C,TS,IE)$(NOT RPC_IREIN(R,P,C,IE,'IN')) = 0; 11 | PAR_IPRIC(R,T,P,C,TS,IE)$(NOT RPC_IREIN(R,P,C,IE,'IN')) = 0; 12 | PARAMETER FLO_IRE(R,LL,P,C,S,IE); 13 | IF(CARD(PAR_IRE), 14 | %VAR%_IRE.FX(RTP_VINTYR(R,V,PREMILE(T),P),C,TS,IE%SWD%)$(((NOT RPC_AIRE(R,P,C))*RPCS_VAR(R,P,C,TS))$RPC_IREIN(R,P,C,IE,'IN')) = 15 | EPS+PAR_IRE(R,V,T,P,C,TS,IE); 16 | LOOP(IE,FLO_BND(R,PREMILE(T),P,C,TS,'FX')$((RPC_AIRE(R,P,C)*RTPCS_VARF(R,T,P,C,TS))$RPC_IREIN(R,P,C,IE,'IN')) = 17 | EPS+SUM(RTP_VINTYR(R,V,T,P),PAR_IRE(R,V,T,P,C,TS,IE))); 18 | ); 19 | * Set target milestone years into FIL 20 | OPTION CLEAR=FIL; LOOP(T$(NOT PREMILE(T)),FIL(TT)$YK(TT,T) = YES); 21 | * Calculate total flows at milestone years 22 | FLO_IRE(R,PREMILE,P,C,TS,IE)$(RPCS_VAR(R,P,C,TS)$RPC_IREIN(R,P,C,IE,'IN')) = 23 | SUM(YK(PREMILE,LL)$PAR_IRE(R,LL,PREMILE,P,C,TS,IE),PAR_IRE(R,LL,PREMILE,P,C,TS,IE))+EPS; 24 | DM_YEAR(PREMILE) = YES; 25 | $BATINCLUDE fillcost FLO_IRE R 'P,C,TS,IE' ",'0'" FIL CARD(FIL) '' '' FLO_IRE X_IREFLO 26 | $BATINCLUDE fillcost PAR_IPRIC R 'P,C,TS,IE' ",'0'" FIL CARD(FIL) '' '' PAR_IPRIC X_IREFLO 27 | * Set bounds for T not in sync with PREMILE 28 | LOOP(IE$CARD(FIL),TRACKPC(R,P,C)$((RPC_AIRE(R,P,C)+PRC_VINT(R,P))$RPC_IREIN(R,P,C,IE,'IN')) = YES); 29 | %VAR%_IRE.FX(RTP_VINTYR(R,FIL(T),T,P),C,TS,IE%SWD%)$(((NOT TRACKPC(R,P,C))*RPCS_VAR(R,P,C,TS))$RPC_IREIN(R,P,C,IE,'IN')) = 30 | EPS+FLO_IRE(R,T,P,C,TS,IE); 31 | * Remove TRACKPC with either IMP or EXP internal, as FLO_BND will be applied to the SUM 32 | LOOP(IE,TRACKPC(R,P,C)$((NOT RPC_IREIN(R,P,C,IE,'IN'))$RPC_IRE(R,P,C,IE)) = NO); 33 | FLO_BND(R,FIL(T),P,C,TS,'FX')$((RPC_AIRE(R,P,C)*RTPCS_VARF(R,T,P,C,TS))$TRACKPC(R,P,C)) = 34 | EPS+SUM(RPC_IREIN(R,P,C,IE,'IN'),FLO_IRE(R,T,P,C,TS,IE)); 35 | OPTION CLEAR=TRACKPC,CLEAR=FLO_IRE; 36 | * Set the IRE prices 37 | LOOP(T$CARD(PAR_IPRIC), 38 | OBJ_IPRIC(R,Y_EOH,P,C,TS,IE,CUR)$(PERIODYR(T,Y_EOH)$RPCS_VAR(R,P,C,TS)$RPC_IREIN(R,P,C,IE,'IN')) = 39 | PAR_IPRIC(R,T,P,C,TS,IE)); 40 | -------------------------------------------------------------------------------- /bnd_macro.tm: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *============================================================================* 6 | * Set the Cut-off Point for Applying the Market Penetration Cost Penalty * 7 | *============================================================================* 8 | TM_CAPTB(R,P) = SUM(RTP(R,T,P),TM_EXPBND(RTP)); 9 | * set the bounds for the step variables for quad approx, * clearing them first 10 | VAR_XCAPP.UP(RTP,J) = INF; 11 | VAR_XCAPP.UP(RTP(R,T,P),XCP(J))$((ORD(J)<7)$TM_CAPTB(R,P)) = TM_CAPTB(R,P); 12 | 13 | *============================================================================* 14 | * Set the Lower Bound and Fix the First Year * 15 | * - Demands * 16 | * - Investment * 17 | * - Capital * 18 | * - Marginal Costs of Demands * 19 | *============================================================================* 20 | * user scalar (from CONSTANT table) to control lower bound on demands 21 | VAR_D.LO(RTC(R,T,C))$DEM(R,C) = TM_DMTOL(R) * TM_D0(R,C); 22 | VAR_D.FX(RTC(R,T,C))$(DEM(R,C)*(ORD(T) EQ 1)) = TM_D0(R,C); 23 | VAR_D.FX(RTC(R,T,C))$((COM_PROJ(R,T,C) EQ 0)$DEM(R,C)) = 0; 24 | VAR_DEM.FX(RTC(R,T,C))$((TM_DDATPREF(R,C)=0)$DEM(R,C)) = COM_PROJ(R,T,C); 25 | 26 | VAR_INV.L(R,T) = TM_IV0(R) * TM_L(R,T); 27 | VAR_INV.FX(R,T(T_1)) = TM_IV0(R); 28 | 29 | VAR_K.L(R,T) = TM_K0(R) * TM_L(R,T); 30 | * user scalar (from CONSTANT table) to control investment tolerance 31 | VAR_K.LO(R,T) = TM_K0(R) * (TM_L(R,T) ** (TM_IVETOL(R)$(NOT TM_SL))); 32 | VAR_K.FX(R,T(T_1)) = TM_K0(R); 33 | 34 | VAR_SP.FX(RTC(R,T,C))$DEM(R,C) = 0; 35 | 36 | *SK* V0.4 set MM_C for base year 37 | * VAR_C.FX(R,T(MIYR_1)) = TM_C0(R); 38 | VAR_C.LO(R,TT) = TM_C0(R)*.5; 39 | -------------------------------------------------------------------------------- /bnd_set.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * BND_SET.MOD set the actual bounds on variables 7 | * %1 - variable reference 8 | * %2 - primary index into variable 9 | * %3 - qualifier/bound expression 10 | * %4 - control index 11 | * %5 - stochastic qualifier 12 | *=============================================================================* 13 | *GaG Questions/Comments: 14 | * - FX take precedence as is set last!!! 15 | * - take primary index loop control criteria too, or reset all in case change 16 | * in data (e.g., process moves from 1 region to another?) LATTER!!! 17 | *----------------------------------------------------------------------------- 18 | *$ONLISTING 19 | * reset any existing bounds 20 | %1.LO(%2%SWD%) = 0; 21 | %1.UP(%2%SWD%) = INF; 22 | * assign from user data 23 | %1.LO(%4%SOW%)%5 $= %3(%2,'LO'); 24 | %1.UP(%4%SOW%)%5 $= %3(%2,'UP'); 25 | %1.FX(%4%SOW%)%5 $= %3(%2,'FX'); 26 | 27 | *----------------------------------------------------------------------------- 28 | * Stochastic bounds 29 | $IF%6 NOT %STAGES%==YES $EXIT 30 | $IF NOT DECLARED S_%3 $EXIT 31 | %1.LO(%4%SOW%)%5 $= S_%3(%2,'LO','1',SOW); 32 | %1.UP(%4%SOW%)%5 $= S_%3(%2,'UP','1',SOW); 33 | %1.FX(%4%SOW%)%5 $= S_%3(%2,'FX','1',SOW); 34 | *$OFFLISTING 35 | -------------------------------------------------------------------------------- /bnd_stg.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * BND_STG.MOD set the actual bounds for non-vintage VAR_SIN/OUT 7 | * %1 - which variable 8 | * %2 - which bound 9 | *=============================================================================* 10 | * reset any existing bounds 11 | 12 | %VAR%_%1.LO(R,V,T,P,C,S%SWD%)$PRC_MAP(R,'STG',P) = 0; 13 | %VAR%_%1.UP(R,V,T,P,C,S%SWD%)$PRC_MAP(R,'STG',P) = INF; 14 | %VAR%_%1.LO(RTP_VINTYR(R,V,T,P),%PGPRIM%,S%SWD%)$((RPS_STG(R,P,S)->0)$RP_STS(R,P)) = %3; 15 | 16 | * set bounds at process activity level 17 | TRACKP(RP(R,P))$((NOT PRC_VINT(R,P))$PRC_MAP(R,'STG',P)) = YES; 18 | STG%2_BND(R,T,P,C,S,BD)$((NOT TOP(R,P,C,'%2'))$RP_STG(R,P)) = 0; 19 | 20 | $IF %STAGES% == YES LOOP(SW_T(T%SWD%), 21 | 22 | %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'); 23 | %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'); 24 | %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'); 25 | 26 | $IF %STAGES% == YES ); 27 | OPTION CLEAR=TRACKP; -------------------------------------------------------------------------------- /bnd_ucw.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * BND_UCW.MOD Wrapper for setting bounds on UC RHS variables * 7 | *=============================================================================* 8 | * %1 - Stochastic dollar control or '' 9 | * %2 - I or '' 10 | *------------------------------------------------------------------------------ 11 | $ SET TMP 12 | $ IF %STAGES%==YES $SET TMP (T-SUC_L(R,UC_N)) 13 | CNT=0; 14 | UC_T_EACH(UC_T_SUCC) = YES; 15 | $ BATINCLUDE bnd_ucv.mod %VAR%_UC "" "" "" UC_RHS $UC_ON(R,UC_N) LOOP(R, ); '' '%2' ",'','',''" 16 | $ BATINCLUDE bnd_ucv.mod %VAR%_UCR "," "R" "" UC_RHSR $UC_ON(R,UC_N) '' '' '' '%2' ",'',''" $UC_R_EACH(R,UC_N) 17 | $ BATINCLUDE bnd_ucv.mod %VAR%_UCT "" "" ",TT" UC_RHST $(UC_ON(R,UC_N)*UC_T_EACH(R,UC_N,TT)%1) LOOP(R, ); '' '%2' ",'',''" '' %TMP% 18 | $ BATINCLUDE bnd_ucv.mod %VAR%_UCRT "," "R" ",TT" UC_RHSRT $(UC_ON(R,UC_N)*UC_T_EACH(R,UC_N,TT)%1) '' '' '' '%2' ",''" $UC_T_EACH(R,UC_N,TT) %TMP% 19 | $ BATINCLUDE bnd_ucv.mod %VAR%_UCTS "" "" ",TT" UC_RHSTS $(UC_ON(R,UC_N)*UC_T_EACH(R,UC_N,TT)%1) LOOP(R, ); ,S '%2' ",''" '' %TMP% 20 | $ BATINCLUDE bnd_ucv.mod %VAR%_UCRTS "," "R" ",TT" UC_RHSRTS $(UC_ON(R,UC_N)*UC_T_EACH(R,UC_N,TT)%1) '' '' ,S '%2' "" $UC_T_EACH(R,UC_N,TT) %TMP% 21 | UC_T_EACH(UC_T_SUCC) = NO; 22 | *------------------------------------------------------------------------------- 23 | $IFI %STAGES%==YES IF(SW_PHASE EQ -9, 24 | $IF %STAGES%==YES CNT$((SW_PARM GT 0)$CNT) = EPS; 25 | $IFI %STAGES%==YES SW_PHASE=-1; SW_PARM = (-2+4$(CNT GT 0))$CNT;); 26 | -------------------------------------------------------------------------------- /cal_cap.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * CAL_CAP the code for capacity dependent commodity flows in EQ_COMxxx 7 | * %1 - IN/OUT indicator 8 | * %2 - I/O indicator 9 | * %3 - cost expression for EQOBJVAR 10 | *=============================================================================* 11 | *GaG Questions/Comments: 12 | * - COEF_CPT derived in COEF_CPT.MOD 13 | *----------------------------------------------------------------------------- 14 | *$ONLISTING 15 | SUM(RTP_CPTYR(R,V,T,P)$NCAP_COM(R,V,P,C,'%1'), 16 | *V05b 980902 - need to apply seasonal fraction 17 | COEF_CPT(R,V,T,P) * NCAP_COM(R,V,P,C,'%1') * G_YRFR(R,S) * 18 | %3 19 | (%VARV%_NCAP%4(R,V,P %SWS%)$T(V) + NCAP_PASTI(R,V,P)$PASTYEAR(V) %RCAPSUB%) * 20 | * Adjust for lagged commodity flows 21 | (1 + COEF_CIO(R,V,T,P,C,'%1')) 22 | ) + 23 | * CAL_NCOM: the term associated with invest/decommission commodities in the EQ_COMxxx 24 | SUM(RPC_CAPFLO(R,V,P,C)$COEF_%2COM(R,V,T,P,C), COEF_%2COM(R,V,T,P,C) * 25 | %3 26 | G_YRFR(R,S) * (%VARV%_NCAP%4(R,V,P %SWS%)$T(V)+NCAP_PASTI(R,V,P)$PASTYEAR(V)) 27 | ) 28 | *$OFFLISTING -------------------------------------------------------------------------------- /cal_caps.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * CAL_CAPS the code for capacity dependent commodity flows regardless of IO 7 | * %1 - Milestone year 8 | * %2 - coefficient expression for EQOBJVAR / UC_FLO 9 | * %3 - TS control index for RPCS_VAR summing 10 | *=============================================================================* 11 | * Questions/Comments: 12 | * - COEF_CPT derived in COEF_CPT.MOD 13 | *----------------------------------------------------------------------------- 14 | *$ONLISTING 15 | *V05c 980923 - use the capacity flow control set 16 | SUM((VNT(V,%1),RPC_CAPFLO(R,V,P,C)), 17 | *V05b 980902 - need to apply seasonal fraction 18 | * Flows related to investment / decommissioning 19 | ((COEF_ICOM(R,V,%1,P,C)+COEF_OCOM(R,V,%1,P,C)) * G_YRFR(R,S) * 20 | (%VARV%_NCAP%4(R,V,P %SWS%)$MILESTONYR(V) + NCAP_PASTI(R,V,P)) * 21 | SUM(RPCS_VAR(R,P,C,%3), RS_FR(R,TS,S) * %2))$(COEF_ICOM(R,V,%1,P,C)+COEF_OCOM(R,V,%1,P,C)) + 22 | * Flows related to existing capacity over lifetime 23 | SUM((RTP_CPTYR(R,V,%1,P),IO)$NCAP_COM(R,V,P,C,IO), 24 | COEF_CPT(R,V,%1,P) * NCAP_COM(R,V,P,C,IO) * G_YRFR(R,S) * 25 | (%VARV%_NCAP%4(R,V,P %SWS%)$T(V) + NCAP_PASTI(R,V,P) 26 | $IF DEFINED VNRET -SUM(VNRET(V,MODLYEAR(%1)),%VARM%_SCAP%4(R,V,%1,P%SWS%))$PRC_RCAP(R,P) 27 | ) * SUM(RPCS_VAR(R,P,C,%3), RS_FR(R,TS,S) * %2) * (1+COEF_CIO(R,V,%1,P,C,IO))) 28 | ) 29 | *$OFFLISTING 30 | -------------------------------------------------------------------------------- /cal_fflo.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * CAL_FFLO the code associated with the flow variable in the EQ_COMxxx 7 | * %1 - 'IN/OUT' for consumption/production 8 | ** %2 - 'I/O' for invest/decommission checks (no longer used) 9 | * %3 - * Peak multiplier 10 | * %4 - Peak by flow contribution 11 | *=============================================================================* 12 | *GaG Questions/Comments: 13 | * - VAR_FLOs according to whether c-in-PCG otherwise RPS_S1 14 | *----------------------------------------------------------------------------- 15 | $IF %REDUCE% == YES $GOTO REDUCE 16 | $SET SHP1 "" SET SHG ",P,CG3,C" 17 | $IF DEFINED RTP_FFCS $SET SHP1 "*(%SHFF%S(R,V%SHG%%SOW%))" 18 | $SET SHP1 "*(%SHFF%X(R,V,T%SHG%)$PRC_VINT(R,P))%SHP1%" 19 | *----------------------------------------------------------------------------- 20 | *V05c 980923 - check that commodity not just capacity related 21 | SUM(TOP(RP_FLO(R,P),C,'%1')$(NOT RPC_EMIS(R,P,C)), 22 | SUM((RTP_VNTBYR(R,T,P,V),RTPCS_VARF(R,T,P,C,TS)), 23 | * equation coarser than variable or equation finer than variable 24 | * consider COM_TS shape too, so both TS_MAP and RS_BELOW embedded 25 | %VAR%_FLO(R,V,T,P,C,TS %SOW%) * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)) %3)%4 26 | ) + 27 | * Handle RPC_EMIS flows separately; They cannot be NOFLO 28 | SUM(TOP(RPC_EMIS(RP_FLO(R,P),C),'%1')%4, 29 | SUM((FS_EMIT(R,P,C,CG3,COM2),RTPCS_VARF(R,T,P,COM2,TS))$RS_FR(R,S,TS), 30 | SUM(RTP_VNTBYR(R,T,P,V),%VAR%_FLO(R,V,T,P,COM2,TS %SOW%) * 31 | COEF_PTRAN(R,V,P,CG3,COM2,C,TS) %SHP1% %3) * 32 | RS_FR(R,S,TS)*(1+RTCS_FR(R,T,COM2,S,TS)))) + 33 | $EXIT 34 | *----------------------------------------------------------------------------- 35 | $LABEL REDUCE 36 | * [UR] model reduction %REDUCE% is set in *.run 37 | * Sum over non-vintaged processes 38 | SUM(TOP(RP_FLO(R,P),C,'%1')$(NOT PRC_VINT(R,P)), 39 | SUM(RTPCS_VARF(R,V(T),P,C,TS), 40 | $ BATINCLUDE cal_red.red C COM TS P T '' T 41 | * equation coarser than variable or equation finer than variable 42 | * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)) %3)%4 43 | ) + 44 | 45 | * Sum over vintaged processes 46 | SUM((TOP(PRC_VINT(RP_FLO(R,P)),C,'%1'),RTPCS_VARF(R,T,P,C,TS))%4, 47 | $ BATINCLUDE cal_red.red C COM TS P T '' V SUM 'RTP_VNTBYR(R,T,P,V),' %3 48 | * equation coarser than variable or equation finer than variable 49 | * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)) 50 | ) + 51 | -------------------------------------------------------------------------------- /cal_ire.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * CAL_IRE the code associated with the inter-region trade variable in EQ_COMxxx 7 | * %1 - IMPort/EXPort indicator 8 | * %2 - IN/OUT nature of the aux/emissions 9 | * %3 - IE or '' 10 | * %4 - * Peak multiplier 11 | *=============================================================================* 12 | *GaG Questions/Comments: 13 | *----------------------------------------------------------------------------- 14 | *$ONLISTING 15 | 16 | $IF DEFINED RTP_FFCS $SET MX "(%SHFF%S(R,V,P,C,C%SOW%))*" 17 | *V0.9 022100 - handle the fact that called 2x for aux 18 | $SET IE '%3' 19 | $IF '%IE%'=='' $SET IE "'%1'" 20 | $IF '%1%2' == 'EXPOUT' $GOTO AUXONLY 21 | $IF '%1%2' == 'IMPIN' $GOTO AUXONLY 22 | * actual exchange 23 | *V05c 981016 - change RTPCS_VARFs to ts 24 | SUM((RPC_IRE(%6R,P%7,C,'%1'),RTP_VNTBYR(R,T,P,V)), 25 | SUM(RTPCS_VARF(R,T,P,C,TS)$RS_FR(R,S,TS), 26 | (%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) 27 | )%4 * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS))) 28 | ) + 29 | 30 | $IF SET IREAUXBAL %IREAUXBAL% %2 %5 31 | $LABEL AUXONLY 32 | *V0.5b handle auxiliary commodity flows too 33 | *** NOTE: assumes that attribute at the same level as the variable!! 34 | *V0.9 022100 - do IN/OUT explicitly 35 | 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)), 36 | IRE_FLOSUM(R,T,P,COM,TS,%IE%,C,'%2') * 37 | SUM(RTP_VNTBYR(R,T,P,V), %MX% 38 | (%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) 39 | )%4 40 | ) * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,COM,S,TS)) 41 | ) + 42 | *$OFFLISTING 43 | -------------------------------------------------------------------------------- /cal_nored.red: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================================* 6 | * CAL_RED the code associated with the substitution of flow variables by activity variables 7 | * %1 - commodity of flow 8 | * %2 - commodity associated with the activity variable 9 | * %3 - timeslice index of flow variable 10 | * %4 - process index of flow variable 11 | * %5 - period index of flow variable 12 | * %6 - for output routine '.L' suffix. otherwise nothing 13 | * %7 - optional T or V or '' (for non-vintaged / vintaged / general case) 14 | *=============================================================================================* 15 | $SETLOCAL SHP3 "" SET VNT '%5' SET SHG ",%4,CG3,%1" SET TST '$PRC_VINT(R,%4)' 16 | $IF '%7' == V $SET TST '' 17 | $IF NOT '%7' == T $SET VNT V 18 | $IF DEFINED RTP_FFCS $SET SHP3 "*(%SHFF%S(R,%VNT%%SHG%%SOW%))" 19 | $IF %VNT% == V $SET SHP3 "*(%SHFF%X(R,V,%5%SHG%)%TST%)%SHP3%" 20 | *============================================================================================== 21 | %8(%9 22 | * flow variable cannot be replaced 23 | %VAR%_FLO%6(R,%VNT%,%5,%4,%1,%3 %SOW%)$(NOT RPC_EMIS(R,%4,%1)) 24 | + 25 | * emission flow = flow variable * emission factor 26 | SUM((FS_EMIT(R,%4,%1,CG3,COM2),ALL_TS)$(RS_FR(R,%3,ALL_TS)*RTPCS_VARF(R,%5,%4,COM2,ALL_TS)), 27 | %VAR%_FLO%6(R,%VNT%,%5,%4,COM2,ALL_TS%SOW%) * COEF_PTRAN(R,%VNT%,%4,CG3,COM2,%1,ALL_TS)%SHP3% * 28 | RS_FR(R,%3,ALL_TS)*(1+RTCS_FR(R,%5,COM2,%3,ALL_TS)) 29 | )$RPC_EMIS(R,%4,%1) 30 | ) 31 | -------------------------------------------------------------------------------- /cal_stgn.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * CAL_STG the code associated with the storage flows in the EQ_COMxxx 7 | * %1 - 'IN/OUT' for consumption/production 8 | * %2 - 'OUT/IN' for consumption/production 9 | * %3 - STG_EFF for output 10 | * %4 - STG_EFF for output 11 | * %5 - for day-night storage indicator 12 | *=============================================================================* 13 | * Questions/Comments: 14 | * %6 - NCAP_PKCNT multiplier 15 | *----------------------------------------------------------------------------- 16 | *V05c 980923 - check that commodity not just capacity related 17 | SUM((TOP(RPC_STG(R,P,C),'%1'),RPCS_VAR(R,P,C,TS))$%5, 18 | SUM(RTP_VNTBYR(R,T,P,V), 19 | (%VAR%_S%1(R,V,T,P,C,TS %SOW%)%3-%4%VAR%_S%2(R,V,T,P,C,TS %SOW%)$RPC_STGN(R,P,C,'%2'))%6)$(NOT RPC_STGN(R,P,C,'%1')) * 20 | * equation coarser than variable or finer than variable 21 | RS_FR(R,S,TS) 22 | ) + 23 | 24 | -------------------------------------------------------------------------------- /clearsol.stc: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * CLEARSOL.stc: Clear solution values 7 | *=============================================================================* 8 | $ IF '%1'=='' $GOTO EXECUTE 9 | $ %SW_NOTAGS% 10 | $ BATINCLUDE mod_vars.mod 11 | $ BATINCLUDE eqdeclr.mod 12 | $ CLEAR VAR_CUMFLO VAR_CUMCOM VAR_CUMCST VAR_ACT VAR_FLO VAR_IRE VAR_SIN VAR_SOUT VAR_COMNET VAR_COMPRD VAR_ELAST VAR_SCAP VAR_UPS VAR_UPT VAR_UDP VAR_UC 13 | $ IFI %1==DEF $EXIT 14 | $ LABEL EXECUTE 15 | * Variables 16 | IF(YES,DISPLAY 'Solution store cleared'; 17 | OPTION CLEAR=VAR_ACT; 18 | OPTION CLEAR=VAR_BLND; 19 | OPTION CLEAR=VAR_COMNET; 20 | OPTION CLEAR=VAR_COMPRD; 21 | OPTION CLEAR=VAR_IRE; 22 | OPTION CLEAR=VAR_ELAST; 23 | OPTION CLEAR=VAR_FLO; 24 | OPTION CLEAR=VAR_SIN,CLEAR=VAR_SOUT; 25 | OPTION CLEAR=VAR_CAP,CLEAR=VAR_NCAP; 26 | OPTION CLEAR=VAR_UC,CLEAR=VAR_UCR; 27 | OPTION CLEAR=VAR_UCT,CLEAR=VAR_UCRT; 28 | OPTION CLEAR=VAR_UCTS,CLEAR=VAR_UCRTS; 29 | OPTION CLEAR=VAR_UPS,CLEAR=VAR_UPT,CLEAR=VAR_UDP; 30 | OPTION CLEAR=VAR_OBJ,CLEAR=VAR_OBJELS; 31 | * Delicate bounds 32 | VAR_CUMCOM.L(R,C,COM_VAR,ALLYEAR,YEAR)=0; 33 | VAR_CUMFLO.L(R,P,C,ALLYEAR,YEAR)=0; 34 | $IF DEFINED %VAR%_DAM VAR_DAM.L(R,T,C,BD,J)=0; 35 | $IF DEFINED %VAR%_SCAP VAR_SCAP.L(R,YEAR,T,P)=0; 36 | * Equations 37 | OPTION CLEAR=EQE_COMBAL,CLEAR=EQG_COMBAL,CLEAR=EQE_COMPRD; 38 | OPTION CLEAR=EQ_PEAK,CLEAR=EQ_IRE,CLEAR=EQE_CPT; 39 | OPTION CLEAR=EQE_FLOMRK,CLEAR=EQG_FLOMRK,CLEAR=EQL_FLOMRK; 40 | OPTION CLEAR=EQE_ACTBND,CLEAR=EQG_ACTBND,CLEAR=EQL_ACTBND; 41 | ); -------------------------------------------------------------------------------- /clearsol.stp: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2025 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * CLEARSOL.stp: Clear solution values for projection years 7 | *=============================================================================* 8 | IF(1%1, 9 | RVT(R,VNT(V,T))$RT_PP(R,T) = YES; 10 | FIL(LL)=T(LL); LOOP(R, FIL(T)$NO_RT(R,T) = NO); 11 | %VAR%_ACT.L(RVT,P,S%SOW%) = 0; 12 | %VAR%_FLO.L(RVT,P,C,S%SOW%) = 0; 13 | %VAR%_IRE.L(RVT,P,C,S,IE%SOW%) = 0; 14 | %VAR%_SIN.L(RVT,P,C,S%SOW%) = 0; 15 | %VAR%_SOUT.L(RVT,P,C,S%SOW%) = 0; 16 | %VAR%_NCAP.L(RT_PP,P%SOW%) = 0; 17 | %VAR%_COMNET.L(RT_PP,C,S%SOW%) = 0; 18 | %VAR%_COMPRD.L(RT_PP,C,S%SOW%) = 0; 19 | %VAR%_NCAP.L(RT_PP,P%SOW%) = 0; 20 | %VAR%_UCT.L(UC_N,T(FIL)%SOW%) = 0; 21 | %VAR%_UCTS.L(UC_N,T(FIL),S%SOW%) = 0; 22 | %VAR%_UCRT.L(UC_N,RT_PP%SOW%) = 0; 23 | %VAR%_UCRTS.L(UC_N,RT_PP,S%SOW%) = 0; 24 | %VAR%_SCAP.L(RVT,P%SOW%) = 0; 25 | %EQ%G_COMBAL.L(RT_PP,C,S%SWT%) = 0; 26 | $IFI %CLI%==YES %VAR%_CLIBOX.L(CM_VAR,LL%SOW%)$CM_LED(LL)=0; 27 | $IFI %ABS%==YES %VAR%_BSPRS.L(RVT,P,C,S,L%SOW%) = 0; 28 | $IFI NOT %MACRO%==YES EQ_OBJ.M = 0; 29 | ); 30 | $IF NOT %STAGES%==YES $EXIT 31 | VAR_NCAP.L(RT_PP,P) = 0; 32 | VAR_UCT.L(UC_N,T(FIL)) = 0; 33 | VAR_UCTS.L(UC_N,T(FIL),S) = 0; 34 | VAR_UCRT.L(UC_N,RT_PP) = 0; 35 | VAR_UCRTS.L(UC_N,RT_PP,S) = 0; 36 | -------------------------------------------------------------------------------- /coefmain.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * COEFMAIN.MOD oversees the bulk of the coefficient calculations 7 | * %1 - mod or v# for the source code to be used 8 | *=============================================================================* 9 | *GaG Questions/Comments: 10 | *----------------------------------------------------------------------------- 11 | $IFI NOT %STAGES%==YES SOW(ALLSOW)=DIAG(ALLSOW,'1'); SW_T(T,ALLSOW)=SOW(ALLSOW); 12 | 13 | * handle the capacity transfer and related equation coefficients 14 | $ BATINCLUDE coef_cpt.%1 %1 15 | 16 | * derive the coefficients related to NCAP I/O flows for new/released 17 | $ BATINCLUDE coef_nio.%1 18 | 19 | * derive the coefficients related to process transformation 20 | $ BATINCLUDE coef_ptr.%1 21 | 22 | * derive the coefficients for the OBJ 23 | $ BATINCLUDE coef_obj.%1 %1 24 | 25 | * derive the additional/adjusted coefficients needed for alternate objectives 26 | $ BATINCLUDE coef_alt.lin VAR%CTST% 27 | 28 | * derive shaped coefficients for process transformation and capacity transfer 29 | $ BATINCLUDE coef_shp.%1 30 | -------------------------------------------------------------------------------- /ddfupd.msa: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *============================================================================== 6 | * DDFUPD.msa - Update DDF factors directly after previous MACRO run 7 | *============================================================================== 8 | 9 | * 10 | * initialize Y 11 | TM_DDF_Y(MR(R),T(T_1)) = 1; 12 | TM_DDF_Y(MR(R),PP) = ((TM_GDPGOAL(R,PP)/TM_GDP(R,PP))**.7) * PAR_Y(R,PP)/SUM(T_1(T),PAR_Y(R,T)); 13 | DISPLAY TM_DDF_Y; 14 | 15 | * normalize to base year 16 | TM_DDF_DM(R,T,DM)$TM_DEM(R,T,DM) = 1; 17 | LOOP(T_1(TT),TM_DDF_DM(R,T,DM)$TM_DEM(R,TT,DM) = TM_DEM(R,T,DM) / TM_DEM(R,TT,DM)); 18 | LOOP(T_1(TT),TM_DDF_SP(R,T,DM)$PAR_MC(R,TT,DM) = PAR_MC(R,T,DM) / PAR_MC(R,TT,DM)); 19 | 20 | * estimate DDF factors 21 | OPTION CLEAR=TM_DDF; 22 | TM_F2(R,T,DM)$TM_DDF_SP(R,T,DM) = TM_DDF_DM(R,T,DM) / (TM_DDF_Y(R,T) * TM_DDF_SP(R,T,DM) ** (-TM_ESUB(R))); 23 | TM_DDF(R,PP(T+1),DM)$TM_F2(R,T,DM) = 100 * (1 - (TM_F2(R,PP,DM)/TM_F2(R,T,DM))**((TM_RHO(R)-1)/(NYPER(T)*TM_RHO(R)))); 24 | 25 | * update growth indicators 26 | TM_GROWV(R,T) = TM_GROWV(R,T) + (TM_GR(R,T) - PAR_GRGDP(R,T)); 27 | TM_GROWV(R,TLAST) = TM_GR(R,TLAST); 28 | 29 | * update other parameters depending on DDFs or growth 30 | TM_AEEIV(MR,T,DM) = TM_DDF(MR,T,DM) / 100; 31 | TM_DFACTCURR(R,T) = 1 - (TM_KPVS(R)/TM_KGDP(R) - TM_DEPR(R)/100 - TM_GROWV(R,T)/100); 32 | TM_IV0(R) = TM_K0(R) * (TM_DEPR(R) + SUM(T_1(T),TM_GROWV(R,T)))/100; 33 | TM_C0(R) = TM_GDP0(R) - TM_IV0(R); 34 | 35 | LOOP(PP(T+1), 36 | TM_AEEIFAC(MR,PP,DM) = TM_AEEIFAC(MR,T,DM) * (1 - TM_AEEIV(MR,PP,DM)) ** NYPER(T); 37 | TM_DFACT(R,PP) = TM_DFACT(R,T) * TM_DFACTCURR(R,T) ** NYPER(T); 38 | TM_L(R,PP) = TM_L(R,T) * (1+TM_GROWV(R,T)/100) ** NYPER(T); 39 | ); 40 | 41 | * Arbitrary multiplier on utility in last time period. 42 | TM_DFACT(MR(R),TLAST)$(TM_ARBM NE 1) = TM_DFACT(R,TLAST) * 43 | (1-MIN(.999,TM_DFACTCURR(R,TLAST))**(NYPER(TLAST)*TM_ARBM)) / 44 | (1-MIN(.999,TM_DFACTCURR(R,TLAST))**(NYPER(TLAST) * 1 )); 45 | 46 | VAR_INV.FX(MR,T(T_1)) = TM_IV0(MR); 47 | -------------------------------------------------------------------------------- /dumpsol.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * DUMPSOL.MOD displays selected solution results * 7 | * %1 - mod or v# for the source code to be used * 8 | * %2 - NO_EMTY if headers to be surpressed if no row * 9 | *=============================================================================* 10 | *GaG Questions/Comments: 11 | *----------------------------------------------------------------------------- 12 | FILE SOLDUMP; PUT SOLDUMP; 13 | SOLDUMP.PW=255; 14 | $SET NO_EMTY '%2' 15 | 16 | $BATINCLUDE dumpsol1.mod 'L' VAR_NCAP VAR_CAP VAR_COMPRD 17 | $BATINCLUDE dumpsolv.mod 'L' VAR_ACT VAR_FLO VAR_IRE VAR_SIN VAR_SOUT 18 | $BATINCLUDE dumpsol1.mod 'M' VAR_NCAP VAR_CAP VAR_COMPRD 19 | $BATINCLUDE dumpsolv.mod 'M' VAR_ACT VAR_FLO VAR_IRE VAR_SIN VAR_SOUT 20 | 21 | $BATINCLUDE dumpsol1.mod 'L' EQG_COMBAL EQE_COMBAL EQE_COMPRD 22 | $BATINCLUDE dumpsol1.mod 'M' EQG_COMBAL EQE_COMBAL EQE_COMPRD 23 | 24 | PARAMETER VARACT(R,T,P) / EMPTY.EMPTY.EMPTY 0 /; 25 | VARACT(RTP(R,T,P)) = SUM((V,S), VAR_ACT.L(R,V,T,P,S)); 26 | $BATINCLUDE dumpsol1.mod 'T' VARACT 27 | 28 | PUTCLOSE SOLDUMP; 29 | -------------------------------------------------------------------------------- /eqactbnd.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQACTBND limits the activity of vintage processes or higher TS-level bounds 7 | * %1 - equation declaration type 8 | * %2 - bound type for %1 9 | * %3 - qualifier that bound exists 10 | *=============================================================================* 11 | * Questions/Comments: 12 | * - ACT_BND ts restricted to the PRC_TS level or above 13 | *----------------------------------------------------------------------------- 14 | *V0.5b 980902 - avoid equations if LO=0/UP=INF 15 | *$ONLISTING 16 | * [UR] 21.07.2003 tightended control for generation of equation to RTP_VARA 17 | %EQ%%1_ACTBND(RTP_VARA(%R_T%,P),S %SWT%)$((RPS_PRCTS(R,P,S)*(PRC_VINT(R,P)+(NOT PRC_TS(R,P,S)))$%3)$ACT_BND(R,T,P,S,'%2')).. 18 | 19 | * sum over all possible at process TS-level 20 | SUM(PRC_TS(R,P,TS)$TS_MAP(R,S,TS), 21 | * sum all the existing activities 22 | SUM(RTP_VINTYR(R,V,T,P), %VAR%_ACT(R,V,T,P,TS%SOW%)) 23 | ) 24 | 25 | =%1= 26 | 27 | ACT_BND(R,T,P,S,'%2') 28 | ; 29 | *$OFFLISTING 30 | -------------------------------------------------------------------------------- /eqactflo.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQACTFLO.MOD relationship between process activity & individual primary * 7 | * commodity flows * 8 | *=============================================================================* 9 | *GaG Questions/Comments: 10 | * - always created at the PRC_TS level as tied to the PCG 11 | *----------------------------------------------------------------------------- 12 | *$ONLISTING 13 | * adjust so VAR_FLO only when not IRE (or STG) 14 | * EQ_ACTFLO(RTP_VINTYR(R,V,T,P),S)$((RP_FLO(R,P) + RP_IRE(R,P)) * PRC_TS(R,P,S) 15 | %EQ%_ACTFLO(RTP_VINTYR(%R_V_T%,P),S %SWT%)$(PRC_TS(R,P,S) * 16 | $IF %REDUCE% == 'YES' (NOT RTPS_OFF(R,T,P,S)) * 17 | PRC_ACT(R,P)) .. 18 | 19 | %VAR%_ACT(R,V,T,P,S %SOW%)$RTP_VARA(R,T,P) 20 | 21 | =E= 22 | 23 | * handle both regular and IRE processes 24 | * need to ensure that said commodity handled in current timeslice 25 | SUM(RPC_PG(R,P,C)$RTPCS_VARF(R,T,P,C,S), 26 | (%VAR%_FLO(R,V,T,P,C,S %SOW%)$RP_FLO(R,P) + 27 | SUM(RPC_IRE(R,P,C,IE)$RP_AIRE(R,P,IE), 28 | %VAR%_IRE(R,V,T,P,C,S,IE %SOW%))$RP_IRE(R,P) 29 | ) / PRC_ACTFLO(R,V,P,C) 30 | ); 31 | *$OFFLISTING 32 | -------------------------------------------------------------------------------- /eqbndcom.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQCOMBND limits the total NET/PRD of a commodity at a level above COM_TS 7 | * %1 - equation declaration type 8 | * %2 - bound type for %1 9 | * %3 - qualifier that bound exists 10 | * %4 - NET/PRD indicator 11 | *=============================================================================* 12 | *GaG Questions/Comments: 13 | * V0.5c added 14 | *----------------------------------------------------------------------------- 15 | *$ONLISTING 16 | %EQ%%1_BND%4(RTC(%R_T%,C),S %SWT%)$((RCS_COMTS(R,C,S)$(NOT COM_TS(R,C,S))$%3)$COM_BND%4(R,T,C,S,'%2')).. 17 | 18 | * sum over all possible commodity flow at/below TS-level 19 | SUM(RTCS_VARC(R,T,C,TS)$TS_MAP(R,S,TS), %VAR%_COM%4(R,T,C,TS %SOW%)) 20 | 21 | =%1= 22 | 23 | COM_BND%4(R,T,C,S,'%2') 24 | ; 25 | *$OFFLISTING 26 | -------------------------------------------------------------------------------- /eqcapact.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQCAPACT is the capacity utilization equation 7 | * %1 - equation declaration type 8 | * %2 - bound type for %1 9 | *=============================================================================* 10 | * Questions/Comments: 11 | * - COEF_CPT is defined in COEF_CPT.MOD 12 | * - COEF_AF established by applying SHAPE in COEF_CPT.MOD 13 | * - Commodity-specific AF handled by EQ(l)_CAFLAC (VDA extension) 14 | *----------------------------------------------------------------------------- 15 | $SETLOCAL PASS '' 16 | $IF DEFINED RPS_CAFLAC $SETLOCAL PASS %PASS%*(NOT RPS_CAFLAC(R,P,S,'%2')) 17 | 18 | SET AFS(R,T,P,S,BD) //; 19 | * COEF_AFs are always at PRC_TS or above, can be directly used for testing: 20 | $IF %1==L LOOP(V,AFS(RTP_VARA(R,T,P),S,BD)$COEF_AF(R,V,T,P,S,BD)=YES); AFS(RTPS_OFF,BD) = NO; 21 | 22 | %EQ%%1_CAPACT(RTP_VINTYR(%R_V_T%,P),S %SWT%)$(AFS(R,T,P,S,'%2') %PASS%) .. 23 | 24 | * normal processes 25 | SUM(PRC_TS(R,P,TS)$TS_MAP(R,S,TS),%VAR%_ACT(R,V,T,P,TS %SOW%))$(NOT RP_STG(R,P)) 26 | + 27 | * storage: parent timeslice fraction of the number of storage cycles in a year 28 | SUM(PRC_TS(R,P,TS)$RS_FR(R,TS,S),(%VAR%_ACT(R,V,T,P,TS %SOW%)+VAR_STS(R,V,T,P,TS,'%2'))*RS_FR(R,TS,S)*EXP(PRC_SC(R,P))/RS_STGPRD(R,TS))$RP_STG(R,P) 29 | 30 | =%1= 31 | 32 | ( 33 | * process is not vintaged 34 | $IF %VALIDATE% == 'YES' $GOTO CAPIT 35 | (SUM(MODLYEAR$COEF_CPT(R,MODLYEAR,T,P), 36 | COEF_CPT(R,MODLYEAR,T,P) * COEF_AF%3(R,MODLYEAR,T,P,S,'%2') * 37 | (%VARM%_NCAP(R,MODLYEAR,P %SWS%)$T(MODLYEAR) + NCAP_PASTI(R,MODLYEAR,P)$PASTYEAR(MODLYEAR)%RCAPSBM%) 38 | ) * PRC_CAPACT(R,P) 39 | $LABEL CAPIT 40 | $IF %VALIDATE% == 'YES' (COEF_AF(R,T,T,P,S,'%2') * PRC_CAPACT(R,P) * %VAR%_CAP(R,T,P %SOW%) 41 | )$(NOT PRC_VINT(R,P)) + 42 | 43 | * process is vintaged 44 | (COEF_AF%3(R,V,T,P,S,'%2') * COEF_CPT(R,V,T,P) * PRC_CAPACT(R,P) * 45 | (%VARV%_NCAP(R,V,P %SWS%)$T(V) + NCAP_PASTI(R,V,P)$PASTYEAR(V)%RCAPSUB%))$PRC_VINT(R,P) 46 | ) * 47 | 48 | * UR 10/05/00 49 | * capacity of storage process fully available in each time slice 50 | POWER(G_YRFR(R,S),1-1$RP_STG(R,P)) 51 | 52 | ; 53 | -------------------------------------------------------------------------------- /eqcapvac.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQCAPVAC is the capacity utilization equation for vintage-simulated processes 7 | * %1 - equation lim type 8 | * %2 - bound type for %1 9 | *=============================================================================* 10 | * Questions/Comments: 11 | * - COEF_CSV is defined in COEF_CSV.MOD 12 | *----------------------------------------------------------------------------- 13 | 14 | EQ%1_CAPVAC(RTP_VINTYR(%R_V_T%,P),S%SWX%)$(%SWTX%AFSV(R,T,P,S,'%2')).. 15 | 16 | * Activity level at timeslice S 17 | SUM(PRC_TS(R,P,TS)$TS_MAP(R,S,TS),%VAR%_ACT(R,V,T,P,TS %SOW%))$(NOT RPS_CAFLAC(R,P,S,'%2')) + 18 | * Flow levels when commodity-specific availabilities 19 | SUM((RPC_PG(R,P,C),COM_TMAP(R,COM_TYPE(CG),C)), (1/PRC_ACTFLO(R,V,P,C)) / 20 | (NCAP_AFCS(R,V,P,C,S)+PROD(XPT$NCAP_AFCS(R,V,P,CG,S),NCAP_AFCS(R,V,P,CG,S))$(NOT NCAP_AFCS(R,V,P,C,S))) * 21 | SUM(RPCS_VAR(R,P,C,TS)$TS_MAP(R,S,TS),%VAR%_FLO(R,V,T,P,C,TS %SOW%)$RP_STD(R,P) + 22 | SUM(RPC_IRE(R,P,C,IE),%VAR%_IRE(R,V,T,P,C,TS,IE %SOW%))))$RPS_CAFLAC(R,P,S,'%2') 23 | 24 | =%1= 25 | 26 | * process is vintaged 27 | SUM(MODLYEAR(K)$COEF_CSV(R,K,T,P,V),COEF_CSV(R,K,T,P,V)*COEF_AF(R,K,T,P,S,'%2')*%VARM%_NCAP(R,K,P%SWS%)$T(K)+NCAP_PASTI(R,K,P))*PRC_CAPACT(R,P)*G_YRFR(R,S) 28 | ; 29 | 30 | 31 | -------------------------------------------------------------------------------- /eqchpelc.ier: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *----------------------------------------------------------------------------- 6 | * Equation bounding the electricity production of extraction condensing CHP plant 7 | * by the available condensing resp. backpressure capacity 8 | * %1 - =L= or =E= qualifier 9 | * %2 - UP of FX bound for ECT_AFCON/ECT_AFCHP 10 | *----------------------------------------------------------------------------- 11 | 12 | EQ%1_CHPCON(RTP_VINTYR(R,V,T,P)%SWX%)$(%SWTX%ECT_AFCON(R,T,P,'%2')*SUM(RTPCS_VARF(R,T,P,C,TS)$ECT_ELC(R,P,C),1)$ECT_CHP(R,P)).. 13 | 14 | SUM(RTPCS_VARF(R,T,P,C,TS)$ECT_ELC(R,P,C), 15 | * [UR] model reduction %REDUCE% is set in *.run 16 | $ BATINCLUDE %cal_red% C COM TS P T 17 | ) 18 | - 19 | SUM(RTPCS_VARF(R,T,P,C,TS)$ECT_DHT(R,P,C), ECT_REH(R,T,P)* 20 | * [UR] model reduction %REDUCE% is set in *.run 21 | $ BATINCLUDE %cal_red% C COM TS P T 22 | ) 23 | 24 | =%1= 25 | 26 | * Case I if AFpcg 27 | * process is not vintaged 28 | SUM(RTP_CPTYR(R,MODLYEAR(K),T,P), 29 | ECT_AFCON(R,T,P,'%2') * ECT_INP2CON(R,T,P) * COEF_CPT(R,K,T,P) * PRC_CAPACT(R,P) * (%VARM%_NCAP(R,K,P %SWS%)$T(K) + NCAP_PASTI(R,K,P)) 30 | )$(NOT PRC_VINT(R,P)) + 31 | 32 | * process is vintaged 33 | (ECT_AFCON(R,T,P,'%2') * ECT_INP2CON(R,T,P) * COEF_CPT(R,V,T,P) * PRC_CAPACT(R,P) * (%VARV%_NCAP(R,V,P %SWS%)$T(V) + NCAP_PASTI(R,V,P)) 34 | )$PRC_VINT(R,P) 35 | ; 36 | 37 | EQ%1_CHPBPT(RTP_VINTYR(R,V,T,P)%SWX%)$(%SWTX%ECT_AFBPT(R,T,P,'%2')*SUM(RTPCS_VARF(R,T,P,C,TS)$ECT_DHT(R,P,C),1)$ECT_CHP(R,P)).. 38 | 39 | SUM(RTPCS_VARF(R,T,P,C,TS)$ECT_DHT(R,P,C), ECT_REH(R,T,P)* 40 | * [UR] model reduction %REDUCE% is set in *.run 41 | $ BATINCLUDE %cal_red% C COM TS P T 42 | ) 43 | 44 | =%1= 45 | 46 | * Case I if AFpcg 47 | * process is not vintaged 48 | SUM(RTP_CPTYR(R,MODLYEAR(K),T,P), 49 | ECT_AFBPT(R,T,P,'%2') * ECT_INP2ELC(R,T,P) * COEF_CPT(R,K,T,P) * PRC_CAPACT(R,P) * (%VARM%_NCAP(R,K,P %SWS%)$T(K) + NCAP_PASTI(R,K,P)) 50 | )$(NOT PRC_VINT(R,P)) + 51 | 52 | * process is vintaged 53 | (ECT_AFBPT(R,T,P,'%2') * ECT_INP2ELC(R,T,P) * COEF_CPT(R,V,T,P) * PRC_CAPACT(R,P) * (%VARV%_NCAP(R,V,P %SWS%)$T(V) + NCAP_PASTI(R,V,P)) 54 | )$PRC_VINT(R,P) 55 | ; 56 | -------------------------------------------------------------------------------- /eqcpt.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQCPT.MOD capacity transfer equation 7 | * - %1 = equation type when VALIDATE 8 | * - %2 = equation name adj (L) when VALIDATE (for DMDs in MARKAL) 9 | * - %3 = control qualifier 10 | * - %4 = RHS constant or VAR_CAP 11 | *=============================================================================* 12 | *GaG Questions/Comments: 13 | * - COEF_CPT established in COEF_CPT.MOD 14 | *----------------------------------------------------------------------------- 15 | *GG*V0.6a_3+ check whether used in UserConstraint 16 | *$onlisting 17 | 18 | %EQ%%2_CPT(RTP(R,T,P) %SWT%)$(%3) .. 19 | 20 | * VAR_CAP(r,t,p %sow%) or CAP_BND(r,t,p,bd): 21 | %4 22 | 23 | =%1= 24 | 25 | SUM(V$COEF_CPT(R,V,T,P), COEF_CPT(R,V,T,P) * 26 | (%VARV%_NCAP(R,V,P %SWS%)$MILESTONYR(V) + NCAP_PASTI(R,V,P)$PASTYEAR(V)%RCAPSUB%)) 27 | ; 28 | *$offlisting 29 | -------------------------------------------------------------------------------- /eqcumcom.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQCUMCOM sets the cumulative limit on a commodity 7 | * %1 - equation declaration type 8 | * %2 - NET/PRD indicator 9 | *=============================================================================* 10 | *GaG Questions/Comments: 11 | * - scale both sides!!! 12 | * [AL] Changed to support arbitrary year range 13 | *----------------------------------------------------------------------------- 14 | *$ONLISTING 15 | %EQ%_CUM%2(RC(R,C),ALLYEAR,LL %SOW%)$RC_CUMCOM(R,'%2',ALLYEAR,LL,C).. 16 | 17 | * all commodity flows within period range 18 | SUM(RTC_%2(R,TT(T),C)$ 19 | $IFI NOT %OBJ%==LIN ((E(T) >= YEARVAL(ALLYEAR))$(B(T) <= YEARVAL(LL))), 20 | $IFI %OBJ%==LIN ((M(T)+LAGT(T) > YEARVAL(ALLYEAR))$(M(T)-LEAD(T) < YEARVAL(LL))), 21 | SUM(RTCS_VARC(R,T,C,S), 22 | $IFI NOT %OBJ%==LIN MAX(0,MIN(E(T),YEARVAL(LL))-MAX(B(T),YEARVAL(ALLYEAR))+1) 23 | $IFI %OBJ%==LIN SUM(TPULSEYR(T,YEAR)$((ORD(YEAR) >= ORD(ALLYEAR))$(ORD(YEAR) <= ORD(LL))),TPULSE(T,YEAR)) 24 | * %VARTT%_COM%2(R,T,C,S %SWS%) 25 | ) 26 | ) / %CUCSCAL% 27 | 28 | =%1= 29 | 30 | * bound range working on 31 | %VAR%_CUMCOM(R,C,'%2',ALLYEAR,LL %SOW%) 32 | ; 33 | 34 | $OFFLISTING 35 | -------------------------------------------------------------------------------- /eqcumflo.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQCUMFLO sets the cumulative upper limit on a flow or activity 7 | * %1 - equation declaration type 8 | *=============================================================================* 9 | *AL Questions/Comments: 10 | * - scale both sides 11 | * - support arbitrary year range 12 | *----------------------------------------------------------------------------- 13 | *$ONLISTING 14 | %EQ%_CUMFLO(RPC_CUMFLO(RP(R,P),C,ALLYEAR,LL) %SOW%) .. 15 | $SETLOCAL SW1 '' SETLOCAL SW2 "" 16 | $IF %STAGES%%SCUM%==YES $SET SOW ',WW' SET SWT ',SOW' SET SW1 'S_' SET SW2 ",'1',SOW" 17 | 18 | * all commodity/activity flows within period range 19 | SUM(TT(T)$ 20 | $IFI NOT %OBJ%==LIN ((E(T) >= YEARVAL(ALLYEAR))$(B(T) <= YEARVAL(LL))), 21 | $IFI %OBJ%==LIN ((M(T)+LAGT(T) > YEARVAL(ALLYEAR))$(M(T)-LEAD(T) < YEARVAL(LL))), 22 | SUM((RTP_VINTYR(R,V,T,P),RTPCS_VARF(R,T,P,C,TS)), 23 | $IFI NOT %OBJ%==LIN MAX(0,MIN(E(T),YEARVAL(LL))-MAX(B(T),YEARVAL(ALLYEAR))+1) 24 | $IFI %OBJ%==LIN SUM(TPULSEYR(T,YEAR)$((ORD(YEAR) >= ORD(ALLYEAR))$(ORD(YEAR) <= ORD(LL))),TPULSE(T,YEAR)) 25 | * ( 26 | $IF %STAGES%==YES SUM(%SWSW% ( 27 | $ BATINCLUDE %cal_red% C COM TS P T 28 | $RP_STD(R,P) + 29 | (SUM(RPC_IRE(R,P,C,IE),%VAR%_IRE(R,V,T,P,C,TS,IE%SOW%))$(NOT RPC_AIRE(R,P,C)) + 30 | (%VAR%_ACT(R,V,T,P,TS%SOW%)*PRC_ACTFLO(R,V,P,C))$RPC_AIRE(R,P,C))$RP_IRE(R,P) 31 | $IF %STAGES%==YES )) 32 | ))$RPC(R,P,C) + 33 | SUM((RTP_VINTYR(R,V,T,P),RTP_VARA(R,T,P),PRC_TS(R,P,TS)), 34 | $IFI NOT %OBJ%==LIN MAX(0,MIN(E(T),YEARVAL(LL))-MAX(B(T),YEARVAL(ALLYEAR))+1) 35 | $IFI %OBJ%==LIN SUM(TPULSEYR(T,YEAR)$((ORD(YEAR) >= ORD(ALLYEAR))$(ORD(YEAR) <= ORD(LL))),TPULSE(T,YEAR)) 36 | * %VARTT%_ACT(R,V,T,P,TS %SWS%) 37 | )$SAMEAS(%PGPRIM%,C) 38 | 39 | ) / %CUFSCAL% 40 | 41 | =E= 42 | 43 | * bound range working on 44 | %VAR%_CUMFLO(R,P,C,ALLYEAR,LL %SWT%)$(MAPVAL(%SW1%FLO_CUM(R,P,C,ALLYEAR,LL,'UP'%SW2%)) NE 8); 45 | ; 46 | 47 | $OFFLISTING 48 | 49 | -------------------------------------------------------------------------------- /eqflobnd.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQFLOBND limits the flow variable at higher TS-leves 7 | * %1 - equation declaration type 8 | * %2 - bound type for %1 9 | * %3 - qualifier that bound exists 10 | *=============================================================================* 11 | *UR Questions/Comments: 12 | *----------------------------------------------------------------------------- 13 | *$ONLISTING 14 | 15 | %EQ%%1_FLOBND(RTP_VARA(%R_T%,P),CG,S %SWT%)$( 16 | * Make an equation of the bound if there are flow variables for commodities in CG that are strictly below S, 17 | * ...or the tuple has been otherwise rejected for VAR bound (process is vintaged or IRE, or flow is reduced): 18 | SUM(RTPCS_VARF(R,T,P,C,TS)$(TS_MAP(R,S,TS)*COM_GMAP(R,CG,C)), 19 | RS_BELOW(R,S,TS) OR FLO_BND(R,'%DFLBL%',P,CG,S,'%2') 20 | )$FLO_BND(R,T,P,CG,S,'%2') 21 | ) .. 22 | 23 | * sum over all flows that are either at S or below it 24 | (SUM((COM_GMAP(R,CG,C),RTPCS_VARF(R,T,P,C,TS))$TS_MAP(R,S,TS), 25 | * sum all the existing flows 26 | SUM(RTP_VINTYR(R,V,T,P), 27 | * [UR] model reduction %REDUCE% is set in *.run 28 | ( 29 | $ BATINCLUDE %cal_red% C COM TS P T 30 | )$RP_FLO(R,P) + 31 | 32 | * [AL] add support for IRE 33 | SUM(RPC_IRE(R,P,C,IE),(%VAR%_IRE(R,V,T,P,C,TS,IE%SOW%) 34 | $IF %REDUCE% == 'YES' 35 | $(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) 36 | * apply IRE bound on net flow if group used, otherwise on sum of IMP/EXP 37 | )*(1-2$XPT(IE)$(NOT COM(CG))))$RP_IRE(R,P) 38 | ) 39 | ) 40 | 41 | - FLO_BND(R,T,P,CG,S,'%2'))$%3 42 | 43 | =%1= 0; 44 | 45 | *$OFFLISTING 46 | -------------------------------------------------------------------------------- /eqflofr.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQFLOFR relationship between total flow and the flow in a specific timeslice 7 | * %1 - equation declaration type 8 | * %2 - LIM type of FLO_FR 9 | *=============================================================================* 10 | * Questions/Comments: 11 | * - FLO_FR must be specified on TS-level of the flow or above; value below will be ignored 12 | * - fraction of flows under parent timelice supported by a parent N (or negative) FLO_FR 13 | 14 | 15 | %EQ%%1_FLOFR(RTPC(%R_T%,P,C),S,L(%2)%SWT%)$(SUM(RPCS_VAR(RP_FLO(R,P),C,TS)$TS_MAP(R,S,TS),1)$FLO_FR(R,T,P,C,S,L)).. 16 | 17 | SUM(RTP_VINTYR(R,V,T,P),%VAR%_FLO(R,V,T,P,C,S%SOW%)$IPS(L) + 18 | SUM(RS_BELOW1(R,SL,S),%VAR%_FLO(R,V,T,P,C,SL%SOW%)$FLO_FR(RTPC,SL,'N') + 19 | SUM(RTPCS_VARF(RTPC,TS)$(FLO_FR(RTPC,S,L)>-INF$RS_FR(R,SL,TS)), 20 | $ BATINCLUDE %cal_red% C COM TS P T 21 | )$(NOT FLO_FR(RTPC,SL,'N')))$BD(L)) * ABS(FLO_FR(RTPC,S,L)) 22 | 23 | =%1= 24 | 25 | SUM((RTP_VINTYR(R,V,T,P),RTPCS_VARF(RTPC,TS))$(STOA(TS)$TS_MAP(R,S,TS)), 26 | $ BATINCLUDE %cal_red% C COM TS P T 27 | ); 28 | -------------------------------------------------------------------------------- /eqfloshr.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQIN/OUTSHR is the market/product share limit constraint 7 | * %1 - equation declaration type 8 | * %2 - FLO_SHAR type for %1 9 | * %3 - IN/OUT indicator 10 | *=============================================================================* 11 | *GaG Questions/Comments: 12 | * - Needs to be adjusted to handle attribute TS-level diff. the operation level 13 | * - for now FLO_SHAR moved down to S1 level in PP_MAIN (which may be OK) 14 | * - [AL] Changed level of equation to be that of RPCS_VAR; RP_STD control added 15 | *----------------------------------------------------------------------------- 16 | 17 | %EQ%%1_%3SHR(RTP_VINTYR(%R_V_T%,P),C,CG,S %SWT%)$((RP_STD(R,P)*TOP(R,P,C,'%3')*RTPCS_VARF(R,T,P,C,S))$FLO_SHAR(R,V,P,C,CG,S,'%2')).. 18 | 19 | * all flows in the group 20 | FLO_SHAR(R,V,P,C,CG,S,'%2') * 21 | *V0.5a 980729 - RPCS_VAR: com not c 22 | * [AL] Handle reduced/non-reduced groups separately 23 | (SUM((TOP(R,P,COM,'%3'),RTPCS_VARF(R,T,P,COM,TS))$COM_GMAP(R,CG,COM), 24 | %VAR%_FLO(R,V,T,P,COM,TS %SOW%)*RS_FR(R,S,TS)*(1+RTCS_FR(R,T,COM,S,TS)) 25 | )$(NOT RPG_RED(R,P,CG,'%3')) + 26 | 27 | SUM((TOP(R,P,COM,'%3'),RTPCS_VARF(R,T,P,COM,TS))$COM_GMAP(R,CG,COM), 28 | $ BATINCLUDE %cal_red% COM COM1 TS P T 29 | * 30 | * share-ts coarser than variable or share finer than variable 31 | RS_FR(R,S,TS)*(1+RTCS_FR(R,T,COM,S,TS)) 32 | )$RPG_RED(R,P,CG,'%3') 33 | )$(FLO_SHAR(R,V,P,C,CG,S,'%2') > 0) 34 | 35 | =%1= 36 | 37 | * commodity working on, summed for all 38 | %VAR%_FLO(R,V,T,P,C,S %SOW%)$(NOT RPG_RED(R,P,CG,'%3')) + 39 | ( 40 | $ BATINCLUDE %cal_red% C COM S P T 41 | )$RPG_RED(R,P,CG,'%3') 42 | ; 43 | -------------------------------------------------------------------------------- /eqobj.tm: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQOBJ the objective cost functions for Macro 7 | * %1 - mod or v# for the source code to be used 8 | *=============================================================================* 9 | *GaG Questions/Comments: 10 | *10/21 11 | * - V-index used in place to T for MODLYEAR 12 | * Note: PASTYEAR always have D(V) = 1 13 | * - V-vintage MODLYEAR year, the point in time where the investment took place 14 | *----------------------------------------------------------------------------- 15 | 16 | SET K_EOH(ALLYEAR); 17 | 18 | * [UR] 21.06.2003: K_EOH must include pastyears, since in eqobjfix.mod it links to past vintages 19 | K_EOH(EACHYEAR)$((YEARVAL(EACHYEAR) >= PYR_V1) * (YEARVAL(EACHYEAR) <= MIYR_VL)) = YES; 20 | 21 | * Sets for periodic costs 22 | SET KTYAGE(LL,YEAR,LL,AGE); 23 | LOOP(SAMEAS('1',AGE),KTYAGE(K(LL),PERIODYR(T,Y_EOH(YEAR)),AGE+(ORD(YEAR)-ORD(LL)))$YK(YEAR,LL)=YES); 24 | 25 | * Cases for ILED and TLIFE/D(t); values assigned in EQOBJINV 26 | SET OBJ_1A(R,ALLYEAR,P) //; 27 | SET OBJ_1B(R,ALLYEAR,P) //; 28 | SET OBJ_2A(R,ALLYEAR,P) //; 29 | SET OBJ_2B(R,ALLYEAR,P) //; 30 | * Salvage controls 31 | SET OBJ_SUMS(R,ALLYEAR,P) //; 32 | SET OBJ_SUMS3(R,ALLYEAR,P) //; 33 | SET OBJ_SUMSI(R,ALLYEAR,P,ALLYEAR) //; 34 | PARAMETER OBJ_DCEOH(REG,CUR) //; 35 | 36 | *=============================================================================== 37 | * Investment Cost, Fixed Cost and Variable Cost components 38 | *=============================================================================== 39 | $ BATINCLUDE eqobjinv.mod tm exit 40 | $ BATINCLUDE eqobjfix.mod tm exit 41 | $ BATINCLUDE eqobsalv.mod tm exit 42 | $ BATINCLUDE eqobjann.tm 43 | 44 | *=============================================================================== 45 | * Elastic Demand costs: only when MLF 46 | *=============================================================================== 47 | $ IF %MACRO%==Yes $BATINCLUDE eqobjels.mod 48 | 49 | *=============================================================================== 50 | * Actual OBJ 51 | *=============================================================================== 52 | EQ_OBJ(R,T) .. 53 | 54 | SUM(RDCUR(R,CUR), 55 | 56 | * Investment Costs, Fixed Costs and Variable Costs (elastic demand costs excluded) 57 | 58 | SUM(OBVANN,VAR_ANNCST(OBVANN,R,T,CUR)) 59 | 60 | ) 61 | 62 | =E= 63 | 64 | VAR_OBJCOST(R,T); 65 | -------------------------------------------------------------------------------- /eqobjels.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQOBJELS the objective function flexible demand utility 7 | *=============================================================================* 8 | *GaG Questions/Comments: 9 | *----------------------------------------------------------------------------- 10 | $IFI %MICRO%==YES $BATINCLUDE pp_micro.mod NLP 11 | 12 | %EQ%_OBJELS(R,BD,CUR %SOW%)$(RDCUR(R,CUR)$SUM_OBJ(R,'OBJELS')).. 13 | 14 | *------------------------------------------------------------------------------ 15 | * Direction with bound sign BDSIG 16 | *------------------------------------------------------------------------------ 17 | *V0.5b 980824 - correct ORD adjustment 18 | SUM(RTCS_VARC(R,T,C,S)$(COM_ELAST(R,T,C,S,BD)$COM_STEP(R,C,BD)), 19 | COEF_PVT(R,T) * COM_BPRICE(R,T,C,S,CUR) * 20 | (SUM(RCJ(R,C,J,BD), %VART%_ELAST(R,T,C,S,J,BD %SWS%) * 21 | (1-BDSIG(BD)*(ORD(J)-.5)*COM_VOC(R,T,C,BD)/COM_STEP(R,C,BD))**(1/COM_ELAST(R,T,C,S,BD)))$(NOT COM_ELASTX(R,T,C,BD)) + 22 | * Shaped elasticities 23 | SUM(RTC_SHED(R,T,C,BD,JJ(AGE)), 24 | SUM((RCJ(R,C,J,BD),SPAN(AGE+CEIL((ORD(J)-.5)*COM_VOC(R,T,C,BD)/COM_STEP(R,C,BD)*100-ORD(AGE)))), 25 | (SHAPED(BD,JJ,SPAN) * 26 | ((1-BDSIG(BD)*(ORD(J)-.5)*COM_VOC(R,T,C,BD)/COM_STEP(R,C,BD))/SHAPED(BD,'1',SPAN))**(1/MAX(1E-3,SHAPE(JJ,SPAN))) 27 | )**(1/COM_ELAST(R,T,C,S,BD)) * %VART%_ELAST(R,T,C,S,J,BD %SWS%))) + 28 | SUM(MI_DMAS(R,COM,C)$MI_DOPE(R,T,C),SUM(RCJ(R,C,J,BD),%VART%_ELAST(R,T,C,S,J,BD %SWS%) * MI_AGC(R,T,COM,C,J,BD))) 29 | ) 30 | )$BDNEQ(BD) 31 | 32 | 33 | * Micro NLP formulation 34 | $IFI NOT %MICRO%==YES $GOTO RHS 35 | + SUM(T$(ORD(T)>1), COEF_PVT(R,T) * 36 | SUM(DEM(R,C)$(MI_ELASP(R,T,C)$RD_NLP(R,C)), MI_CCONS(R,T,C) * 37 | ((%VART%_DEM(R,T,C%SWS%)**MI_ELASP(R,T,C))$(RD_NLP(R,C)=1) + 38 | ((SUM(MI_DMAS(R,C,COM),RD_SHAR(R,T,C,COM)**(1/MI_ESUB(R,T,C))*(COM_AGG(R,T,COM,C)*%VART%_DEM(R,T,COM%SWS%))**MI_RHO(R,T,C))**(1/MI_RHO(R,T,C)))**MI_ELASP(R,T,C))$(RD_NLP(R,C)>2) - 39 | DDF_QREF(R,T,C)**MI_ELASP(R,T,C))$(RD_NLP(R,C)>0) 40 | ))$LNX(BD) 41 | 42 | $LABEL RHS 43 | =E= 44 | %VAR%_OBJELS(R,BD,CUR %SOW%); 45 | 46 | *------------------------------------------------------------------------------ 47 | 48 | * Step bounds for linear CES demand functions 49 | %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)).. 50 | 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))) 51 | =L= %VAR%_COMPRD(R,T,COM,'ANNUAL'%SOW%)/DDF_QREF(R,T,COM); 52 | -------------------------------------------------------------------------------- /eqobjels.rpt: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQOBJELS the objective function flexible demand costs reporting 7 | *=============================================================================* 8 | * %1 - assigned parameter(..%2..) 9 | * %2 - year index (Y_EOH/TT) 10 | * %3 - mult or '' 11 | *----------------------------------------------------------------------------- 12 | *V0.5a 980729 control the inner sums according to the years in the periods 13 | 14 | %1$SUM(RCJ(R,C,'1',BDNEQ),1) = %3 15 | 16 | SUM((RDCUR(R,CUR),BDNEQ(BD)), BDSIG(BD) * 17 | *V0.5b 980824 - correct ORD adjustment 18 | SUM((PERIODYR(T,%2),COM_TS(R,C,S))$COM_ELAST(R,T,C,S,BD), COM_BPRICE(R,T,C,S,CUR) * 19 | (SUM(RCJ(R,C,J,BD), VAR_ELAST.L(R,T,C,S,J,BD) * 20 | ((1-BDSIG(BD)*(ORD(J)-.5)*COM_VOC(R,T,C,BD)/COM_STEP(R,C,BD))**(1/COM_ELAST(R,T,C,S,BD))))$(NOT COM_ELASTX(R,T,C,BD)) + 21 | SUM(RTC_SHED(R,T,C,BD,JJ(AGE)), 22 | SUM((RCJ(R,C,J,BD),SPAN(AGE+CEIL((ORD(J)-.5)*COM_VOC(R,T,C,BD)/COM_STEP(R,C,BD)*100-ORD(AGE)))), 23 | (SHAPED(BD,JJ,SPAN) * 24 | ((1-BDSIG(BD)*(ORD(J)-.5)*COM_VOC(R,T,C,BD)/COM_STEP(R,C,BD))/SHAPED(BD,'1',SPAN))**(1/MAX(1E-3,SHAPE(JJ,SPAN))) 25 | )**(1/COM_ELAST(R,T,C,S,BD)) * VAR_ELAST.L(R,T,C,S,J,BD))) 26 | $IF DEFINED MI_AGC +SUM(MI_DMAS(R,COM,C)$MI_DOPE(R,T,C),SUM(RCJ(R,C,J,BD),VAR_ELAST.L(R,T,C,S,J,BD)*MI_AGC(R,T,COM,C,J,BD))) 27 | )) 28 | ); 29 | $IFI NOT %MICRO%==YES $EXIT 30 | * NLP utility loss 31 | %1$RD_NLP(R,C) = %3 32 | SUM(RDCUR(R,CUR), 33 | SUM((PERIODYR(T,%2),COM_TS(R,C,S))$(COM_BPRICE(R,T,C,S,CUR)$MI_ELASP(R,T,C)), -COM_FR(R,T,C,S) * MI_CCONS(R,T,C) * 34 | ((VAR_DEM.L(R,T,C)**MI_ELASP(R,T,C))$(RD_NLP(R,C)=1) + 35 | ((SUM(MI_DMAS(R,C,COM),RD_SHAR(R,T,C,COM)**(1/MI_ESUB(R,T,C))*(COM_AGG(R,T,COM,C)*VAR_DEM.L(R,T,COM))**MI_RHO(R,T,C))**(1/MI_RHO(R,T,C)))**MI_ELASP(R,T,C))$(RD_NLP(R,C)>2) - 36 | DDF_QREF(R,T,C)**MI_ELASP(R,T,C))$(RD_NLP(R,C)>0)) 37 | ); -------------------------------------------------------------------------------- /eqpk_ect.ier: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * [UR]: 04/22/2003: adjustment for extraction condensing CHP plants 7 | + SUM(ECT_ELC(ECT_CHP(R,P),C)$((NOT PRC_CAP(R,P)*RPC_PKC(R,P,C))$TOP(R,P,C,'OUT')), 8 | $ BATINCLUDE cal_fflo.mod OUT O '*(-(NCAP_PKCNT(R,V,P,S)**RPC_PKF(R,P,C)))$RPC_PKF(R,P,C)' 9 | (G_YRFR(R,S)*SUM(RTP_CPTYR(R,V,T,P),PRC_CAPACT(R,P)* 10 | NCAP_PKCNT(R,V,P,S)*COEF_CPT(R,V,T,P)* 11 | (%VARV%_NCAP(R,V,P %SWS%)$MILESTONYR(V)+NCAP_PASTI(R,V,P)$PASTYEAR(V))))) 12 | -------------------------------------------------------------------------------- /eqptrans.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQPTRANS is the flow-to-flow transformation constraint 7 | *=============================================================================* 8 | * Questions/Comments: 9 | * - EQ_PTRANS is dropped if substition for FLO_FUNC activated 10 | * - EQ level according to RPS_S1, VAR_FLOs according RPCS_VAR 11 | * - COEF_PTRAN created in coef_ptr.mod 12 | *----------------------------------------------------------------------------- 13 | *$ONLISTING 14 | $SET SHP1 "" SET SHG ",P,COM_GRP,CG" 15 | $IF DEFINED RTP_FFCS $SET SHP1 "*(%SHFF%S(R,V%SHG%%SOW%))" 16 | $SET SHP1 "*(%SHFF%X(R,V,T%SHG%)$PRC_VINT(R,P))%SHP1%" 17 | *----------------------------------------------------------------------------- 18 | 19 | %EQ%_PTRANS(RTP_VINTYR(%R_V_T%,P),COM_GRP,CG,RTS(S)%SWT%)$((RPS_S1(R,P,S) * RP_STD(R,P) * 20 | * All valid tuples are in RPCC_FFUNC (REDUCE taken into account); all STG excluded 21 | SUM((RPC(R,P,C),RS_TREE(R,S,TS))$COEF_PTRAN(R,V,P,COM_GRP,C,CG,TS),1))$RPCC_FFUNC(R,P,COM_GRP,CG)).. 22 | 23 | * dependent commodities - consider that the commodity may have a COM_TS shape 24 | SUM((COM_GMAP(R,CG,C),RS_TREE(R,S,TS))$RTPCS_VARF(R,T,P,C,TS), 25 | RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)) * 26 | * [UR] model reduction %REDUCE% is set in *.run 27 | $ BATINCLUDE %cal_red% C COM TS P T 28 | ) 29 | 30 | =E= 31 | 32 | * control commodities 33 | SUM((RTPCS_VARF(R,T,P,C,TS),RS_TREE(R,S,TS))$COEF_PTRAN(R,V,P,COM_GRP,C,CG,TS), 34 | COEF_PTRAN(R,V,P,COM_GRP,C,CG,TS) * 35 | RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)) * 36 | * [UR] model reduction %REDUCE% is set in *.run 37 | $ BATINCLUDE %cal_red% C COM TS P T 38 | ) %SHP1% * (1+(ACT_FLO(R,V,P,CG,S)-1$ACT_FLO(R,V,P,CG,S))$PRC_CG(R,P,COM_GRP)) 39 | ; 40 | 41 | *$OFFLISTING 42 | -------------------------------------------------------------------------------- /eqstgaux.lin: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQSTGAUX auxiliary commodities for storage 7 | *=============================================================================* 8 | *AL Questions/Comments: 9 | * Assumption is that all auxiliary flows are at PRC_TS level; NST primary flows can be also above 10 | *-----------------------------------------------------------------------------* 11 | *$ONLISTING 12 | 13 | 14 | %EQ%_STGAUX(RTP_VINTYR(%R_V_T%,P),C,RTS(S)%SWT%)$((RPCS_VAR(R,P,C,S)*(NOT RPC_STG(R,P,C)+RPC_EMIS(R,P,C)))$RP_STG(R,P)).. 15 | 16 | * Auxiliary flow variable 17 | %VAR%_FLO(R,V,T,P,C,S %SOW%) 18 | 19 | =E= 20 | 21 | * flow depends on storage level in period T 22 | SUM(ANNUAL(SL),PRC_ACTFLO(R,V,P,C) * 23 | ( 24 | SUM(PRC_TS(R,P,TS)$TS_MAP(R,TS,S),%VAR%_ACT(R,V,T,P,TS %SOW%)/RS_STGPRD(R,TS)) * G_YRFR(R,S) - 25 | * subtract in- and output flows to/from storage during latter half of milestone year 26 | SUM(TOP(PRC_STGIPS(R,P,COM),IO), 0.5 * 27 | (%VAR%_SIN(R,V,T,P,COM,SL%SOW%)$IPS(IO) - %VAR%_SOUT(R,V,T,P,COM,SL%SOW%)$(NOT IPS(IO))) / PRC_ACTFLO(R,V,P,COM) * 28 | * storage losses (assume that Inflows and outflows occur at the mid-point of each year) 29 | ((1-STG_LOSS(R,V,P,SL))**0.5)) 30 | * For IPS, MID storage level is (1-LOSS)**(0.5) higher 31 | ) * (1+((1-STG_LOSS(R,V,P,SL))**(-0.5)-1)$PRC_MAP(R,'STK',P))) + 32 | 33 | * flow depends on storage in- or outflow in period T 34 | SUM((COM_GMAP(R,CG,COM),TOP(RPC_STG(R,P,COM),'IN'),RPCS_VAR(R,P,COM,TS))$COEF_PTRAN(R,V,P,CG,COM,C,TS), 35 | (%VAR%_SIN(R,V,T,P,COM,TS %SOW%) * COEF_PTRAN(R,V,P,CG,COM,C,TS))$((NOT PRC_MAP(R,'NST',P))+PRC_NSTTS(R,P,TS)) * 36 | RS_FR(R,S,TS) * (1+RTCS_FR(R,T,C,S,TS))) + 37 | SUM((COM_GMAP(R,CG,C),TOP(RPC_STG(R,P,COM),'OUT'),RPCS_VAR(R,P,COM,TS))$COEF_PTRAN(R,V,P,CG,C,COM,S), 38 | (%VAR%_SOUT(R,V,T,P,COM,TS %SOW%) * (1/COEF_PTRAN(R,V,P,CG,C,COM,S)))$(PRC_NSTTS(R,P,TS) EQV RPC_STGN(R,P,COM,'OUT')) * 39 | RS_FR(R,S,TS) * (1+RTCS_FR(R,T,C,S,TS))) 40 | 41 | ; 42 | 43 | $OFFLISTING 44 | -------------------------------------------------------------------------------- /eqstgaux.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQSTGAUX auxiliary commodities for storage 7 | *=============================================================================* 8 | *AL Questions/Comments: 9 | * Assumption is that all auxiliary flows are at PRC_TS level; NST primary flows can be also above 10 | *-----------------------------------------------------------------------------* 11 | *$ONLISTING 12 | 13 | 14 | %EQ%_STGAUX(RTP_VINTYR(%R_V_T%,P),C,RTS(S)%SWT%)$((RPCS_VAR(R,P,C,S)*(NOT RPC_STG(R,P,C)+RPC_EMIS(R,P,C)))$RP_STG(R,P)).. 15 | 16 | * Auxiliary flow variable 17 | %VAR%_FLO(R,V,T,P,C,S %SOW%) 18 | 19 | =E= 20 | 21 | * flow depends on storage level in period T 22 | SUM(ANNUAL(SL),PRC_ACTFLO(R,V,P,C) * 23 | ( 24 | SUM(PRC_TS(R,P,TS)$TS_MAP(R,TS,S),%VAR%_ACT(R,V,T,P,TS %SOW%)/RS_STGPRD(R,TS)) * G_YRFR(R,S) - 25 | * subtract in- and output flows to/from storage during latter half of period (from middle of M(T)) 26 | SUM(TOP(PRC_STGIPS(R,P,COM),IO), 27 | (%VAR%_SIN(R,V,T,P,COM,SL%SOW%)$IPS(IO) - %VAR%_SOUT(R,V,T,P,COM,SL%SOW%)$(NOT IPS(IO)))/PRC_ACTFLO(R,V,P,COM)) * 28 | SUM(PERIODYR(T,Y_EOH)$(YEARVAL(Y_EOH) GE M(T)), 29 | * storage losses (assume that Inflows and outflows occur at the mid-point of each year) 30 | MIN(1,YEARVAL(Y_EOH)-M(T)+MAX(0,M(T)+D(T)/2-E(T))) * ((1-STG_LOSS(R,V,P,SL))**(E(T)-YEARVAL(Y_EOH)+0.5))) 31 | * For IPS, MID storage level is (1-LOSS)**(E(T)-M(T)+0.5) higher 32 | ) * (1+((1-STG_LOSS(R,V,P,SL))**(M(T)-E(T)-MIN(0.5,MAX(0,M(T)+D(T)/2-E(T))))-1)$PRC_MAP(R,'STK',P))) + 33 | 34 | * flow depends on storage in- or outflow in period T 35 | SUM((COM_GMAP(R,CG,COM),TOP(RPC_STG(R,P,COM),'IN'),RPCS_VAR(R,P,COM,TS))$COEF_PTRAN(R,V,P,CG,COM,C,TS), 36 | (%VAR%_SIN(R,V,T,P,COM,TS %SOW%) * COEF_PTRAN(R,V,P,CG,COM,C,TS))$((NOT PRC_MAP(R,'NST',P))+PRC_NSTTS(R,P,TS)) * 37 | RS_FR(R,S,TS) * (1+RTCS_FR(R,T,C,S,TS))) + 38 | SUM((COM_GMAP(R,CG,C),TOP(RPC_STG(R,P,COM),'OUT'),RPCS_VAR(R,P,COM,TS))$COEF_PTRAN(R,V,P,CG,C,COM,S), 39 | (%VAR%_SOUT(R,V,T,P,COM,TS %SOW%) * (1/COEF_PTRAN(R,V,P,CG,C,COM,S)))$(PRC_NSTTS(R,P,TS) EQV RPC_STGN(R,P,COM,'OUT')) * 40 | RS_FR(R,S,TS) * (1+RTCS_FR(R,T,C,S,TS))) 41 | 42 | ; 43 | 44 | $OFFLISTING 45 | -------------------------------------------------------------------------------- /eqstgflo.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQSTGFLO limits the flow of storage process at flow TS-level or higher 7 | * %1 - IN/OUT 8 | * %2 - equation declaration type 9 | * %3 - bound type for %2 10 | * %4 - qualifier that bound exists 11 | *=============================================================================* 12 | *GaG Questions/Comments: 13 | * - Bound TS restricted to the PRC_TS level or above 14 | * - avoid equations if LO=0/UP=INF 15 | *----------------------------------------------------------------------------- 16 | $SET TMP (NOT PRC_MAP(R,'NST',P))+ 17 | $IF %1==OUT $SET TMP NOT 18 | *$ONLISTING 19 | 20 | %EQ%%2_STG%1(RTPC(%R_T%,P,C),S %SWT%)$((STG%1_BND(R,T,P,C,S,'%3') NE %4)$(PRC_VINT(R,P)+(NOT RPCS_VAR(R,P,C,S))) 21 | $RPS_PRCTS(R,P,S)$RPC_STG(R,P,C)$STG%1_BND(R,T,P,C,S,'%3')) .. 22 | 23 | * sum over all possible flow variables at process TS-level 24 | SUM(RPCS_VAR(R,P,C,TS)$(RS_FR(R,S,TS) * (%TMP% PRC_NSTTS(R,P,TS))), 25 | SUM(RTP_VINTYR(R,V,T,P),%VAR%_S%1(R,V,T,P,C,TS %SOW%)*RS_FR(R,S,TS)*(1+RTCS_FR(R,T,C,S,TS)))) 26 | 27 | =%2= 28 | 29 | STG%1_BND(R,T,P,C,S,'%3') 30 | ; 31 | *$OFFLISTING 32 | -------------------------------------------------------------------------------- /eqstgips.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQSTG Inter-Period Storage (IPS) and TIME-Slice Storage (TSS) * 7 | *=============================================================================* 8 | *UR Questions/Comments: 9 | * 10 | *-----------------------------------------------------------------------------* 11 | *$ONLISTING 12 | 13 | %EQ%_STGIPS(RTP_VINTYR(%R_V_T%,P),IPS %SWT%)$(((MIYR_1(V)*MIYR_1(T)+LIM(IPS))*SUM(PRC_STGIPS(R,P,C),1))$PRC_MAP(R,'STK',P)) .. 14 | 15 | * storage level in the end of period T 16 | %VAR%_ACT(R,V,T,P,'ANNUAL' %SOW%)$LIM(IPS) + 17 | SUM((IO(IPS),MODLYEAR,MIYR_1(LL))$RTP_VINTYR(R,MODLYEAR,T,P), 18 | %VAR%_ACT(R,MODLYEAR,LL-LEAD(LL),P,'ANNUAL' %SOW%)) 19 | 20 | =E= 21 | 22 | ( 23 | * storage level in the end of period T-1 24 | (SUM(TT(T-1), 25 | (%VARTT%_ACT(R,V,TT,P,'ANNUAL'%SWS%)$RTP_VINTYR(R,V,TT,P))$PRC_VINT(R,P) + 26 | (%VARTT%_ACT(R,TT,TT,P,'ANNUAL'%SWS%)$RTP_VINTYR(R,TT,TT,P))$(NOT PRC_VINT(R,P))) + 27 | * [AL] In the first period VAR_ACT is not available, but exogenous charge can be used 28 | SUM(MIYR_1(LL),%VAR%_ACT(R,V,LL-LEAD(LL),P,'ANNUAL' %SOW%))$MIYR_1(T)) * 29 | * storage losses 30 | * [AL] Initial storage level/charge is reduced to (1-LOSS)**D(T) during the period 31 | POWER(1-STG_LOSS(R,V,P,'ANNUAL'),D(T)) + 32 | 33 | * in- and output flows to/from storage 34 | * [AL] Added summing over PERIODYR, as the storage operates during the whole period 35 | SUM(TOP(PRC_STGIPS(R,P,C),IO), 36 | (%VAR%_SIN(R,V,T,P,C,'ANNUAL' %SOW%)$IPS(IO) - %VAR%_SOUT(R,V,T,P,C,'ANNUAL' %SOW%)$(NOT IPS(IO))) * 37 | * storage losses 38 | * [AL] Inflows and outflows occur, on average, at the mid-point of each year 39 | SUM(PERIODYR(T,Y_EOH),((1-STG_LOSS(R,V,P,'ANNUAL'))**(E(T)-YEARVAL(Y_EOH)+0.5))) / PRC_ACTFLO(R,V,P,C) 40 | ) 41 | )$LIM(IPS) + 42 | * Exogenous charge at BOH 43 | SUM((IO(IPS),MIYR_1(LL)),STG_CHRG(R,LL-LEAD(LL),P,'ANNUAL')) 44 | ; 45 | $OFFLISTING 46 | 47 | -------------------------------------------------------------------------------- /equ_ext.dsc: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * EQ_EXT.dsc declarations & call for actual DSC equations 7 | * %1 - mod or v# for the source code to be used 8 | *=============================================================================* 9 | * Questions/Comments: 10 | *----------------------------------------------------------------------------- 11 | $ IFI NOT %DSC%==YES $EXIT 12 | *----------------------------------------------------------------------------- 13 | * Discrete investments 14 | 15 | EQUATIONS 16 | %EQ%_DSCNCAP(R,ALLYEAR,P%SWTD%) 'Discrete capacity extension (=E=)' 17 | %EQ%_DSCONE(R,ALLYEAR,P%SWTD%) 'Discrete capacity extension unity condition (=E=)' 18 | ; 19 | $ IF '%STAGES%'==YES $%WITSPINE% %SW_STVARS% 20 | *----------------------------------------------------------------------------- 21 | %EQ%_DSCNCAP(RTP(%R_T%,P)%SWT%)$PRC_DSCNCAP(R,P).. 22 | 23 | %VAR%_NCAP(R,T,P%SOW%) =E= 24 | 25 | SUM(UNIT$NCAP_DISC(R,T,P,UNIT), %VAR%_DNCAP(R,T,P%SOW%,UNIT)*NCAP_DISC(R,T,P,UNIT)) + 26 | %VAR%_SNCAP(R,T,P%SOW%)$NCAP_SEMI(R,T,P); 27 | 28 | %EQ%_DSCONE(RTP(%R_T%,P)%SWT%)$(NCAP_DISC(R,T,P,'0')$PRC_DSCNCAP(R,P)).. 29 | 30 | SUM(UNIT$NCAP_DISC(R,T,P,UNIT), %VAR%_DNCAP(R,T,P%SOW%,UNIT)) =E= 1; 31 | 32 | *----------------------------------------------------------------------------- 33 | -------------------------------------------------------------------------------- /err_stat.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * ERR_STAT.MOD checks/displays GAMS/Solver Errors 7 | * %1 - Condition to be checked or 'SOLVE' used 8 | * %2 - Action or Condition to be checked 9 | * %3 - Error Message if Not SOLVE 10 | *=============================================================================* 11 | *GaG Questions/Comments: 12 | * - for %system.filesys% == UNIX file /dev/tty 13 | * - does not affect stopping BAT 14 | *------------------------------------------------------------------------------ 15 | *$ONLISTING 16 | $ IFI NOT %SHELL%==ANSWER $SET TMP END_GAMS 17 | $ IFI %SHELL%==ANSWER $SET TMP END_GAMS.STA 18 | $ IF "%1" == SOLVE $GOTO SOLVE 19 | $ IF DEFINED SOLVESTAT $GOTO ACTION 20 | *------------------------------------------------------------------------------ 21 | SET SOLVESTAT(J) / 22 | 1 "Optimal" 23 | 2 "Locally optimal" 24 | 3 "Unbounded" 25 | 4 "Infeasible" 26 | 5 "Locally infeasible" 27 | 6 "Intermediate infeasible" 28 | 7 "Intermediate nonoptimal" 29 | 8 "Integer solution" 30 | 9 "Intermediate non-integer" 31 | 10 "Integer infeasible" 32 | 11 "Lic problem" 33 | 12 "Error unknown" 34 | 13 "Error no solution" 35 | 14 "No solution returned" 36 | 15 "Solved unique" 37 | 16 "Solved locally unique" 38 | 17 "Solved singular" 39 | 18 "Unbnd no solution" 40 | 19 "Infes no solution" 41 | /; 42 | FILE SCREEN / '' /; 43 | FILE END_GAMS / %TMP% /; 44 | *------------------------------------------------------------------------------ 45 | $LABEL ACTION 46 | 47 | $ IF %ERR_ABORT%==NO $GOTO DONE 48 | %4; 49 | * compile or GAMS execute error 50 | $IF NOT ERRORFREE $ECHO %3%5 > %TMP% 51 | IF(execerror,PUT END_GAMS "%3%5"; PUTCLOSE); 52 | %1 $%2 "%3" 53 | $GOTO DONE 54 | 55 | $LABEL SOLVE 56 | Z = MIN(14,%MODEL_NAME%.MODELSTAT)-1; IF(Z > 18, Z=11); 57 | IF(Z>=0,PUT SCREEN /"--- TIMES Solve status: "; 58 | LOOP(SAMEAS(J,'1'), PUT SOLVESTAT.TE(J+Z)); 59 | PUTCLOSE; 60 | PUT END_GAMS "Solve status: "; 61 | LOOP(SAMEAS(J,'1'), PUT SOLVESTAT.TE(J+Z) /); 62 | PUTCLOSE; 63 | Z = ABS(ABS(2*%MODEL_NAME%.MODELSTAT-9)-6)); 64 | IF(Z>1.5 OR %MODEL_NAME%.MODELSTAT=7,execerror=1); 65 | $IF %ERR_ABORT%==NO Z=0; 66 | * [UR] allow solution "optimal with unscaled infeasibilities" 67 | * -- allow even "intermediate non-optimal" for investigation 68 | *ABORT$((%MODEL_NAME%.MODELSTAT GT 1) OR (%MODEL_NAME%.SOLVESTAT GT 1)) '*** ERRORS IN OPTIMIZATION ***' 69 | ABORT$(Z>1.5) '%2'; 70 | IF(execerror,execerror=0); 71 | $LABEL DONE 72 | *$OFFLISTING 73 | ; 74 | -------------------------------------------------------------------------------- /fillcost.gms: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2023 IEA-ETSAP. Licensed under GPLv3 (see file NOTICE-GPLv3.txt). 3 | ******************************************************************************* 4 | * FILLCOST : Fill cost parameters 5 | * Description: Dense interpolation/extrapolation of cost parameters 6 | * Parameters: 7 | * %1 - table name 8 | * %2 - control set 1 (before year index) 9 | * %3 - control set 2 (after year index) 10 | * %4 - UNCD7 residual dimension 11 | * %5 - CKEYERS2 or EOHYEARS depending on cost parameter 12 | * %6 - Validity Qualifier restricting interpolation 13 | * %7 - Qualifier restricting backward extrapolation 14 | * %8 - Qualifier restricting forward extrapolation 15 | * %9 - Original data table 16 | * %10 - Write cache 17 | ******************************************************************************* 18 | *$ONLISTING 19 | $ EOLCOM ! 20 | $SETLOCAL SRC '%9' SETLOCAL DATA '%10(%2,%3,%5)' SETLOCAL TAKE '$%6' SETLOCAL TMP %3%4 21 | $IF DIMENSION 8 %9 $SETLOCAL TMP %4 22 | PARAMETER %10(%2,%3,ALLYEAR); 23 | IF(YES,OPTION CLEAR=UNCD7; 24 | $IF '%11'==1 %1(%2,DATAYEAR,%3) $= %9(%2,DATAYEAR,%3)%TAKE%; 25 | $IF '%11'==1 $SETLOCAL TAKE '' SETLOCAL SRC %1 26 | UNCD7(%2,LL--ORD(LL),%TMP%)%TAKE% $= %SRC%(%2,LL,%3); 27 | LOOP(UNCD7(%2,YEAR,%TMP%), F=0; LAST_VAL=0; 28 | OPTION CLEAR=MY_FIL2; MY_ARRAY(DM_YEAR)= %SRC%(%2,DM_YEAR,%3); 29 | * do linear interpolation 30 | LOOP(DM_YEAR(LL)$MY_ARRAY(DM_YEAR), ! check for nonzero 31 | MY_F = MY_ARRAY(LL); Z = YEARVAL(LL); 32 | IF(LAST_VAL, LAST_VAL=(MY_F-LAST_VAL)/(Z-MY_FYEAR); 33 | FOR(CNT=MY_FYEAR-Z+1 TO -1, MY_FIL2(%5(LL+CNT)) = MY_F+LAST_VAL*CNT;); 34 | ELSE F = Z; FIRST_VAL = MY_F;); 35 | LAST_VAL = MY_F; MY_FYEAR=Z); ! remember the value and year 36 | * Do back/forward extrapolate 37 | $IF '%11'==2 MY_FIL2(%5) $= MY_ARRAY(%5); 38 | %DATA% $= FIRST_VAL$(%7(YEARVAL(%5) LT F)) + MY_FIL2(%5) + LAST_VAL$(%8(YEARVAL(%5) GT Z)); 39 | ); 40 | ); 41 | $IF NOT '%11'==2 %1(%2,%5,%3) $= %DATA%; OPTION CLEAR=%10; 42 | $IF '%11'==2 %10('EMPTY',%3,'EMPTY')=0; 43 | $OFFLISTING 44 | -------------------------------------------------------------------------------- /fillsow.stc: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | ******************************************************************************* 6 | * FILLSOW : Fill stochastic parameters 7 | * Description: Preprocessing of stochastic uncertain data 8 | * Parameters: 9 | * %1 - table name 10 | * %2 - control set 1 (before year index) 11 | * %3 - control set 2 (after year index) 12 | * %4 - Source data years T/LL 13 | * %5 - YES/NO for absolute/relative parameters 14 | * %6 - PERIOD control (SW_T OR PERIODYR OR SUPERYR) 15 | * %7 - YES/NO to copy baseline parameters 16 | ******************************************************************************* 17 | *$ONLISTING 18 | $SETLOCAL TAIL ',%3' SETLOCAL STG '' SETLOCAL IX "'0'" 19 | $IF '%3' == '' $SETLOCAL TAIL '' 20 | $IF '%4' == '' $SETLOCAL IX '' 21 | $IF '%4' =='T' $SETLOCAL STG SW_TSTG(T,J)$ 22 | 23 | * Clean up stage 1 from invalid SOW: 24 | S_%1(%2%4%TAIL%,'1',SOW)$(NOT SAMEAS(SOW,'1')) = 0; 25 | 26 | * Set up data indicators 27 | $IF NOT '%4'=='' S_%1(%2LL--ORD(LL)%TAIL%,J,WW) $= S_%1(%2LL%TAIL%,J,WW); 28 | F = CARD(S_%1); 29 | 30 | * Copy parameters from first to other branches when appropriate 31 | S_%1(%2%4%TAIL%,J,WW)$(%STG%(NOT S_%1(%2%IX%%TAIL%,J,WW))) $= SUM(SW_CPMAP(J,WW,SOW),S_%1(%2%4%TAIL%,J,SOW)); 32 | 33 | $IF NOT '%5' == 'YES' $EXIT 34 | 35 | * Update data indicators if eventual copy occurred 36 | $IF NOT '%4'=='' IF(CARD(S_%1)>F, S_%1(%2LL--ORD(LL)%TAIL%,J,WW) $= S_%1(%2LL%TAIL%,J,WW)); 37 | 38 | * Copy baseline parameters to stage 1, SOW 1: 39 | $IF '%7'==YES S_%1(%2%4%TAIL%,'1','1')$(NOT S_%1(%2%IX%%TAIL%,'1','1')) $= %1(%2%4%TAIL%); 40 | 41 | * Merge to single stage 1: 42 | 43 | $IFI NOT '%4'==LL LOOP(J$SW_START(J),S_%1(%2%4%TAIL%,'1',WW)$(%STG%%6) $= SUM(SW_REV(WW,J,SOW),S_%1(%2%4%TAIL%,J,SOW))); 44 | $IFI '%4' == LL LOOP(SW_TSTG(T,J), S_%1(%2%4%TAIL%,'1',WW)$(%6$SW_T(T,WW)) $= SUM(SW_REV(WW,J,SOW),S_%1(%2%4%TAIL%,J,SOW))); 45 | 46 | * Remove flags if LL 47 | $IF '%4'=='LL' S_%1(%2%IX%%TAIL%,J,WW) = 0; 48 | -------------------------------------------------------------------------------- /fillvint.gms: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2023 IEA-ETSAP. Licensed under GPLv3 (see file NOTICE-GPLv3.txt). 3 | ******************************************************************************* 4 | * FILLVINT : Optional weighting of vintaged attributes 5 | * %1 - table name 6 | * %2 - Control set 1 7 | * %3 - Control set 2 8 | * %4 - Name for temporary cache 9 | ******************************************************************************* 10 | *$ONLISTING 11 | $ IF NOT '%4'=='' $GOTO FILL 12 | *------------------------------------------------------------------------------ 13 | * Initialization 14 | OPTION CLEAR=PRC_YMIN,CLEAR=PASTSUM; 15 | $IF %VINTOPT%==2 PRC_SIMV(PRC_VINT(R,P)) = NOT PRC_MAP(R,'STG',P); 16 | $IF DEFINED PRC_SIMV PRC_SIMV(R,P)$PRC_MAP(R,'STG',P) = NO; PRC_VINT(PRC_SIMV) = YES; 17 | * Make sure that all PRC_VINT have first leading V in RTP: 18 | LOOP(T(LL),RVP(R,V(LL-LEAD(T)),P)$((NOT RVP(R,V,P))$RVP(R,T,P)$PRC_VINT(R,P)) = YES); 19 | $IF DEFINED PRC_SIMV RTP(RVP(R,V,P)) $=PRC_SIMV(R,P); 20 | $EXIT 21 | *------------------------------------------------------------------------------ 22 | $ LABEL FILL 23 | PARAMETER %4(%2,%3,ALLYEAR); 24 | IF(CARD(PASTSUM)=0, 25 | PASTSUM(RTP(R,T,P))$PRC_VINT(R,P) = 26 | MIN(1,(MAX(YEARVAL(T)-(LEAD(T)-1)/2,B(T)+MAX(NCAP_ILED(RTP),(D(T)+NCAP_ILED(RTP)-NCAP_TLIFE(RTP))/2)) - 27 | (YEARVAL(T)-LEAD(T))) / LEAD(T))); 28 | TRACKP(PRC_VINT) = YES; 29 | $IF DEFINED PRC_SIMV TRACKP(PRC_SIMV) = NO; 30 | * Weighted average of vintages T and T-1 31 | LOOP((T(LL),V(LL-LEAD(LL))), 32 | %4(%2,%3,T)$(%1(%2,T,%3)$TRACKP(R,P)) = %1(%2,T,%3)*PASTSUM(R,T,P)+%1(%2,V,%3)*(1-PASTSUM(R,T,P))); 33 | %1(%2,T,%3) $= %4(%2,%3,T); 34 | OPTION CLEAR=%4,CLEAR=TRACKP; 35 | $OFFLISTING 36 | -------------------------------------------------------------------------------- /fillwave.gms: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2023 IEA-ETSAP. Licensed under GPLv3 (see file NOTICE-GPLv3.txt). 3 | ******************************************************************* 4 | * FILLWAVE : Fill parameters via weighted centered averaging 5 | * %1 - table name 6 | * %2 - index set (after year index) 7 | ******************************************************************* 8 | $ SET TMP OBJ_DISC(R,LL,CUR)/COEF_PVT(R,T) 9 | $ IF '%CTST%'=='' $SET TMP 1/D(T) 10 | SET REG_%2(REG,%2); 11 | IF(CARD(VDA_DISC)=0,VDA_DISC(R,MIYR_1)=1; LOOP((G_RCUR(R,CUR),T(TT+1)),VDA_DISC(R,Y_EOH(LL))$PERIODYR(T,LL)=%TMP%)); 12 | OPTION REG_%2 <= %1; DONE=SMAX(T,M(T)); 13 | LOOP(REG_%2(R,%2), OPTION CLEAR=FIL2; 14 | MY_ARRAY(DM_YEAR)=%1(R,DM_YEAR,%2); MY_F=0; Z=0; 15 | * interpolate densely 16 | LOOP(DM_YEAR(LL)$MY_ARRAY(LL), 17 | LAST_VAL=MY_F; F=Z; MY_F=MY_ARRAY(LL); Z=YEARVAL(LL); 18 | IF(LAST_VAL, FOR(CNT=F-Z+1 TO -1, FIL2(LL+CNT)=MY_F+(MY_F-LAST_VAL)/(Z-F)*CNT))); 19 | IF(DONE=Z$%3,FIL2(Y_EOH)$(YEARVAL(Y_EOH)>Z)=MY_F); 20 | * weighted centered average 21 | %1(R,T,%2) = SUM(PERIODYR(T,Y_EOH(LL)),(MY_ARRAY(LL)+FIL2(LL))*VDA_DISC(R,LL))); 22 | -------------------------------------------------------------------------------- /filparam.gms: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2023 IEA-ETSAP. Licensed under GPLv3 (see file NOTICE-GPLv3.txt). 3 | ******************************************************************************* 4 | * FILPARAM : Fill parameter 5 | * Description: Dense interpolation/extrapolation of parameters 6 | * Parameters: 7 | * %1 - table name 8 | * %2 - control set 1 (before year index) 9 | * %3 - control set 2 (after year index) 10 | * %4 - UNCD7 residual dimension 11 | * %5 - Source data years (e.g. ALLYEAR, DM_YEAR) 12 | * %6 - Target data years (e.g. ALLYEAR, MILESTONYR) 13 | * %7 - Qualifier restricting backward extrapolation 14 | * %8 - Qualifier restricting forward extrapolation 15 | * %9 - Default interpolation option 16 | ******************************************************************************* 17 | *$ONLISTING 18 | $ EOLCOM ! 19 | $SETLOCAL SRC '%1' SETLOCAL TAIL1 '%3' SETLOCAL TAIL2 ',%3' 20 | $IF '%3' == '' $SETLOCAL TAIL1 "''" SETLOCAL TAIL2 '' 21 | $IF '%10'=='' IF(YES, OPTION CLEAR = UNCD7; LOOP((%2%5%TAIL2%)$%SRC%(%2%5%TAIL2%), UNCD7(%2%TAIL1%%4) = YES)); 22 | $IF NOT '%10'=='' IF(YES, OPTION CLEAR = UNCD7; UNCD7(%2LL--ORD(LL),%TAIL1%%4)$%SRC%(%2LL%TAIL2%) = YES); 23 | LOOP(UNCD7(%2%10%TAIL1%%4), F=0; Z=INF; MY_FYEAR=9999; 24 | DFUNC = ROUND(%SRC%(%2'%DFLBL%'%TAIL2%)); 25 | $IF NOT %9=='' IF(NOT DFUNC, DFUNC = %9); 26 | IF(DFUNC GE 0, 27 | MY_ARRAY(%5) = %SRC%(%2%5%TAIL2%); MY_ARRAY('%DFLBL%')=0; 28 | * do interpolate 29 | LOOP(%5$MY_ARRAY(%5), ! check for nonzero (including EPS) 30 | MY_F = MY_ARRAY(%5); Z = YEARVAL(%5); 31 | IF(Z > MY_FYEAR+1, ! linear interpolation 32 | %1(%2%6%TAIL2%)$((Z GT YEARVAL(%6))$(YEARVAL(%6) GT MY_FYEAR)) 33 | = LAST_VAL + (MY_F-LAST_VAL)/(Z-MY_FYEAR)*(YEARVAL(%6)-MY_FYEAR); ! not the first one 34 | ELSEIF Z LT MY_FYEAR, F=Z; FIRST_VAL = MY_F); 35 | LAST_VAL = MY_F; MY_FYEAR=Z); ! remember the value and year 36 | * Do back/forward extrapolate 37 | IF(DFUNC GT 1, DFUNC=MOD(DFUNC,10); 38 | IF(DFUNC EQ 2, FIRST_VAL=EPS; LAST_VAL=EPS; ELSEIF DFUNC EQ 4, Z=INF; ELSEIF DFUNC EQ 5, F=0)); 39 | IF(DFUNC NE 1, 40 | %1(%2%6%TAIL2%) $= FIRST_VAL$(%7(YEARVAL(%6) LT F)) + LAST_VAL$(%8(YEARVAL(%6) GT Z)); 41 | )); 42 | ); 43 | $OFFLISTING 44 | -------------------------------------------------------------------------------- /filshape.gms: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2023 IEA-ETSAP. Licensed under GPLv3 (see file NOTICE-GPLv3.txt). 3 | ******************************************************************************* 4 | * FILSHAPE : Fill shape parameters 5 | * Description: Dense interpolation/extrapolation of shape values 6 | * Parameters: 7 | * %1 - Limit for forward extrapolation (MAXLIFE) 8 | ******************************************************************************* 9 | *$ONLISTING 10 | $ EOLCOM ! 11 | SET AGEFIL(AGE); 12 | LOOP(J, Z = 0; MY_FYEAR = 9999; 13 | * do interpolate 14 | AGEFIL(AGE) = YES$SHAPE(J,AGE); 15 | LOOP(AGE$AGEFIL(AGE), ! check for nonzero (including EPS) 16 | MY_F = SHAPE(J,AGE); Z = ORD(AGE); 17 | IF(Z > MY_FYEAR+1, ! linear interpolation 18 | SHAPE(J,LIFE)$((ORD(LIFE) GT MY_FYEAR)$(Z GT ORD(LIFE))) 19 | = LAST_VAL + (MY_F-LAST_VAL)/(Z-MY_FYEAR)*(ORD(LIFE)-MY_FYEAR); 20 | ELSEIF Z LT MY_FYEAR, F = Z;); 21 | LAST_VAL = MY_F; MY_FYEAR=Z;); ! remember the value and year 22 | * Do back/forward extrapolate 23 | IF(Z, SHAPE(J,LIFE)$(ORD(LIFE) LT F) = 1; 24 | SHAPE(J,LIFE)$((ORD(LIFE) GT Z)$(ORD(LIFE) LE %1)) = LAST_VAL;); 25 | ); 26 | $OFFLISTING 27 | -------------------------------------------------------------------------------- /forcupd.cli: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *---------------------------------------------------------------------------- 6 | * FORCUPD.cli - Climate Module forcing function update 7 | *---------------------------------------------------------------------------- 8 | $SET CH4_PRE 700 9 | $SET N2O_PRE 270 10 | $SET FOFO (0.47*LOG(1 + 2.01E-5*(F*Z)**0.75 + 5.31E-15*F*(F*Z)**1.52)-MY_SUM) 11 | 12 | LOOP(CM_ATMAP(CM_EMIS,CM_HISTS), CM_RESULT(CM_HISTS,LL)$CM_LED(LL) = 13 | SUM(CM_BOXMAP(CM_EMIS,CM_VAR,CM_BOX)$CM_PHI(CM_EMIS,CM_BOX,CM_EMIS),VAR_CLIBOX.L(CM_VAR,LL))/CM_PPM(CM_EMIS)); 14 | F=%CH4_PRE%; Z=%N2O_PRE%; MY_SUM=0; MY_SUM=%FOFO%; 15 | LOOP(LL$CM_LED(LL), 16 | *...methane 17 | F = MAX(1,CM_RESULT('CH4-PPB',LL)-.5); Z = %N2O_PRE%; 18 | FIRST_VAL = .036*(SQRT(F)-SQRT(%CH4_PRE%)) - %FOFO%; F=F+1; 19 | LAST_VAL = .036*(SQRT(F)-SQRT(%CH4_PRE%)) - %FOFO%; 20 | Z=LAST_VAL-FIRST_VAL; LAST_VAL=(FIRST_VAL+LAST_VAL)/2; 21 | CM_LINFOR(LL,'CH4-PPB','N') = Z; 22 | CM_LINFOR(LL,'CH4-PPB','FX') = LAST_VAL-Z*(F-0.5); 23 | *...nitrous 24 | F = %CH4_PRE%; Z = MAX(1,CM_RESULT('N2O-PPB',LL)-.5); 25 | FIRST_VAL = 0.12*(SQRT(Z)-SQRT(%N2O_PRE%)) - %FOFO%; Z=Z+1; 26 | LAST_VAL = 0.12*(SQRT(Z)-SQRT(%N2O_PRE%)) - %FOFO%; 27 | F=LAST_VAL-FIRST_VAL; LAST_VAL=(FIRST_VAL+LAST_VAL)/2; 28 | CM_LINFOR(LL,'N2O-PPB','N') = F; 29 | CM_LINFOR(LL,'N2O-PPB','FX') = LAST_VAL-F*(Z-0.5); 30 | ); 31 | * carbon 32 | CM_LINFOR(LL,'CO2-PPM',BDNEQ)$CM_LED(LL) = CM_RESULT('CO2-PPM',LL); 33 | $ BATINCLUDE coef_ext.cli SLOPE 34 | -------------------------------------------------------------------------------- /gdxfilter.gms: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2023 IEA-ETSAP. Licensed under GPLv3 (see file NOTICE-GPLv3.txt). 3 | *=============================================================================* 4 | * Filtering Domain Violations via GDX 5 | $ GOTO %1 6 | $ LABEL MAIN 7 | $ SET TMP "'" SET MX 8 | $ IFI %SYSTEM.FILESYS%==MSNT $SET TMP '"' 9 | DISPLAY 'GAMS Warnings detected; Data have been Filtered via GDX'; 10 | $ hiddencall gdxdump _dd_.gdx NODATA > _dd_.dmp 11 | $ hiddencall sed %TMP%/^\(Scalar\|[^$(]*([^,]*)\|[^$].*empty *$\)/{N;d;}; /^\([^$]\|$\)/d; s/\$LOAD.. /\$LOADR /I%TMP% _dd_.dmp > _dd_.dd 12 | $ IF gamsversion 301 $onFiltered 13 | * Half-baked workaround for GAMS 342 14 | $ IF %SYSTEM.GAMSVERSION%==342 15 | $ ONRECURSE $BATINCLUDE gdxfilter DAM_COST GR_VARGEN NCAP_DISC NCAP_OLIFE NCAP_SEMI PRC_DSCNCAP PRC_RCAP PRC_REACT PRC_REFIT RCAP_BLK REG_BDNCAP TM_CATT TM_UDF UC_ACTBET UC_CLI UC_FLOBET S_COM_FR S_DAM_COST S_FLO_FUNC S_NCAP_AFS 16 | $ INCLUDE _dd_.dd 17 | $ GDXIN 18 | $ IF %SYSTEM.GAMSVERSION%==342 $INCLUDE _dd_.dmp 19 | $ hiddencall rm -f _dd_.dmp 20 | $ EXIT 21 | *------------------------------------------------------------------------------ 22 | $ LABEL DAM_COST 23 | * Prepare for killing with GAMS 34.2 24 | $ LABEL MORE 25 | $ IF %1.==. $GOTO PUTOUT 26 | $ IF DECLARED %1 27 | $ IF NOT DEFINED %1 $SET MX %1 %MX% 28 | $ SHIFT GOTO MORE 29 | $ LABEL PUTOUT 30 | $ echon $KILL %MX% > _dd_.dmp -------------------------------------------------------------------------------- /globals.def: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *==============================================================================* 6 | * GLOBALS.DEF has all the declaration & defaults for SCALARS & Parameters * 7 | *==============================================================================* 8 | 9 | * global initialization and other scalar defaults which may be changed here 10 | * or overwritten in the user *.DD 11 | SCALAR G_DYEAR 'Year to discount to' / 0 /; 12 | SCALAR G_ILEDNO '1/threshold at which to ignore ILED' / 10 /; 13 | SCALAR G_TLIFE 'Default technology life if not provided' / 10 /; 14 | SCALAR G_VINT '% annual change in input data for vintaging' / .1 /; 15 | SCALAR G_NOINTERP 'Turn off interplation' / 0 /; 16 | PARAMETER G_CYCLE(TSLVL) 'Number of cycles in average year' / ANNUAL 1, SEASON 1, DAYNITE 365 /; 17 | -------------------------------------------------------------------------------- /init_ext.abs: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * INIT_EXT.xtd oversees initial preprocessor activities 7 | * %1 - mod or v# for the source code to be used 8 | *=============================================================================* 9 | SET BS_RVT(R,YEAR,T); 10 | * Get processes allowed to participate in the reserve markets per region 11 | OPTION BS_BSC0) $=BS_RTYPE(R,C); 23 | BS_ANEG(R,C) $= BS_ABD(R,C,'LO'); 24 | BS_APOS(R,C) $= BS_ABD(R,C,'UP'); 25 | * Remove invalid values 26 | BS_DEMDET(R,YEAR,RSP,C,S)$(NOT BS_RTYPE(R,C))=0; 27 | BS_OMEGA(R,YEAR,C,S)$(NOT BS_RTYPE(R,C))=0; 28 | BS_DELTA(R,YEAR,C,S)$(NOT BS_RTYPE(R,C))=0; 29 | BS_LAMBDA(R,YEAR,C)$(NOT BS_RTYPE(R,C))=0; 30 | BS_DETWT(R,YEAR,C)$(NOT BS_RTYPE(R,C))=0; 31 | BS_SIGMA(R,YEAR,C,ITEM,S)$(NOT BS_RTYPE(R,C))=0; 32 | BS_RMAX(R,YEAR,P,C,S)$(NOT BS_RTYPE(R,C))=0; 33 | BS_STIME(R,P,C,BD)$(NOT BS_RTYPE(R,C))=0; 34 | -------------------------------------------------------------------------------- /init_ext.dsc: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * INIT_EXT.xtd oversees initial preprocessor activities * 7 | * %1 - mod or v# for the source code to be used * 8 | *=============================================================================* 9 | * Questions/Comments: 10 | *----------------------------------------------------------------------------- 11 | * Handle automatic activation of discrete extension 12 | $ IF DEFINED PRC_DSCNCAP NCAP_DISC(R,T--ORD(T),P,'0')$PRC_DSCNCAP(R,P) = EPS; 13 | OPTION PRC_SEMI / block will appear for each model supported * 8 | *=============================================================================* 9 | 10 | MODEL TIMES_MACRO / 11 | 12 | $IFI %MERGE%==YES ALL /; 13 | $IFI %MERGE%==YES $EXIT 14 | *----------------------------------------------------------------------------- 15 | * Objective Function & Components 16 | *----------------------------------------------------------------------------- 17 | * Overall OBJ linear combination of the regional objs (which are built from rest) 18 | EQ_OBJ 19 | 20 | * Fixed Costs 21 | EQ_ANNFIX 22 | 23 | * Investment component 24 | EQ_ANNINV 25 | 26 | * Variable operating costs (including substitution loss in MLF) 27 | EQ_ANNVAR 28 | 29 | *----------------------------------------------------------------------------- 30 | * Core Equations 31 | *----------------------------------------------------------------------------- 32 | $ SET OBJANN NO 33 | $ BATINCLUDE mod_equa.mod CORE 34 | $ IF %MACRO%==Yes $GOTO MLF 35 | *--------------------------------------------------------------------- 36 | * MACRO equations 37 | *--------------------------------------------------------------------- 38 | EQ_UTIL 39 | EQ_CONSO 40 | EQ_DD 41 | EQ_MCAP 42 | EQ_TMC 43 | EQ_IVECBND 44 | EQ_ESCOST 45 | EQ_MPEN 46 | EQ_XCAPDB 47 | $ EXIT 48 | *--------------------------------------------------------------------- 49 | $ LABEL MLF 50 | $ IF %NONLP%==NL $GOTO NONLP 51 | *--------------------------------------------------------------------- 52 | * MACRO MLF equations 53 | *--------------------------------------------------------------------- 54 | EQ_UTILP 55 | EQ_CONSO 56 | EQ_CONDA 57 | EQ_LOGBD 58 | EQ_MACSH 59 | EQ_MACAG 60 | EQ_MACES 61 | EQ_KNCAP 62 | EQ_MCAP 63 | EQ_TMC 64 | EQ_IVECBND 65 | EQ_DD 66 | EQ_DEMSH 67 | EQ_DEMAG 68 | EQ_DEMCES 69 | EQ_ENSCST 70 | EQ_TRDBAL 71 | * EQ_MPEN 72 | * EQ_XCAPDB 73 | $ EXIT 74 | *--------------------------------------------------------------------- 75 | $ LABEL NONLP 76 | *--------------------------------------------------------------------- 77 | * MACRO MLF NLP benchmark equations 78 | *--------------------------------------------------------------------- 79 | EQ_UTIL 80 | EQ_PROD_Y 81 | EQ_AKL 82 | EQ_LABOR 83 | EQ_KNCAP 84 | EQ_MCAP 85 | EQ_TMC 86 | EQ_DD 87 | EQ_IVECBND 88 | EQ_DNLCES 89 | EQ_ENSCST 90 | EQ_TRDBAL 91 | * End of MODEL statement now in maindrv.mod 92 | -------------------------------------------------------------------------------- /mod_ext.abs: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *==================================================================* 6 | * MOD_EQUA.ABS Ancillary Balancing Services equations 7 | * called from MOD_EQUA.MOD 8 | *==================================================================* 9 | $IFI NOT %OBMAC%==YES $EXIT 10 | EQ_BS00 11 | EQ_BS01 12 | EQ_BS02 13 | EQ_BS03 14 | EQ_BS04 15 | EQ_BS05 16 | EQ_BS07 17 | EQ_BS09 18 | EQ_BS10 19 | EQ_BS11 20 | EQ_BS18 21 | EQ_BS19 22 | EQ_BS22 23 | EQ_BS23 24 | EQ_BS24 25 | EQ_BS25 26 | EQ_BS26 27 | EQ_BS27 28 | EQ_BS28 29 | -------------------------------------------------------------------------------- /mod_ext.cli: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *==================================================================* 6 | * MOD_EXT.EXT EXTENSION EQUATIONS * 7 | * called from MAINDRV.MOD * 8 | *==================================================================* 9 | %EQ%_CLITOT 10 | %EQ%_CLICONC 11 | %EQ%_CLITEMP 12 | %EQ%_CLIBEOH 13 | %EQ%_CLIMAX 14 | -------------------------------------------------------------------------------- /mod_ext.dsc: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *==================================================================* 6 | * MOD_EXT.EXT EXTENSION EQUATIONS * 7 | * called from MAINDRV.MOD * 8 | *==================================================================* 9 | $ IFI NOT %DSC%%SOLMIP%==YESYES $EXIT 10 | 11 | %EQ%_DSCNCAP 12 | %EQ%_DSCONE 13 | -------------------------------------------------------------------------------- /mod_ext.etl: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *==================================================================* 6 | * MOD_EQUA.ETL Endogenous Technological learning equations * 7 | * called from MOD_EQUA.MOD * 8 | *==================================================================* 9 | %EQ%_CUINV 10 | %EQ%_CC 11 | %EQ%_DEL 12 | %EQ%_COS 13 | %EQ%_LA1 14 | %EQ%_LA2 15 | %EQ%_EXPE1 16 | %EQ%_EXPE2 17 | %EQ%_IC1 18 | %EQ%_IC2 19 | * cluster 20 | %EQ%_CLU 21 | %EQ%_MRCLU 22 | -------------------------------------------------------------------------------- /mod_ext.ier: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *==================================================================* 6 | * MOD_EXT.EXT EXTENSION EQUATIONS * 7 | * called from MAINDRV.MOD * 8 | *==================================================================* 9 | EQE_MRKPRD 10 | EQL_MRKPRD 11 | EQG_MRKPRD 12 | EQE_MRKCON 13 | EQL_MRKCON 14 | EQG_MRKCON 15 | $IF %CHP_MODE%==YES EQL_CHPCON 16 | $IF %CHP_MODE%==YES EQL_CHPBPT 17 | $IF %CHP_MODE%==YES EQE_CHPCON 18 | $IF %CHP_MODE%==YES EQE_CHPBPT 19 | -------------------------------------------------------------------------------- /mod_ext.vda: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *============================================================================* 6 | * MOD_EXT.EXT Extension equations 7 | * Called from MAINDRV.MOD 8 | *============================================================================* 9 | 10 | %EQ%E_ACTEFF 11 | %EQ%L_CAFLAC 12 | %EQ%E_CAFLAC 13 | %EQ%L_CAPFLO 14 | 15 | %EQ%_CAPLOAD 16 | %EQ%_ACTRAMP 17 | %EQ%E_ACTUPS 18 | %EQ%L_ACTUPS 19 | %EQ%L_ACTUPC 20 | %EQ%_ACTPL 21 | %EQ%_ACTRMPC 22 | %EQ%_SLSIFT 23 | EQL_STGCCL 24 | 25 | %EQ%E_UCRTP 26 | %EQ%N_UCRTP 27 | %EQ%N_UCRTC 28 | 29 | %EQ%E_ASHAR 30 | %EQ%L_ASHAR 31 | %EQ%G_ASHAR 32 | 33 | $IF %OBMAC%==YES 34 | eq_sdlogic, eq_sudupt, eq_sdslant, eq_sdminon, eq_sudload, eq_sudtime, eq_sudpll 35 | 36 | $IFI %DUC%%OBMAC%==YESYES 37 | eq_sdind_1, eq_sdind_0 38 | 39 | $IF DEFINED UC_FLOBET 40 | %EQ%G_UCMAX, %EQ%G_UCSUMAX 41 | 42 | $IF DEFINED COM_CSTBAL 43 | EQ_OBJBAL 44 | 45 | $IFI %POWERFLO%==YES 46 | %EQ%_GR_POWFLO, %EQ%_GR_PTDFLO, %EQ%_GR_GENALL, %EQ%_GR_DEMALL, %EQ%_GR_XBND, %EQ%_GR_VIRTCAP, %EQ%_GR_VIRTBND 47 | 48 | $IF DEFINED GR_VARGEN 49 | %EQ%_RL_LOAD, %EQ%_RL_NDIS, %EQ%_RL_STCAP, %EQ%_RL_PKCAP, %EQ%_RL_THMIN 50 | 51 | $IF DEFINED RTC_MS 52 | $IF %ECB%==YES %EQ%_MSNCAP, %EQ%_MSNCAPB 53 | 54 | $IF DEFINED GG_MM 55 | EQ_GG_MFLO, EQ_GG_GAMA, EQ_GG_MBND, EQ_GG_HLIP, EQ_GG_HLEV, EQ_GG_STEP, EQ_GG_PRIO, EQ_GG_PDIF1, EQ_GG_PDIF2, EQ_GG_WEYMST, EQ_GG_WEYMTX -------------------------------------------------------------------------------- /mod_vars.cli: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * MOD_VARS.CLI lists the individual variables of CLI instances of the MODEL * 7 | *=============================================================================* 8 | * Comments: For convenience, equations are declared here as well 9 | *----------------------------------------------------------------------------- 10 | POSITIVE VARIABLES 11 | %VAR%_CLITOT(CM_VAR,LL %SWD%) 'Total emissions or forcing by milestone year' 12 | %VAR%_CLIBOX(CM_VAR,LL %SWD%) 'Quantities in the climate reservoirs' 13 | ; 14 | *----------------------------------------------------------------------------- 15 | EQUATIONS 16 | %EQ%_CLITOT(CM_VAR,T,LL %SWD%) 'Balances for the total emissions or forcing' 17 | %EQ%_CLICONC(CM_VAR,CM_BOX,T %SWD%) 'Balances for the concentration in the reservoirs' 18 | %EQ%_CLITEMP(CM_VAR,CM_BOX,T %SWD%) 'Balances for the temperature in the reservoirs' 19 | %EQ%_CLIBEOH(CM_VAR,CM_BOX,T,LL %SWD%) 'Balances for the quantities in the BEOH reservoirs' 20 | %EQ%_CLIMAX(ALLYEAR,CM_VAR %SWD%) 'Constraint for maximum climate quantities' 21 | ; 22 | OPTION CLEAR=%EQ%_CLITOT; 23 | *----------------------------------------------------------------------------- 24 | * Allow some negative emissions 25 | %VAR%_CLITOT.LO(CM_VAR,LL %SOW%)$CM_LED(LL) = MIN(-15,CM_BEMI(CM_VAR,LL)); 26 | %VAR%_CLITOT.LO(CM_VAR('FORCING'),LL%SOW%)$CM_LED(LL) = -2; -------------------------------------------------------------------------------- /mod_vars.dsc: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * MOD_VARS.EXT EXTENSION VARIABLES 7 | * called from MAINDRV.MOD 8 | *=============================================================================* 9 | *-----------------------------------------------------------------------------* 10 | * Discrete capacity extensions 11 | *-----------------------------------------------------------------------------* 12 | * Investments 13 | $SETGLOBAL SEMICONT SEMICONT 14 | SOS1 VARIABLE %VAR%_DNCAP(R,ALLYEAR,P%SWD%,UNIT); 15 | %SEMICONT% VARIABLE %VAR%_SNCAP(R,ALLYEAR,P%SWD%); 16 | 17 | * Bounds for semicont 18 | %VAR%_SNCAP.LO(R,T,P%SOW%) $= NCAP_SEMI(R,T,P); 19 | %VAR%_SNCAP.UP(R,T,P%SOW%)$NCAP_SEMI(R,T,P) = MAX(NCAP_SEMI(R,T,P),NCAP_BND(R,T,P,'UP')); -------------------------------------------------------------------------------- /mod_vars.etl: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * MOD_VARS.ETL endogenous technology change variables 7 | *=============================================================================* 8 | * %1 - source code extension 9 | *----------------------------------------------------------------------------- 10 | * VARIABLES 11 | *----------------------------------------------------------------------------- 12 | POSITIVE VARIABLES 13 | %VAR%_LAMBD(R,ALLYEAR, PRC, KP %SWD%) 14 | %VAR%_CCAP(R,ALLYEAR,PRC %SWD%) 15 | %VAR%_CCOST(R,ALLYEAR,PRC %SWD%) 16 | %VAR%_IC(R,ALLYEAR,PRC %SWD%) 17 | 18 | BINARY VARIABLES 19 | %VAR%_DELTA(R,ALLYEAR,PRC,KP %SWD%) 20 | 21 | *----------------------------------------------------------------------------- 22 | * EQUATIONS 23 | *----------------------------------------------------------------------------- 24 | EQUATIONS 25 | %EQ%_CUINV(R,ALLYEAR, PRC %SWTD%) Cumulative Capacity Definition 26 | %EQ%_CC(R,ALLYEAR, PRC %SWTD%) Cumulative Capacity Interpolation 27 | %EQ%_DEL(R,ALLYEAR, PRC %SWTD%) Delta to 1 28 | %EQ%_COS(R,ALLYEAR, PRC %SWTD%) Cumulative Cost 29 | %EQ%_LA1(R,ALLYEAR, PRC, KP %SWTD%) Constraints on lambda 1 30 | %EQ%_LA2(R,ALLYEAR, PRC, KP %SWTD%) Constraints on lambda 2 31 | %EQ%_EXPE1(R,ALLYEAR, PRC, KP %SWTD%) Experience grows 1 32 | %EQ%_EXPE2(R,ALLYEAR, PRC, KP %SWTD%) Experience grows 2 33 | %EQ%_IC1(R,ALLYEAR, PRC %SWTD%) Investments tech. change 1st period 34 | %EQ%_IC2(R,ALLYEAR, PRC %SWTD%) Investments tech. change other periods 35 | * cluster 36 | %EQ%_CLU(R,ALLYEAR, PRC %SWTD%) Cluster 37 | %EQ%_MRCLU(R,ALLYEAR, PRC %SWTD%) Multi-regional Cluster 38 | ; 39 | 40 | -------------------------------------------------------------------------------- /mod_vars.msa: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *============================================================================* 6 | * MOD_VARS.MSA Variable declarations for MACRO Stand-Alone 7 | *============================================================================* 8 | $ BATINCLUDE preppm.msa MSA 9 | *---------------------------------------------------------------------------- 10 | * MACRO Related Variables 11 | 12 | POSITIVE VARIABLES 13 | VAR_K(REG,T) total capital stock 14 | VAR_D(REG,T,COM) annual energy demands - before aeei adjustments 15 | VAR_INV(REG,T) annual investments 16 | VAR_EC(REG,T) annual energy cost 17 | VAR_SP(REG,T,COM) artificial variable for scaling shadow price of demand 18 | VAR_Y(REG,T) annual economy output (production) 19 | VAR_C(REG,T) annual consumption 20 | VAR_DEM(REG,T,COM) Decoupled demands used in the energy model 21 | VAR_CDM(R,ITEM,LL) climate change damage 22 | 23 | * Objective Function Value 24 | 25 | VARIABLES 26 | VAR_UTIL discounted log of consumption 27 | VAR_NTX(R,T,ITEM) trade (exports positive) 28 | ; 29 | OPTION CLEAR=VAR_NTX; 30 | VAR_CDM.LO(R,'N',XTP) = .01; 31 | 32 | * Enable MACRO discount rates if requested 33 | $IF DEFINED TM_UDF $SETGLOBAL OBJANN YES 34 | $IF NOT DEFINED TM_UDF OPTION CLEAR=TM_UDF; 35 | -------------------------------------------------------------------------------- /mod_vars.tm: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * MOD_VARS.MOD lists the individual variables of all instances of the MODEL 7 | *=============================================================================* 8 | * Questions/Comments: 9 | * - no need to add SOW-index to variables under MACRO 10 | *----------------------------------------------------------------------------- 11 | 12 | * Include declarations for all variables in standard TIMES 13 | $ INCLUDE mod_vars.mod 14 | 15 | SET OBVANN(OBV) / OBJINV, OBJFIX, OBJVAR /; 16 | 17 | * Activate demand variables 18 | RD_NLP(DEM) = 1; 19 | 20 | POSITIVE VARIABLES 21 | 22 | *-----------------------------------------------------------------------------* 23 | * MACRO Interface Variables 24 | * - Annual Cost Components: investment, fixed, variable costs 25 | * - Annual Demands 26 | *-----------------------------------------------------------------------------* 27 | VAR_ANNCST(OBV,R,ALLYEAR,CUR) Annualized costs 28 | VAR_DEM(R,MILESTONYR,C) Annual useful demand 29 | 30 | *-----------------------------------------------------------------------------* 31 | * MACRO variables 32 | *-----------------------------------------------------------------------------* 33 | VAR_EC(R,ALLYEAR) 'Annual energy costs in MACRO' 34 | VAR_C(R,T) 'Annual consumption in MACRO' 35 | VAR_Y(R,T) 'Annual production in MACRO' 36 | VAR_K(R,T) 'Total capital' 37 | VAR_INV(R,T) 'Annual investments in MACRO' 38 | VAR_D(R,T,CG) 'Annual useful demand in MACRO' 39 | VAR_SP(R,T,CG) 'Artificial variable for scaling shadow price' 40 | VAR_OBJCOST(R,ALLYEAR) 'Annual energy costs in TIMES' 41 | VAR_XCAP(R,YEAR,ITEM) 'Market penetration bounds - total new capacity' 42 | VAR_XCAPP(R,YEAR,P,J) 'Market penetration bounds - additional capacity' 43 | VAR_MELA(R,T,CG,J,BD) 'Step variables for elasticities' 44 | ; 45 | 46 | 47 | VARIABLES 48 | 49 | *-----------------------------------------------------------------------------* 50 | * MACRO variables 51 | *-----------------------------------------------------------------------------* 52 | VAR_UTIL Total utility 53 | VAR_NTX(R,T) Trade in numeraire 54 | ; 55 | 56 | VAR_ANNCST.LO(OBV(UCN),R,T,CUR)$(RDCUR(R,CUR)$UC_RHS(UCN,'N')) = INF; 57 | VAR_ANNCST.LO(OBV(UCN),R,T,CUR)$(RDCUR(R,CUR)$UC_RHSR(R,UCN,'N')) = INF; -------------------------------------------------------------------------------- /par_uc.rpt: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *==================================================================== 6 | * Par_uc.rpt : reporting parameters for UCs (no STAGES/SENSIS) 7 | * %1 - parameter suffix 8 | * %2 - equation prefix 9 | *-------------------------------------------------------------------- 10 | PARAMETER PAR_RTUS(R,YEAR,UC_N,S) //; 11 | PARAMETER PAR_URTS(UC_N,R,YEAR,S) //; 12 | %3PAR_UC%1(%4UC_N,'NONE','NONE','NONE') $= %2_UC.M(UC_N); 13 | %3PAR_UC%1(%4UC_N,'NONE',T,'NONE') $= %2_UCT.M(UC_N,T); 14 | %3PAR_UC%1(%4UC_N,'NONE',T,S) $= %2_UCTS.M(UC_N,T,S); 15 | %3PAR_UC%1(%4UC_N,'NONE',T,'NONE') $= %2_UCSU.M(UC_N,T); 16 | %3PAR_UC%1(%4UC_N,'NONE',T,S) $= %2_UCSUS.M(UC_N,T,S); 17 | * Handle shuffled indexes 18 | PAR_RTUS(R,'0',UC_N,ANNUAL) $= %2_UCR.M(R,UC_N); 19 | PAR_RTUS(R,T,UC_N,ANNUAL) $= %2_UCRT.M(R,T,UC_N); 20 | PAR_RTUS(R,T,UC_N,ANNUAL) $= %2_UCRSU.M(R,T,UC_N); 21 | OPTION PAR_URTS1,Z=F; ELSE Z=SUM((RS_BELOW(R,TS,S),BDNEQ(BD))$(TS_BD(S,BD)$TS_BD(TS,BD)),1)$F); 31 | IF(Z, F=(F>Z); 32 | $ BATINCLUDE pp_qaput.mod PUTOUT PUTGRP 01 '%1 Bounds conflict: Value at %6 level and below, latter ignored' 33 | PUT QLOG ' WARNING - %1: R=',%RL%,' Y=',T.TL,' %2=',%2.TL,' S=',TS.TL); 34 | IF(F, BDVAL(BD)=(NOT TS_BD(TS,BD))$BDNEQ(BD); 35 | * Clear neg bounds and those below the topmost ones 36 | $IF NOT %9=='' TS_BD(S,BDNEQ)$(TS_BD(S,BDNEQ)<0) = %9; 37 | TS_BD(S,BDVAL(BD))$SUM(RS_BELOW(R,SL,S)$TS_BD(SL,BD),1)=0; 38 | * Check the INF default for UP bounds before summing 39 | BDVAL(BDVAL('UP')) = (G_YRFR(R,TS)-SUM(RS_BELOW(R,TS,S)$TS_BD(S,'UP'),G_YRFR(R,S))) < 1E-5; 40 | TS_BD(TS,BDVAL)=SUM(RS_BELOW(R,TS,S),TS_BD(S,BDVAL)); 41 | IF((TS_BD(TS,'UP')-TS_BD(TS,'LO') < 1E-7)$(SUM(BD$TS_BD(TS,BD),1)=2), 42 | %1(R,T,%2,%3TS,%4'FX') = TS_BD(TS,'LO'); 43 | ELSE %1(R,T,%2,%3TS,%4BDVAL) $= TS_BD(TS,BDVAL)))); 44 | 45 | %1(R,T,%2,%3S,%4BDNEQ)$%1(R,T,%2,%3S,%4'FX') = 0; 46 | OPTION CLEAR=%8; 47 | *$OFFLISTING 48 | -------------------------------------------------------------------------------- /pp_lvlfc.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PP_LVLPC aggregate/inherit attributes if at different than target level 7 | * Parameter arguments must be of the form (R,V,{P/C/P,C},S[,xx]*) 8 | * %1 - attribute name (FLO_COST, FLO_TAX etc.) 9 | * %2 - 'P', 'C' 'COM' or 'P,C' depending on attribute 10 | * %3 - TS set shooting for 11 | * %4 - remaining indexes (e.g. ',CUR') 12 | * %5 - UNCD7 residual dimension 13 | * %6 - ALL_TS or TS depending on whether inheritance is allowed 14 | * %7 - YEAR set to look for data (DATAYEAR/XMILE/V/'') 15 | * %8 - Existence qualifier set or YES 16 | * %9 - Optional indicator for weighting: Use 1 if inheritance is weighted 17 | * %10 - Optional indexes between TS set items and the S index 18 | *=============================================================================* 19 | OPTION CLEAR=UNCD7; 20 | $SETLOCAL TAKE '%12' SETLOCAL REGY 'R,%7' SETLOCAL TS (NOT %3(R,%2,S))$ 21 | $SETLOCAL AWGT 'G_YRFR(R,S)/G_YRFR(R,TS)' SETLOCAL IWGT '' 22 | $IF '%7' == '' $SETLOCAL REGY 'R' 23 | $IF '%6' == 'S2' $SETLOCAL TS '' 24 | $IF '%9' == '1' $SETLOCAL AWGT '1' SETLOCAL IWGT '*G_YRFR(R,S)/G_YRFR(R,%6)' 25 | $IF '%11'=='N' $SETLOCAL TAKE $%1(R,'0',%2%10,'ANNUAL'%4) 26 | $IF '%11'=='N' %1(R,LL--ORD(LL),%2%10,S+STOA(S)%4)$(STOAL(R,S)$%1(R,LL,%2%10,S%4)) = 1; 27 | *----------------------------------------------------------------------------- 28 | * Mark to be levelized if inheritance is allowed or S is not ANNUAL: 29 | LOOP((%REGY%,%2%10,S%4)$(%TS%%1(%REGY%,%2%10,S%4)), UNCD7(%REGY%,%2%10%4%5)$(%8%TAKE%) = YES); 30 | *----------------------------------------------------------------------------- 31 | * Aggregation/inheritance to target timeslices 32 | *----------------------------------------------------------------------------- 33 | LOOP(UNCD7(%REGY%,%2%10%4%5), TS_ARRAY(S) = %1(%REGY%,%2%10,S%4); 34 | IF((NOT SUM(RS_BELOW(R,'ANNUAL',S)$TS_ARRAY(S),1))$TS_ARRAY('ANNUAL'), 35 | %1(%REGY%,%2%10,S%4)$%3(R,%2,S) = SUM(ANNUAL(%6),TS_ARRAY(%6)%IWGT%); 36 | ELSE 37 | * Leveling by simultaneous aggregation/inheritance; but only if target level value is not present 38 | LOOP(%3(R,%2,TS)$(NOT TS_ARRAY(TS)), 39 | %1(%REGY%,%2%10,TS%4) $= 40 | SUM(TS_MAP(R,TS,S)$FINEST(R,S), %AWGT% * (TS_ARRAY(S) + 41 | SUM(RS_BELOW(R,%6,S)$(TS_ARRAY(%6) AND NOT SUM(SL$RS_BELOW(R,%6,SL),TS_MAP(R,SL,S)*TS_ARRAY(SL))), 42 | TS_ARRAY(%6)%IWGT%)));))); 43 | *----------------------------------------------------------------------------- 44 | $IF '%11'==0 %1(%REGY%,%2%10,S%4)$((NOT %1(%REGY%,%2%10,S%4))$%3(R,%2,S)) $= %1(%REGY%,%2%10,'ANNUAL'%4); 45 | $IF NOT '%11'=='' %1(R,LL,%2%10,S%4)$((NOT %3(R,%2,S))%TAKE%) = 0; 46 | -------------------------------------------------------------------------------- /pp_lvlff.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PP_LVLFF set the level of FLO_FUNC attribute using aggregation/inheritance 7 | * %1 - mod or v# for the source code to be used 8 | *=============================================================================* 9 | *GaG Questions/Comments: 10 | * - Assumption is that values can be given at any levels 11 | *----------------------------------------------------------------------------- 12 | *$ONLISTING 13 | SET FFCKS(REG,PRC,CG,CG,TS) //; 14 | 15 | * check all commodities in the groups of a process at other than PRC_TS level 16 | OPTION FFCKS <= FLO_FUNC; FFCKS(R,P,CG,CG2,S)$(PRC_TS(R,P,S)+ACTCG(CG))=NO; 17 | LOOP(FFCKS(R,P,CG,COM_GRP,S)$STOA(S),CG_GRP(R,P,CG,COM_GRP) = YES); 18 | *----------------------------------------------------------------------------- 19 | * Leveling by simultaneous aggregation/inheritance 20 | *----------------------------------------------------------------------------- 21 | LOOP((CG_GRP(R,P,CG,COM_GRP),RTP(R,V,P)), 22 | TS_ARRAY(ALL_TS) = FLO_FUNC(R,V,P,CG,COM_GRP,ALL_TS); 23 | FLO_FUNC(R,V,P,CG,COM_GRP,TS)$((NOT TS_ARRAY(TS))$PRC_TS(R,P,TS)) = 24 | SUM(RS_TREE(FINEST(R,S),TS), G_YRFR(R,S) * (TS_ARRAY(S) + 25 | SUM(RS_BELOW(R,ALL_TS,S)$((NOT SUM(TS_MAP(R,SL,S)$RS_BELOW(R,ALL_TS,SL),TS_ARRAY(SL)))$TS_ARRAY(ALL_TS)), 26 | TS_ARRAY(ALL_TS))))/G_YRFR(R,TS)); 27 | *----------------------------------------------------------------------------- 28 | * Leveling by direct inheritance 29 | *----------------------------------------------------------------------------- 30 | FLO_FUNC(R,V,P,CG,COM_GRP,TS)$(NOT FLO_FUNC(R,V,P,CG,COM_GRP,TS)) $= 31 | SUM(FFCKS(R,P,CG,COM_GRP,ANNUAL)$PRC_TS(R,P,TS),FLO_FUNC(R,V,P,CG,COM_GRP,ANNUAL)); 32 | *----------------------------------------------------------------------------- 33 | 34 | *UR* after inheritance aggregation delete all data that are not specified for elements of PRC_TS 35 | * ? not a good idea since at least partially deleting the input of the user ? 36 | * 37 | * FLO_FUNC(R,T,P,CG,COM_GRP,S)$(FFCKS(R,P,CG,COM_GRP,S)*(NOT PRC_TS(R,P,S))) = 0; 38 | 39 | OPTION CLEAR = FFCKS, CLEAR = CG_GRP; 40 | *$OFFLISTING 41 | 42 | -------------------------------------------------------------------------------- /pp_lvlfs.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PP_LVLFS set the level of FLO_SUM attribute using aggregation/inheritance 7 | * %1 - mod or v# for the source code to be used 8 | *=============================================================================* 9 | *GaG Questions/Comments: 10 | * - Assumption is that values can be at any level 11 | *----------------------------------------------------------------------------- 12 | *$ONLISTING 13 | SET FSTSL(TSLVL,R,P,CG,CG,CG,S) //; 14 | 15 | * check all commodities in the groups of a process at other than PRC_TS level 16 | COEF_PTRAN(R,LL,P,CG,C,COM_GRP,S) $= FLO_SUM(R,LL,P,CG,C,COM_GRP,S)$(NOT RPCS_VAR(R,P,C,S)); 17 | OPTION FSCKS <= COEF_PTRAN; 18 | FSCK(R,P,CG,C,COM_GRP) $= SUM(FSCKS(R,P,CG,C,COM_GRP,S)$(NOT RPS_PRCTS(R,P,S)),1); 19 | LOOP(ANNUAL(TS(TSLVL)),FSTSL(TSLVL+STOAL(R,S),FSCKS(R,P,CG,C,COM_GRP,S)) = YES); 20 | *----------------------------------------------------------------------------- 21 | * Leveling by simultaneous aggregation/inheritance 22 | *----------------------------------------------------------------------------- 23 | LOOP((FSCK(R,P,CG,C,COM_GRP),RTP(R,V,P)), 24 | TS_ARRAY(ALL_TS) = FLO_SUM(R,V,P,CG,C,COM_GRP,ALL_TS); 25 | FLO_SUM(R,V,P,CG,C,COM_GRP,TS)$RPCS_VAR(R,P,C,TS) = 26 | SUM(RS_TREE(FINEST(R,S),TS), G_YRFR(R,S) * (TS_ARRAY(S) + 27 | SUM(RS_BELOW(R,ALL_TS,S)$((NOT SUM(TS_MAP(R,SL,S)$RS_BELOW(R,ALL_TS,SL),TS_ARRAY(SL)))$TS_ARRAY(ALL_TS)), 28 | TS_ARRAY(ALL_TS))))/G_YRFR(R,TS)); 29 | *----------------------------------------------------------------------------- 30 | * Leveling by direct inheritance 31 | *----------------------------------------------------------------------------- 32 | * after mixed aggregation/inheritance delete all data that are not specified at PRC_TS 33 | FLO_SUM(R,LL,P,CG,C,COM_GRP,S)$COEF_PTRAN(R,LL,P,CG,C,COM_GRP,S) = 0; 34 | FLO_SUM(R,LL,P,CG,C,COM_GRP,S)$(NOT RTP(R,LL,P)) = 0; 35 | FOR(Z=CARD(TSLVL)-2 DOWNTO 0, 36 | LOOP(SAMEAS(TSLVL-Z,'ANNUAL'), 37 | FLO_SUM(RTP(R,V,P),CG,C,COM_GRP,TS)$((NOT FLO_SUM(R,V,P,CG,C,COM_GRP,TS))$RPCS_VAR(R,P,C,TS)) $= 38 | SUM(FSTSL(TSLVL,R,P,CG,C,COM_GRP,S)$RS_BELOW(R,S,TS),COEF_PTRAN(R,V,P,CG,C,COM_GRP,S)); 39 | )); 40 | *----------------------------------------------------------------------------- 41 | OPTION CLEAR=COEF_PTRAN, CLEAR = FSCK, CLEAR = FSCKS, CLEAR=FSTSL; 42 | FLO_SUM(R,LL,P,CG,C,CG,S)$FSCKS(R,P,CG,C,CG,S) = 0; 43 | *$OFFLISTING 44 | -------------------------------------------------------------------------------- /pp_lvlif.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PP_LVLIF set the level of a IRE_FLO attribute using aggregation/inheritance 7 | * %1 - mod or v# for the source code to be used 8 | *=============================================================================* 9 | *GaG Questions/Comments: 10 | * - Assumption is that values can be at any level 11 | *----------------------------------------------------------------------------- 12 | *$ONLISTING 13 | 14 | OPTION CLEAR=UNCD7; PUTGRP = 0; 15 | *----------------------------------------------------------------------------- 16 | LOOP((REG,V,P,COM,R,C,S)$IRE_FLO(REG,V,P,COM,R,C,S), 17 | IF((NOT RPCS_VAR(R,P,C,S))$STOA(S), 18 | IF(NOT UNCD7(REG,V,P,COM,R,C,'N'), 19 | IF(NOT RPC_IRE(R,P,C,'IMP'),TRACKPC(R,P,C)=YES; 20 | ELSE UNCD7(REG,V,P,COM,R,C,'N') = YES)))); 21 | LOOP(TRACKPC(R,P,C), 22 | $ BATINCLUDE pp_qaput.%1 PUTOUT PUTGRP 02 'IRE_FLO import commodity not in TOP_IRE' 23 | PUT QLOG ' WARNING - R=',%RL%,' P=',%PL%,' C=',C.TL ); 24 | *----------------------------------------------------------------------------- 25 | * Aggregation/inheritance to target timeslices 26 | *----------------------------------------------------------------------------- 27 | LOOP(UNCD7(REG,V,P,COM,R,C,L), 28 | * Leveling by simultaneous aggregation/inheritance; but only if target level value not present 29 | TS_ARRAY(S) = IRE_FLO(REG,V,P,COM,R,C,S); 30 | IRE_FLO(REG,V,P,COM,R,C,TS)$((NOT TS_ARRAY(TS))$PRC_TS(R,P,TS)) $= 31 | SUM(RS_TREE(FINEST(R,S),TS), G_YRFR(R,S) * (TS_ARRAY(S) + 32 | SUM(RS_BELOW(R,ALL_TS,S)$((NOT SUM(TS_MAP(R,SL,S)$RS_BELOW(R,ALL_TS,SL),TS_ARRAY(SL)))$TS_ARRAY(ALL_TS)), 33 | TS_ARRAY(ALL_TS))))/G_YRFR(R,TS)); 34 | *----------------------------------------------------------------------------- 35 | * Simple direct inheritance down 36 | IRE_FLO(RTP(REG,V,P),COM,R,C,S)$((NOT IRE_FLO(REG,V,P,COM,R,C,S))$PRC_TS(R,P,S)) $= IRE_FLO(REG,V,P,COM,R,C,'ANNUAL'); 37 | OPTION CLEAR=TRACKPC, CLEAR=UNCD7; 38 | 39 | *$OFFLISTING 40 | -------------------------------------------------------------------------------- /pp_lvlus.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PP_LVLUS aggregate/inherit UC_N attributes if at different than target level 7 | * %1 - attribute name (UC_ACT, UC_FLO etc.) 8 | * %2 - other qualifying indexes before S index (e.g. ',C') 9 | * %3 - TS set shooting for (PRC_TS, RPCS etc.) 10 | * %4 - UNCD7 residual dimension 11 | * %5 - optional remaining indexes (e.g. 'IE') 12 | * %6 - optional UC_N qualifying indexes (e.g. COM_VAR) 13 | *=============================================================================* 14 | OPTION CLEAR=UNCD7; 15 | LOOP((UC_N%6,SIDE,R,T,%2,S%5)$%1(UC_N%6,SIDE,R,T,%2,S%5), 16 | IF((NOT %3(R,%7%10,S))$STOA(S),Z=STOAL(R,S); 17 | IF(UNCD7(UC_N%6,SIDE,R,%2%5,'OUT'%4), IF(Z>F, F=9; UNCD7(UC_N%6,SIDE,R,%2%5,'IN'%4)=YES); 18 | ELSE F=SMAX(%7%8_TSL(R,%7,TSL),MAX(%9+EPS,ORD(TSL)-1)); 19 | IF(Z>F, F=9; UNCD7(UC_N%6,SIDE,R,%2%5,IO%4)=YES; ELSE UNCD7(UC_N%6,SIDE,R,%2%5,'OUT'%4)=YES)))); 20 | *----------------------------------------------------------------------------- 21 | * Simultaneous aggregation/inheritance to target timeslices 22 | *----------------------------------------------------------------------------- 23 | LOOP(UNCD7(UC_N%6,SIDE,R,%2%5,IO%4), 24 | IF(IPS(IO), F=0; 25 | *...Leveling by simultaneous aggregation/inheritance; but only if target level value is not present 26 | LOOP(T, TS_ARRAY(S) = %1(UC_N%6,SIDE,R,T,%2,S%5); 27 | %1(UC_N%6,SIDE,R,T,%2,TS%5)$((NOT TS_ARRAY(TS))$%3(R,%7%10,TS)) $= 28 | SUM(RS_TREE(FINEST(R,S),TS), G_YRFR(R,S) * (TS_ARRAY(S) + 29 | SUM(RS_BELOW(R,ALL_TS,S)$((NOT SUM(TS_MAP(R,SL,S)$RS_BELOW(R,ALL_TS,SL),TS_ARRAY(SL)))$TS_ARRAY(ALL_TS)), 30 | TS_ARRAY(ALL_TS))))/G_YRFR(R,TS)) 31 | ELSEIF F, 32 | *...Inherit all from above 33 | LOOP(T, TS_ARRAY(S) = %1(UC_N%6,SIDE,R,T,%2,S%5); 34 | LOOP(RJLVL(J,R,TSL)$(ORD(TSL)<4), 35 | LOOP(TS_GROUP(R,TSL,TS),TS_ARRAY(S)$(NOT TS_ARRAY(S)) $= TS_ARRAY(TS)$RS_BELOW(R,TS,S)); 36 | %1(UC_N%6,SIDE,R,T,%2,S%5)$%3(R,%7%10,S) $= TS_ARRAY(S))); 37 | ELSE F=1)); 38 | *----------------------------------------------------------------------------- 39 | %1(UC_N%6,SIDE,R,T,%2,S%5)$(%3(R,%7%10,S)$(NOT %1(UC_N%6,SIDE,R,T,%2,S%5))) $= %1(UC_N%6,SIDE,R,T,%2,'ANNUAL'%5); 40 | OPTION CLEAR=UNCD7; -------------------------------------------------------------------------------- /pp_off.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PP_OFF sets to Start/End of the OFF period range 7 | * %1 - OFF Set name 8 | * %2 - 'C'ommodity/'P'rocess index indicator 9 | * %3 - control set 10 | * %4 - Table to set for each off-range with qualifier and one open ( 11 | * %5 - The value for the off range (EPS/NO) 12 | *=============================================================================* 13 | * Comments: Depends on BOHYEAR/EOHYEAR being ordered 1 higher than ALLYEAR 14 | *----------------------------------------------------------------------------- 15 | *$ONLISTING 16 | * Cope with multiple OFF-ranges 17 | OPTION CLEAR=FIL; 18 | LOOP(%1(R,%2,BOHYEAR,EOHYEAR)%3, STARTOFF=ORD(BOHYEAR)-2; ENDOFF=ORD(EOHYEAR); 19 | * set the flags of the shutoff period 20 | FIL(EOHYEARS(LL))$((ORD(LL) > STARTOFF)$(ORD(LL) < ENDOFF)) = YES); 21 | * open ( 22 | %4(SUM(PERIODYR(T,FIL),1)/D(T) GE G_OFFTHD(T))$FIL(T)) = %5; 23 | *$OFFLISTING 24 | -------------------------------------------------------------------------------- /pp_qaput.mod: -------------------------------------------------------------------------------- 1 | *============================================================================* 2 | * PP_QAPUT.MOD - puts out an error message 3 | * %1 - main header output flag 4 | * %2 - group header output flag 5 | * %3 - error level (e.g., WARNING, ERROR, FATAL) 6 | * %4 - group description 7 | * -- group header written on first error for group; ERRLEV holds highest errlevel 8 | *============================================================================* 9 | IF(NOT %1, %1=1; PUT QLOG @15; 10 | WHILE(QLOG.CC<67,PUT '*****'); PUT @21,'%SYSTEM.TITLE%':<>43 / @15; 11 | WHILE(QLOG.CC<67,PUT '*****'); PUT @29,'QUALITY ASSURANCE LOG':<>27; 12 | ); 13 | PUT$(NOT %2) QLOG // ' *** %4 '; 14 | 15 | * hold highest errorlevel for shutdown or not 16 | $IF NOT %3==* %2=1+1$(ROUND(%3)>9); PUT QLOG / ' *00'@(5-%2) MIN(99,%3):%2:0; ERRLEV$(%3>ERRLEV)=%3; 17 | -------------------------------------------------------------------------------- /pp_shapr.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2025 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PP_SHPRC.MOD shape a process based attribute 7 | * %1 - attribute name 8 | * %2 - driving indexes 9 | * %3 - any qualifiers to help narrow loop (if none, set to YES) 10 | * %4 - mapped coefficient 11 | * %5 - optional -M(R,V,P) or 1 12 | *=============================================================================* 13 | *AL Comments: 14 | *----------------------------------------------------------------------------- 15 | SET RTP_SHAPI(REG,ALLYEAR,PRC,BD,J,J,LL,LL); 16 | $ SETLOCAL PASS %3 17 | $ IF %3=='' $SETLOCAL PASS YES 18 | 19 | LOOP(BD,RTP_ISHPR(RTP(R,V,P))$((%1%6X(RTP,BD) GE 1.5)$%1%6X(RTP,BD)) = YES); 20 | RTP_ISHPR(RTP(R,V,P))$((%5 GE 1.5)$%5) = YES; 21 | 22 | * Prepare for start and end years 23 | OPTION CLEAR=FIL2; FIL2(V) = B(V)-YEARVAL(V); 24 | PASTSUM(RTP_ISHPR(R,V,P)) = FIL2(V)+NCAP_ILED(R,V,P)+NCAP_TLIFE(R,V,P)-1; 25 | 26 | * Shape attributes only for processes around for > 1 period 27 | %1%6X(RTP_ISHPR(R,V,P),BD)$(PASTSUM(R,V,P)-FIL2(V)+1 < D(V)) = 0; 28 | 29 | * Get hold of the shape and multi index J,JJ for each RVP, as well as start and end years 30 | LOOP(SAMEAS(J,'1'), 31 | 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; 32 | ); 33 | 34 | LOOP(SAMEAS(AGE,'1'), 35 | * Calculate average SHAPE for plants still operating in each period: 36 | %4$((%PASS%)$RTP_ISHPR(R,V,P)) = %1%2 * 37 | SUM(RTP_SHAPI(R,V,P,BD,J,JJ,LL,YEAR), EPS+MULTI(JJ,T) * 38 | SUM(PERIODYR(T,EOHYEARS)$(YEARVAL(EOHYEARS) LE MAX(B(T),YEARVAL(YEAR))), 39 | SHAPE(J,AGE+(MIN(YEARVAL(EOHYEARS),YEARVAL(YEAR))-YEARVAL(LL)))) / 40 | (MAX(1,MIN(E(T),YEARVAL(YEAR))-MAX(B(T),YEARVAL(LL))+1)))); 41 | 42 | * If no shape index is specified, set the BASE value for the attribute 43 | RTP_ISHPR(RTP(R,V,P)) = (NOT RTP_ISHPR(RTP)); 44 | %4$(RTP_ISHPR(R,V,P)$(%PASS%)) = %1%2; 45 | * Clear the temporary sets 46 | OPTION CLEAR=RTP_SHAPI,CLEAR=RTP_ISHPR,CLEAR=PASTSUM; 47 | -------------------------------------------------------------------------------- /ppm_ext.dsc: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PPM_EXT.dsc oversees extended preprocessor activities 7 | * %1 - mod or v# for the source code to be used 8 | *=============================================================================* 9 | * Questions/Comments: 10 | * 11 | *----------------------------------------------------------------------------- 12 | $ IFI NOT %DSC%==YES $EXIT 13 | *----------------------------------------------------------------------------- 14 | * Discrete capacity extensions 15 | *----------------------------------------------------------------------------- 16 | NCAP_DISC(RTP(R,T,P),'0')$PRC_DSCNCAP(R,P) = EPS$(NOT NCAP_SEMI(R,T,P)); 17 | -------------------------------------------------------------------------------- /ppm_ext.ecb: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * ppm_ext.ecb - coefficients for market sharing (economic choice behavior) 7 | *----------------------------------------------------------------------------- 8 | SET COM_GRP / '_MSVIOL_' /; 9 | SET COM / '_MSVIOL_' /; 10 | *----------------------------------------------------------------------------- 11 | $ IFI %STAGES%==YES $EXIT 12 | $ IF %MACRO%==YES $EXIT 13 | $ IFI %MACRO%==CSA $EXIT 14 | $ IFI %MACRO%==MSA $EXIT 15 | $ IF %STEPPED%==+ $EXIT 16 | $ SETGLOBAL ECB YES 17 | *----------------------------------------------------------------------------- 18 | SET COM_TMAP / (SET.REG).FIN.'_MSVIOL_'/; 19 | SET COM_LIM / (SET.REG).'_MSVIOL_'.N /; 20 | SET RTC_MS(R,YEAR,C) 'Commodities with market sharing' // ; 21 | PARAMETER COEF_LMS(R,ALLYEAR,C,P) 'Logit Market Share coefficients' // ; 22 | PARAMETER ECB_NCAPR(R,ALLYEAR,P) 'First pass LEC results' //; 23 | 24 | $ SET RESET 0 25 | $ BATINCLUDE fillparm COM_MSHGV R C ",'','','','',''" T 'RTC(R,T,C)' 'GE 0' 26 | $ BATINCLUDE fillparm NCAP_MSPRF R 'C,P,L' ",'','',''" T 'RTP(R,T,P)' 'GE 0' 27 | 28 | * Initialize probing shares 29 | 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; 30 | LOOP(RTC_MS(R,T,C), OPTION CLEAR=PRC_YMAX; 31 | PRC_YMAX(RP_FLO(PRC_CAP(R,P)))$TOP(R,P,C,'OUT') = RPC_PG(R,P,C)$(NOT RTP_OFF(R,T,P)); 32 | Z=SUM(P$PRC_YMAX(R,P),1); IF(Z, COEF_LMS(R,T,C,P)$PRC_YMAX(R,P) = -0.05 / Z)); 33 | 34 | * Complete flow controls for dummy 35 | OPTION TRACKPC < COEF_LMS, RVP < COEF_LMS, TRACKP < TRACKPC; 36 | TOP(TRACKP(R,P),'_MSVIOL_','IN') = YES; 37 | RPC_NOFLO(TRACKP,'_MSVIOL_') = YES; 38 | RPCS_VAR(TRACKP(R,P),'_MSVIOL_',ANNUAL) = YES; 39 | RTPCS_VARF(RTP_VARA(R,T,P),'_MSVIOL_',ANNUAL) = YES; 40 | IF(RPT_OPT('NCAP','1')<>1, RPT_OPT('NCAP','101')=ROUND(RPT_OPT('NCAP','1')); RPT_OPT('NCAP','1')=1); 41 | 42 | * Default values 43 | NCAP_MSPRF(R,T,C,P,L('N'))$((NOT NCAP_MSPRF(R,T,C,P,L))$COEF_LMS(R,T,C,P)) = 1; 44 | NCAP_MSPRF(R,T,C(ACTCG),P,L('UP'))$((NOT NCAP_MSPRF(R,T,C,P,L))$RVP(R,T,P)) = MAX(0,SMAX(TRACKPC(R,P,COM),NCAP_MSPRF(R,T,COM,P,L))); 45 | NCAP_MSPRF(R,T,C(ACTCG),P,L('UP'))$((NOT NCAP_MSPRF(R,T,C,P,L))$RVP(R,T,P)) = 2; 46 | 47 | * Initialize ceiling costs 48 | FLO_COST(R,DATAYEAR,P,C('_MSVIOL_'),ANNUAL,CUR)$TRACKP(R,P) $= NCAP_COST(R,DATAYEAR,P,CUR); 49 | FLO_DELIV(R,DATAYEAR,P,C('_MSVIOL_'),ANNUAL,CUR)$TRACKP(R,P) $= NCAP_FOM(R,DATAYEAR,P,CUR); 50 | OPTION CLEAR=TRACKP,CLEAR=TRACKPC,CLEAR=PRC_YMAX,CLEAR=RVP; 51 | -------------------------------------------------------------------------------- /prep_ext.abs: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PREP_ext.abs oversees all the added interpolation activities needed by ABS 7 | * %1 - mod or v# for the source code to be used 8 | *=============================================================================* 9 | * Add reserve commodities to RC 10 | RC(R,C) $= BS_RTYPE(R,C); 11 | LOOP((RP,ITEM)$GR_GENMAP(RP,ITEM),BS_K(ITEM)=YES); 12 | LOOP((R,T,C,P,BD)$BS_SHARE(R,T,C,P,BD),BS_K(P)=YES); 13 | 14 | * Bulk processing 15 | OPTION BS_RTCS < BS_DEMDET; 16 | BS_RTCS('OMEGA',R,YEAR,C,S) $= BS_OMEGA(R,YEAR,C,S); 17 | BS_RTCS('DELTA',R,YEAR,C,S) $= BS_DELTA(R,YEAR,C,S); 18 | 19 | * Interpolation/extrapolation 20 | $ BATINCLUDE fillparm BS_LAMBDA R C ",'0','0','0','0','0'" T YES '>=0' 21 | $ BATINCLUDE fillparm BS_DETWT R C ",'0','0','0','0','0'" T YES '>=0' 22 | $ BATINCLUDE fillparm BS_SIGMA R 'C,BS_K,S' ",'0','0','0'" T YES >=0 23 | $ BATINCLUDE fillparm BS_SHARE R 'C,BS_K,BD' ",'0','0','0'" T YES >=0 24 | $ BATINCLUDE fillparm BS_RTCS 'RSP,R' 'C,S' ",'0','0','0'" T YES >=0 25 | $ BATINCLUDE fillparm BS_MAINT R 'P,S' ",'0','0','0','0'" V 'RTP(R,V,P)' >=0 26 | $ BATINCLUDE fillparm BS_RMAX R 'P,C,S' ",'0','0','0'" V 'RTP(R,V,P)' >=0 27 | $ BATINCLUDE prepparm BS_BNDPRS R 'P,C,S,BD' ",'0'" T 'RTP(R,T,P)' 1 28 | 29 | * Intermediate QA clean-up 30 | BS_RTCS(RSP('OMEGA'),R,T,C,S)$BS_RTCS(RSP,R,T,C,S) = ROUND(BS_RTCS(RSP,R,T,C,S)); 31 | BS_SIGMA(R,T,C,BS_K,S)$(BS_LAMBDA(R,T,C)=0)=0; 32 | BS_RMAX(R,LL--ORD(LL),P,C,S+STOA(S)) $= (BS_RMAX(R,LL,P,C,S)>0); 33 | BS_RMAX(R,LL,P,C,S)$(NOT BS_RMAX(R,'0',P,C,'ANNUAL'))=0; 34 | BS_BNDPRS(R,T,P,C,S,BD)$((BS_LAMBDA(R,T,C)=0)$BS_BNDPRS(R,T,P,C,S,BD))=0; 35 | OPTION BS_BSC < BS_RMAX, CLEAR=BS_OMEGA; -------------------------------------------------------------------------------- /prep_ext.dsc: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PREP_EXT.dsc oversees extended preprocessor activities for DSC 7 | * %1 - mod or v# for the source code to be used 8 | *=============================================================================* 9 | * Questions/Comments: 10 | * The default option for NCAP_DISC is 10 (no interpolation/extrapolation, but migrate to milestone years) 11 | *----------------------------------------------------------------------------- 12 | $ IFI NOT %DSC%==YES $EXIT 13 | PRC_DSCNCAP(R,P) $= PRC_SEMI(R,P); 14 | 15 | * Inter-/extrapolation 16 | $ BATINCLUDE prepparm NCAP_DISC 'R' 'P,UNIT' ",'0','0','0'" MILESTONYR 'RTP(R,MILESTONYR,P)' 1 17 | 18 | * Process semicontinuous requests 19 | NCAP_SEMI(RTP(R,T,P))$PRC_DSCNCAP(R,P) = (NCAP_DISC(RTP,'0')+1)-1; 20 | NCAP_SEMI(RTP)$SUM(UNIT(J)$NCAP_DISC(RTP,UNIT),1) = 0; 21 | -------------------------------------------------------------------------------- /prep_ext.ier: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PREP_ext.vtt oversees all the added inperpolation activities needed by IER * 7 | * %1 - mod or v# for the source code to be used * 8 | *=============================================================================* 9 | 10 | *$BATINCLUDE fillparm FLO_MRKCON 'R' 'P,C,TS,BD' ",'0','0'" MODLYEAR 'RTP(R,MODLYEAR,P)' 'GE 0' 11 | *$BATINCLUDE fillparm FLO_MRKPRD 'R' 'P,C,TS,BD' ",'0','0'" MODLYEAR 'RTP(R,MODLYEAR,P)' 'GE 0' 12 | $BATINCLUDE fillparm ECT_AFCON 'R' 'P,BD' ",'0','0','0','0'" MODLYEAR 'RTP(R,MODLYEAR,P)' 'GE 0' 13 | $BATINCLUDE fillparm ECT_AFBPT 'R' 'P,BD' ",'0','0','0','0'" MODLYEAR 'RTP(R,MODLYEAR,P)' 'GE 0' 14 | 15 | *----------------------------------------------------------------------------- 16 | * Convert capacity related data for extraction condensing turbines 17 | * from electricity commodity to input commodity grooup 18 | * Assumption: original PRC_ACTUNT contains the electricity commodity of this process 19 | *----------------------------------------------------------------------------- 20 | $IF %CHP_MODE% == YES $BATINCLUDE pp_chp.ier 21 | $SETGLOBAL PEAKCHP eqpk_ect.ier 22 | -------------------------------------------------------------------------------- /prep_ext.mlf: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PREP_ext.tm oversees all the added inperpolation activities needed by MACRO * 7 | * %1 - mod or v# for the source code to be used * 8 | *=============================================================================* 9 | $ IF NOT '%CTST%'=='' MINYR = MIYR_V1; 10 | *------------------------------------------------------------------------------ 11 | * Interpolate MACRO-specific parameters 12 | $ BATINCLUDE filparam TM_EXPBND 'R,' 'P' ",'','','','',''" DATAYEAR T 13 | $ BATINCLUDE filparam TM_EXPF 'R,' '' ",'','','','',''" DATAYEAR T 14 | $ BATINCLUDE filparam TM_VOC 'R,' 'C,BD' ",'','','',''" YEAR T 15 | $ BATINCLUDE filparam TM_GR 'R,' '' ",'','','','',''" YEAR T 16 | *------------------------------------------------------------------------------ 17 | * Additions to support MACRO linear formulation 18 | SET MAG(CG) / ACT, AKL, LAB, KN, YN /; 19 | SET MR(R), PP(T), TLAST(T), DM(C), XCP(J) /1, 6, 12/; 20 | SET TM_DM(REG,COM); 21 | SET XTP(LL); 22 | ALIAS (MIYR_1,T_1,TB); 23 | ALIAS (T,TP); 24 | PARAMETER NYPER(ALLYEAR); 25 | PARAMETER CM_LED(LL); 26 | PARAMETER TM_TAXREV(R,T) //; 27 | PARAMETER TM_HDF(R,T) //; 28 | * Periods stuff 29 | PP(T+1) = YES; 30 | TLAST(T--ORD(T)) = YES; 31 | NYPER(T) = LAGT(T); 32 | NYPER(TLAST(T+1)) = NYPER(T); 33 | CM_LED(T+1)=LAGT(T); 34 | XTP(LL)$=CM_LED(LL); 35 | XTP(T) = YES; 36 | TM_PP(R,PP)=YES; 37 | 38 | MR(R) $= SUM(T$TM_GR(R,T),YES); 39 | TM_GDPGOAL(R,TB) = TM_GDP0(R); 40 | LOOP(PP(T+1),TM_GDPGOAL(R,PP) = TM_GDPGOAL(R,T)*(1+TM_GR(R,T)/100)**NYPER(T)); 41 | * Save demand LIM for non-MR 42 | OPTION TM_DM < COM_PROJ; 43 | TM_STEP(TM_DM(R,C),'N') = NOT COM_LIM(R,C,'FX'); -------------------------------------------------------------------------------- /prep_ext.tm: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * PREP_ext.tm oversees all the added inperpolation activities needed by MACRO * 7 | * %1 - mod or v# for the source code to be used * 8 | *=============================================================================* 9 | * Comments: If TM_EC0 not defined, try loading MSADDF 10 | *------------------------------------------------------------------------------ 11 | $IF NOT DEFINED TM_EC0 12 | $IF EXIST msaddf.dd $INCLUDE msaddf.dd 13 | $IF NOT DEFINED TM_EC0 OPTION CLEAR=TM_EC0; 14 | *------------------------------------------------------------------------------ 15 | * Interpolate MACRO-specific parameters 16 | $BATINCLUDE filparam TM_DDF 'R,' 'C' ",'','','','',''" DATAYEAR T '' '' 17 | $BATINCLUDE filparam TM_EXPBND 'R,' 'P' ",'','','','',''" DATAYEAR T '' '' 18 | $BATINCLUDE filparam TM_EXPF 'R,' '' ",'','','','',''" DATAYEAR T '' '' 19 | $BATINCLUDE filparam TM_GR 'R,' '' ",'','','','',''" DATAYEAR T '' '' 20 | $BATINCLUDE filparam TM_GROWV 'R,' '' ",'','','','',''" DATAYEAR T '' '' 21 | *------------------------------------------------------------------------------ 22 | * Additions to support MACRO soft-link 23 | SCALAR TM_SL /0/; 24 | SETS MR(R), PP(T), TLAST(T), DM(C), XCP(J) /1, 6, 12/; 25 | ALIAS (MIYR_1,T_1); 26 | PARAMETER NYPER(ALLYEAR); 27 | PP(T+1) = YES; 28 | TLAST(T)$(ORD(T) EQ CARD(T)) = YES; 29 | TM_SL = (ROUND(TM_ARBM,1) EQ 1); 30 | IF(TM_SL,NYPER(T) = LAGT(T); ELSE NYPER(TT(T-1)) = (D(T)+D(TT))/2); 31 | NYPER(TLAST(T+1)) = LAGT(T); 32 | LOOP(R,DM(C)$DEM(R,C)=YES); 33 | -------------------------------------------------------------------------------- /preshape.gms: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2024 IEA-ETSAP. Licensed under GPLv3 (see file NOTICE-GPLv3.txt). 3 | ******************************************************************************* 4 | * PRESHAPE : Prepare SHAPE parameters for preprocessing 5 | * Description: Interpolation of X parameter on user request 6 | * Parameters: 7 | * %1 - table name 8 | * %2 - control set 1 9 | * %3 - control set 2 10 | * %4 - residual dimension for control tuple 11 | * %5 - MODLYEAR or MILESTONYR depending on parameter 12 | * %6 - temporary table of control tuples 13 | * %7 - P/C 14 | ******************************************************************************* 15 | *$ONLISTING 16 | $EOLCOM ! 17 | $SETLOCAL TAIL ",%3" SETLOCAL DEF 10 18 | $IF '%3'=='' $SETLOCAL TAIL 19 | $IF NOT '%8'=='' $SETLOCAL DEF %8 20 | OPTION CLEAR = %6; 21 | %6(%2,LL--ORD(LL)%TAIL%%4) $= %1(%2,LL%TAIL%); 22 | LOOP(%6(%2,'%DFLBL%'%TAIL%%4), 23 | DFUNC=%DEF%; DFUNC $= MOD(ROUND(%1(%2,'%DFLBL%'%TAIL%)),1000); 24 | MY_ARRAY(DM_YEAR) = %1(%2,DM_YEAR%TAIL%); 25 | IF(DFUNC NE 10, F=0; LAST_VAL=0; 26 | * do interpolate 27 | LOOP(DM_YEAR$MY_ARRAY(DM_YEAR), ! check for nonzero (including EPS) 28 | MY_F = MY_ARRAY(DM_YEAR); Z = YEARVAL(DM_YEAR); 29 | IF(LAST_VAL, %1(%2,%5%TAIL%)$((Z>YEARVAL(%5))$(YEARVAL(%5)>MY_FYEAR)) = LAST_VAL; 30 | ELSE F = Z; FIRST_VAL = MY_F); 31 | LAST_VAL = ROUND(MY_F); MY_FYEAR=Z;); ! remember the value and year 32 | ELSE FIRST_VAL = 0; MY_FYEAR = 0; ! intra-period I/E 33 | LOOP(MY_FIL(LL)$MY_ARRAY(MY_FIL), ! check for data values 34 | MY_F = MY_ARRAY(LL); Z = YEARVAL(MY_FIL); F = FIL2(MY_FIL); 35 | IF(MY_FYEARMIN(FIRST_VAL,Z), LAST_VAL = MY_F; FIRST_VAL = F;); 36 | %1(%2,%5(LL+(F-YEARVAL(LL)))%TAIL%)$(NOT MY_ARRAY(%5)) = LAST_VAL); 37 | LAST_VAL = MY_F; MY_FYEAR=Z;); ! remember the value and year 38 | DFUNC=0; 39 | ); 40 | IF(ROUND(DFUNC-5,-1)=10, 41 | %1(%2,%5%TAIL%)$%7 $= FIRST_VAL$(YEARVAL(%5)Z)$(B(%5) LE Z); 42 | DFUNC=DFUNC-10); 43 | IF(DFUNC GE 2, 44 | * Do back/forward extrapolate 45 | IF(DFUNC=4, Z = INF; ELSEIF DFUNC=5, F = 0; ELSEIF DFUNC=(2-F), LAST_VAL=EPS; Z=0); 46 | %1(%2,%5%TAIL%)$%7 $= FIRST_VAL$(YEARVAL(%5)Z); 47 | ); 48 | ); 49 | $OFFLISTING 50 | -------------------------------------------------------------------------------- /readbprice.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * Importing sol_bprice and assigning it to parameter COM_BPRICE 7 | *=============================================================================* 8 | PARAMETER SOL_BPRICE(R,YEAR,C,TS,CUR) //; 9 | 10 | $IF NOT ERRORFREE $EXIT 11 | $KILL DAM_TVOC 12 | $SET TMP com_bprice 13 | $IFI %TIMESED%==YES $GOTO LOAD 14 | $SETLOCAL TMP %GDXPATH%%TIMESED% 15 | $IF EXIST %TMP%_DP.gdx $SETLOCAL TMP %TMP%_DP 16 | $IF NOT EXIST %TMP%.gdx $DROPLOCAL TMP 17 | $LABEL LOAD 18 | $GDXIN %TMP% 19 | $IF NOT ERRORFREE $GOTO FINISH 20 | $IFI %MACRO%==MLF $SET MX SET MACRO 'Yes' 21 | $LOAD sol_bprice 22 | $IF NOT ERRORFREE $GOTO FINISH 23 | $SETGLOBAL MX %MX% SET TIMESED 'YES' 24 | $IF DEFINED DAM_ELAST $LOAD DAM_COEF 25 | $IF DEFINED DAM_ELAST $LOAD DAM_TVOC 26 | $IFI %MACRO%==MLF $LOAD SOL_ACFR 27 | $GDXIN 28 | 29 | OPTION DEM < COM_PROJ; 30 | DEM(R,C)$COM_TMAP(R,'DEM',C) = YES; 31 | * Fill in missing tail milestoneyrs to reduce abruption 32 | OPTION FORWARD < SOL_BPRICE; FIL(T) = PROD(FORWARD(TT),ORD(TT)0)+EPS; 44 | DAM_TQTY(R,T,C)$TRACKC(R,C) $= DAM_TVOC(R,T,C,'N'); 45 | OPTION CLEAR=DAM_TVOC,CLEAR=TRACKC; 46 | *-------------------------------------------------------------------- 47 | $LABEL FINISH 48 | $IFI NOT %MACRO%==MLF $CLEARERROR 49 | -------------------------------------------------------------------------------- /rpt_ext.cli: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *----------------------------------------------------------------------------- 6 | * RPT_EXT.cli - Extension for Climate Module: Stochastic report 7 | *----------------------------------------------------------------------------- 8 | * Questions/Comments: 9 | * 10 | *----------------------------------------------------------------------------- 11 | * Calculate Reporting parameters for Climate Module 12 | 13 | *----------------------------------------------------------------------------- 14 | $IFI %SENSIS%==YES $EXIT 15 | $%SW_NOTAGS% 16 | *----------------------------------------------------------------------------- 17 | EQUATIONS 18 | %EQ%_CLITOT(CM_VAR,T,LL %SWD%) 'Balances for the total emissions or forcing' 19 | %EQ%_CLIMAX(ALLYEAR,CM_VAR %SWD%) 'Constraint for maximum climate quantities' 20 | ; 21 | 22 | VARIABLES 23 | %VAR%_CLITOT(CM_VAR,LL %SWD%) 'Total emissions or forcing by milestone year' 24 | POSITIVE VARIABLES 25 | %VAR%_CLIBOX(CM_VAR,LL %SWD%) 'Quantities in the climate reservoirs' 26 | ; 27 | *----------------------------------------------------------------------------- 28 | $IF %STAGES%==YES $%SW_TAGS% SET SWSW SW_TSW(SOW,T,WW), 29 | $IF %SCUM%==1 $SET SWSW 'SW_T(T,WW),' SET SCUM *SW_TPROB(T,WW) 30 | 31 | * Results for each SOW 32 | $IF NOT %STAGES%==YES LOOP(SOW, 33 | $IF %STAGES%==YES LOOP(AUXSOW(SOW)$SW_PROB(SOW), 34 | * Clear results from previous SOW 35 | $IF NOT %STAGES%==YES $GOTO REPORT 36 | OPTION CLEAR=VAR_CLITOT,CLEAR=VAR_CLIBOX; 37 | OPTION CLEAR=EQ_CLITOT, CLEAR=EQ_CLIMAX; 38 | LOOP(SUPERYR(T,LL)$CM_LED(LL), 39 | VAR_CLITOT.L(CM_VAR,LL) $= SUM(%SWSW% %VAR%_CLITOT.L(CM_VAR,LL%SWD%)%SCUM%); 40 | VAR_CLIBOX.L(CM_VAR,LL) $= SUM(%SWSW% %VAR%_CLIBOX.L(CM_VAR,LL%SWD%)%SCUM%); 41 | $IF %STAGES%%SCUM%==YES VAR_CLIBOX.L(CM_VAR,LL) $= %VAR%_CLIBOX.L(CM_VAR,LL,SOW); 42 | EQ_CLIMAX.M(LL,CM_VAR) $= SUM(%SWSW% %EQ%_CLIMAX.M(LL,CM_VAR%SWD%)*SW_UNPB(T,WW))); 43 | EQ_CLITOT.M(CM_VAR,T,T) $= SUM(%SWSW% %EQ%_CLITOT.M(CM_VAR,T,T%SWD%)*SW_UNPB(T,WW)); 44 | $LABEL REPORT BATINCLUDE rpt_par.cli 45 | ); 46 | IF(CARD(SOW)=1,DISPLAY CM_RESULT,CM_MAXC_M; ELSE DISPLAY CM_SRESULT,CM_SMAXC_M); 47 | *----------------------------------------------------------------------------- 48 | $IF NOT %STAGES%==YES $EXIT 49 | * Expected marginals 50 | LOOP(SUPERYR(T,LL)$CM_LED(LL), 51 | EQ_CLIMAX.M(LL,CM_VAR) $= SUM(SW_T(T,W),%EQ%_CLIMAX.M(LL,CM_VAR,W)); 52 | VAR_CLITOT.L(CM_VAR,LL) $= SUM(SW_T(T,W),SW_TPROB(T,W)*%VAR%_CLITOT.L(CM_VAR,LL,W)); 53 | VAR_CLIBOX.L(CM_VAR,LL) $= SUM(SW_T(T,W),SW_TPROB(T,W)*%VAR%_CLIBOX.L(CM_VAR,LL,W))); 54 | -------------------------------------------------------------------------------- /rptlite.rpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etsap-TIMES/TIMES_model/c1bc28d72d5b260e2ef2fd18bf1f0031e0311eea/rptlite.rpt -------------------------------------------------------------------------------- /rptmain.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * RPTMAIN.MOD is the main driver for the report writer * 7 | * %1 - mod or v# for the source code to be used * 8 | *=============================================================================* 9 | *GaG Questions/Comments: 10 | * - COM, PRC descriptions need to be taken from the COM_GMAP/PRC_MAP Sets 11 | *----------------------------------------------------------------------------- 12 | *----------------------------------------------------------------------------- 13 | * dump solution if requested 14 | $IF NOT %STAGES% == YES 15 | $IF %DUMPSOL% == 'YES' $BATINCLUDE dumpsol.%1 %1 16 | *----------------------------------------------------------------------------- 17 | $IFI %VDA% == YES $SETLOCAL SOLVEDA 1 18 | $IFI %SENSIS% == YES $GOTO FINISH 19 | $IF NOT '%SOLVEDA%'==NO $BATINCLUDE solsetv.v3 20 | $IFI %MACRO% == YES $GOTO OTHER_REP 21 | $IF DEFINED VAR_NTX $GOTO FINISH 22 | $IF %STAGES% == YES $GOTO OTHER_REP 23 | *----------------------------------------------------------------------------- 24 | * produce standard VEDA report 25 | $IFI %SOLVEDA% == 'YES' $BATINCLUDE rptmain.rpt 26 | $IFI %SOLVEDA% == '1' $BATINCLUDE rptlite.rpt S WW, "'1'," 27 | 28 | $LABEL OTHER_REP 29 | $IF %MACRO% == YES $BATINCLUDE rptmain.tm 30 | 31 | * If running stochastics, streamline reports 32 | $IF %STAGES% == YES $BATINCLUDE rptmain.stc SOW %SWS% "'1'" ",'1')" 33 | 34 | * output ETL info 35 | $IFI %ETL% == 'YES' $BATINCLUDE atlearn.etl 36 | 37 | * produce damage report 38 | $IF DEFINED DAM_COST $BATINCLUDE rpt_dam.%1 39 | *----------------------------------------------------------------------------- 40 | $LABEL FINISH 41 | 42 | * Extensions 43 | $IF NOT '%EXTEND%' == '' $BATINCLUDE main_ext.mod rpt_ext %EXTEND% 44 | 45 | * Back-end software dependent reporting routines 46 | * produce ANSWER-TIMES report 47 | $IFI %SOLANS% == YES $BATINCLUDE solputta.ans S WW, SOW, 48 | $IFI %VDA%==YES $BATINCLUDE solsetv.v3 FINISHUP -------------------------------------------------------------------------------- /rptmisc.rpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etsap-TIMES/TIMES_model/c1bc28d72d5b260e2ef2fd18bf1f0031e0311eea/rptmisc.rpt -------------------------------------------------------------------------------- /sol_flo.red: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * SOL_FLO - code associated with the substitution of flow variables 7 | * %1 - target parameter name 8 | * %2 - parameter name suffix 9 | * %3 - VAR_FLO suffix (.L or .M) 10 | *=============================================================================* 11 | $SET SHP1 "" SET SHP2 "" SET SHP3 "" SET TST '$PRC_VINT(R,P)' SET%4 V VAR 12 | $SET SHG1 ",P,%PGPRIM%,C" SET SHG ',P,CG1,C' 13 | $IF DEFINED RTP_FFCS 14 | $SET SHP1 "*(%SHFF%S(R,V%SHG1%%SOW%))" SET SHP3 "*(%SHFF%S(R,V%SHG%%SOW%))" 15 | $SET SHP1 "*(%SHFF%X(R,V,T%SHG1%)%TST%)%SHP1%" SET SHP3 "*(%SHFF%X(R,V,T%SHG%)%TST%)%SHP3%" 16 | 17 | * Non-substituted flows 18 | $IF '%2'=='' %1(R,V,T,P,C,S%5) $= %V%_FLO%3(R,V,T,P,C,S%5); 19 | 20 | * Activity flows 21 | $IF '%3'=='.L' %1%2(RTP_VINTYR(R,V,T,P),C,S%5)$PRC_TS(R,P,S) $= SUM(RPC_ACT(RP_PGACT(R,P),C),%V%_ACT%3(R,V,T,P,S%5)*PRC_ACTFLO(R,V,P,C)); 22 | $IF '%3'=='.M' %1%2(RTP_VINTYR(R,V,T,P),C,S%5)$PRC_TS(R,P,S) $= SUM(RPC_ACT(RP_PGACT(R,P),C),%V%_ACT%3(R,V,T,P,S%5)*(1/PRC_ACTFLO(R,V,P,C))); 23 | 24 | * Set NO_ACT flows to activity; they were not substituted 25 | $IF '%3'=='.L' %V%_ACT%3(RTP_VINTYR(R,V,T,P),S%5) $= SUM(RPC_PG(RP_FLO(NO_ACT(R,P)),C),%V%_FLO%3(R,V,T,P,C,S%5)*(1/PRC_ACTFLO(R,V,P,C))); 26 | $IF '%3'=='.L' %V%_ACT%3(RTP_VINTYR(R,V,T,P),S%5) $= SUM(RPC_IRE(RPC_PG(NO_ACT(R,P),C),IE)$RP_AIRE(R,P,IE),%V%_IRE%3(R,V,T,P,C,S,IE%5)*(1/PRC_ACTFLO(R,V,P,C))); 27 | $IF '%3'=='.M' %V%_ACT%3(R,V,T,P,S%5) $= SUM(RPC_PG(RP_FLO(NO_ACT(R,P)),C),%V%_FLO%3(R,V,T,P,C,S%5)*PRC_ACTFLO(R,V,P,C)); 28 | $IF '%3'=='.M' %V%_ACT%3(R,V,T,P,S%5) $= SUM(RPC_IRE(RPC_PG(NO_ACT(R,P),C),IE)$RP_AIRE(R,P,IE),%V%_IRE%3(R,V,T,P,C,S,IE%5)*PRC_ACTFLO(R,V,P,C)); 29 | *------------------------------------------------------------------------------- 30 | * Marginals for substituted flows currently not supported 31 | $IF '%3'=='.M' $EXIT 32 | *------------------------------------------------------------------------------- 33 | * FFUNC substituted flows 34 | %1%2(RTP_VINTYR(R,V,T,P),C,S%5)$(RTPCS_VARF(R,T,P,C,S)%6$RPC_FFUNC(R,P,C)) = 35 | SUM((RPC_ACT(R,P,COM),RS_TREE(R,S,TS))$%V%_ACT%3(R,V,T,P,TS%5), 36 | %V%_ACT%3(R,V,T,P,TS%5) * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,COM,S,TS)) * 37 | ( ACT_FLO(R,V,P,C,S)%SHP1% )); 38 | 39 | * Emission flows 40 | %1%2(RTP_VINTYR(R,V,T,P),C,S%5)$(RTPCS_VARF(R,T,P,C,S)%6$RPC_EMIS(R,P,C)) = 41 | SUM((FS_EMIT(R,P,C,CG1,COM),RS_TREE(R,S,TS))$%1%2(R,V,T,P,COM,TS%5), 42 | %1%2(R,V,T,P,COM,TS%5) * RS_FR(R,S,TS)*(1+RTCS_FR(R,T,COM,S,TS)) * 43 | COEF_PTRAN(R,V,P,CG1,COM,C,TS)%SHP3%); 44 | -------------------------------------------------------------------------------- /sol_ire.rpt: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *==============================================================================* 6 | * SOL_IRE - basic solution parameters for IRE flows and auxiliaries 7 | *==============================================================================* 8 | $SET SRC 'PAR_IRE(R,V,T,P,C,S,IE)' SET%1 V VAR 9 | $SET SWS %V%_IRE.L(R,V,T,P,C,S,IE%2)$(NOT RPC_AIRE(R,P,C))+(%V%_ACT.L(R,V,T,P,S%2)*PRC_ACTFLO(R,V,P,C))$RPC_AIRE(R,P,C) 10 | $SET SWD %V%_IRE.M(R,V,T,P,C,S,IE%2)$(NOT RPC_AIRE(R,P,C))+(%V%_ACT.M(R,V,T,P,S%2)/PRC_ACTFLO(R,V,P,C))$RPC_AIRE(R,P,C) 11 | $IF '%4'==) $SET SRC '%SWS%' SET SWS '0' SET SWD 0 12 | 13 | OPTION CLEAR=PAR_IRE,CLEAR=PAR_IREM; 14 | PAR_IRE(RTP_VINTYR(R,V,T,P),C,S,IE)$(RTPCS_VARF(R,T,P,C,S)$RPC_IRE(R,P,C,IE)) = %SWS%; 15 | PAR_IREM(RTP_VINTYR(R,V,T,P),C,S,IE)$(RTPCS_VARF(R,T,P,C,S)$RPC_IRE(R,P,C,IE)) = %SWD%; 16 | 17 | * emissions & auxiliary flows from IRE 18 | $IF DEFINED RTP_FFCS $SET MX "(%SHFF%S(R,V,P,COM,COM%SOW%))*" 19 | F_INOUTS(F_IOSET(R,V,T,P,COM,S,IO)) = %3 %MX% 20 | SUM(RPC_IRE(R,P,C,IE),IRE_FLOSUM(R,T,P,C,S,IE,COM,IO)*(%SRC%%4)); 21 | -------------------------------------------------------------------------------- /solsubta.ans: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2023 IEA-ETSAP. Licensed under GPLv3 (see file NOTICE-GPLv3.txt). 3 | *--------------------------------------------------------------------- 4 | * SOLSUB_TA.ANS 5 | * 6 | * Sub routine for SOLPUTTA.ANS to ouput ANSWER dumps 7 | * %1 - control set 8 | * %2 - qualifier 9 | * %3 - parameter name 10 | * %4 - region 11 | * %5 - process 12 | * %6 - commodity 13 | * %7 - vintage 14 | * %8 - timeslice 15 | * %9 - .Level/.Marginal indicator 16 | * %10 - result values 17 | * %11 - loop indices 18 | * %12 - assigned indices 19 | * - Looping over all rows and filling cells 20 | * 21 | *--------------------------------------------------------------------- 22 | $SET SOW "'1'" 23 | $IFI %STAGES%==YES $SET SOW 'SOW.TL' 24 | *--------------------------------------------------------------------- 25 | *PUT @1, 'ATTRIB', 26 | **** @17, 'SCENARIO', 27 | * @21, 'REG', 28 | * @32, 'PRC', 29 | * @57, 'COM' 30 | * @82, 'VIN' 31 | * @91, 'TS' 32 | * @:1, 'P/D' 33 | OPTION CLEAR=%1; 34 | $IF NOT %SUPZERO%==NO %1%12$%2 $= %10; 35 | $IF %SUPZERO%==NO %1%12$%2 = YES; 36 | LOOP((%1%11), 37 | * print trigger so that only output once 38 | PUT @1, '%3':0, '%9':0, %13 39 | @17, %SOW%, 40 | @21, %4, 41 | @32, %5, 42 | @57, %6, 43 | @82, %7, 44 | @91, %8, @116 45 | $IF NOT %9=='' LOOP(T, 46 | PUT (%10):12,' ':0 47 | $IF NOT %9=='' ) 48 | PUT / ; 49 | ); 50 | OPTION CLEAR=%1; 51 | 52 | -------------------------------------------------------------------------------- /solsysd.v3: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2023 IEA-ETSAP. Licensed under GPLv3 (see file NOTICE-GPLv3.txt). 3 | *----------------------------------------------------------------------------- 4 | * SOLSYSD.V3 - define system label mappings 5 | *----------------------------------------------------------------------------- 6 | $SETARGS P1 P2 P3 P4 * 7 | $SHIFT SHIFT EOLCOM %P2% GOTO %1 8 | $LABEL SYSUC SHIFT 9 | SET %P1% / %P3%%1 %1 /,%P1%MAP(%P1%,*) / %P3%%1.%1 /; 10 | $IF NOT '%2'=='' $GOTO %P1% 11 | $EXIT 12 | $LABEL %P1% SHIFT SHIFT 13 | $IF DEFINED %2%P1% %2%P1%(%1%P3%SYSUC%P4%)$=SUM(SYSUCMAP(SYSUC,U2),%2%P1%(%1%P3%U2%P4%));;%2%P1%(%1%P3%U2%P4%)$(NOT SYSUC(U2))=0; 14 | $IF NOT '%3'=='' $GOTO %P1% 15 | -------------------------------------------------------------------------------- /solve.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * SOLVE.MOD solver and solve controls 7 | *=============================================================================* 8 | *GaG Questions/Comments: 9 | *----------------------------------------------------------------------------- 10 | *$ONLISTING 11 | * Release some memory 12 | $ BATINCLUDE pp_clean.mod 13 | * get the optimizer directive file 14 | %MODEL_NAME%.OPTFILE = OPTFILEID; 15 | %MODEL_NAME%.PRIOROPT=(OPTFILEID=2); 16 | * set the model solver status 17 | %MODEL_NAME%.MODELSTAT = 0; 18 | %MODEL_NAME%.TOLPROJ= 1e-8; 19 | 20 | * MACRO: Loading solution from GDX file replaced by activating the SPOINT utility 21 | 22 | $ IF '%SOLVE_NOW%'==NO $GOTO NO_SOLVE 23 | * solve TIMES with appropriate METHOD 24 | $ IF NOT SET MIXLP $SETLOCAL MIXLP '' 25 | $ IF NOT SET NONLP $SETLOCAL NONLP '' 26 | * if ETL or DSC with binary variables use MIP 27 | $ IF '%DAMAGE%'==NLP $SETLOCAL NONLP NL 28 | $ IF '%MICRO%'==YES $SETLOCAL NONLP NL 29 | $ IF '%MACRO%'==YES $SETLOCAL NONLP NL 30 | $ IF '%ETL%' == YES $SETLOCAL MIXLP MI 31 | $ IF '%SOLMIP%'==YES $SETLOCAL MIXLP MI 32 | $ SETLOCAL METHOD '%MIXLP%%NONLP%P' 33 | $ IF %METHOD% == P $SETLOCAL METHOD LP 34 | $ IFI '%MACRO%'==YES SOLVE %MODEL_NAME% MAXIMIZING VAR_UTIL USING %METHOD%; 35 | $ IFI '%MACRO%'==YES $GOTO CHECK 36 | * solve TIMES as an LP/MIP 37 | SOLVE %MODEL_NAME% MINIMIZING objZ USING %METHOD%; 38 | 39 | $LABEL CHECK 40 | * do an check on solution errors 41 | $ BATINCLUDE err_stat.mod SOLVE '*** ERRORS DURING SOLUTION ***' 42 | 43 | * hook for GAMS-CGI WWW output 44 | $ IF %GAMS_CGI% == WWW $BATINCLUDE www_out.cgi 45 | 46 | $LABEL NO_SOLVE 47 | *$OFFLISTING 48 | -------------------------------------------------------------------------------- /timesrng.gms: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2023 IEA-ETSAP. Licensed under GPLv3 (see file NOTICE-GPLv3.txt). 3 | *============================================================================* 4 | * Create Ranging GDX at execution time 5 | *============================================================================* 6 | $ONWARNING 7 | $ONMULTI 8 | $OFFLISTING 9 | $PHANTOM EMPTY 10 | ALIAS (*,R,REG,ALLYEAR,P,RNGLIM); 11 | ALIAS (*,C,COM,J,S,T,ALL_REG,IE,CUR,BD,OBV,LL); 12 | ALIAS (*,COM_GRP,CG,ITEM,IO,UC_N,CM_VAR,CM_BOX); 13 | ALIAS (*,PRC,KP,UNIT); 14 | PARAMETER VAR_NCAPRNG(R,ALLYEAR,P,RNGLIM) / EMPTY.EMPTY.EMPTY.EMPTY 0 /; 15 | $IF EXIST timesrng.inc $INCLUDE timesrng.inc 16 | EXECUTE_UNLOAD 'timesrng',VAR_NCAPRNG; 17 | -------------------------------------------------------------------------------- /uc_act.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * UC_ACT the code associated with the activity variable in the EQ_USERCON 7 | * - %1 region summation index 8 | * - %2 period summation index 9 | * - %3 time-slice summation index 10 | * - %4 'T' or 'T+1' index 11 | * - %5 'LHS' or 'RHS' 12 | * - %6 Type of constraint (0=EACH, 1=SUCC or 2=SEVERAL) 13 | *=============================================================================* 14 | *UR Questions/Comments: 15 | * - 16 | *----------------------------------------------------------------------------- 17 | 18 | *"SUM(UC_R_SUM(R,UC_N)," or bracket "(" 19 | %1 20 | * "SUM(UC_T_SUM(UC_N,T)," or bracket "(" 21 | %2 22 | $IF %6==2 (1+(FPD(T)+(COEF_PVT(R,T)-FPD(T))$UC_ATTR(R,UC_N,'LHS','ACT','PERDISC')-1)$UC_DT(R,UC_N)) * 23 | * "SUM(UC_TS_SUM(UC_N,S)," or bracket "(" 24 | %3 25 | SUM(RTP_VINTYR(R,V,%4,P)$UC_GMAP_P(R,UC_N,'ACT',P), 26 | ( 27 | *V0.9a S reference should be TS 28 | SUM(PRC_TS(R,P,TS)$(RS_FR(R,S,TS)*RTP_VARA(R,%4,P)), 29 | %VAR%_ACT(R,V,%4,P,TS %SOW%)*UC_ACT(UC_N,%5,R,%7,P,TS)* 30 | 31 | * [AL] PROD operator is useful here: 32 | PROD(ANNUAL,RS_FR(R,S,TS)) * 33 | 34 | $IF %6==1 PROD(UC_ATTR(R,UC_N,%5,'ACT','GROWTH'), 35 | $IF %6==1 POWER(ABS(UC_ACT(UC_N,%5,R,%7,P,TS)),%8*UC_SIGN(%5)-1)) * 36 | $IF %6==S (1/G_YRFR(R,S)) * 37 | PROD(UC_ATTR(R,UC_N,%5,'ACT',UC_PERDS),FPD(%4) * 38 | PROD(UC_NEWFLO(UC_PERDS),1$(SAMEAS(V,%4)+RVPT(R,V,P,%4))/FPD(%4))) 39 | 40 | ) 41 | ) 42 | * 43 | PROD(UC_ATTR(R,UC_N,%5,'ACT','COST'),SUM(RDCUR(R,CUR),OBJ_ACOST(R,%4,P,CUR))) 44 | ) 45 | * closing bracket of %3 : 46 | ) 47 | 48 | * closing bracket of %2 : 49 | ) 50 | 51 | * closing bracket of %1 : 52 | ) 53 | 54 | -------------------------------------------------------------------------------- /uc_cap.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * UC_CAP the code associated with the VAR_CAP variable in the EQ_USERCON 7 | * - %1 region summation index 8 | * - %2 period summation index 9 | * - %3 'T' or 'T+1' or 'T-1' index 10 | * - %4 'LHS' or 'RHS' 11 | * - %5 Type of constraint (0=EACH, 1=SUCC or 2=SEVERAL) 12 | *=============================================================================* 13 | *UR Questions/Comments: 14 | * - 15 | *----------------------------------------------------------------------------- 16 | * "SUM(UC_R_SUM(R,UC_N)," or bracket ( 17 | %1 18 | * "SUM(UC_T_SUM(UC_N,T)," or bracket ( 19 | %2 20 | SUM(RTP(R,%3,P)$UC_GMAP_P(R,UC_N,'CAP',P), 21 | 22 | * VAR_CAP can always be directly used for UC_CAP 23 | %VAR%_CAP(R,%3,P %SOW%) * UC_CAP(UC_N,%4,R,%6,P) * 24 | 25 | * PROD operator needs to be 'tweaked' due to bug in older GAMS versions 26 | $IF %5==1 PROD(UC_ATTR(R,UC_N,%4,'CAP','GROWTH'), 27 | $IF %5==1 POWER(ABS(UC_CAP(UC_N,%4,R,%6,P)),%7*UC_SIGN(%4)-1)) * 28 | PROD(UC_ATTR(R,UC_N,%4,'CAP','CAPACT'),PRC_CAPACT(R,P)) * 29 | PROD(L('N'),1) 30 | ) 31 | * closing bracket of %2 : 32 | ) 33 | * closing bracket of %1 : 34 | ) 35 | 36 | $IF NOT %VDA%%5==YESS $GOTO END 37 | * Subtract offline capacity if requested 38 | * SUM or bracket ( 39 | +%2 40 | SUM(RTP(R,%3,P)$(RP_UPL(R,P,'FX')$UC_GMAP_P(R,UC_N,'CAP',P)), EPS+ 41 | UC_CAP(UC_N,%4,R,%6,P)*PROD(UC_ATTR(R,UC_N,%4,'CAP','CAPACT'),PRC_CAPACT(R,P)) * 42 | SUM(RTP_VINTYR(R,V,%3,P),(%UPSCAPS%)))$UC_ATTR(R,UC_N,%4,'CAP','ONLINE') 43 | ) 44 | $IFI NOT %ABS%==YES $GOTO END 45 | * Add reserve flows if requested 46 | +%2 47 | SUM(BS_UCMAP(UC_N,%4,R,P,C)$BS_COMTS(R,C,S),UC_FLO(UC_N,%4,R,%6,P,C,'ANNUAL') * PRC_CAPACT(R,P) * 48 | SUM((RTP_VINTYR(R,V,%3,P),BS_PRS(R,P,TS))$RS_FR(R,S,TS),RS_FR(R,TS,S) * 49 | SUM(LNX(L),%VAR%_BSPRS(R,V,T,P,C,TS,L%SOW%)$(IPS(L)+BS_SUPP(R,P)$(ABS(BS_RTYPE(R,C))>2))))) 50 | ) 51 | 52 | $LABEL END 53 | -------------------------------------------------------------------------------- /uc_cli.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * UC_CLI the UC code associated with climate variables 7 | * - %1 region summation index 8 | * - %2 period summation index 9 | * - %3 time-slice summation index 10 | * - %4 'T' or 'T+1' index 11 | * - %5 'LHS' or 'RHS' 12 | * - %6 Type of constraint (0=EACH, 1=SUCC or 2=SEVERAL) 13 | *=============================================================================* 14 | *[AL] Questions/Comments: 15 | * - 16 | *----------------------------------------------------------------------------- 17 | $IF NOT DEFINED UC_CLI $EXIT 18 | * "SUM(UC_R_SUM(R,UC_N)," or bracket ( 19 | + %1 20 | * "SUM(UC_T_SUM(UC_N,T)," or bracket ( 21 | %2 22 | * "SUM(UC_TS_SUM(UC_N,S)," or bracket ( 23 | %3 24 | SUM(CM_VAR$UC_CLI(UC_N,%5,R,%7,CM_VAR), UC_CLI(UC_N,%5,R,%7,CM_VAR) * 25 | (%VAR%_CLITOT(CM_VAR,%4 %SOW%)$CM_KIND(CM_VAR) + 26 | SUM(CM_BOXMAP(CM_KIND,CM_VAR,CM_BOX),%VAR%_CLIBOX(CM_VAR,%4 %SOW%))) * 27 | 28 | * [AL] PROD operator is useful here, but requires 'initialization' due to GAMS bug 29 | PROD(ANNUAL,1) * 30 | $IF %6==1 PROD(UC_ATTR(R,UC_N,%5,'CLI','GROWTH'), 31 | $IF %6==1 POWER(ABS(UC_CLI(UC_N,%5,R,%7,CM_VAR)),%8*UC_SIGN(%5)-1)) * 32 | PROD(UC_ATTR(R,UC_N,%5,'CLI','PERIOD'),FPD(%4)) 33 | ) 34 | 35 | * closing bracket of %3 : 36 | ) 37 | 38 | * closing bracket of %2 : 39 | ) 40 | 41 | * closing bracket of %1 : 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /uc_com.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * UC_COMPD the code associated with the COMPRD variable in the EQ_USERCON 7 | * - %1 region summation index 8 | * - %2 period summation index 9 | * - %3 time-slice summation index 10 | * - %4 'T' or 'T+1' index 11 | * - %5 'LHS' or 'RHS' 12 | * - %6 Type of constraint (0=EACH, 1=SUCC or 2=SEVERAL) 13 | *=============================================================================* 14 | *UR Questions/Comments: 15 | * - 16 | *----------------------------------------------------------------------------- 17 | 18 | *"SUM(UC_R_SUM(R,UC_N)," or bracket ( 19 | %1 20 | * "SUM(UC_T_SUM(UC_N,T)," or bracket ( 21 | %2 22 | * "SUM(UC_TS_SUM(UC_N,S)," or bracket ( 23 | %3 24 | SUM(UC_GMAP_C(R,UC_N,'%9',C,UC_GRPTYPE), 25 | $IF %6==2 (1+(FPD(T)+(COEF_PVT(R,T)-FPD(T))$UC_ATTR(R,UC_N,'LHS',UC_GRPTYPE,'PERDISC')-1)$UC_DT(R,UC_N)) * 26 | SUM(RHS_COM%8(R,%4,C,TS)$RS_FR(R,S,TS), 27 | UC_COM(UC_N,'%9',%5,R,%7,C,TS,UC_GRPTYPE) * %VAR%_COM%9(R,%4,C,TS %SOW%)* 28 | (1+(1/COM_IE(R,%4,C,TS)-1)$(UC_ATTR(R,UC_N,%5,UC_GRPTYPE,'EFF') XOR DIAG(UC_GRPTYPE,'COM%9'))) * 29 | 30 | * [AL] PROD operator is useful here 31 | PROD(ANNUAL,1)*PROD(RS_BELOW(R,TS,S),RS_FR(R,S,TS)*(1+RTCS_FR(R,%4,C,S,TS))) * 32 | $IF %6==1 PROD(UC_ATTR(R,UC_N,%5,UC_GRPTYPE,'GROWTH'), 33 | $IF %6==1 POWER(ABS(UC_COM(UC_N,'%9',%5,R,%7,C,TS,UC_GRPTYPE)),%11*UC_SIGN(%5)-1)) * 34 | $IF %6==S (1/G_YRFR(R,S)) * 35 | PROD(UC_ATTR(R,UC_N,%5,UC_GRPTYPE,'PERIOD'),FPD(%4)) * 36 | 37 | PROD(REG(R)$SUM(UC_ATTR(R,UC_N,%5,UC_GRPTYPE,UC_COST),1), 38 | SUM((UC_ATTR(R,UC_N,%5,UC_GRPTYPE,UC_COST),RDCUR(R,CUR)), 39 | OBJ_COM%10(R,%4,C,TS,UC_COST,CUR))) 40 | ) 41 | ) 42 | * closing bracket of %3 : 43 | ) 44 | * closing bracket of %2 : 45 | ) 46 | * closing bracket of %1 : 47 | ) 48 | -------------------------------------------------------------------------------- /uc_ncap.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * UC_NCAP the code associated with the flow variable in the EQ_USERCON 7 | * - %1 region summation index 8 | * - %2 period summation index 9 | * - %3 'T' or 'T+1' index 10 | * - %4 'LHS' or 'RHS' 11 | * - %5 Type of constraint (0=EACH, 1=SUCC or 2=SEVERAL) 12 | *=============================================================================* 13 | *UR Questions/Comments: 14 | * - 15 | *----------------------------------------------------------------------------- 16 | *"SUM(UC_R_SUM(R,UC_N)," or bracket "(" 17 | %1 18 | 19 | * UR 05/15/00 20 | * SUM(UC_GRP$( UC_GMAP(R,UC_N,'NCAP',UC_GRP)*%4 ), 21 | 22 | * "SUM(UC_T_SUM(UC_N,T)," or bracket "(" 23 | %2 24 | * [AL] VAR_NCAP(R,%3,P) can be active even if there is no RTP_CPTYR(R,V,T,P) (due to ILED)! 25 | * [AL] Therefore, changed to check for RTP(R,%3,P) without RTP_OFF(R,%3,P) 26 | * SUM((P,CUR)$(UC_GMAP_P(R,UC_N,'NCAP',P)*SUM(V,RTP_CPTYR(R,V,T,P))), 27 | SUM(UC_GMAP_P(R,UC_N,'NCAP',P)$RTP(R,%3,P), UC_NCAP(UC_N,%4,R,%6,P) * 28 | (%VAR%_NCAP(R,%3,P %SOW%)$(NOT RTP_OFF(R,%3,P)) + 29 | (SUM(RVPT(R,V,P,%3),%VARV%_NCAP(R,V,P %SWS%)) + %VAR%_NCAP(R,%3,P %SOW%) * 30 | (COEF_RPTI(R,%3,P)-PROD(RVPT(R,%3,P,MILESTONYR),2)))$UC_ATTR(R,UC_N,%4,'NCAP','PERIOD')) * 31 | 32 | * [AL] PROD operator is useful here, but needs to be 'tweaked' due to a bug in GAMS 21.3-21.4: 33 | $IF %5==1 PROD(UC_ATTR(R,UC_N,%4,'NCAP','GROWTH'), 34 | $IF %5==1 POWER(ABS(UC_NCAP(UC_N,%4,R,%6,P)),%7*UC_SIGN(%4)-1)) * 35 | PROD(UC_ATTR(R,UC_N,%4,'NCAP','BUILDUP'),1/LEAD(%3)) * 36 | 37 | PROD(L('N'),PROD(REG(R)$SUM(UC_ATTR(R,UC_N,%4,'NCAP',UC_COST),1), 38 | SUM(RDCUR(R,CUR), 39 | $IF NOT %3==%6 SUM(UC_ATTR(R,UC_N,%4,'NCAP',UC_ANNUL),CST_ANNC(R,%3,P,%6,UC_ANNUL,CUR))+ 40 | OBJ_ICOST(R,%3,P,CUR)$UC_ATTR(R,UC_N,%4,'NCAP','COST') 41 | +OBJ_ITAX(R,%3,P,CUR)$UC_ATTR(R,UC_N,%4,'NCAP','TAX') 42 | -OBJ_ISUB(R,%3,P,CUR)$UC_ATTR(R,UC_N,%4,'NCAP','SUB')))) 43 | 44 | ) 45 | 46 | * closing bracket of %2 : 47 | ) 48 | 49 | * closing bracket of %1 : 50 | ) 51 | 52 | -------------------------------------------------------------------------------- /uc_pasti.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * UC_PASTI code associated with first period capacity in GROWTH constraint 7 | * - %1 region summation index 8 | * - %2 period summation index (MIYR_1) 9 | * - %3 T index 10 | * - %4 'LHS' or 'RHS' 11 | *=============================================================================* 12 | *AL Questions/Comments: 13 | * - Possible bound attributes are for now ignored for PASTI 14 | *----------------------------------------------------------------------------- 15 | *"SUM(UC_R_SUM(R,UC_N)," or bracket "(" 16 | %1 17 | 18 | *[AL] Sum over RTP that have UC_CAP specified on current side 19 | SUM(RTP(R,%3,P)$UC_GMAP_P(R,UC_N,'CAP',P), 20 | 21 | * Sum of PASTI inherited to first period is used as a capacity value for T-1 of MIYR_1(T) 22 | * UC_CAP coefficient is taken from MIYR_1, because UC_CAP is interpolated on T only 23 | SUM(RTP_CPTYR(R,PASTYEAR,%3,P),COEF_CPT(R,PASTYEAR,%3,P)*NCAP_PASTI(R,PASTYEAR,P)) * 24 | UC_CAP(UC_N,%4,R,%3,P) * 25 | * [AL] PROD operator is useful here, but needs to be 'initialized' due to a GAMS bug: 26 | PROD(SIDE(%4),PROD(UC_ATTR(R,UC_N,SIDE,'CAP','GROWTH'), 27 | POWER(ABS(UC_CAP(UC_N,%4,R,%3,P)),M(%3)-B(%3)))) 28 | 29 | ) 30 | 31 | * closing bracket of %1 : 32 | )$SUM(%2(%3),1) 33 | 34 | -------------------------------------------------------------------------------- /units.def: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *=============================================================================* 6 | * UNITS.DEF has complete list of unit types * 7 | *=============================================================================* 8 | 9 | * units by group 10 | SET UNITS 'Units' / Bv-km, Bv-kma, GW, MW, Mt, Mta, kt, kta, kth, t, PJ, PJa, TJ, TJa, TWh, GWh, MWh, uvol, CUR, GPKM, GVKM, Mcar, UCU / 11 | ALIAS(UNITS,U); 12 | SET UNITS_COM(UNITS) 'Commodity Units' / Bv-km, Mt, kt, t, PJ, TJ, uvol, GPKM, GVKM, UCU / 13 | SET UNITS_CAP(UNITS) 'Capacity Units' / PJa, GW, MW, Mta, kta, Bv-kma, Mcar / 14 | SET UNITS_ACT(UNITS) 'Activity Units' / Mt, kt, kth, PJ, TJ, TWh, GWh, MWh, GPKM, GVKM / 15 | SET UNITS_MONY(UNITS) 'Monatary Units' / CUR / 16 | 17 | * unit mapping table(s) 18 | PARAMETER G_UNCA(UNITS,UNITS_ACT) 'Cap-to-Act conversions' / 19 | GW.GWH 8760 20 | GW.PJ 31.536 21 | GW.TWH 8.760 22 | GWH.PJ 0.0036 23 | GWH.TJ 3.6 24 | GWH.TWH 0.001 25 | MW.GWH 8.76 26 | MW.MWH 8760 27 | MW.PJ 0.031536 28 | MW.TJ 31.536 29 | MWH.GWH 0.001 30 | MWH.TJ 0.0036 31 | PJA.PJ 1 32 | TJA.TJ 1 33 | TWH.PJ 3.6 34 | Mta.Mt 1 35 | Mta.kt 1000 36 | kta.Mt 0.001 37 | kta.kt 1 38 | kta.kth 8760 /; -------------------------------------------------------------------------------- /wrtbprice.mod: -------------------------------------------------------------------------------- 1 | *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | * Copyright (C) 2000-2023 Energy Technology Systems Analysis Programme (ETSAP) 3 | * This file is part of the IEA-ETSAP TIMES model generator, licensed 4 | * under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt). 5 | *============================================================================== 6 | * Saving shadow prices of commodity balances to be used as base prices 7 | * for elastic demands into gdx files com_bprice.gdx & _DP.dgx 8 | *============================================================================== 9 | PARAMETER DINV(R,YEAR,CUR) //; 10 | PARAMETER SOL_BPRICE(REG,ALLYEAR,COM,ALL_TS,CUR) //; 11 | PARAMETER SOL_ACFR(R,UC_COST,YEAR) //; 12 | SET ANCAT(UC_COST,ITEM) / COST.(INV, FIX, VAR, DAM), TAX.(INVX, FIXX, VARX) /; 13 | *------------------------------------------------------------------------------ 14 | * Undiscounting via matrix inversion currently disabled; using direct method 15 | DINV(R,T,CUR)$G_RCUR(R,CUR) = 1/COEF_PVT(R,T); 16 | 17 | SOL_BPRICE(R,T,C,S,CUR)$(RCS_COMBAL(R,T,C,S,'LO')$DEM(R,C)) = DINV(R,T,CUR)*EQG_COMBAL.M(R,T,C,S); 18 | SOL_BPRICE(R,T,C,S,CUR)$(RCS_COMBAL(R,T,C,S,'FX')$DEM(R,C)) = DINV(R,T,CUR)*EQE_COMBAL.M(R,T,C,S); 19 | 20 | * Check elastic supply curve requests 21 | $ IF DEFINED DAM_ELAST TRACKC(RC)$((NOT DAM_BQTY(RC))$DAM_ELAST(RC,'N')) = YES; 22 | $ IF DEFINED DAM_COST LOOP((R,T,C,CUR)$DAM_COST(R,T,C,CUR), TRACKC(R,C) = NO); 23 | OPTION CLEAR=DAM_COEF,CLEAR=DAM_TVOC; 24 | DAM_COEF(RTCS_VARC(R,T,C,S))$TRACKC(R,C) = EQE_COMPRD.M(R,T,C,S)/COEF_PVT(R,T)+EPS; 25 | DAM_TVOC(RTC(R,T,C),'N')$TRACKC(R,C) = SUM(RTCS_VARC(RTC,S),DAM_COEF(RTC,S)*VAR_COMPRD.L(RTC,S)); 26 | 27 | * Save also annual cost to expenditure ratios for TIMES CGE calibration 28 | RB(R,T) = SUM((COM_TS(DEM(R,C),S),RDCUR(R,CUR)),SOL_BPRICE(R,T,C,S,CUR)*COM_FR(R,T,C,S)*COM_PROJ(R,T,C))+1-1; 29 | $ IFI NOT %STAGES%==YES 30 | $ IFI %ANNCOST%==LEV SOL_ACFR(R,UC_COST,T)$RB(R,T)=SUM(SYSUCMAP(SYSUC,ITEM)$ANCAT(UC_COST,ITEM),REG_ACOST(R,T,SYSUC)) / RB(R,T); 31 | OPTION CLEAR=RB,CLEAR=TRACKC; 32 | 33 | EXECUTE_UNLOAD 'com_bprice',sol_bprice,DAM_COEF,DAM_TVOC,SOL_ACFR; 34 | EXECUTE_UNLOAD '%GDXPATH%%RUN_NAME%_DP',sol_bprice,DAM_COEF,DAM_TVOC,SOL_ACFR; 35 | *------------------------------------------------------------------------------ 36 | --------------------------------------------------------------------------------