Skip to content
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

eSOH calculation fails with drive cycle #1842

Closed
brosaplanella opened this issue Dec 3, 2021 · 0 comments · Fixed by #1850
Closed

eSOH calculation fails with drive cycle #1842

brosaplanella opened this issue Dec 3, 2021 · 0 comments · Fixed by #1850
Labels
bug Something isn't working

Comments

@brosaplanella
Copy link
Sponsor Member

  • PyBaMM version - $ python -m pip show pybamm: 21.11
  • Python version - $ python --version: 3.7

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behaviour:

  1. Go to the change input current notebook
  2. In cell [5] add an initial_soc: e.g. simulation.solve(initial_soc=0.5)
  3. See error (copied below)

Additional context
Tino's comment on it: It looks like it’s trying to solve the eSOH simulation (an algebraic model) with t_eval=[0] but since the current in the parameter set is a drive cycle it goes into the drive cycle branch where it expects t_eval to match the drive cycle. We should make it not go into that branch if t_eval=[0] is provided (which the user would probably not do accidentally)

Error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/tmp/ipykernel_4616/1614736939.py in <module>
      1 # simulate US06 drive cycle (duration 600 seconds)
----> 2 simulation.solve(initial_soc=0.5)
      3 
      4 # plot
      5 simulation.plot()

~/PyBaMM/pybamm/simulation.py in solve(self, t_eval, solver, check_model, save_at_cycles, calc_esoh, starting_solution, initial_soc, **kwargs)
    706             c_p_max = self.parameter_values.evaluate(param.c_p_max)
    707             x, y = pybamm.lithium_ion.get_initial_stoichiometries(
--> 708                 initial_soc, self.parameter_values
    709             )
    710             self.parameter_values.update(

~/PyBaMM/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py in get_initial_stoichiometries(initial_soc, parameter_values)
    136             "C_n": C_n,
    137             "C_p": C_p,
--> 138             "n_Li": n_Li,
    139         },
    140     )

~/PyBaMM/pybamm/simulation.py in solve(self, t_eval, solver, check_model, save_at_cycles, calc_esoh, starting_solution, initial_soc, **kwargs)
    783                     )
    784                     dt_data_min = np.min(np.diff(time_data))
--> 785                     dt_eval_max = np.max(np.diff(t_eval))
    786                     if dt_eval_max > dt_data_min + sys.float_info.epsilon:
    787                         warnings.warn(

<__array_function__ internals> in amax(*args, **kwargs)

~/PyBaMM/.tox/dev/lib/python3.7/site-packages/numpy/core/fromnumeric.py in amax(a, axis, out, keepdims, initial, where)
   2753     """
   2754     return _wrapreduction(a, np.maximum, 'max', axis, None, out,
-> 2755                           keepdims=keepdims, initial=initial, where=where)
   2756 
   2757 

~/PyBaMM/.tox/dev/lib/python3.7/site-packages/numpy/core/fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
     84                 return reduction(axis=axis, out=out, **passkwargs)
     85 
---> 86     return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
     87 
     88 

ValueError: zero-size array to reduction operation maximum which has no identity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant