PyPSA / whobs-server

Online optimisation tool for wind+solar+storage systems
GNU Affero General Public License v3.0
35 stars 12 forks source link

Job failed -> with option Limit on CO2 emissions + Dispatchable technology #14

Closed JanFrederickUnnewehr closed 4 years ago

JanFrederickUnnewehr commented 4 years ago

Hey PyPSA Team,

thanks for this nice tool. We are using it in our lecture to make and discuss rough capacity estimates for wind and solar in different countries. If both options CO2 constrain (Limit on CO2 emissions) and Dispatchable technology 1 are selected, the solver gives an error and indicates that the job could not be executed.

Thanks for your work Best Freddy

nworbmot commented 4 years ago

Hi Freddy, thanks, I can confirm it's failing on this setting (take default case with Germany, tick box for dispatchable 1 and for co2 constraints).

It's a bit weird, because it was working before.

@FabianHofmann It seems to be a problem with the emissions in nomopyomo constraint, see error message. I'll try to get a minimum example where it fails.

11:26:12 whobs: solve.solve({'location': 'country:DE', 'job_type': 'solve', 'year': '2012', 'frequency': '1', 'cf_exponent': 2, 'load': '62000', 'hydrogen_load': 0, 'discount_rate': 5, 'co2_emissions': '100', 'wind': True, 'solar': False, 'battery': True, 'hydrogen': True, 'dispatchable1': True, 'dispatchable2': False, 'co2_limit': True, 'location_name': 'Germany', 'version': 190929, 'wind_cost': 1040, 'solar_cost': 300, 'battery_energy_cost': 142, 'battery_power_cost': 160, 'hydrogen_energy_cost': 0.7, 'hydrogen_electrolyser_cost': 600, 'hydrogen_electrolyser_efficiency': 62, 'hydrogen_turbine_cost': 830, 'hydrogen_turbine_efficiency': 58, 'dispatchable1_cost': '4001', 'dispatchable1_marginal_cost': '50', 'dispatchable1_emissions': '400', 'dispatchable1_discount': 10, 'dispatchable2_cost': 6000, 'dispatchable2_marginal_cost': 10, 'dispatchable2_emissions': 0, 'dispatchable2_discount': 10}) (072bb698-bb0c-4a12-9d75-6f6ee47793fb) INFO:pypsa.linopf:Prepare linear problem 11:26:21 ValueError: matrices are not aligned Traceback (most recent call last): File "/home/tom/whenv/lib/python3.6/site-packages/rq/worker.py", line 799, in perform_job rv = job.perform() File "/home/tom/whenv/lib/python3.6/site-packages/rq/job.py", line 600, in perform self._result = self._execute() File "/home/tom/whenv/lib/python3.6/site-packages/rq/job.py", line 606, in _execute return self.func(*self.args, self.kwargs) File "./solve.py", line 832, in solve results_overview, results_series, error_msg = run_optimisation(assumptions, pu) File "./solve.py", line 537, in run_optimisation extra_functionality=extra_functionality) File "/home/tom/whenv/lib/python3.6/site-packages/pypsa/components.py", line 502, in lopf return network_lopf_lowmem(self, args) File "/home/tom/whenv/lib/python3.6/site-packages/pypsa/linopf.py", line 877, in network_lopf extra_functionality, solver_dir) File "/home/tom/whenv/lib/python3.6/site-packages/pypsa/linopf.py", line 617, in prepare_lopf define_global_constraints(n, snapshots) File "/home/tom/whenv/lib/python3.6/site-packages/pypsa/linopf.py", line 458, in define_global_constraints em_pu = n.snapshot_weightings.to_frame() @ em_pu.to_frame('weightings').T File "/home/tom/whenv/lib/python3.6/site-packages/pandas/core/frame.py", line 1113, in matmul return self.dot(other) File "/home/tom/whenv/lib/python3.6/site-packages/pandas/core/frame.py", line 1078, in dot raise ValueError("matrices are not aligned") ValueError: matrices are not aligned

nworbmot commented 4 years ago

Hi Freddy, it took a while to find, but the bug is now fixed in commit https://github.com/PyPSA/whobs-server/commit/887e5ff50a0b1dbe90a9f64999efbe0410236c7c. Thanks for pointing this out! It's a bug in the new PyPSA nomopyomo implementation which was hard to find, I'm glad we got!

nworbmot commented 4 years ago

Proper fix is in this PyPSA PR: https://github.com/PyPSA/PyPSA/pull/133 Will be there for PyPSA 0.16.2.