Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e26b984
Make some group region/tech indexing more clear
idelder Aug 7, 2026
666fca2
Return region groups as sets for O(1) ownership checks and guaranteed…
idelder Aug 7, 2026
7ff190d
Remove + delineated tech groups as loading does not support them. Als…
idelder Aug 7, 2026
9a87cec
Generalise reserve margin constraints to any group of regions and techs
idelder Aug 7, 2026
2f00fec
Remove reserve margin method from config
idelder Aug 7, 2026
e6af2a2
Remove tech_reserve set and also therefore rps_requirement constraint…
idelder Aug 7, 2026
b2730a7
Create 4.1 schema with reserve update
idelder Aug 7, 2026
98e016b
Update testing data
idelder Aug 7, 2026
6706794
Update docs for reserve margin generalisation
idelder Aug 7, 2026
236d5c4
Remember that annual exchange techs exist
idelder Aug 8, 2026
21b0b5c
Add reserve margin test that builds and checks for an identical LP file
idelder Aug 8, 2026
e46ad40
Remember to increment db minor version
idelder Aug 8, 2026
e8ff99a
Add v4 to v4.1 migrator and test for it
idelder Aug 8, 2026
00e0865
Fix typing errors in testing folder
idelder Aug 8, 2026
a0aee86
Fix a log format
idelder Aug 20, 2026
af6834a
Increment minor version of test dbs
idelder Aug 20, 2026
714a722
Remove period filter from derate/credit tables
idelder Aug 20, 2026
24e39ff
Remove removed dict type
idelder Aug 20, 2026
3362ae6
Fix a couple errors in docs
idelder Aug 20, 2026
35ae3bc
Fix some issues in v4 to 4.1 migrator
idelder Aug 20, 2026
d42cde1
Fix some docs notation
idelder Aug 20, 2026
f8bb35c
Add in-thread migration test for code coverage
idelder Aug 20, 2026
641b82b
Consolidate schema version updating
idelder Aug 21, 2026
b113bdb
Consolidate static and dynamic reserve margins into single planning_r…
idelder Oct 5, 2026
af36ab7
Implement new operating_reserve_margins under the unit_commitment ext…
idelder Oct 5, 2026
3282ce6
Update existing tests
idelder Oct 5, 2026
a5bef75
Update reserve margins test to test all combinations of PRMs and ORMs
idelder Oct 5, 2026
5d90e60
Update v4 migrator and test
idelder Oct 5, 2026
9785f22
Fix schema for planning_reserve_margin
idelder Oct 5, 2026
36473c8
Update temoa migrate cli command for multiple migrations in chain
idelder Oct 5, 2026
5948209
Update credit checks for reserves
idelder Oct 5, 2026
4b36e25
Remove redundant second direction on exchange symmetry constraints
idelder Oct 5, 2026
16a3145
Clear results myopically for extension outputs too
idelder Oct 5, 2026
68371c5
Remove type from PRM primary key
idelder Oct 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/computational_implementation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ The Temoa model code is organized into clear, purpose-driven packages:
* ``flows.py`` - Commodity flow balance constraints
* ``capacity.py`` - Capacity and activity constraints
* ``emissions.py`` - Emission accounting and constraints
* ``reserves.py`` - Reserve margin requirements
* ``reserves.py`` - Planning reserve margin and shared reserve helpers
* ``limits.py`` - Various limit constraints (capacity, activity, emissions, etc.)
* ``storage.py`` - Energy storage constraints
* ``operations.py`` - Baseload and ramping constraints for generators
Expand Down
51 changes: 30 additions & 21 deletions docs/source/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,26 @@ recommend that you populate input tables in the following order:
Group Region and Technology Constraints
---------------------------------------

Some constraint tables support summation over groups of regions or technologies. Note that each row in these tables will still only create one constraint, but that constraint will be a summation over the defined group. For example, the ``limit_capacity`` table will limit the total summed capacity of all technologies in the technology group (if used) and over all the regions in the region group (if used). Consider behaviour carefully. For example, the ``limit_annual_capacity_factor`` table will constrain the total summed capacity factor of the group, which would allow for varying capacity factors of processes within that group as long as the limit is met in aggregate.
Some constraint tables support summation over groups of regions or technologies.
Note that each row in these tables will still only create one constraint, but
that constraint will be a summation over the defined group. For example, the
``limit_capacity`` table will limit the total summed capacity of all technologies
in the technology group (if used) and over all the regions in the region group (if used).
Consider behaviour carefully. For example, the ``limit_annual_capacity_factor`` table will
constrain the total summed capacity factor of the group, which would allow for varying
capacity factors of processes within that group as long as the limit is met in aggregate.

**Group Regions:**

For the supported tables, the ``region`` column can be populated with either a single region (e.g., ``"east"``), a subset of regions delineated with a ``+`` (e.g., ``"east+west"``), or ``"global"`` to indicate summation over all model regions.

.. important::
When grouped or global region constraints are used with exchange technologies,
exchange flows are only counted if the relevant exchange-technology keys are
When ``+`` delineated region summations are used with exchange technologies,
exchange flows are only counted if the relevant exchange-technology region pairs are
explicitly included in the region string used by the constraint row.
Exchange-technology keys are directional and use a hyphen to separate the
two regions (e.g., ``east-west`` and ``west-east`` are distinct keys).
Exchange-technology regions are directional and use a hyphen to separate the
two regions (e.g., ``east-west`` and ``west-east`` are distinct keys). ``"global"``
*does* include all exchange flows by default.

For example, to constrain activity across the ``east`` and ``west`` regions
including all exchange flows between them, the region string should be:
Expand All @@ -132,7 +140,13 @@ For the supported tables, the ``region`` column can be populated with either a s

If exchange keys are omitted (e.g., using only ``east+west``), flows through
exchange technologies between those regions will *not* be included in the
constrained summation.
constraint summation.

The only exception to this rule is reserve margin constraints,
:code:`planning_reserve_margin` and :code:`operating_reserve_margin`
(:ref:`unit_commitment extension <extension-unit-commitment>`),
which automatically include all exchange flows into and out of the region
or region group due to their specific logic requiring this behaviour.

Supported tables:

Expand All @@ -146,18 +160,17 @@ Supported tables:
* limit_capacity_share
* limit_new_capacity_share
* limit_emission
* limit_growth_capacity
* limit_growth_new_capacity
* limit_growth_new_capacity_delta
* limit_degrowth_capacity
* limit_degrowth_new_capacity
* limit_degrowth_new_capacity_delta
* planning_reserve_margin
* operating_reserve_margin (unit_commitment extension)

**Technology Groups:**

For the supported tables, the following columns accept either technologies or technology groups, over which the constraint is summed. Technology groups are defined in the ``tech_group`` and ``tech_group_member`` tables.
For the supported tables, the following columns accept either technologies or
technology groups, over which the constraint is summed. Technology groups are
defined in the ``tech_group`` and ``tech_group_member`` tables.

Technology group columns:

* tech
* tech_or_group
* sub_group
* super_group
Expand All @@ -173,18 +186,14 @@ Supported tables:
* limit_activity_share
* limit_capacity_share
* limit_new_capacity_share
* limit_growth_capacity
* limit_growth_new_capacity
* limit_growth_new_capacity_delta
* limit_degrowth_capacity
* limit_degrowth_new_capacity
* limit_degrowth_new_capacity_delta
* planning_reserve_margin
* operating_reserve_margin (unit_commitment extension)


For help getting started, consider using the ``temoa tutorial``
command to generate a template project or inspect the example SQL file at
``temoa/tutorial_assets/utopia.sql``. To begin building your own database file, use
``temoa/db_schema/temoa_schema_v4.sql``, which is a database file with the requisite
``temoa/db_schema/temoa_schema_v4_1.sql``, which is a database file with the requisite
structure but no data added. We recommend leaving the database structure intact,
and simply adding data to the schema file, or constructing an empty database
from the schema file and then using a script or database editor to import data.
Expand Down
52 changes: 12 additions & 40 deletions docs/source/database_schema.mmd
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
erDiagram
capacity_credit {
INTEGER period PK
planning_reserve_credit {
TEXT reserve_name PK
TEXT region PK
TEXT tech PK
INTEGER vintage PK
REAL credit
TEXT notes
}
planning_reserve_margin {
TEXT reserve_name PK
TEXT region PK
TEXT tech_or_group PK
TEXT type
REAL margin
TEXT notes
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
technology {
TEXT tech PK
INTEGER annual
Expand All @@ -16,7 +23,6 @@ technology {
INTEGER exchange
TEXT flag
INTEGER flex
INTEGER reserve
INTEGER retire
INTEGER seas_stor
TEXT sector
Expand Down Expand Up @@ -539,11 +545,6 @@ output_storage_level {
REAL level
TEXT sector
}
planning_reserve_margin {
TEXT region PK
REAL margin
TEXT notes
}
ramp_down_hourly {
TEXT region PK
TEXT tech PK
Expand All @@ -556,22 +557,6 @@ ramp_up_hourly {
TEXT notes
REAL rate
}
reserve_capacity_derate {
INTEGER period PK
TEXT region PK
TEXT season PK
TEXT tech PK
INTEGER vintage PK
REAL factor
TEXT notes
}
rps_requirement {
TEXT notes
INTEGER period
TEXT region
REAL requirement
TEXT tech_group
}
tech_group {
TEXT group_name PK
TEXT notes
Expand Down Expand Up @@ -621,8 +606,8 @@ time_segment_fraction {
TEXT notes
REAL segment_fraction
}
technology one or zero--0+ capacity_credit : has
time_period one or zero--0+ capacity_credit : has
planning_reserve_margin one or zero--0+ planning_reserve_credit : has
technology one or zero--0+ planning_reserve_credit : has
technology_type 1--0+ technology : has
time_period_type one or zero--0+ time_period : has
technology one or zero--0+ capacity_factor_process : has
Expand Down Expand Up @@ -698,15 +683,9 @@ operator 1--0+ limit_capacity : has
time_period one or zero--0+ limit_capacity : has
time_period one or zero--0+ limit_capacity_share : has
operator 1--0+ limit_capacity_share : has
operator 1--0+ limit_degrowth_capacity : has
operator 1--0+ limit_degrowth_new_capacity : has
operator 1--0+ limit_degrowth_new_capacity_delta : has
commodity one or zero--0+ limit_emission : has
operator 1--0+ limit_emission : has
time_period one or zero--0+ limit_emission : has
operator 1--0+ limit_growth_capacity : has
operator 1--0+ limit_growth_new_capacity : has
operator 1--0+ limit_growth_new_capacity_delta : has
time_period one or zero--0+ limit_new_capacity : has
operator 1--0+ limit_new_capacity : has
operator 1--0+ limit_new_capacity_share : has
Expand Down Expand Up @@ -797,15 +776,8 @@ sector_label one or zero--0+ output_storage_level : has
time_period one or zero--0+ output_storage_level : has
season_label one or zero--0+ output_storage_level : has
time_of_day one or zero--0+ output_storage_level : has
region one or zero--1 planning_reserve_margin : has
technology one or zero--0+ ramp_down_hourly : has
technology one or zero--0+ ramp_up_hourly : has
technology one or zero--0+ reserve_capacity_derate : has
time_period one or zero--0+ reserve_capacity_derate : has
season_label one or zero--0+ reserve_capacity_derate : has
time_period 1--0+ rps_requirement : has
tech_group 1--0+ rps_requirement : has
region 1--0+ rps_requirement : has
tech_group one or zero--0+ tech_group_member : has
technology one or zero--0+ tech_group_member : has
time_period one or zero--0+ time_season : has
Expand Down
Loading
Loading