Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
from .geometry.geometry import Geometry
from .geometry.battery_geometry import battery_geometry

from .expression_tree.independent_variable import KNOWN_COORD_SYS
from .geometry import standard_spatial_vars

# Parameter classes and methods
Expand Down
9 changes: 2 additions & 7 deletions src/pybamm/expression_tree/independent_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import pybamm
from pybamm.type_definitions import DomainType, AuxiliaryDomainType, DomainsType

KNOWN_COORD_SYS = ["cartesian", "cylindrical polar", "spherical polar"]


class IndependentVariable(pybamm.Symbol):
"""
Expand Down Expand Up @@ -141,9 +139,7 @@ def __init__(
domain: DomainType = None,
auxiliary_domains: AuxiliaryDomainType = None,
domains: DomainsType = None,
coord_sys=None,
) -> None:
self.coord_sys = coord_sys
super().__init__(
name, domain=domain, auxiliary_domains=auxiliary_domains, domains=domains
)
Expand Down Expand Up @@ -176,7 +172,7 @@ def create_copy(
perform_simplifications=True,
):
"""See :meth:`pybamm.Symbol.new_copy()`."""
return self.__class__(self.name, domains=self.domains, coord_sys=self.coord_sys)
return self.__class__(self.name, domains=self.domains)


class SpatialVariableEdge(SpatialVariable):
Expand Down Expand Up @@ -206,9 +202,8 @@ def __init__(
domain: DomainType = None,
auxiliary_domains: AuxiliaryDomainType = None,
domains: DomainsType = None,
coord_sys=None,
) -> None:
super().__init__(name, domain, auxiliary_domains, domains, coord_sys)
super().__init__(name, domain, auxiliary_domains, domains)

def _evaluates_on_edges(self, dimension):
return True
Expand Down
103 changes: 47 additions & 56 deletions src/pybamm/geometry/battery_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,86 +39,74 @@ def battery_geometry(

# Set up electrode/separator/electrode geometry
geometry = {
"negative electrode": {"x_n": {"min": 0, "max": L_n}},
"separator": {"x_s": {"min": L_n, "max": L_n_L_s}},
"positive electrode": {"x_p": {"min": L_n_L_s, "max": geo.L_x}},
"negative electrode": {"x_n": {"min": 0, "max": L_n}, "coord_sys": "cartesian"},
"separator": {"x_s": {"min": L_n, "max": L_n_L_s}, "coord_sys": "cartesian"},
"positive electrode": {
"x_p": {"min": L_n_L_s, "max": geo.L_x},
"coord_sys": "cartesian",
},
}

# Add particle domains
if include_particles is True:
for domain in ["negative", "positive"]:
domain_options = getattr(options, domain)
if options.electrode_types[domain] == "porous":
particle_coord_sys = domain_options["particle shape"] + " polar"
geo_domain = geo.domain_params[domain]
d = domain[0]
geometry.update(
{
f"{domain} particle": {
f"r_{d}": {"min": 0, "max": geo_domain.prim.R_typ}
f"r_{d}": {"min": 0, "max": geo_domain.prim.R_typ},
"coord_sys": particle_coord_sys,
},
}
)
phases = int(getattr(options, domain)["particle phases"])
phases = int(domain_options["particle phases"])
if phases >= 2:
geometry.update(
{
f"{domain} primary particle": {
f"r_{d}_prim": {"min": 0, "max": geo_domain.prim.R_typ}
f"r_{d}_prim": {"min": 0, "max": geo_domain.prim.R_typ},
"coord_sys": particle_coord_sys,
},
f"{domain} secondary particle": {
f"r_{d}_sec": {"min": 0, "max": geo_domain.sec.R_typ}
f"r_{d}_sec": {"min": 0, "max": geo_domain.sec.R_typ},
"coord_sys": particle_coord_sys,
},
}
)

# Add particle size domains
if (
options is not None
and options.negative["particle size"] == "distribution"
and options.electrode_types["negative"] == "porous"
):
R_min_n = geo.n.prim.R_min
R_max_n = geo.n.prim.R_max
geometry.update(
{
"negative particle size": {"R_n": {"min": R_min_n, "max": R_max_n}},
}
)
phases = int(options.negative["particle phases"])
if phases >= 2:
geometry.update(
{
"negative primary particle size": {
"R_n_prim": {"min": R_min_n, "max": R_max_n}
},
"negative secondary particle size": {
"R_n_sec": {"min": R_min_n, "max": R_max_n}
},
}
)
if (
options is not None
and options.positive["particle size"] == "distribution"
and options.electrode_types["positive"] == "porous"
):
R_min_p = geo.p.prim.R_min
R_max_p = geo.p.prim.R_max
geometry.update(
{
"positive particle size": {"R_p": {"min": R_min_p, "max": R_max_p}},
}
)
phases = int(options.positive["particle phases"])
if phases >= 2:
geometry.update(
{
"positive primary particle size": {
"R_p_prim": {"min": R_min_p, "max": R_max_p}
},
"positive secondary particle size": {
"R_p_sec": {"min": R_min_p, "max": R_max_p}
},
}
)
if domain_options["particle size"] == "distribution":
if phases == 1:
geometry.update(
{
f"{domain} particle size": {
f"R_{d}": {
"min": geo_domain.prim.R_min,
"max": geo_domain.prim.R_max,
}
},
}
)
elif phases == 2:
geometry.update(
{
f"{domain} primary particle size": {
f"R_{d}_prim": {
"min": geo_domain.prim.R_min,
"max": geo_domain.prim.R_max,
}
},
f"{domain} secondary particle size": {
f"R_{d}_sec": {
"min": geo_domain.sec.R_min,
"max": geo_domain.sec.R_max,
}
},
}
)

# Add current collector domains
current_collector_dimension = options["dimensionality"]
Expand All @@ -128,6 +116,7 @@ def battery_geometry(
elif current_collector_dimension == 1:
geometry["current collector"] = {
"z": {"min": 0, "max": geo.L_z},
"coord_sys": "cartesian",
"tabs": {
"negative": {"z_centre": geo.n.centre_z_tab},
"positive": {"z_centre": geo.p.centre_z_tab},
Expand All @@ -137,6 +126,7 @@ def battery_geometry(
geometry["current collector"] = {
"y": {"min": 0, "max": geo.L_y},
"z": {"min": 0, "max": geo.L_z},
"coord_sys": "cartesian",
"tabs": {
"negative": {
"y_centre": geo.n.centre_y_tab,
Expand All @@ -156,6 +146,7 @@ def battery_geometry(
elif current_collector_dimension == 1:
geometry["current collector"] = {
"r_macro": {"min": geo.r_inner, "max": 1},
"coord_sys": "cylindrical polar",
}
else:
raise pybamm.GeometryError(
Expand Down
Loading
Loading