-
-
Notifications
You must be signed in to change notification settings - Fork 529
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
Issue 1253 reformat dfn half cell #1282
Merged
brosaplanella
merged 19 commits into
pybamm-team:develop
from
brosaplanella:issue-1253-reformat-dfn-half-cell
Dec 22, 2020
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
07c64ce
#1253 added copy for original DFN half cell
brosaplanella 2577684
Merge branch 'develop' into issue-1253-reformat-dfn-half-cell
brosaplanella 81914c0
#1253 added half-cell geometry and variables
brosaplanella 13ebd4d
#1253 reformatted DFN half-cell model
brosaplanella 61b882b
#1253 update example script
brosaplanella f1fb793
#1253 working model including conservation checks
brosaplanella 1035e4b
#1253 updated working example
brosaplanella 8bfda77
flake8
brosaplanella 44757ac
Merge branch 'develop' into issue-1253-reformat-dfn-half-cell
brosaplanella fde2cee
Merge branch 'develop' into issue-1253-reformat-dfn-half-cell
brosaplanella 861141b
#1253 allow for half-cell plots
brosaplanella adb7264
#1253 cleaned example
brosaplanella ecbd853
#1253 remove old half-cell model
brosaplanella cf6c957
#1253 added tests
brosaplanella cf0a410
Merge branch 'develop' into issue-1253-reformat-dfn-half-cell
brosaplanella b9e9582
#1253 improved tests
brosaplanella ab1eb5d
#1253 Tino's comments
brosaplanella 133df03
Merge branch 'develop' into issue-1253-reformat-dfn-half-cell
brosaplanella ad0144e
#1253 update CHANGELOG
brosaplanella File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# | ||
# Function to create battery geometries | ||
# | ||
import pybamm | ||
from pybamm.geometry import half_cell_spatial_vars | ||
|
||
|
||
def half_cell_geometry( | ||
include_particles=True, current_collector_dimension=0, working_electrode="positive" | ||
): | ||
""" | ||
A convenience function to create battery geometries. | ||
|
||
Parameters | ||
---------- | ||
include_particles : bool | ||
Whether to include particle domains | ||
current_collector_dimensions : int, default | ||
The dimensions of the current collector. Should be 0 (default), 1 or 2 | ||
current_collector_dimensions : string | ||
The electrode taking as working electrode. Should be "positive" or "negative" | ||
|
||
Returns | ||
------- | ||
:class:`pybamm.Geometry` | ||
A geometry class for the battery | ||
|
||
""" | ||
var = half_cell_spatial_vars | ||
geo = pybamm.geometric_parameters | ||
if working_electrode == "positive": | ||
l_w = geo.l_p | ||
elif working_electrode == "negative": | ||
l_w = geo.l_n | ||
else: | ||
raise ValueError( | ||
"The option 'working_electrode' should be either 'positive'" | ||
" or 'negative'" | ||
) | ||
l_Li = geo.l_Li | ||
l_s = geo.l_s | ||
|
||
geometry = { | ||
"lithium counter electrode": {var.x_Li: {"min": 0, "max": l_Li}}, | ||
"separator": {var.x_s: {"min": l_Li, "max": l_Li + l_s}}, | ||
"working electrode": {var.x_w: {"min": l_Li + l_s, "max": l_Li + l_s + l_w}}, | ||
} | ||
# Add particle domains | ||
if include_particles is True: | ||
geometry.update( | ||
{"working particle": {var.r_w: {"min": 0, "max": 1}}} | ||
) | ||
|
||
if current_collector_dimension == 0: | ||
geometry["current collector"] = {var.z: {"position": 1}} | ||
elif current_collector_dimension == 1: | ||
geometry["current collector"] = { | ||
var.z: {"min": 0, "max": 1}, | ||
"tabs": { | ||
"negative": {"z_centre": geo.centre_z_tab_n}, | ||
"positive": {"z_centre": geo.centre_z_tab_p}, | ||
}, | ||
} | ||
elif current_collector_dimension == 2: | ||
geometry["current collector"] = { | ||
var.y: {"min": 0, "max": geo.l_y}, | ||
var.z: {"min": 0, "max": geo.l_z}, | ||
"tabs": { | ||
"negative": { | ||
"y_centre": geo.centre_y_tab_n, | ||
"z_centre": geo.centre_z_tab_n, | ||
"width": geo.l_tab_n, | ||
}, | ||
"positive": { | ||
"y_centre": geo.centre_y_tab_p, | ||
"z_centre": geo.centre_z_tab_p, | ||
"width": geo.l_tab_p, | ||
}, | ||
}, | ||
} | ||
else: | ||
raise pybamm.GeometryError( | ||
"Invalid current collector dimension '{}' (should be 0, 1 or 2)".format( | ||
current_collector_dimension | ||
) | ||
) | ||
|
||
return pybamm.Geometry(geometry) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import pybamm | ||
|
||
whole_cell = ["separator", "working electrode"] | ||
|
||
# Domains at cell centres | ||
x_Li = pybamm.SpatialVariable( | ||
"x_Li", | ||
domain=["lithium counter electrode"], | ||
auxiliary_domains={"secondary": "current collector"}, | ||
coord_sys="cartesian", | ||
) | ||
x_s = pybamm.SpatialVariable( | ||
"x_s", | ||
domain=["separator"], | ||
auxiliary_domains={"secondary": "current collector"}, | ||
coord_sys="cartesian", | ||
) | ||
x_w = pybamm.SpatialVariable( | ||
"x_w", | ||
domain=["working electrode"], | ||
auxiliary_domains={"secondary": "current collector"}, | ||
coord_sys="cartesian", | ||
) | ||
x = pybamm.SpatialVariable( | ||
"x", | ||
domain=whole_cell, | ||
auxiliary_domains={"secondary": "current collector"}, | ||
coord_sys="cartesian", | ||
) | ||
|
||
y = pybamm.SpatialVariable("y", domain="current collector", coord_sys="cartesian") | ||
z = pybamm.SpatialVariable("z", domain="current collector", coord_sys="cartesian") | ||
|
||
r_w = pybamm.SpatialVariable( | ||
"r_w", | ||
domain=["working particle"], | ||
auxiliary_domains={ | ||
"secondary": "working electrode", | ||
"tertiary": "current collector", | ||
}, | ||
coord_sys="spherical polar", | ||
) | ||
|
||
# Domains at cell edges | ||
x_Li_edge = pybamm.SpatialVariableEdge( | ||
"x_Li", | ||
domain=["lithium counter electrode"], | ||
auxiliary_domains={"secondary": "current collector"}, | ||
coord_sys="cartesian", | ||
) | ||
x_s_edge = pybamm.SpatialVariableEdge( | ||
"x_s", | ||
domain=["separator"], | ||
auxiliary_domains={"secondary": "current collector"}, | ||
coord_sys="cartesian", | ||
) | ||
x_w_edge = pybamm.SpatialVariableEdge( | ||
"x_w", | ||
domain=["working electrode"], | ||
auxiliary_domains={"secondary": "current collector"}, | ||
coord_sys="cartesian", | ||
) | ||
x_edge = pybamm.SpatialVariableEdge( | ||
"x", | ||
domain=whole_cell, | ||
auxiliary_domains={"secondary": "current collector"}, | ||
coord_sys="cartesian", | ||
) | ||
|
||
y_edge = pybamm.SpatialVariableEdge( | ||
"y", domain="current collector", coord_sys="cartesian" | ||
) | ||
z_edge = pybamm.SpatialVariableEdge( | ||
"z", domain="current collector", coord_sys="cartesian" | ||
) | ||
|
||
r_w_edge = pybamm.SpatialVariableEdge( | ||
"r_w", | ||
domain=["working particle"], | ||
auxiliary_domains={ | ||
"secondary": "working electrode", | ||
"tertiary": "current collector", | ||
}, | ||
coord_sys="spherical polar", | ||
) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check why this was necessary but not urgent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this has to do because the separator and current collector were defined in
fixed_domain_sizes
but the new domains weren't, so when they interact it breaks down...Also, random question related to that. When we get the size of a variable defined in a domain in
fixed_domain_sizes
, why do we take the sum and not the product? I thought the idea of assigning prime numbers to the domains was to get unique signatures for each combination.