Skip to content

Commit 2d6248d

Browse files
committed
#492 added voltage getters to parameter values
1 parent c50eaab commit 2d6248d

File tree

6 files changed

+50
-10
lines changed

6 files changed

+50
-10
lines changed

pybamm/discretisations/discretisation.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,11 @@ def process_dict(self, var_eqn_dict):
431431

432432
new_var_eqn_dict[eqn_key] = self.process_symbol(eqn)
433433

434-
new_var_eqn_dict[eqn_key].test_shape()
434+
try:
435+
new_var_eqn_dict[eqn_key].test_shape()
436+
except:
437+
new_var_eqn_dict[eqn_key].test_shape()
438+
435439

436440
return new_var_eqn_dict
437441

pybamm/models/full_battery_models/base_battery_model.py

+4
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ def default_parameter_values(self):
3434
),
3535
{
3636
"Typical current [A]": 1,
37+
"Typical voltage [V]": 3.5,
3738
"Current function": pybamm.GetConstantCurrent(
3839
pybamm.standard_parameters_lithium_ion.I_typ
3940
),
41+
"Voltage function": pybamm.GetConstantVoltage(
42+
pybamm.standard_parameters_lithium_ion.V_typ
43+
),
4044
"Electrolyte diffusivity": os.path.join(
4145
input_path, "electrolyte_diffusivity_Capiglia1999.py"
4246
),

pybamm/models/full_battery_models/lithium_ion/dfn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def __init__(self, options=None, name="Doyle-Fuller-Newman model"):
1919
self.set_current_collector_submodel()
2020
self.set_porosity_submodel()
2121
self.set_convection_submodel()
22+
self.set_solid_submodel()
2223
self.set_interfacial_submodel()
2324
self.set_particle_submodel()
24-
self.set_solid_submodel()
2525
self.set_electrolyte_submodel()
2626
self.set_thermal_submodel()
2727

pybamm/models/submodels/current_collector/homogeneous_current_collector.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,34 @@ class Uniform(BaseModel):
1818
**Extends:** :class:`pybamm.current_collector.BaseModel`
1919
"""
2020

21-
def __init__(self, param):
21+
def __init__(self, param, options=None):
2222
super().__init__(param)
23+
if options:
24+
self.options = options
25+
else:
26+
self.options = {"problem type": "potentiostatic"}
2327

2428
def get_fundamental_variables(self):
29+
if self.options["problem type"] == "potentiostatic":
30+
variables = self._get_potentiostatic_fundamental_variables()
31+
elif self.options["problem type"] == "galvanostatic":
32+
variables = self._get_galvanostatic_fundamental_variables()
33+
else:
34+
raise pybamm.OptionError
2535

26-
i_cc = pybamm.Scalar(0)
36+
return variables
2737

38+
def _get_galvanostatic_fundamental_variables(self):
39+
i_cc = pybamm.Scalar(0)
2840
i_boundary_cc = self.param.current_with_time
29-
3041
variables = self._get_standard_current_variables(i_cc, i_boundary_cc)
42+
return variables
43+
44+
def _get_potentiostatic_fundamental_variables(self):
3145

46+
phi_s_cn = pybamm.Scalar(0)
47+
phi_s_cp = self.param.voltage_with_time
48+
49+
variables = self._get_standard_potential_variables(phi_s_cn, phi_s_cp)
3250
return variables
51+

pybamm/models/submodels/electrode/ohm/full_ohm.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ def get_coupled_variables(self, variables):
5858
if self.domain == "Positive":
5959
variables.update(self._get_standard_whole_cell_current_variables(variables))
6060

61+
if (
62+
self.domain == "Positive"
63+
and self.options["problem type"] == "potentiostatic"
64+
):
65+
variables.update(self._get_current_collector_current_density(i_s))
66+
67+
return variables
68+
69+
def _get_current_collector_current_density(self, i_s):
70+
i_boundary_cc = pybamm.BoundaryValue(i_s, "right")
71+
variables = {"Current collector current density": i_boundary_cc}
6172
return variables
6273

6374
def set_algebraic(self, variables):
@@ -107,15 +118,15 @@ def _set_galvanostatic_boundary_conditions(self, variables):
107118
def _set_potentiostatic_boundary_conditions(self, variables):
108119

109120
phi_s = variables[self.domain + " electrode potential"]
110-
v = variables["Applied voltage"]
121+
v_cc = variables["Local current collector potential difference"]
111122

112123
if self.domain == "Negative":
113124
lbc = (pybamm.Scalar(0), "Dirichlet")
114125
rbc = (pybamm.Scalar(0), "Neumann")
115126

116127
elif self.domain == "Positive":
117128
lbc = (pybamm.Scalar(0), "Neumann")
118-
rbc = (v, "Dirichlet")
129+
rbc = (v_cc, "Dirichlet")
119130

120131
self.boundary_conditions[phi_s] = {"left": lbc, "right": rbc}
121132

pybamm/parameters/parameter_values.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,19 @@ def _process_symbol(self, symbol):
239239
new_children = [self.process_symbol(child) for child in symbol.children]
240240
function_name = self[symbol.name]
241241

242-
# if current setter, process any parameters that are symbols and
242+
# if current/voltage setter, process any parameters that are symbols and
243243
# store the evaluated symbol in the parameters_eval dict
244-
if isinstance(function_name, pybamm.GetCurrent):
244+
if isinstance(function_name, (pybamm.GetCurrent, pybamm.GetVoltage)):
245245
for param, sym in function_name.parameters.items():
246246
if isinstance(sym, pybamm.Symbol):
247247
new_sym = self.process_symbol(sym)
248248
function_name.parameters[param] = new_sym
249249
function_name.parameters_eval[param] = new_sym.evaluate()
250250
# If loading data, need to update interpolant with
251251
# evaluated parameters
252-
if isinstance(function_name, pybamm.GetCurrentData):
252+
if isinstance(
253+
function_name, (pybamm.GetCurrentData, pybamm.GetVoltageData)
254+
):
253255
function_name.interpolate()
254256

255257
if callable(function_name):

0 commit comments

Comments
 (0)