Skip to content

Conversation

@DrSOKane
Copy link
Contributor

Edited BasicDFN2D to make the porosity and active material fractions into FunctionParameters. However, it doesn't seem to have any effect:

import pybamm
import numpy as np

model = pybamm.lithium_ion.BasicDFN2D()
param = pybamm.ParameterValues("Ecker2015")
Lz = param["Electrode height [m]"]


def sigmoid(arg):
    return (1 + np.tanh(arg)) / 2


def top_hat(arg, a, b, k=2025):
    return sigmoid(k * (arg - a)) * sigmoid(k * (b - arg))


def eps_sep(x_s, z_s):
    return 0.508 - 0.458 * (
        top_hat(arg=z_s, a=Lz*0.45, b=Lz*0.55)
    )


param_defect = param.copy()
param_defect.update({"Separator porosity": eps_sep})

Ls = param_defect["Separator thickness [m]"]
param_defect["Separator porosity"](Ls/2,0.5*Lz)

The output is np.float64(0.05000000120084669), as expected.

exp = pybamm.Experiment(["Discharge at 1C until 2.7 V", "Charge at 1C until 4.2 V", "Hold at 4.2 V until C/20"])
sim = pybamm.Simulation(model, parameter_values=param_defect, experiment=exp)
sol = sim.solve()
output_variables = [
    "Negative electrolyte potential [V]",
    "Negative electrode potential [V]",
    "Negative electrode ocp [V]",
    "Electrolyte flux X-component [mol.m-2.s-1]",
    "Electrolyte flux Z-component [mol.m-2.s-1]",
    "Voltage [V]",
]
plot = sol.plot(output_variables, variable_limits="tight", shading="auto")
plot.plot(2.35)
plot.fig.savefig("defect_test_basic2d.png")

yields this figure, in which the z-component of the electrolyte flux is zero plus noise.
defect_test_basic2d

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.77%. Comparing base (6ba2cde) to head (c197af3).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5266   +/-   ##
========================================
  Coverage    98.77%   98.77%           
========================================
  Files          321      321           
  Lines        27727    27727           
========================================
  Hits         27387    27387           
  Misses         340      340           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants