-
Notifications
You must be signed in to change notification settings - Fork 10
Fix commodity price calculations #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Copy changes to quantities module from #556 * Fix tests * Remove line * Add simple example to docstring
|
I suspect there may be a mistake in the treatment of regions, as I've noticed that electricity prices are unexpectedly high for the example models with multiple regions. I'm looking into it... |
|
I'm holding the review until you have sorted the issue with the regions. |
|
@dalonsoa As far as I can tell it's not something I've done wrong in this PR, but the treatment of regions is generally a mess. It brings me back to issue #475 I think generally the problem is this: In arrays with an "asset" dimension (e.g. supply, consumption), "region" should always be a property of the asset (not sure if that's the correct xarray term) rather than its own dimension. This is because each asset belongs to a specific region. However, the supply data passed to the LCOE function has "region" and "asset" as separate dimension, in which all the assets in each region have been copied across both regions. Ultimately LCOE is ending up approximately twice as high in the the model with two regions, which carries through to commodity prices. Basically, I don't think there's any good reason for any array to have both "asset" and "region" dimensions. I might try adding a check to the I suspect the reason prices were previously similar in multi-region models was just a case of two bugs cancelling each other out. I suspect one of the bugs was the same one that was causing #607, which is now fixed, although I haven't fully figured out why. In any case, I think you can go ahead and review this PR when you have the time. |
commit 8f1333c Author: Tom Bland <[email protected]> Date: Wed Dec 18 08:46:51 2024 +0000 Fix timeslice level error commit 35b4c28 Author: Tom Bland <[email protected]> Date: Tue Dec 17 14:14:56 2024 +0000 Use pytest parametrize commit ff793a3 Author: Tom Bland <[email protected]> Date: Tue Dec 17 14:10:52 2024 +0000 Add another test commit 9307fa1 Author: Tom Bland <[email protected]> Date: Tue Dec 17 13:32:33 2024 +0000 Update remaining model commit e621574 Author: Tom Bland <[email protected]> Date: Tue Dec 17 12:53:14 2024 +0000 Add new test for LCOE commit 2edb631 Merge: d6e2616 4b0200f Author: Tom Bland <[email protected]> Date: Tue Dec 17 11:08:23 2024 +0000 Merge branch 'costs2' of https://github.com/EnergySystemsModellingLab/MUSE_OS into costs2 commit d6e2616 Author: Tom Bland <[email protected]> Date: Tue Dec 17 11:07:57 2024 +0000 Revert change to utilities commit 4b0200f Merge: c4f8240 339ea03 Author: Tom Bland <[email protected]> Date: Tue Dec 17 10:46:55 2024 +0000 Merge branch 'main' into costs2 commit c4f8240 Author: Tom Bland <[email protected]> Date: Mon Dec 16 16:32:17 2024 +0000 Timeslice broadcasting fix commit 4b2d007 Author: Tom Bland <[email protected]> Date: Mon Dec 16 15:59:18 2024 +0000 Remove redundant function commit 540d40f Author: Tom Bland <[email protected]> Date: Mon Dec 16 15:53:11 2024 +0000 Use crf for annualized capital costs commit 63d47a5 Author: Tom Bland <[email protected]> Date: Mon Dec 16 15:14:44 2024 +0000 Typo commit 3688983 Author: Tom Bland <[email protected]> Date: Mon Dec 16 11:43:59 2024 +0000 Revert "Changes to annual/lifetime costs to match original code" This reverts commit 3842925. commit 3842925 Author: Tom Bland <[email protected]> Date: Mon Dec 16 11:26:50 2024 +0000 Changes to annual/lifetime costs to match original code commit 68bf815 Merge: 4df625b 03bbf49 Author: Tom Bland <[email protected]> Date: Mon Dec 16 10:49:24 2024 +0000 Merge branch 'costs2' of https://github.com/EnergySystemsModellingLab/MUSE_OS into costs2 commit 03bbf49 Merge: 0c97585 a22b9d0 Author: Tom Bland <[email protected]> Date: Fri Dec 13 17:10:32 2024 +0000 Merge branch 'objective_prices' into costs2 commit a22b9d0 Author: Tom Bland <[email protected]> Date: Fri Dec 13 16:25:57 2024 +0000 Pass objectives only prices from investment year commit 0c97585 Merge: 50f0f39 fb2eba1 Author: Tom Bland <[email protected]> Date: Fri Dec 13 16:01:25 2024 +0000 Merge branch 'consumption' into costs2 commit fb2eba1 Author: Tom Bland <[email protected]> Date: Fri Dec 13 15:57:31 2024 +0000 Remove line commit bfe81ee Author: Tom Bland <[email protected]> Date: Fri Dec 13 15:51:54 2024 +0000 Fix tests commit d36b248 Author: Tom Bland <[email protected]> Date: Fri Dec 13 15:42:56 2024 +0000 Copy changes to quantities module from #556 commit 4df625b Author: Tom Bland <[email protected]> Date: Fri Dec 13 14:50:53 2024 +0000 Add lifetime_to_annual commit 50f0f39 Merge: b1754b4 9a2ab3c Author: Tom Bland <[email protected]> Date: Thu Dec 12 14:32:27 2024 +0000 Merge branch 'main' into costs2 commit b1754b4 Author: Tom Bland <[email protected]> Date: Thu Dec 12 14:30:07 2024 +0000 Combine tests commit 6205f4d Author: Tom Bland <[email protected]> Date: Thu Dec 12 14:28:50 2024 +0000 Small improvements to consumption function commit 5abfe53 Author: Tom Bland <[email protected]> Date: Wed Dec 11 10:38:40 2024 +0000 Test for production_amplitude commit 9359cf7 Author: Tom Bland <[email protected]> Date: Tue Dec 10 09:57:37 2024 +0000 Fix timeslice_level error (more) commit 6bfe232 Author: Tom Bland <[email protected]> Date: Tue Dec 10 09:55:37 2024 +0000 Fix timeslice_level error commit cd532ab Author: Tom Bland <[email protected]> Date: Mon Dec 9 19:16:24 2024 +0000 Add assertion commit e83193d Author: Tom Bland <[email protected]> Date: Mon Dec 9 17:07:16 2024 +0000 Beef up discount rate function commit fd77cf5 Author: Tom Bland <[email protected]> Date: Mon Dec 9 16:20:04 2024 +0000 Docstrings for costs module commit c0395db Author: Tom Bland <[email protected]> Date: Mon Dec 9 12:01:43 2024 +0000 Tests for new costs functions commit 8d7bb92 Merge: 5c24b13 478c8e2 Author: Tom Bland <[email protected]> Date: Mon Dec 9 11:49:19 2024 +0000 Merge branch 'main' into costs2 commit 5c24b13 Author: Tom Bland <[email protected]> Date: Mon Dec 9 11:46:46 2024 +0000 Fix error in capacity_to_service_demand function commit 45a0e3f Merge: 8e927b1 a7bb1ee Author: Tom Bland <[email protected]> Date: Fri Dec 6 17:30:16 2024 +0000 Merge branch 'main' into costs2 commit 8e927b1 Author: Tom Bland <[email protected]> Date: Fri Dec 6 17:26:19 2024 +0000 Modify objectives to use new cost functions commit cae24bf Author: Tom Bland <[email protected]> Date: Fri Dec 6 16:42:20 2024 +0000 Separate functions for running cost components commit 0a54642 Author: Tom Bland <[email protected]> Date: Fri Dec 6 16:19:36 2024 +0000 annual_to_lifetime function commit ec730ed Author: Tom Bland <[email protected]> Date: Fri Dec 6 15:59:33 2024 +0000 Functions for capital costs, running costs, annual_weights commit 58ffc1c Author: Tom Bland <[email protected]> Date: Fri Dec 6 14:21:31 2024 +0000 Docstring description of lifetime vs annual commit 2d70544 Author: Tom Bland <[email protected]> Date: Thu Dec 5 14:56:00 2024 +0000 Remove code, reorder commit eb4ddf5 Author: Tom Bland <[email protected]> Date: Thu Dec 5 14:46:16 2024 +0000 Tidy NPV function commit 88cbe33 Author: Tom Bland <[email protected]> Date: Thu Dec 5 14:35:01 2024 +0000 Modern annotations in costs module commit c3d1fd6 Author: Tom Bland <[email protected]> Date: Thu Dec 5 14:30:40 2024 +0000 Combine lifetime and annual LCOE functions commit dc9f77b Author: Tom Bland <[email protected]> Date: Thu Dec 5 13:49:28 2024 +0000 Simplify checks commit 3cb4376 Author: Tom Bland <[email protected]> Date: Thu Dec 5 12:39:06 2024 +0000 Decorator to validate cost function inputs/outputs commit 58c0cab Merge: c25918d 9e9e7b9 Author: Tom Bland <[email protected]> Date: Tue Dec 3 12:47:13 2024 +0000 Merge branch 'main' into costs2 commit c25918d Merge: 0cfd120 64e55a9 Author: Tom Bland <[email protected]> Date: Tue Dec 3 12:38:50 2024 +0000 Merge branch 'v1.3' into costs2 commit 0cfd120 Author: Tom Bland <[email protected]> Date: Fri Nov 29 15:05:39 2024 +0000 Helper function for calculating production amplitude commit 28107f0 Author: Tom Bland <[email protected]> Date: Fri Nov 29 13:33:50 2024 +0000 Fix failing tests commit 89f2a10 Merge: cda7af2 e448b09 Author: Tom Bland <[email protected]> Date: Fri Nov 29 12:47:09 2024 +0000 Merge branch 'v1.3' into costs2 commit cda7af2 Author: Tom Bland <[email protected]> Date: Thu Nov 28 18:43:05 2024 +0000 Fix merge error commit fa11c36 Merge: 5308569 f94ee1b Author: Tom Bland <[email protected]> Date: Thu Nov 28 09:12:43 2024 +0000 Merge branch 'v1.3' into costs2 commit 5308569 Merge: e21130a c423ad5 Author: Tom Bland <[email protected]> Date: Tue Nov 19 13:31:57 2024 +0000 Merge branch 'v1.3' into costs2 commit e21130a Merge: c071bc8 375ebee Author: Tom Bland <[email protected]> Date: Wed Nov 13 10:43:46 2024 +0000 Merge branch 'v1.3' into costs2 commit c071bc8 Merge: ef4112a 1c8226c Author: Tom Bland <[email protected]> Date: Tue Nov 12 17:55:50 2024 +0000 Merge branch 'convert_timeslice2' into costs2 commit ef4112a Author: Tom Bland <[email protected]> Date: Tue Nov 12 17:53:59 2024 +0000 Rename variable commit 3baf63b Merge: 4310b5f 4a9d29d Author: Tom Bland <[email protected]> Date: Tue Nov 12 17:52:13 2024 +0000 Merge branch 'convert_timeslice2' into costs2 commit 1c8226c Merge: 4a9d29d cb253e6 Author: Tom Bland <[email protected]> Date: Tue Nov 12 17:49:44 2024 +0000 Merge branch 'v1.3' into convert_timeslice2 commit 4a9d29d Merge: b591866 b0697c6 Author: Tom Bland <[email protected]> Date: Tue Nov 12 17:44:39 2024 +0000 Merge branch 'v1.3' into convert_timeslice2 commit 4310b5f Author: Tom Bland <[email protected]> Date: Tue Nov 12 11:50:10 2024 +0000 Update example model results commit b591866 Merge: b78c843 9b55d5d Author: Tom Bland <[email protected]> Date: Tue Nov 12 11:45:51 2024 +0000 Merge branch 'v1.3' into convert_timeslice2 commit 0754bd1 Merge: 98d5955 953194c Author: Tom Bland <[email protected]> Date: Tue Nov 12 11:45:01 2024 +0000 Merge branch 'costs2' of https://github.com/EnergySystemsModellingLab/MUSE_OS into costs2 commit 953194c Merge: cda674c b591866 Author: Tom Bland <[email protected]> Date: Tue Nov 12 11:46:13 2024 +0000 Merge branch 'convert_timeslice2' into costs2 commit 98d5955 Author: Tom Bland <[email protected]> Date: Tue Nov 12 10:53:33 2024 +0000 Update tutorial results commit cda674c Merge: 2b61176 b78c843 Author: Tom Bland <[email protected]> Date: Tue Nov 12 08:58:59 2024 +0000 Merge branch 'convert_timeslice2' into costs2 commit b78c843 Author: Tom Bland <[email protected]> Date: Mon Nov 11 17:00:43 2024 +0000 Docstring and better error message for patch commit e77b227 Merge: bd08d1f 87132ab Author: Tom Bland <[email protected]> Date: Mon Nov 11 16:32:56 2024 +0000 Merge branch 'v1.3' into convert_timeslice2 commit 2b61176 Author: Tom Bland <[email protected]> Date: Fri Nov 8 16:27:54 2024 +0000 Delete supply_cost tests commit 5cef7fd Author: Tom Bland <[email protected]> Date: Fri Nov 8 16:21:39 2024 +0000 Delete legacy lcoe function commit 0d1759a Merge: a767c54 bd08d1f Author: Tom Bland <[email protected]> Date: Fri Nov 8 15:55:59 2024 +0000 Merge branch 'convert_timeslice2' into costs2 commit bd08d1f Merge: 59ba25c 6406723 Author: Tom Bland <[email protected]> Date: Fri Nov 8 15:52:59 2024 +0000 Merge branch 'v1.3' into convert_timeslice2 commit a767c54 Author: Tom Bland <[email protected]> Date: Fri Nov 8 12:08:14 2024 +0000 Simplify consumption tests (for now) commit fec7123 Author: Tom Bland <[email protected]> Date: Fri Nov 8 10:54:08 2024 +0000 Revert a change to the consumption function commit 8737b60 Author: Tom Bland <[email protected]> Date: Thu Nov 7 15:54:13 2024 +0000 Properly calculate consumption in objectives commit caacd9b Author: Tom Bland <[email protected]> Date: Thu Nov 7 15:34:17 2024 +0000 Fix consumption function commit 59ba25c Author: Tom Bland <[email protected]> Date: Thu Nov 7 11:26:57 2024 +0000 Rename timeslice_op, add docstring commit 59cceb8 Author: Tom Bland <[email protected]> Date: Thu Nov 7 09:54:47 2024 +0000 Delete sections from documentation commit d44d31e Author: Tom Bland <[email protected]> Date: Thu Nov 7 09:36:08 2024 +0000 Fix merge errors commit 0a8a097 Author: Tom Bland <[email protected]> Date: Wed Nov 6 13:56:40 2024 +0000 Fix some tests commit 0c10f56 Author: Tom Bland <[email protected]> Date: Thu Nov 7 09:19:29 2024 +0000 Restore old ALCOE commit e650f0b Author: Tom Bland <[email protected]> Date: Wed Nov 6 14:52:16 2024 +0000 Remove assert statements commit 798cc96 Author: Tom Bland <[email protected]> Date: Wed Nov 6 14:42:45 2024 +0000 Fix for timeslice models commit baae2e8 Author: Tom Bland <[email protected]> Date: Wed Nov 6 14:34:53 2024 +0000 Restore old ALCOE as legacy function commit fb605f4 Merge: 128416d d3604dc Author: Tom Bland <[email protected]> Date: Wed Nov 6 13:16:58 2024 +0000 Merge branch 'convert_timeslice2' into costs2 commit 128416d Author: Tom Bland <[email protected]> Date: Wed Nov 6 12:51:51 2024 +0000 Pass consumption to costs, improve aLCOE commit 6021f2b Author: Tom Bland <[email protected]> Date: Wed Nov 6 10:21:51 2024 +0000 Properly fix merge error commit e970843 Author: Tom Bland <[email protected]> Date: Wed Nov 6 10:12:28 2024 +0000 Fix merge error commit 9acbd8b Merge: 0518e5a 92ca64e Author: Tom Bland <[email protected]> Date: Wed Nov 6 10:12:18 2024 +0000 Merge branch 'v1.3' into costs commit 0518e5a Author: Tom Bland <[email protected]> Date: Wed Nov 6 10:03:04 2024 +0000 Simplify costs module, add assert statements commit d3604dc Merge: 908be7b 92ca64e Author: Tom Bland <[email protected]> Date: Tue Nov 5 17:16:44 2024 +0000 Merge branch 'v1.3' into convert_timeslice2 commit 908be7b Author: Tom Bland <[email protected]> Date: Mon Nov 4 14:44:48 2024 +0000 Remove timeslice attribute from sectors commit 366c37c Author: Tom Bland <[email protected]> Date: Fri Nov 1 15:57:56 2024 +0000 Drop convert_market_timeslice commit ae3c06c Author: Tom Bland <[email protected]> Date: Wed Oct 30 11:36:09 2024 +0000 Turn off automatic broadcasting over the timeslice dimension (#530) * xarray patch to prevent automatic broadcasting * Fix most remaining broadcasting bugs * Fix some tests * Fix more tests * Simplify dlc constraint * More timeslice broadcasting * Fix incorrect uses of distribute_timeslice * Fix bug in _inner_split * Remove unnecessary drop_timeslice operations * Fix correlation model * Fix a couple of tests * Restore drop_timeslice * Restore more drop_timeslice * Fix demand_matching tests * Fix correlation model * Consistent timeslice dimension in objectives * Revert change to capacity_in_use * Fix objective tests * Fix more tests * Fix another test * Fix final test (hopefully) commit d5b5676 Author: Tom Bland <[email protected]> Date: Mon Oct 28 15:33:48 2024 +0000 Fix tests commit 46ab820 Author: Tom Bland <[email protected]> Date: Mon Oct 28 13:48:35 2024 +0000 Remove timeslice arguments commit d5875f9 Author: Tom Bland <[email protected]> Date: Mon Oct 28 13:38:08 2024 +0000 Fix tests commit fde592b Merge: 433c39c b521d93 Author: Tom Bland <[email protected]> Date: Mon Oct 28 13:32:21 2024 +0000 Merge branch 'legacy' into convert_timeslice2 commit b521d93 Merge: 5c5fc45 c270dfa Author: Tom Bland <[email protected]> Date: Mon Oct 28 11:33:46 2024 +0000 Merge branch 'refactor' into legacy commit c270dfa Merge: 423fafe 48e0cd7 Author: Tom Bland <[email protected]> Date: Mon Oct 28 11:33:14 2024 +0000 Merge branch 'main' into refactor commit 423fafe Merge: 2e601ea 43c893c Author: Tom Bland <[email protected]> Date: Mon Oct 28 08:57:22 2024 +0000 Merge branch 'main' into refactor commit 2e601ea Merge: 6975787 be29358 Author: Tom Bland <[email protected]> Date: Fri Oct 25 16:16:46 2024 +0100 Merge branch 'v1.2.2' into refactor commit 6975787 Merge: 8d06e85 2acef46 Author: Tom Bland <[email protected]> Date: Fri Oct 25 14:39:04 2024 +0100 Merge branch 'broadcast_errors2' into refactor commit 433c39c Author: Tom Bland <[email protected]> Date: Fri Oct 25 09:47:21 2024 +0100 Fix merge conflicts commit 885f752 Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri Oct 25 08:33:20 2024 +0000 [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci commit 8149020 Merge: b0ce228 5c5fc45 Author: Tom Bland <[email protected]> Date: Fri Oct 25 09:33:06 2024 +0100 Merge branch 'legacy' into convert_timeslice2 commit 5c5fc45 Merge: 4ce54e6 8d06e85 Author: Tom Bland <[email protected]> Date: Fri Oct 25 09:31:46 2024 +0100 Merge branch 'refactor' into legacy commit 8d06e85 Merge: 65313de d7d47d6 Author: Tom Bland <[email protected]> Date: Fri Oct 25 09:31:24 2024 +0100 Merge branch 'v1.3' into refactor commit b0ce228 Author: Tom Bland <[email protected]> Date: Tue Oct 22 17:51:13 2024 +0100 Fix test commit 0258ae9 Author: Tom Bland <[email protected]> Date: Tue Oct 22 17:28:41 2024 +0100 Check for existing timeslice dimension in broadcast_timeslice commit 4fbc1ff Author: Tom Bland <[email protected]> Date: Tue Oct 22 16:17:24 2024 +0100 Create separate functions for broadcasting and distributing timeslices commit 88d40b4 Author: Tom Bland <[email protected]> Date: Tue Oct 22 09:07:30 2024 +0100 Fix remaining tests commit 4785412 Author: Tom Bland <[email protected]> Date: Tue Oct 22 09:03:34 2024 +0100 Fix constraints tests commit a02088e Author: Tom Bland <[email protected]> Date: Mon Oct 21 15:09:41 2024 +0100 Small changes commit ad3766e Merge: c616694 4ce54e6 Author: Tom Bland <[email protected]> Date: Mon Oct 21 14:59:25 2024 +0100 Merge branch 'legacy' into convert_timeslice2 commit 4ce54e6 Merge: acdcbf8 65313de Author: Tom Bland <[email protected]> Date: Mon Oct 21 14:11:15 2024 +0100 Merge branch 'refactor' into legacy commit 65313de Merge: 0c84ba9 8e8b5bf Author: Tom Bland <[email protected]> Date: Mon Oct 21 14:07:25 2024 +0100 Merge branch 'v1.3' into refactor commit 0c84ba9 Author: Tom Bland <[email protected]> Date: Thu Oct 17 15:12:34 2024 +0100 Remove inline comment commit d054a3b Author: Tom Bland <[email protected]> Date: Thu Oct 17 15:09:31 2024 +0100 A few more tiny changes (e.g. typing) commit c616694 Author: Tom Bland <[email protected]> Date: Thu Oct 17 09:43:02 2024 +0100 Fix docstring tests commit 1bd7c84 Author: Tom Bland <[email protected]> Date: Wed Oct 16 16:26:39 2024 +0100 Move default timeslice settings to conftest commit 86d7dd2 Merge: 8034807 acdcbf8 Author: Tom Bland <[email protected]> Date: Wed Oct 16 15:54:39 2024 +0100 Merge branch 'legacy' into convert_timeslice2 commit 8034807 Author: Tom Bland <[email protected]> Date: Wed Oct 16 15:47:45 2024 +0100 Fix a fixture commit e0a8c3a Author: Tom Bland <[email protected]> Date: Wed Oct 16 15:23:34 2024 +0100 More test fixes commit 908872a Author: Tom Bland <[email protected]> Date: Wed Oct 16 15:11:33 2024 +0100 Fix market fixtures commit 993af9f Author: Tom Bland <[email protected]> Date: Wed Oct 16 15:02:09 2024 +0100 Delete unused fixture commit a59580c Author: Tom Bland <[email protected]> Date: Wed Oct 16 14:42:42 2024 +0100 Fix timeslice import in tests commit 22c141e Author: Tom Bland <[email protected]> Date: Wed Oct 16 14:36:52 2024 +0100 Fix incorrect convert_timeslice usage in tests commit 793aacf Author: Tom Bland <[email protected]> Date: Wed Oct 16 10:27:09 2024 +0100 More benign changes commit 89f8c61 Author: Tom Bland <[email protected]> Date: Wed Oct 16 10:19:05 2024 +0100 Carry changes from fix_supply_issue2 branch commit acdcbf8 Merge: 9360ad1 cc9d237 Author: Tom Bland <[email protected]> Date: Mon Oct 14 16:24:13 2024 +0100 Merge branch 'refactor' into legacy commit cc9d237 Author: Tom Bland <[email protected]> Date: Mon Oct 14 16:22:05 2024 +0100 Fix test commit 94ef9b7 Merge: b2e8294 9360ad1 Author: Tom Bland <[email protected]> Date: Mon Oct 14 16:18:03 2024 +0100 Merge branch 'legacy' into convert_timeslice2 commit b2e8294 Merge: c7f67f4 3a05344 Author: Tom Bland <[email protected]> Date: Mon Oct 14 16:15:02 2024 +0100 Merge branch 'legacy' into convert_timeslice2 commit 9360ad1 Merge: 3a05344 3b0cb49 Author: Tom Bland <[email protected]> Date: Mon Oct 14 14:20:47 2024 +0100 Merge branch 'refactor' into legacy commit c7f67f4 Author: Tom Bland <[email protected]> Date: Fri Oct 11 14:16:00 2024 +0100 Update results files commit 0288459 Author: Tom Bland <[email protected]> Date: Fri Oct 11 14:03:38 2024 +0100 Default arguments for convert_timeslice commit dc8b8b8 Author: Tom Bland <[email protected]> Date: Fri Oct 11 12:00:34 2024 +0100 Formatting commit e4150e3 Author: Tom Bland <[email protected]> Date: Fri Oct 11 12:00:11 2024 +0100 Simplify timeslie import process commit 57c1c73 Author: Tom Bland <[email protected]> Date: Fri Oct 11 11:31:16 2024 +0100 Delete unused functions commit 19cf269 Author: Tom Bland <[email protected]> Date: Fri Oct 11 11:07:20 2024 +0100 Delete old convert_timeslice function commit 81e7a6a Author: Tom Bland <[email protected]> Date: Fri Oct 11 11:02:55 2024 +0100 Simplify timeslice_op function commit 5cbc8f2 Author: Tom Bland <[email protected]> Date: Fri Oct 11 10:53:56 2024 +0100 Remove remaining convert_timeslice calls commit c2b94e7 Author: Tom Bland <[email protected]> Date: Fri Oct 11 10:08:46 2024 +0100 Fix issue with timeslice ordering commit a0fe43c Author: Tom Bland <[email protected]> Date: Thu Oct 10 16:18:05 2024 +0100 Remove represent_hours function commit 7ebab9e Author: Tom Bland <[email protected]> Date: Thu Oct 10 16:08:53 2024 +0100 Update tests commit d9eb060 Author: Tom Bland <[email protected]> Date: Thu Oct 10 14:01:00 2024 +0100 Use new function wherever possible commit 65c3e48 Author: Tom Bland <[email protected]> Date: Wed Oct 9 12:11:42 2024 +0100 Draft new function with intended behaviour commit 8faf468 Author: Tom Bland <[email protected]> Date: Tue Oct 8 16:12:07 2024 +0100 Simplify some other parts of the code accordingly commit 647d3fe Author: Tom Bland <[email protected]> Date: Tue Oct 8 15:57:37 2024 +0100 Use global TIMESLICE variable throughout commit 977647d Author: Tom Bland <[email protected]> Date: Tue Oct 8 15:20:39 2024 +0100 Remove unnecessary convert_timeslice operations commit 3a05344 Author: Tom Bland <[email protected]> Date: Fri Oct 4 15:56:28 2024 +0100 Delete new_to_old_timeslice function commit 3b0cb49 Author: Tom Bland <[email protected]> Date: Fri Oct 4 15:51:45 2024 +0100 Remove more redundant code commit 1518034 Author: Tom Bland <[email protected]> Date: Fri Oct 4 15:05:35 2024 +0100 Delete tests and documentation commit 51a5273 Author: Tom Bland <[email protected]> Date: Fri Oct 4 14:58:40 2024 +0100 Delete legacy sector commit 4fd2e79 Author: Tom Bland <[email protected]> Date: Fri Oct 4 14:02:07 2024 +0100 Small fix to another test commit 018ca5c Author: Tom Bland <[email protected]> Date: Fri Oct 4 12:32:59 2024 +0100 Fix tests commit e386da1 Author: Tom Bland <[email protected]> Date: Fri Oct 4 12:10:10 2024 +0100 Revert some changes to fix tests commit 9d2cac9 Author: Tom Bland <[email protected]> Date: Fri Oct 4 10:08:01 2024 +0100 More comments added to code commit 941a5a6 Author: Tom Bland <[email protected]> Date: Fri Oct 4 10:07:36 2024 +0100 Delete unused factory commit 3e51311 Author: Tom Bland <[email protected]> Date: Fri Oct 4 10:06:02 2024 +0100 Revert change to merge_assets commit a86e07f Author: Tom Bland <[email protected]> Date: Thu Oct 3 14:56:04 2024 +0100 Simplify merge_assets commit b47c811 Author: Tom Bland <[email protected]> Date: Thu Oct 3 14:15:51 2024 +0100 Simplify retirment profile code commit 697ff3f Author: Tom Bland <[email protected]> Date: Thu Oct 3 11:27:03 2024 +0100 Simplify agent module, more comments commit fa59017 Author: Tom Bland <[email protected]> Date: Wed Oct 2 17:10:56 2024 +0100 Add comments and simplify sector.next
dalonsoa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a couple of comments/questions, but this looks really good. A much simplified and easy to follow code - and therefore, easier to figure out if things go wrong in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming that the results are correct - which seem to be the case for what you say - this looks way, way better than it was before. Much clearer code, much clear execution pipeline, and much clearer explanations. Nothing to add, here, to be honest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that coming up with tests that check some other properties of the outputs of the cost functions, besides the dimensions, is tricky, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's a bit tricky. A lot of the test elsewhere just copy code directly from the respective function and check that the output is the same - which is completely pointless. I've added some tests for LCOE which demonstrate how LCOE is expected to change (or not) as the inputs are changed. I couldn't really think of similar tests for the other costs (or didn't try that hard), but since LCOE uses a lot of the individual cost components I think the coverage is still pretty good.
Description
This PR aims to address a number of issues in the
costsmodule to make the code cleaner and fix some incorrect calculations.The main motivation for this was that models are currently particularly sensitive to the scaling of technology inputs and outputs, and often fail spectacularly if the output quantity isn't 1 (#552). In reality, we'd expect the scaling of inputs/outputs in the CommIn/CommOut files to have very little impact on the results, as long as inputs and outputs are scaled together - in other words it's the ratio that matters and not the absolute values. I've added a test to prove that this is fixed (at least for the LCOE calculation).
I've also noticed that #607 to do with the timeslice level is fixed, which is a good sign
Detailed changes below.
The results have now changed for all models, particularly commodity prices which now look a bit closer to what's expected as far as I can tell (electricity and gas prices more closely match the values in the projections file, which I assume are at least on the expected order of magnitude). I can't exactly pinpoint which changes are most responsible for changing the results as there's a lot going on. I'm actually a bit surprised that prices have changed this much as none of these models have technologies with output quantities not equal to 1. But I've double checked and can't see any mistakes in what I've done, so I have to assume it's all fine.
Note: We're currently still calculating costs at the timeslice level, so this will all change again. But it will be based on what I've done here, so this can still be reviewed and merged.
Main changes
Combining lifetime and annual LCOE into the same function
Separate functions for cost components (e.g. fuel costs, environmental costs)
Cost functions only take and return data for a single year
yearargument for any of the cost functionsPassing consumption data to cost functions rather than calculating it internally
There was a
+ 1applied to the year argument for the discount factor calculations (here), which meant that the discount factor was being applied in the first year of the technology lifetime. I think this is incorrect, so I've remove this+ 1(i.e.year = 0for the first year, so discount factor = 1)Fixes #552
Fixes #607
Type of change
Key checklist
$ python -m pytest$ python -m sphinx -b html docs docs/buildFurther checks