-
Notifications
You must be signed in to change notification settings - Fork 40
/
dynslite.vda
129 lines (129 loc) · 6.06 KB
/
dynslite.vda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright (C) 2000-2024 Energy Technology Systems Analysis Programme (ETSAP)
* This file is part of the IEA-ETSAP TIMES model generator, licensed
* under the GNU General Public License v3.0 (see file NOTICE-GPLv3.txt).
*=============================================================================*
* dynslite.vda - experimental lite implementation for dynamic timeslice trees
*=============================================================================*
$ IF %RTS%==S $EXIT
$ SET TMP $NORTS(R,T,S)
IF(CARD(NORTS),
$ GOTO %1
*------------------------------
$ LABEL PRELEV
$ IFI %DUC%==YES Abort "TS_OFF cannot be used with DUC";
* Re-calculate the leads for the SEASON timeslice cycle
LOOP((R,ANNUAL(S),T), F=0;
LOOP(RS_BELOW1(R,S,TS)$(NOT NORTS(R,T,TS)), IF(F, RS_STG(R,TS)=ORD(TS)-Z; Z=ORD(TS); ELSE Z=ORD(TS); F=Z));
RS_STG(R,S+(F-ORD(S)))$F = F-Z);
* Re-calculate average residence time for storage activity for SEASON
LOOP((TS_GROUP(R,'SEASON',S),TS(S--RS_STG(R,S)))$RS_STGPRD(R,S),RS_STGAV(R,S) = (G_YRFR(R,S)+G_YRFR(R,TS))/2/RS_STGPRD(R,S));
* QA Check
PUTGRP=0;
LOOP(RT_PP(R,T), Z=SUM((RS_BELOW1(R,ANNUAL,TS),S(TS--RS_STG(R,TS)))$((NOT NORTS(R,T,TS))$NORTS(R,T,S)),1);
IF(Z,
$ BATINCLUDE pp_qaput.mod PUTOUT PUTGRP 99 'Unsupported dynamic timeslice trees with overlap -- Fatal'
PUT QLOG ' FATAL ERROR - Timeslice trees have shared branches (R.T)=',RT_PP.TE(RT_PP)));
*------------------------------
* Remove timeslices turned off
* Bounds+varcosts pre-cleared only
ACT_BND(R,T,P,S,BD)%TMP%=0;
COM_BNDNET(R,T,C,S,BD)%TMP%=0;
COM_BNDPRD(R,T,C,S,BD)%TMP%=0;
FLO_BND(R,T,P,CG,S,BD)%TMP%=0;
FLO_FR(R,T,P,C,S,L)%TMP% = 0;
IRE_BND(R,T,C,S,ALL_R,IE,BD)%TMP%=0;
IRE_XBND(R,T,C,S,IE,BD)%TMP%=0;
STGIN_BND(R,T,P,C,S,BD)%TMP%=0;
STGOUT_BND(R,T,P,C,S,BD)%TMP%=0;
COM_BPRICE(R,T,C,S,CUR)%TMP%=0;
$ LABEL CLEAR
* Vintage-based cleared selectively
$ SETLOCAL RTS $(NORTS(R,V,S)+NORTS(R,T,S)$PASTMILE(V))
RVP(RTP(R,T,P))$(NOT PRC_VINT(R,P))=YES;
ACT_FLO(RVP(R,T,P),CG,S)%TMP%=0;
FLO_FUNC(RVP(R,T,P),CG,CG2,S)%TMP%=0;
FLO_SUM(RVP(R,T,P),CG,C,CG2,S)%TMP%=0;
NCAP_AF(RVP(R,T,P),S,BD)%TMP%=0;
FLO_SHAR(RVP(R,T,P),C,CG,S,BD)%TMP%=0;
FLO_ASHAR(RVP(R,T,P),C,CG,S,BD)%TMP%=0;
STG_LOSS(RVP(R,T,P),S)%TMP%=0;
IRE_FLO(RVP(R,T,P),C,ALL_R,COM,S)%TMP%=0;
ACT_EFF(RVP(R,T,P),CG,S)%TMP%=0;
OPTION CLEAR=RVP;
* Vintaged ANNUAL
RVP(RTP(R,V,P))$PRC_VINT(R,P)$=PRC_TSL(R,P,'ANNUAL');
LOOP(MIYR_1(T),
ACT_FLO(RVP(R,V,P),CG,S)$(RPS_S1(R,P,'ANNUAL')%RTS%)=0;
FLO_FUNC(RVP(R,V,P),CG,CG2,S)%RTS%=0;
FLO_SUM(RVP(R,V,P),CG,C,CG2,S)$(RPCS_VAR(R,P,C,'ANNUAL')%RTS%)=0;
NCAP_AF(RVP(R,V,P),S,BD)%RTS%=0;
FLO_SHAR(RVP(R,V,P),C,CG,S,BD)$(RPCS_VAR(R,P,C,'ANNUAL')%RTS%)=0;
FLO_ASHAR(RVP(R,V,P),C,CG,S,BD)$(RPS_S2(R,P,'ANNUAL')%RTS%)=0;
STG_LOSS(RVP(R,V,P),S)%RTS%=0;
IRE_FLO(RVP(R,V,P),C,ALL_R,COM,S)%RTS%=0);
OPTION CLEAR=RVP;
* Milestonyr-based all cleared
COM_IE(R,T,C,S)%TMP%=0;
COM_PKFLX(R,T,C,S)%TMP%=0;
COM_ELAST(R,T,C,S,L)%TMP%=0;
FLO_PKCOI(R,T,P,C,S)%TMP%=0;
STG_SIFT(R,T,P,C,S)%TMP%=0;
IRE_FLOSUM(R,T,P,C,S,IE,COM,IO)%TMP%=0;
UC_ACT(UCN,SIDE,R,T,P,S)%TMP%=0;
UC_FLO(UCN,SIDE,R,T,P,C,S)%TMP%=0;
UC_IRE(UCN,SIDE,R,T,P,C,S,IE)%TMP%=0;
UC_COM(UCN,COM_VAR,SIDE,R,T,C,S,UC_GRPTYPE)%TMP%=0;
UC_RHSRTS(R,UCN,T,S,L)%TMP% = 0;
$ GOTO FINISH
*------------------------------
$ LABEL REDUCE
* Remove from sets timeslices turned off
RTPS_OFF(RTP(R,T,P),S)$PRC_TS(R,P,S) $= NORTS(R,T,S);
RTPCS_OUT(RTP(R,T,P),C,S)$RPCS_VAR(R,P,C,S) $= NORTS(R,T,S);
RTCS_VARC(R,T,C,S)%TMP% = NO;
RCS_COMBAL(R,T,C,S,BD)%TMP% = NO;
RCS_COMPRD(R,T,C,S,BD)%TMP% = NO;
RHS_COMBAL(R,T,C,S)%TMP% = NO;
RHS_COMPRD(R,T,C,S)%TMP% = NO;
RTX_MARK(R,T,ITEM,C,BD,S)%TMP% = NO;
$ GOTO FINISH
*------------------------------
$ LABEL POSTLEV
* After all levelized, re-interpolate coping ANNUAL fallback
$ SET RESET 0
RVP(RTP(R,V,P))$PRC_VINT(R,P)$=PRC_TSL(R,P,'ANNUAL');
OPTION FIL<DATAYEAR; DATAYEAR(LL)=LASTLL(LL);
FLO_FUNC(R,LL--ORD(LL),P,CG,CG2,ANNUAL)$(FLO_FUNC(R,LL,P,CG,CG2,ANNUAL)$RVP(R,LL,P))=3;
$ BATINCLUDE fillparm FLO_FUNC R 'P,CG,CG2,ANNUAL' ",'',''" V 'RVP(R,V,P)' '>0' X_RPGGS X_RPGGS
RVP(R,V,P)$(NOT RPS_S1(R,P,'ANNUAL')) = NO;
ACT_EFF(R,LL--ORD(LL),P,CG,ANNUAL)$(ACT_EFF(R,LL,P,CG,ANNUAL)$RVP(R,LL,P))=3;
ACT_FLO(R,LL--ORD(LL),P,CG,ANNUAL)$(ACT_FLO(R,LL,P,CG,ANNUAL)$RVP(R,LL,P))=3;
FLO_SUM(R,LL--ORD(LL),P,CG,C,CG2,ANNUAL)$(FLO_SUM(R,LL,P,CG,C,CG2,ANNUAL)$RVP(R,LL,P))=3;
$ BATINCLUDE fillparm ACT_EFF R 'P,CG,ANNUAL' ",'','',''" V 'RVP(R,V,P)' '>0' X_RPGS X_RPGS
$ BATINCLUDE fillparm ACT_FLO R 'P,CG,ANNUAL' ",'','',''" V 'RVP(R,V,P)' '>0' X_RPGS X_RPGS
$ BATINCLUDE fillparm FLO_SUM R 'P,CG1,C,CG2,ANNUAL' ",''" V 'RVP(R,V,P)' '>0' X_RPGCGS X_RPGCGS
OPTION DATAYEAR<FIL;
$ GOTO CLEAR
*------------------------------
$ LABEL BOUNDS
* Fix variables turned off to zero with holdfixed
$ IF %STAGES%==YES $SETLOCAL SWT SW_T(T%SWD%)$
$ SETLOCAL SWT %SWD%)$(%SWT%RT_PP(R,T)%TMP%
OPTION RTC_NET<RHS_COMBAL,RTC_PRD<RHS_COMPRD;
%MODEL_NAME%.HOLDFIXED=1;
%MODEL_NAME%.SOLVEOPT=1;
%VAR%_ACT.FX(RTP_VINTYR(R,V,T,P),S%SWT%$PRC_TS(R,P,S)) = 0;
%VAR%_FLO.FX(RTP_VINTYR(R,V,T,P),C,S%SWT%$RPCS_VAR(R,P,C,S)) = 0;
%VAR%_IRE.FX(RTP_VINTYR(R,V,T,P),C,S,IE%SWT%$RPCS_VAR(R,P,C,S)) = 0;
%VAR%_SIN.FX(RTP_VINTYR(R,V,T,P),C,S%SWT%$RPCS_VAR(R,P,C,S)) = 0;
%VAR%_SOUT.FX(RTP_VINTYR(R,V,T,P),C,S%SWT%$RPCS_VAR(R,P,C,S)) = 0;
%VAR%_UPS.FX(RTP_VINTYR(R,V,T,P),S,L%SWT%$RPS_UPS(R,P,S)) = 0;
%VAR%_UPT.FX(RTP_VINTYR(R,V,T,P),S,UPT%SWT%$RPS_UPS(R,P,S)$RP_DP(R,P)) = 0;
%VAR%_UDP.FX(RTP_VINTYR(R,V,T,P),S,BD%SWT%$PRC_TS(R,P,S)$RP_UPR(R,P,BD)) = 0;
%VAR%_COMNET.FX(RTC_NET(R,T,C),S%SWT%$COM_TS(R,C,S)) = 0;
%VAR%_COMPRD.FX(RTC_PRD(R,T,C),S%SWT%$COM_TS(R,C,S)) = 0;
$IF %VAR_UC%==YES UC_RHSMAP(R,T,UCN,UC_NUMBER,S)%TMP% = NO;
*------------------------------
$ LABEL FINISH
);