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

Could not solve for summary variables error for certain experiment values #1856

Closed
LostCorgi opened this issue Dec 11, 2021 · 0 comments · Fixed by #2095
Closed

Could not solve for summary variables error for certain experiment values #1856

LostCorgi opened this issue Dec 11, 2021 · 0 comments · Fixed by #2095

Comments

@LostCorgi
Copy link

  • PyBaMM version - $ python -m pip show pybamm:
    Name: pybamm
    Version: 21.11
    Summary: Python Battery Mathematical Modelling.
    Home-page: https://github.com/pybamm-team/PyBaMM
    Author: None
    Author-email: None
    License: UNKNOWN
    Location: /usr/local/lib/python3.7/dist-packages
    Requires: pybtex, jupyter, casadi, imageio, pandas, anytree, scikit-fem, sympy, matplotlib, numpy, scipy, autograd

Required-by:

  • Python version - $ python --version:
    Python 3.7.12

Describe the bug
Could not solve for summary variables when using certain values in the experiment steps.

To Reproduce
Steps to reproduce the behaviour:

  1. Use parameters as listed (same as used for HW5 for 24643/27700)

{'1 + dlnf/dlnc': 1.0,
'Ambient temperature [K]': 298.15,
'Cation transference number': 0.2594,
'Current function [A]': 5.0,
'Electrode height [m]': 0.065,
'Electrode width [m]': 1.58,
'Electrolyte conductivity [S.m-1]': <function electrolyte_conductivity_Nyman2008 at 0x7fb443d06050>,
'Electrolyte diffusivity [m2.s-1]': <function electrolyte_diffusivity_Nyman2008 at 0x7fb443ce25f0>,
'Initial concentration in electrolyte [mol.m-3]': 1000.0,
'Initial concentration in negative electrode [mol.m-3]': 30170.0,
'Initial concentration in positive electrode [mol.m-3]': 16653.0,
'Initial temperature [K]': 298.15,
'Lower voltage cut-off [V]': 2.5,
'Maximum concentration in negative electrode [mol.m-3]': 33133.0,
'Maximum concentration in positive electrode [mol.m-3]': 63104.0,
'Negative electrode Bruggeman coefficient (electrode)': 1.5,
'Negative electrode Bruggeman coefficient (electrolyte)': 1.5,
'Negative electrode OCP entropic change [V.K-1]': 0.0,
'Negative electrode active material volume fraction': 0.75,
'Negative electrode conductivity [S.m-1]': 215.0,
'Negative electrode diffusivity [m2.s-1]': 3.3e-14,
'Negative electrode electrons in reaction': 1.0,
'Negative electrode exchange-current density [A.m-2]': <function graphite_LGM50_electrolyte_exchange_current_density_Chen2020 at 0x7fb443d060e0>,
'Negative electrode porosity': 0.25,
'Negative electrode thickness [m]': 8.52e-05,
'Negative particle radius [m]': 5.86e-06,
'Nominal cell capacity [A.h]': 5.0,
'Number of cells connected in series to make a battery': 1.0,
'Number of electrodes connected in parallel to make a cell': 1.0,
'Positive electrode Bruggeman coefficient (electrode)': 1.5,
'Positive electrode Bruggeman coefficient (electrolyte)': 1.5,
'Positive electrode OCP entropic change [V.K-1]': 0.0,
'Positive electrode active material volume fraction': 0.665,
'Positive electrode conductivity [S.m-1]': 0.18,
'Positive electrode diffusivity [m2.s-1]': 4e-15,
'Positive electrode electrons in reaction': 1.0,
'Positive electrode exchange-current density [A.m-2]': <function nmc_LGM50_electrolyte_exchange_current_density_Chen2020 at 0x7fb443d06170>,
'Positive electrode porosity': 0.335,
'Positive electrode thickness [m]': 7.56e-05,
'Positive particle radius [m]': 5.22e-06,
'Reference temperature [K]': 298.15,
'Separator Bruggeman coefficient (electrolyte)': 1.5,
'Separator porosity': 0.47,
'Separator thickness [m]': 1.2e-05,
'Typical current [A]': 5.0,
'Typical electrolyte concentration [mol.m-3]': 1000.0,
'Upper voltage cut-off [V]': 4.2}

  1. add following RK polynomial functions for electrode voltage
nmc_params = [    7.52708209,     7.94586208,     8.12577489,     7.15626014,
           8.89795867,    23.44057239,    11.52212408,  -125.12125392,
        -150.18406158,   518.15073251,  1051.9467633 ,  -599.50608226,
       -2720.48892608, -1045.56180925,  2431.91011101,  2649.56138638,
         791.10566913]

gra_params = [-5.68802700e-01,  2.71233533e-01, -6.96758627e-01, -8.31413849e-02,
        2.45114013e+00,  3.93196117e+00, -3.12695424e+01, -2.64271082e+01,
        1.70107514e+02,  1.16180944e+02, -5.25943391e+02, -2.66184769e+02,
        8.99407315e+02,  3.01567717e+02, -8.02709948e+02, -1.30203735e+02,
        2.89125187e+02]

k = 8.617e-5
T = 298.15
def pyb_rk(order, params):
    def rk_term(x, a, k):
        f2 = -2*k*x*(1-x)*(1-2*x)**(k-1)
        f1 = (1-2*x)**(k+1)
        return a*(f1+f2)
    def base_term(x):        
        val = k * T * pybamm.log(x/(1-x))
        return val
    def rk_fun(x):
        RK = 0
        for ct in range(order+1):
            RK += (rk_term(x, params[ct], ct))
        return RK + base_term(x)
    return rk_fun

def f_nmc_rk(x):
    return -(pyb_rk(16, nmc_params))(x)

def f_gra_rk(x):
    return -(pyb_rk(16, gra_params))(x)
 
parameter_values.update({'Negative electrode OCP [V]': f_gra_rk}, check_already_exists=False)
parameter_values.update({'Positive electrode OCP [V]': f_nmc_rk}, check_already_exists=False)

  1. Define experiment as follows, where total_cells is 8000, 15500, or certain other values
full_wattage = [
                419875.07810354204,
                290671.67288570706,
                178324.67752738303,
                105603.195907928,
                -12925.2048255579,
                195046.73170923634,
                419875.07810354204
                ]
cell_wattage =  np.array(full_wattage)/total_cells
experiment = pybamm.Experiment(
    [
     "Discharge at {} W for 15.0 s".format(cell_wattage[0]),
     "Discharge at {} W for 30.0 s".format(cell_wattage[1]),
     "Discharge at {} W for 108.109091 s".format(cell_wattage[2]),
     "Discharge at {} W for 1431.639227 s".format(cell_wattage[3]),
     "Discharge at {} W for 108.10909100000003 s".format(cell_wattage[4]),
     "Discharge at {} W for 30.0 s".format(cell_wattage[5]),
     "Discharge at {} W for 45.45454500000005 s".format(cell_wattage[6])
    ]
)
  1. Make model and run sim
model = pybamm.lithium_ion.DFN()
sim_mission = pybamm.Simulation(model, experiment=experiment, parameter_values=parameter_values)
mission_sol = sim_mission.solve()
  1. Error appears
    SolverError: Could not solve for summary variables, run `sim.solve(calc_esoh=False)` to skip this step

Expected behaviour
Would've expected the simulation to run for this number of cells, it can run some values above and below without adding calc_esoh = False.

Additional context
Running on Collab and ran this pip install jax==0.2.11 after pip install pybamm to fix compatibility issue.
Error is resolved by setting calc_esoh = False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant