-
-
Notifications
You must be signed in to change notification settings - Fork 597
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
Allow 3D process variables #4804
base: develop
Are you sure you want to change the base?
Conversation
All these cases work now import pybamm
# Process variable in 3D
model = pybamm.lithium_ion.DFN(
options={"current collector": "potential pair", "dimensionality": 1}
)
sim = pybamm.Simulation(model)
sol = sim.solve([0, 100])
sol["Negative particle concentration [mol.m-3]"].entries
# Experiment with 3D vars (particle size distribution)
model = pybamm.lithium_ion.DFN(
{
"working electrode": "positive",
"surface form": "differential",
"contact resistance": "true",
"particle size": "distribution",
}
)
parameter_values = model.default_parameter_values
def f_a_dist_p_dim(R):
return pybamm.lognormal(R, 8e-6, 1e-6)
distribution_params = {
"Positive minimum particle radius [m]": 0,
"Positive maximum particle radius [m]": 3e-5,
"Positive area-weighted " + "particle-size distribution [m-1]": f_a_dist_p_dim,
}
parameter_values.update(distribution_params, check_already_exists=False)
def D_p(sto, T):
return 8e-15 + 3e-15 * sto
parameter_values.update(
{"Positive particle diffusivity [m2.s-1]": D_p}, check_already_exists=False
)
experiment = pybamm.Experiment(["Charge at C/100 for 20 hours", "Rest for 2 hours"])
sim = pybamm.Simulation(
model,
parameter_values=parameter_values,
experiment=experiment,
solver=pybamm.IDAKLUSolver(),
)
sim.solve(initial_soc=0)
# Experiment with 3D vars (current collector)
options = {"cell geometry": "pouch", "thermal": "x-lumped", "dimensionality": 2}
model = pybamm.lithium_ion.SPMe(options=options)
experiment = pybamm.Experiment(
[
"Discharge at 5 C for 10 seconds",
"Charge at 1 C for 10 seconds",
]
)
sim = pybamm.Simulation(model, experiment=experiment, solver=pybamm.IDAKLUSolver())
sol = sim.solve(calc_esoh=False)
sol["Negative electrode potential [V]"].entries |
…m-team/PyBaMM into issue-4776-3D-process-vars
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4804 +/- ##
===========================================
- Coverage 98.70% 98.65% -0.06%
===========================================
Files 304 304
Lines 23482 23723 +241
===========================================
+ Hits 23179 23405 +226
- Misses 303 318 +15 ☔ View full report in Codecov by Sentry. |
@martinjrobins @MarcBerliner, could you please take a look? I think you are probably most familiar with this part of the code |
@rtimms I'm not as familiar with the |
Description
Allow 3D (in space) processed variables. There is a lot of code duplication in the processed variables code, but we can fix that in a separate PR.
This currently covers the case of variables that are 3D and have a tertiary domain (e.g. particle -> particle size -> electrode) but doesn't work for the special case of 3D variables that only have a primary and secondary domain (e.g. electrode -> current collector, when using the 2D current collector mesh).
Still needs tests.
Fixes #4776 and #2394.
Also, see #1549
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ pre-commit run
(or$ nox -s pre-commit
) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)$ python -m pytest
(or$ nox -s tests
)$ python -m pytest --doctest-plus src
(or$ nox -s doctests
)You can run integration tests, unit tests, and doctests together at once, using
$ nox -s quick
.Further checks: