Skip to content

[Bug]: Variable equality is not preserved at domain interphase #5030

@DundalekJan

Description

@DundalekJan

PyBaMM Version

25.4.2

Python Version

3.9.13

Describe the bug

I am observing that the variable equality (electrolyte potential and electrolyte concentration) is not preserved at domain interphase within solver tolerances. I use in my simulations default numbers of points with default relative and absolute solver tolerances.

Steps to Reproduce

import pybamm

model = pybamm.lithium_ion.DFN()
parameter_values=pybamm.ParameterValues('Chen2020')

experiment = pybamm.Experiment(['Discharge at 1C for 30 minutes'])
sim = pybamm.Simulation(model=model, parameter_values=parameter_values, experiment=experiment)
sim.solve()
sol=sim.solution

t_sample=max(sol.t)
x_bns=parameter_values['Negative electrode thickness [m]']
x_bsp=parameter_values['Negative electrode thickness [m]']+parameter_values['Separator thickness [m]']
print('Electrolyte potential at negative electrode-separator boundary')
phi_e_bns=sol['Electrolyte potential [V]'](t=t_sample,x=x_bns)
print(' - "Negative electrolyte potential" vs "Electrolyte potential"')
phi_ne_bns=sol['Negative electrolyte potential [V]'](t=t_sample,x=x_bns)
print('   - absolute deviation [V]: '+str(phi_ne_bns-phi_e_bns))
print('   - relative deviation [-]: '+str((phi_ne_bns-phi_e_bns)/phi_e_bns))
print(' - "Separator electrolyte potential" vs "Electrolyte potential"')
phi_se_bns=sol['Separator electrolyte potential [V]'](t=t_sample,x=x_bns)
print('   - absolute deviation [V]: '+str(phi_se_bns-phi_e_bns))
print('   - relative deviation [-]: '+str((phi_se_bns-phi_e_bns)/phi_e_bns))
print('')
print('Electrolyte potential at separator-positive electrode boundary')
phi_e_bsp=sol['Electrolyte potential [V]'](t=t_sample,x=x_bsp)
print(' - "Separator electrolyte potential" vs "Electrolyte potential"')
phi_se_bsp=sol['Separator electrolyte potential [V]'](t=t_sample,x=x_bsp)
print('   - absolute deviation [V]: '+str(phi_se_bsp-phi_e_bsp))
print('   - relative deviation [-]: '+str((phi_se_bsp-phi_e_bsp)/phi_e_bsp))
print(' - "Positive electrolyte potential" vs "Electrolyte potential"')
phi_pe_bsp=sol['Positive electrolyte potential [V]'](t=t_sample,x=x_bsp)
print('   - absolute deviation [V]: '+str(phi_pe_bsp-phi_e_bsp))
print('   - relative deviation [-]: '+str((phi_pe_bsp-phi_e_bsp)/phi_e_bsp))
print('')
print('')
print('Electrolyte concentration at negative electrode-separator boundary')
c_e_bns=sol['Electrolyte concentration [mol.m-3]'](t=t_sample,x=x_bns)
print(' - "Negative electrolyte concentration" vs "Electrolyte concentration"')
c_ne_bns=sol['Negative electrolyte concentration [mol.m-3]'](t=t_sample,x=x_bns)
print('   - absolute deviation [mol.m-3]: '+str(c_ne_bns-c_e_bns))
print('   - relative deviation [-]: '+str((c_ne_bns-c_e_bns)/c_e_bns))
print(' - "Separator electrolyte concentration" vs "Electrolyte concentration"')
phi_se_bns=sol['Separator electrolyte concentration [mol.m-3]'](t=t_sample,x=x_bns)
print('   - absolute deviation [mol.m-3]: '+str(phi_se_bns-c_e_bns))
print('   - relative deviation [-]: '+str((phi_se_bns-c_e_bns)/c_e_bns))
print('')
print('Electrolyte concentration at separator-positive electrode boundary')
c_e_bsp=sol['Electrolyte concentration [mol.m-3]'](t=t_sample,x=x_bsp)
print(' - "Separator electrolyte concentration" vs "Electrolyte concentration"')
c_se_bsp=sol['Separator electrolyte concentration [mol.m-3]'](t=t_sample,x=x_bsp)
print('   - absolute deviation [mol.m-3]: '+str(c_se_bsp-c_e_bsp))
print('   - relative deviation [-]: '+str((c_se_bsp-c_e_bsp)/c_e_bsp))
print(' - "Positive electrolyte concentration" vs "Electrolyte concentration"')
c_pe_bsp=sol['Positive electrolyte concentration [mol.m-3]'](t=t_sample,x=x_bsp)
print('   - absolute deviation [mol.m-3]: '+str(c_pe_bsp-c_e_bsp))
print('   - relative deviation [-]: '+str((c_pe_bsp-c_e_bsp)/c_e_bsp))

Relevant log output

Electrolyte potential at negative electrode-separator boundary
 - "Negative electrolyte potential" vs "Electrolyte potential"
   - absolute deviation [V]: -0.00036311572573907713
   - relative deviation [-]: 0.0015423251629823785
 - "Separator electrolyte potential" vs "Electrolyte potential"
   - absolute deviation [V]: -0.0001231738798248283
   - relative deviation [-]: 0.0005231780416266227

Electrolyte potential at separator-positive electrode boundary
 - "Separator electrolyte potential" vs "Electrolyte potential"
   - absolute deviation [V]: 5.413445853100218e-05
   - relative deviation [-]: -0.00022512061117577144
 - "Positive electrolyte potential" vs "Electrolyte potential"
   - absolute deviation [V]: 0.00010668551351444844
   - relative deviation [-]: -0.00044365656658816187


Electrolyte concentration at negative electrode-separator boundary
 - "Negative electrolyte concentration" vs "Electrolyte concentration"
   - absolute deviation [mol.m-3]: -1.8603160897802127
   - relative deviation [-]: -0.0021204991088142047
 - "Separator electrolyte concentration" vs "Electrolyte concentration"
   - absolute deviation [mol.m-3]: -2.4816230159749466
   - relative deviation [-]: -0.0028287017581025203

Electrolyte concentration at separator-positive electrode boundary
 - "Separator electrolyte concentration" vs "Electrolyte concentration"
   - absolute deviation [mol.m-3]: 0.8463012480577845
   - relative deviation [-]: 0.0010459294281669775
 - "Positive electrolyte concentration" vs "Electrolyte concentration"
   - absolute deviation [mol.m-3]: -0.24807998109781693
   - relative deviation [-]: -0.0003065978614173066

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @DundalekJan

        Issue actions

          [Bug]: Variable equality is not preserved at domain interphase · Issue #5030 · pybamm-team/PyBaMM