Skip to content

Commit 57cdcc1

Browse files
committed
index update
1 parent 50bb1c1 commit 57cdcc1

52 files changed

Lines changed: 329 additions & 4 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## What is energy system modelling?
2+
3+
<!-- TODO: Add section content. -->
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Mathematical optimisation
2+
3+
<!-- TODO: Add section content. -->
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Computer implementation
2+
3+
- Must be defined in blocks. For example, a set and all its subsets
4+
should constitute one block in the sets section.
5+
- Names are intended to be meaningful. Follow conventions
6+
- Items with the same name represent the same concept in different
7+
models
8+
- Units should be used in all definitions
9+
- Parameters are named pParameterName (e.g., pOperReserveDw)
10+
- Variables are named vVariableName (e.g., vReserveDown)
11+
- Equations are named eEquationName (e.g., eOperReserveDw)
12+
- Use short set names (one or two letters) for easier reading
13+
- Equations are laid out as clearly as possible
14+
- Use the same layout for all equations, with the left-hand side on one line and the right-hand side on another line, indented by a tab
15+
- Good Optimisation Modelling Practices

chapters/01-introduction/index.qmd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Introduction
2+
3+
{{< include 01-energy-system-models.qmd >}}
4+
5+
{{< include 02-optimisation.qmd >}}
6+
7+
{{< include 03-computer-implementation.qmd >}}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Description
2+
3+
<!-- TODO: Add section content. -->
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Formulation
2+
3+
<!-- TODO: Add section content. -->
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
jupyter: compass-python
3+
---
4+
5+
## Example in Python
6+
7+
This example solves the economic dispatch problem with Pyomo and HiGHS. The reusable implementation lives in `examples/python/dispatch_model.py`; this section imports that script, defines a small generator fleet, and reports the least-cost dispatch.
8+
9+
```{python}
10+
from pathlib import Path
11+
import sys
12+
13+
for project_root in [Path.cwd(), *Path.cwd().parents]:
14+
examples_dir = project_root / "examples" / "python"
15+
if (examples_dir / "dispatch_model.py").exists():
16+
sys.path.insert(0, str(examples_dir))
17+
break
18+
else:
19+
raise FileNotFoundError("Could not find examples/python/dispatch_model.py")
20+
21+
from dispatch_model import Generator, merit_order_dispatch, total_cost
22+
```
23+
24+
The generator data include a zero-marginal-cost wind unit, a low-cost solar unit, and a gas unit that covers the remaining demand.
25+
26+
```{python}
27+
generators = [
28+
Generator("wind", marginal_cost=0.0, capacity=35.0),
29+
Generator("solar", marginal_cost=3.0, capacity=25.0),
30+
Generator("gas", marginal_cost=75.0, capacity=60.0),
31+
]
32+
33+
demand = 80.0
34+
```
35+
36+
The solver chooses generation from the cheapest available units first, while enforcing the demand balance and each unit's capacity limit.
37+
38+
```{python}
39+
dispatch = merit_order_dispatch(demand, generators)
40+
cost = total_cost(dispatch, generators)
41+
42+
dispatch, cost
43+
```
44+
45+
The solution uses all available wind and solar output, then dispatches gas for the remaining demand.
46+
47+
```{python}
48+
for generator_name, output in dispatch:
49+
print(f"{generator_name}: {output:.1f} MW")
50+
51+
print(f"Total cost: {cost:.2f}")
52+
```
53+
54+
If demand exceeds total available capacity, the model is infeasible and the example raises a clear error.
55+
56+
```{python}
57+
try:
58+
merit_order_dispatch(200.0, generators)
59+
except ValueError as error:
60+
print(error)
61+
```
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## Example in Julia
2+
3+
This example solves the economic dispatch problem with JuMP and HiGHS. The reusable implementation lives in `examples/julia/dispatch_model.jl`; this section includes that script, defines a small generator fleet, and reports the least-cost dispatch.
4+
5+
```{julia}
6+
include(joinpath(@__DIR__, "..", "..", "examples", "julia", "dispatch_model.jl"))
7+
using .DispatchModel
8+
```
9+
10+
The generator data include a zero-marginal-cost wind unit, a low-cost solar unit, and a gas unit that covers the remaining demand.
11+
12+
```{julia}
13+
generators = [
14+
Generator("wind", 0.0, 35.0),
15+
Generator("solar", 3.0, 25.0),
16+
Generator("gas", 75.0, 60.0),
17+
]
18+
19+
demand = 80.0
20+
```
21+
22+
The solver chooses generation from the cheapest available units first, while enforcing the demand balance and each unit's capacity limit.
23+
24+
```{julia}
25+
dispatch = merit_order_dispatch(demand, generators)
26+
cost = total_cost(dispatch, generators)
27+
28+
dispatch, cost
29+
```
30+
31+
The solution uses all available wind and solar output, then dispatches gas for the remaining demand.
32+
33+
```{julia}
34+
for (generator_name, output) in dispatch
35+
println("$generator_name: $(round(output; digits = 1)) MW")
36+
end
37+
38+
println("Total cost: $(round(cost; digits = 2))")
39+
```
40+
41+
If demand exceeds total available capacity, the model is infeasible and the example raises a clear error.
42+
43+
```{julia}
44+
try
45+
merit_order_dispatch(200.0, generators)
46+
catch error
47+
println(error)
48+
end
49+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Economic Dispatch
2+
3+
{{< include 01-description.qmd >}}
4+
5+
{{< include 02-formulation.qmd >}}
6+
7+
{{< include 04-example-in-julia.qmd >}}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Description
2+
3+
<!-- TODO: Add section content. -->

0 commit comments

Comments
 (0)