Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan Ruiz Manuel <72193617+irm-codebase@users.noreply.github.com>
  • Loading branch information
brynpickering and irm-codebase authored Nov 7, 2024
1 parent f706ebf commit 6a8815b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/user_defined_math/helper_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
For [`where` strings](syntax.md#where-strings) and [`expression` strings](syntax.md#where-strings), there are many helper functions available to use, to allow for more complex operations to be undertaken within the string.
Their functionality is detailed in the [helper function API page](../reference/api/helper_functions.md).
Here, we give a brief summary.
Some of these helper functions require a good understanding of their functionality to apply, so make sure you are comfortable with them before using them.
Helper functions generally require a good understanding of their functionality, so make sure you are comfortable with them beforehand.

## inheritance

using `inheritance(...)` in a `where` string allows you to grab a subset of technologies / nodes that all share the same [`template`](../creating/templates.md) in the technology's / node's `template` key.
Using `inheritance(...)` in a `where` string allows you to grab a subset of technologies / nodes that all share the same [`template`](../creating/templates.md) in the technology's / node's `template` key.
If a `template` also inherits from another `template` (chained inheritance), you will get all `techs`/`nodes` that are children along that inheritance chain.

So, for the definition:
Expand Down Expand Up @@ -67,7 +67,7 @@ nodes:

## sum

Using `sum(..., over=)` in an expression allows you to sum over one or more dimension of your component array (be it a parameter, decision variable, or global expression).
Using `sum(..., over=)` in an expression allows you to sum over one or more dimensions of your component array (be it a parameter, decision variable, or global expression).

## select_from_lookup_arrays

Expand Down
8 changes: 4 additions & 4 deletions docs/user_defined_math/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ When checking the existence of an input parameter it is possible to first sum it
- If you want to apply a constraint across all `nodes` and `techs`, but only for node+tech combinations where the `flow_out_eff` parameter has been defined, you would include `flow_out_eff`.
- If you want to apply a constraint over `techs` and `timesteps`, but only for combinations where the `source_use_max` parameter has at least one `node` with a value defined, you would include `any(resource, over=nodes)`. (1)

1. `any` is a [helper function](helper_functions.md#any); read more below!
1. `any` is a [helper function](helper_functions.md#any)!

1. Checking the value of a configuration option or an input parameter.
Checks can use any of the operators: `>`, `<`, `=`, `<=`, `>=`.
Expand All @@ -50,15 +50,15 @@ Configuration options are any that are defined in `config.build`, where you can
- If you want to apply a constraint only for the first timestep in your timeseries, you would include `timesteps=get_val_at_index(dim=timesteps, idx=0)`. (1)
- If you want to apply a constraint only for the last timestep in your timeseries, you would include `timesteps=get_val_at_index(dim=timesteps, idx=-1)`.

1. `get_val_at_index` is a [helper function](helper_functions.md#get_val_at_index); read more below!
1. `get_val_at_index` is a [helper function](helper_functions.md#get_val_at_index)!

1. Checking the `base_tech` of a technology (`storage`, `supply`, etc.) or its inheritance chain (if using `templates` and the `template` parameter).

??? example "Examples"

- If you want to create a decision variable across only `storage` technologies, you would include `base_tech=storage`.
- If you want to apply a constraint across only your own `rooftop_supply` technologies (e.g., you have defined `rooftop_supply` in `templates` and your technologies `pv` and `solar_thermal` define `#!yaml template: rooftop_supply`), you would include `inheritance(rooftop_supply)`.
Note that `base_tech=...` is a simple check for the given value of `base_tech`, while `inheritance()` is a helper function ([see below](helper_functions.md)) which can deal with finding techs/nodes using the same template, e.g. `pv` might inherit the `rooftop_supply` template which in turn might inherit the template `electricity_supply`.
Note that `base_tech=...` is a simple check for the given value of `base_tech`, while `inheritance()` is a [helper function](helper_functions.md) which can deal with finding techs/nodes using the same template, e.g. `pv` might inherit the `rooftop_supply` template which in turn might inherit the template `electricity_supply`.

1. Subsetting a set.
The sets available to subset are always [`nodes`, `techs`, `carriers`] + any additional sets defined by you in [`foreach`](#foreach-lists).
Expand All @@ -67,7 +67,7 @@ The sets available to subset are always [`nodes`, `techs`, `carriers`] + any add

- If you want to filter `nodes` where any of a set of `techs` are defined: `defined(techs=[tech1, tech2], within=nodes, how=any)` (1).

1. `defined` is a [helper function](helper_functions.md#defined); read more below!
1. `defined` is a [helper function](helper_functions.md#defined)!

To combine statements you can use the operators `and`/`or`.
You can also use the `not` operator to negate any of the statements.
Expand Down

0 comments on commit 6a8815b

Please sign in to comment.