Model fails when existing capacity for all technologies in a sector is set to zero [BUG]
Describe the bug
Probably a niche scenario, but has come up for one of Sumin's models
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\tbland\AppData\Local\anaconda3\envs\muse_env\Scripts\muse.exe\__main__.py", line 7, in <module>
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\__main__.py", line 61, in run
muse_main(args.settings, args.model, args.copy)
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\__main__.py", line 56, in muse_main
MCA.factory(settings).run()
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\mca.py", line 343, in run
_, new_market, self.sectors = self.find_equilibrium(new_market)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\mca.py", line 208, in find_equilibrium
return find_equilibrium(
^^^^^^^^^^^^^^^^^
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\mca.py", line 552, in find_equilibrium
market, equilibrium_sectors = single_year_iteration(market, sectors)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\mca.py", line 464, in single_year_iteration
sector_market = sector.next(
^^^^^^^^^^^^
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\sectors\sector.py", line 231, in next
subsector.invest(
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\sectors\subsector.py", line 68, in invest
lp_problem = self.aggregate_lp(
^^^^^^^^^^^^^^^^^^
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\sectors\subsector.py", line 110, in aggregate_lp
demands = self.demand_share(
^^^^^^^^^^^^^^^^^^
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\demand_share.py", line 105, in demand_share
return function(agents, market, technologies, **keyword_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\registration.py", line 174, in decorated
result = inner_decorated(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\demand_share.py", line 286, in new_and_retro
retro_demands: MutableMapping[Hashable, xr.DataArray] = _inner_split(
^^^^^^^^^^^^^
File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\demand_share.py", line 472, in _inner_split
.groupby("technology")
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tbland\AppData\Local\anaconda3\envs\muse_env\Lib\site-packages\xarray\core\dataarray.py", line 6759, in groupby
rgrouper = ResolvedGrouper(UniqueGrouper(), group, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 6, in __init__
File "C:\Users\tbland\AppData\Local\anaconda3\envs\muse_env\Lib\site-packages\xarray\core\groupby.py", line 440, in __post_init__
self.group: T_Group = _resolve_group(self.obj, self.group)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tbland\AppData\Local\anaconda3\envs\muse_env\Lib\site-packages\xarray\core\groupby.py", line 785, in _resolve_group
raise ValueError(f"{newgroup.name} must not be empty")
ValueError: technology must not be empty
To Reproduce
Set all values in the ExistingCapacity.csv for a sector to zero (current and future years)
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Context
Please, complete the following to better understand the system you are using to run MUSE.
- Operating system (eg. Windows 10):
- MUSE version (eg. 1.0.1): dev
- Installation method (eg. pipx, pip, development mode):
- Python version (you can get this running
python --version): 3.12
Thanks for this. I think zero capacity should only be allowed (for the base year) when demand is also zero for the base year. The idea is that modellers calibrate the base year - i.e. they tell the model what the existing capacity is for any process that gas capacity in the base year. If they enter a capacity value that is not sufficient to meet demand in the peak time slice, then the model should throw a helpful error telling them that they need to calibrate the base year.
From: Tom Bland @.> Sent: 23 July 2024 10:57 To: EnergySystemsModellingLab/MUSE_OS @.> Cc: Subscribed @.***> Subject: [EnergySystemsModellingLab/MUSE_OS] Model fails when existing capacity for all technologies in a sector is set to zero [BUG] (Issue #427)
This email from @.*** originates from outside Imperial. Do not click on links and attachments unless you recognise the sender. If you trust the sender, add them to your safe senders listhttps://spam.ic.ac.uk/SpamConsole/Senders.aspx to disable email stamping for this address.
Describe the bug
Probably a niche scenario, but has come up for one of Sumin's models
Traceback (most recent call last):
File "
To Reproduce
Set all values in the ExistingCapacity.csv for a sector to zero
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Context
Please, complete the following to better understand the system you are using to run MUSE.
- Operating system (eg. Windows 10):
- MUSE version (eg. 1.0.1): dev
- Installation method (eg. pipx, pip, development mode):
- Python version (you can get this running python --version): 3.12
— Reply to this email directly, view it on GitHubhttps://github.com/EnergySystemsModellingLab/MUSE_OS/issues/427, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC37JLPMVXM4SZSI4LKGDT3ZNYSHHAVCNFSM6AAAAABLKCHS4CVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZDINZXGQ2DGNQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Ok makes sense. I've noticed that most of the models I've been working with don't meet demand in the base year (e.g. see #316), and don't give any kind of warning. So I guess we'll need to go through all the example/tutorial models to make sure they're sufficiently calibrated.
Also just linking #286, as this issue has come up (and been fixed) before, but it looks like it's back
Note: this also happens when an agent has no initial capacity assigned to it
I don't see this issue any more so I assume it's fixed itself. I've opened another issue about warnings for uncalibrated models (#669)