Adding a set/parameter/variable for "materials"

6 views
Skip to first unread message

Jonathan Peel

unread,
May 28, 2026, 10:04:41 AM (7 days ago) May 28
to ZEN-garden
Hi team! I'm trying to add a new parameter to track the material needs of certain technologies.

e.g., in BEV/attributes.json
```
"material": {
"default_value": 5,
"unit": "kilotons/pkm"
},
```

I understand from https://zen-garden.readthedocs.io/en/latest/files/developer_guide/adding_param_variable_constraint.html#adding-parameters, the first thing I should do is add a call to optimization_setup.sets.add_set(), probably in EnergySystem.construct_sets. Do you think that this new set should also be included in the "all_elements" set?

jmannhardt

unread,
May 28, 2026, 10:22:30 AM (7 days ago) May 28
to ZEN-garden
Hi Jonathan,

First, identify the model class to which you want to add the set. Adding it to the Energy System class makes sense if it is used throughout the optimization problem (actually, this is more for order and style, because it will be accessible from anywhere, no matter where you place it). If you use your materials only in the Technology class, you can also add them to the "construct_sets()" there.

No matter in which "construct_sets()" you put it, follow the structure of the existing sets there. For example, an idea could be:

self.optimization_setup.sets.add_set(
            name="materials",
            data=self.materials, <--- you would need to load this from the system.json as for example the list of technologies 
            doc="Critical materials that are needed for constructing the technologies."
        )

I don't think you need to specify an index set, because the selection of materials doesn't depend on anything.

I hope this helps!
Cheers,
Jacob

jmannhardt

unread,
May 28, 2026, 10:23:42 AM (7 days ago) May 28
to ZEN-garden
P.S.: what do you mean with "should also be included in 'all_elements'"?
Reply all
Reply to author
Forward
0 new messages