Skip to content

Commit f7b1f85

Browse files
committed
feat: Add type hints to constant_concentration.py
1 parent 4587f83 commit f7b1f85

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

src/pybamm/models/submodels/electrolyte_diffusion/constant_concentration.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
#
2-
# Class for leading-order electrolyte diffusion employing stefan-maxwell
3-
#
41
import pybamm
5-
from typing import Dict, Optional, Any, TYPE_CHECKING
6-
7-
if TYPE_CHECKING:
8-
from pybamm import ParameterValues
2+
from typing import Optional, Any, TYPE_CHECKING
93

104
from .base_electrolyte_diffusion import BaseElectrolyteDiffusion
115

6+
if TYPE_CHECKING:
7+
from pybamm import ParameterValues, Symbol
8+
129

1310
class ConstantConcentration(BaseElectrolyteDiffusion):
1411
"""Class for constant concentration of electrolyte
@@ -21,19 +18,17 @@ class ConstantConcentration(BaseElectrolyteDiffusion):
2118
A dictionary of options to be passed to the model.
2219
"""
2320

24-
def __init__(
25-
self, param: "ParameterValues", options: Optional[Dict[str, Any]] = None
26-
) -> None:
21+
def __init__(self, param: "ParameterValues", options: Optional[dict[str, Any]] = None) -> None:
2722
super().__init__(param, options)
2823

29-
def get_fundamental_variables(self) -> Dict[str, pybamm.Symbol]:
24+
def get_fundamental_variables(self) -> dict[str, pybamm.Symbol]:
3025
c_e_init: float = self.param.c_e_init
31-
eps_c_e_dict: Dict[str, pybamm.Symbol] = {
26+
eps_c_e_dict: dict[str, pybamm.Symbol] = {
3227
domain: self.param.domain_params[domain.split()[0]].epsilon_init * c_e_init
3328
for domain in self.options.whole_cell_domains
3429
}
35-
variables: Dict[str, pybamm.Symbol] = (
36-
self._get_standard_porosity_times_concentration_variables(eps_c_e_dict)
30+
variables: dict[str, pybamm.Symbol] = self._get_standard_porosity_times_concentration_variables(
31+
eps_c_e_dict
3732
)
3833
N_e: pybamm.Symbol = pybamm.FullBroadcastToEdges(
3934
0,
@@ -45,16 +40,12 @@ def get_fundamental_variables(self) -> Dict[str, pybamm.Symbol]:
4540

4641
return variables
4742

48-
def get_coupled_variables(
49-
self, variables: Dict[str, pybamm.Symbol]
50-
) -> Dict[str, pybamm.Symbol]:
51-
c_e_dict: Dict[str, pybamm.Symbol] = {}
43+
def get_coupled_variables(self, variables: dict[str, pybamm.Symbol]) -> dict[str, pybamm.Symbol]:
44+
c_e_dict: dict[str, pybamm.Symbol] = {}
5245
for domain in self.options.whole_cell_domains:
5346
Domain = domain.capitalize()
5447
eps_k: pybamm.Symbol = variables[f"{Domain} porosity"]
55-
eps_c_e_k: pybamm.Symbol = variables[
56-
f"{Domain} porosity times concentration [mol.m-3]"
57-
]
48+
eps_c_e_k: pybamm.Symbol = variables[f"{Domain} porosity times concentration [mol.m-3]"]
5849
c_e_k: pybamm.Symbol = eps_c_e_k / eps_k
5950
c_e_dict[domain] = c_e_k
6051

@@ -70,7 +61,7 @@ def get_coupled_variables(
7061

7162
return variables
7263

73-
def set_boundary_conditions(self, variables: Dict[str, pybamm.Symbol]) -> None:
64+
def set_boundary_conditions(self, variables: dict[str, pybamm.Symbol]) -> None:
7465
"""
7566
We provide boundary conditions even though the concentration is constant
7667
so that the gradient of the concentration has the correct shape after
@@ -86,6 +77,6 @@ def set_boundary_conditions(self, variables: Dict[str, pybamm.Symbol]) -> None:
8677
}
8778
}
8879

89-
def add_events_from(self, variables: Dict[str, pybamm.Symbol]) -> None:
80+
def add_events_from(self, variables: dict[str, pybamm.Symbol]) -> None:
9081
# No event since the concentration is constant
91-
pass
82+
pass

0 commit comments

Comments
 (0)