Skip to content

Commit 0ed352a

Browse files
committed
Enable textmacros package for sphinx
* Convert all \text{*_*} to \text{*\_*}
1 parent e748b8c commit 0ed352a

File tree

9 files changed

+300
-296
lines changed

9 files changed

+300
-296
lines changed

doc/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@
160160
mathjax3_config = dict(
161161
tex=dict(
162162
macros={k.replace("_", ""): r"\text{" + k + "}" for k in text_macros.split()},
163+
packages={"[+]": ["textmacros"]},
164+
),
165+
loader=dict(
166+
load=["[tex]/textmacros"],
163167
),
164168
)
165169

doc/efficiency.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ As an additional benefit, we do not need to define an explicit efficiency parame
1616
or "main" input and output fuels.
1717

1818
The recommended approach is illustrated below for multiple examples.
19-
The decision variables :math:`\text{CAP_NEW}`, :math:`\text{CAP}` and :math:`\text{ACT}` as well as all bounds
19+
The decision variables :math:`\text{CAP\_NEW}`, :math:`\text{CAP}` and :math:`\text{ACT}` as well as all bounds
2020
are always understood to be in the same units. All cost parameters also have to be provided
2121
in monetary units per these units - there is no "automatic rescaling" done either within the ixmp API
2222
or in the GAMS implementation pre- or postprocessing.

doc/time.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ Example 5
8282
Using the same setup as Example 2:
8383

8484
- Discounting for the element ``1010`` involves discounting for years ``1001``, ``1002``, ... , ``1010``.
85-
- Using the standard PV formula, we have that, for the year ``1001`` the discount factor would be :math:`(1 + \text{interest_rate})^{1000 - 1001}`, for the year ``1002`` the discount factor would be :math:`(1 + \text{interest_rate})^{1000 - 1002}`, and so on.
86-
- Therefore, the period discount factor for the element ``1010`` is :math:`\text{df}_{1010} = (1 + \text{interest_rate})^{1000 - 1001} + ... + (1 + \text{interest_rate})^{1000 - 1010}`
87-
- Analogously, the period discount factor for the element ``1020`` is :math:`\text{df}_{1020} = (1 + \text{interest_rate})^{1000 - 1011} + ... + (1 + \text{interest_rate})^{1000 - 1020}`
85+
- Using the standard PV formula, we have that, for the year ``1001`` the discount factor would be :math:`(1 + \text{interest\_rate})^{1000 - 1001}`, for the year ``1002`` the discount factor would be :math:`(1 + \text{interest\_rate})^{1000 - 1002}`, and so on.
86+
- Therefore, the period discount factor for the element ``1010`` is :math:`\text{df}_{1010} = (1 + \text{interest\_rate})^{1000 - 1001} + ... + (1 + \text{interest\_rate})^{1000 - 1010}`
87+
- Analogously, the period discount factor for the element ``1020`` is :math:`\text{df}_{1020} = (1 + \text{interest\_rate})^{1000 - 1011} + ... + (1 + \text{interest\_rate})^{1000 - 1020}`
8888
- So, if we have a cost of ``K_1010`` for the element ``1010``, its discounted value would be ``df_1010 * K_1010``, which means, all the years in element ``1010`` have a representative cost of ``K_1010`` that is discounted up to the initial ``year`` of the setup, namely, the year ``1000``.
8989

9090
In practice, since the representative year of a period is always its final year, the actual calculation of the period discount factor within the model is performed backwards, i.e., starting from the final year of the period until the initial year.

message_ix/model/MACRO/macro_core.gms

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,25 @@
3232
*
3333
* A listing of all parameters used in MACRO together with a decription can be found in the table below.
3434
*
35-
* ================================== ================================================================================================================================
36-
* Parameter Description
37-
* ================================== ================================================================================================================================
38-
* :math:`\text{duration_period}_y` Number of years in time period :math:`y` (forward diff)
39-
* :math:`\text{total_cost}_{n,y}` Total system costs in region :math:`n` and period :math:`y` from MESSAGE model run
40-
* :math:`\text{enestart}_{n,s,y}` Consumption level of (commercial) end-use services :math:`s` in region :math:`n` and period :math:`y` from MESSAGE model run
41-
* :math:`\text{eneprice}_{n,s,y}` Shadow prices of (commercial) end-use services :math:`s` in region :math:`n` and period :math:`y` from MESSAGE model run
42-
* :math:`\epsilon_n` Elasticity of substitution between capital-labor and total energy in region :math:`n`
43-
* :math:`\rho_n` :math:`\epsilon - 1 / \epsilon` where :math:`\epsilon` is the elasticity of subsitution in region :math:`n`
44-
* :math:`\text{depr}_n` Annual depreciation rate in region :math:`n`
45-
* :math:`\alpha_n` Capital value share parameter in region :math:`n`
46-
* :math:`a_n` Production function coefficient of capital and labor in region :math:`n`
47-
* :math:`b_{n,s}` Production function coefficients of the different end-use sectors in region :math:`n`, sector :math:`s` and period :math:`y`
48-
* :math:`\text{udf}_{n,y}` Utility discount factor in period year in region :math:`n` and period :math:`y`
49-
* :math:`\text{newlab}_{n,y}` New vintage of labor force in region :math:`n` and period :math:`y`
50-
* :math:`\text{grow}_{n,y}` Annual growth rates of potential GDP in region :math:`n` and period :math:`y`
51-
* :math:`\text{aeei}_{n,s,y}` Autonomous energy efficiency improvement (AEEI) in region :math:`n`, sector :math:`s` and period :math:`y`
52-
* :math:`\text{fin_time}_{n,y}` finite time horizon correction factor in utility function in region :math:`n` and period :math:`y`
53-
* ================================== ================================================================================================================================
35+
* =================================== ================================================================================================================================
36+
* Parameter Description
37+
* =================================== ================================================================================================================================
38+
* :math:`\text{duration\_period}_y` Number of years in time period :math:`y` (forward diff)
39+
* :math:`\text{total\_cost}_{n,y}` Total system costs in region :math:`n` and period :math:`y` from MESSAGE model run
40+
* :math:`\text{enestart}_{n,s,y}` Consumption level of (commercial) end-use services :math:`s` in region :math:`n` and period :math:`y` from MESSAGE model run
41+
* :math:`\text{eneprice}_{n,s,y}` Shadow prices of (commercial) end-use services :math:`s` in region :math:`n` and period :math:`y` from MESSAGE model run
42+
* :math:`\epsilon_n` Elasticity of substitution between capital-labor and total energy in region :math:`n`
43+
* :math:`\rho_n` :math:`\epsilon - 1 / \epsilon` where :math:`\epsilon` is the elasticity of subsitution in region :math:`n`
44+
* :math:`\text{depr}_n` Annual depreciation rate in region :math:`n`
45+
* :math:`\alpha_n` Capital value share parameter in region :math:`n`
46+
* :math:`a_n` Production function coefficient of capital and labor in region :math:`n`
47+
* :math:`b_{n,s}` Production function coefficients of the different end-use sectors in region :math:`n`, sector :math:`s` and period :math:`y`
48+
* :math:`\text{udf}_{n,y}` Utility discount factor in period year in region :math:`n` and period :math:`y`
49+
* :math:`\text{newlab}_{n,y}` New vintage of labor force in region :math:`n` and period :math:`y`
50+
* :math:`\text{grow}_{n,y}` Annual growth rates of potential GDP in region :math:`n` and period :math:`y`
51+
* :math:`\text{aeei}_{n,s,y}` Autonomous energy efficiency improvement (AEEI) in region :math:`n`, sector :math:`s` and period :math:`y`
52+
* :math:`\text{fin\_time}_{n,y}` finite time horizon correction factor in utility function in region :math:`n` and period :math:`y`
53+
* =================================== ================================================================================================================================
5454
***
5555

5656
*----------------------------------------------------------------------------------------------------------------------*
@@ -138,14 +138,14 @@ EQUATIONS
138138
* The utility function which is maximized sums up the discounted logarithm of consumption of a single representative producer-consumer over the entire time horizon
139139
* of the model.
140140
*
141-
* .. math:: \text{UTILITY} = \sum_{n} \bigg( & \sum_{y | ( ( {ord}( y ) > 1 ) \wedge ( {ord}( y ) < | y | ) )} \text{udf}_{n, y} \cdot {\log}( \text{C}_{n, y} ) \cdot \text{duration_period}_{y} \\
142-
* + &\sum_{y | ( {ord}( y ) = | y | ) } \text{udf}_{n, y} \cdot {\log}( \text{C}_{n, y} ) \cdot \big( \text{duration_period}_{y-1} + \frac{1}{\text{fin_time}_{n, y}} \big) \bigg)
141+
* .. math:: \text{UTILITY} = \sum_{n} \bigg( & \sum_{y | ( ( {ord}( y ) > 1 ) \wedge ( {ord}( y ) < | y | ) )} \text{udf}_{n, y} \cdot {\log}( \text{C}_{n, y} ) \cdot \text{duration\_period}_{y} \\
142+
* + &\sum_{y | ( {ord}( y ) = | y | ) } \text{udf}_{n, y} \cdot {\log}( \text{C}_{n, y} ) \cdot \big( \text{duration\_period}_{y-1} + \frac{1}{\text{fin\_time}_{n, y}} \big) \bigg)
143143
*
144144
* The utility discount rate for period :math:`y` is set to :math:`\text{drate}_{n} - \text{grow}_{n,y}`, where :math:`\text{drate}_{n}` is the discount rate used in MESSAGE, typically set to 5%,
145145
* and :math:`\text{grow}` is the potential GDP growth rate. This choice ensures that in the steady state, the optimal growth rate is identical to the potential GDP growth rates :math:`\text{grow}`.
146-
* The values for the utility discount rates are chosen for descriptive rather than normative reasons. The term :math:`\frac{\text{duration_period}_{y} + \text{duration_period}_{y-1}}{2}` mutliples the
147-
* discounted logarithm of consumption with the period length. The final period is treated separately to include a correction factor :math:`\frac{1}{\text{fin_time}_{n, y}}` reflecting
148-
* the finite time horizon of the model. Note that the sum over nodes :math:`\text{node_active}` is artificial, because :math:`\text{node_active}` only contains one element.
146+
* The values for the utility discount rates are chosen for descriptive rather than normative reasons. The term :math:`\frac{\text{duration\_period}_{y} + \text{duration\_period}_{y-1}}{2}` mutliples the
147+
* discounted logarithm of consumption with the period length. The final period is treated separately to include a correction factor :math:`\frac{1}{\text{fin\_time}_{n, y}}` reflecting
148+
* the finite time horizon of the model. Note that the sum over nodes :math:`\text{node\_active}` is artificial, because :math:`\text{node\_active}` only contains one element.
149149
*
150150
***
151151

@@ -181,7 +181,7 @@ C(node_active, year) + I(node_active, year) + EC(node_active, year)
181181
* The accumulation of capital in the sectors not represented in MESSAGE is governed by new capital stock equation. Net capital formation :math:`\text{KN}_{n,y}` is derived from gross
182182
* investments :math:`\text{I}_{n,y}` minus depreciation of previsouly existing capital stock.
183183
*
184-
* .. math:: \text{KN}_{n,y} = \text{duration_period}_{y} \cdot \text{I}_{n,y} \qquad \forall{n, y > 1}
184+
* .. math:: \text{KN}_{n,y} = \text{duration\_period}_{y} \cdot \text{I}_{n,y} \qquad \forall{n, y > 1}
185185
*
186186
* Here, the initial boundary condition for the base year :math:`y_0` implies for the investments that :math:`\text{I}_{n,y_0} = (\text{grow}_{n,y_0} + \text{depr}_{n}) \cdot \text{kgdp}_{n} \cdot \text{gdp}_{n,y_0}`.
187187
***
@@ -212,7 +212,7 @@ YN(node_active, year) =E=
212212
* Equivalent to the total production equation above, the total capital stock, again excluding those sectors which are modeled in MESSAGE, is then simply a summation
213213
* of capital stock in the previous period :math:`y-1`, depreciated with the depreciation rate :math:`\text{depr}_{n}`, and the capital stock added in the current period :math:`y`.
214214
*
215-
* .. math:: \text{K}_{n, y} = \text{K}_{n, y-1} \cdot { \left( 1 - \text{depr}_n \right) }^{\text{duration_period}_{y}} + \text{KN}_{n, y} \qquad \forall{ n, y > 1}
215+
* .. math:: \text{K}_{n, y} = \text{K}_{n, y-1} \cdot { \left( 1 - \text{depr}_n \right) }^{\text{duration\_period}_{y}} + \text{KN}_{n, y} \qquad \forall{ n, y > 1}
216216
*
217217
***
218218

@@ -227,7 +227,7 @@ SUM(year2$( seq_period(year2,year) ), K(node_active, year2)) * (1 - depr(node_ac
227227
* Total production in the economy (excluding energy sectors) is the sum of production from assets that were already existing in the previous period :math:`y-1`,
228228
* depreciated with the depreciation rate :math:`\text{depr}_{n}`, and the new vintage of production from period :math:`y`.
229229
*
230-
* .. math:: \text{Y}_{n, y} = \text{Y}_{n, y-1} \cdot { \left( 1 - \text{depr}_n \right) }^{\text{duration_period}_{y}} + \text{YN}_{n, y} \qquad \forall{ n, y > 1}
230+
* .. math:: \text{Y}_{n, y} = \text{Y}_{n, y-1} \cdot { \left( 1 - \text{depr}_n \right) }^{\text{duration\_period}_{y}} + \text{YN}_{n, y} \qquad \forall{ n, y > 1}
231231
*
232232
***
233233

@@ -243,7 +243,7 @@ SUM(year2$( seq_period(year2,year) ), Y(node_active, year2)) * (1 - depr(node_ac
243243
* in the previous period :math:`y-1`, depreciated with the depreciation rate :math:`\text{depr}_{n}`, and the the new vintage of energy production from
244244
* period :math:`y`.
245245
*
246-
* .. math:: \text{PRODENE}_{n, s, y} = \text{PRODENE}_{n, s, y-1} \cdot { \left( 1 - \text{depr}_n \right) }^{\text{duration_period}_{y}} + \text{NEWENE}_{n, s, y} \qquad \forall{ n, s, y > 1}
246+
* .. math:: \text{PRODENE}_{n, s, y} = \text{PRODENE}_{n, s, y-1} \cdot { \left( 1 - \text{depr}_n \right) }^{\text{duration\_period}_{y}} + \text{NEWENE}_{n, s, y} \qquad \forall{ n, s, y > 1}
247247
*
248248
***
249249

@@ -258,11 +258,11 @@ SUM(year2$( seq_period(year2,year) ), PRODENE(node_active, sector, year2)) * (1
258258
* The relationship below establishes the link between physical energy :math:`\text{PHYSENE}_{r, s, y}` as accounted in MESSAGE for the six commerical energy demands :math:`s` and
259259
* energy in terms of monetary value :math:`\text{PRODENE}_{n, s, y}` as specified in the production function of MACRO.
260260
*
261-
* .. math:: \text{PHYSENE}_{n, s, y} \geq \text{PRODENE}_{n, s, y} \cdot \text{aeei_factor}_{n, s, y} \qquad \forall{ n, s, y > 1}
261+
* .. math:: \text{PHYSENE}_{n, s, y} \geq \text{PRODENE}_{n, s, y} \cdot \text{aeei\_factor}_{n, s, y} \qquad \forall{ n, s, y > 1}
262262
*
263263
* The cumulative effect of autonomous energy efficiency improvements (AEEI) is captured in
264-
* :math:`\text{aeei_factor}_{n,s,y} = \text{aeei_factor}_{n, s, y-1} \cdot (1 - \text{aeei}_{n,s,y})^{\text{duration_period}_{y}}`
265-
* with :math:`\text{aeei_factor}_{n,s,y=1} = 1`. Therefore, choosing the :math:`\text{aeei}_{n,s,y}` coefficients appropriately offers the possibility to calibrate MACRO to a certain energy demand trajectory
264+
* :math:`\text{aeei\_factor}_{n,s,y} = \text{aeei\_factor}_{n, s, y-1} \cdot (1 - \text{aeei}_{n,s,y})^{\text{duration\_period}_{y}}`
265+
* with :math:`\text{aeei\_factor}_{n,s,y=1} = 1`. Therefore, choosing the :math:`\text{aeei}_{n,s,y}` coefficients appropriately offers the possibility to calibrate MACRO to a certain energy demand trajectory
266266
* from MESSAGE.
267267
*
268268
***
@@ -278,7 +278,7 @@ PRODENE(node_active, sector, year) * aeei_factor(node_active, sector, year)
278278
* Energy system costs are based on a previous MESSAGE model run. The approximation of energy system costs in vicinity of the MESSAGE solution are approximated by a Taylor expansion with the
279279
* first order term using shadow prices :math:`\text{eneprice}_{s, y, n}` of the MESSAGE model's solution and a quadratic second-order term.
280280
*
281-
* .. math:: \text{EC}_{n, y} = & \text{total_cost}_{n, r} \\
281+
* .. math:: \text{EC}_{n, y} = & \text{total\_cost}_{n, r} \\
282282
* + & \displaystyle \sum_{s} \text{eneprice}_{s, y, n} \cdot \left( \text{PHYSENE}_{n, s, y} - \text{enestart}_{s, y, n} \right) \\
283283
* + & \displaystyle \sum_{s} \frac{\text{eneprice}_{s, y, n}}{\text{enestart}_{s, y, n}} \cdot \left( \text{PHYSENE}_{n, s, y} - \text{enestart}_{s, y, n} \right)^2 \qquad \forall{ n, y > 1}
284284
*

0 commit comments

Comments
 (0)