-
-
Notifications
You must be signed in to change notification settings - Fork 580
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
[WIP] Allow 3D process variables #4804
Draft
rtimms
wants to merge
13
commits into
develop
Choose a base branch
from
issue-4776-3D-process-vars
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+712
−114
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rtimms
commented
Jan 27, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: