Skip to content

Commit 7ee11c5

Browse files
#492 get working for 3d (in theory)
1 parent 049960d commit 7ee11c5

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

pybamm/models/full_battery_models/base_battery_model.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -686,16 +686,6 @@ def set_voltage_variables(self):
686686
eta_r_av = eta_r_p_av - eta_r_n_av
687687
eta_r_av_dim = eta_r_p_av_dim - eta_r_n_av_dim
688688

689-
# terminal voltage (Note: phi_s_cn is zero at the negative tab)
690-
phi_s_cp = self.variables["Positive current collector potential"]
691-
phi_s_cp_dim = self.variables["Positive current collector potential [V]"]
692-
if self.options["dimensionality"] == 0:
693-
V = phi_s_cp
694-
V_dim = phi_s_cp_dim
695-
elif self.options["dimensionality"] in [1, 2]:
696-
V = pybamm.BoundaryValue(phi_s_cp, "positive tab")
697-
V_dim = pybamm.BoundaryValue(phi_s_cp_dim, "positive tab")
698-
699689
# TODO: add current collector losses to the voltage in 3D
700690

701691
self.variables.update(
@@ -708,12 +698,11 @@ def set_voltage_variables(self):
708698
"X-averaged reaction overpotential [V]": eta_r_av_dim,
709699
"X-averaged solid phase ohmic losses": delta_phi_s_av,
710700
"X-averaged solid phase ohmic losses [V]": delta_phi_s_av_dim,
711-
"Terminal voltage": V,
712-
"Terminal voltage [V]": V_dim,
713701
}
714702
)
715703

716704
# Battery-wide variables
705+
V_dim = self.variables["Terminal voltage [V]"]
717706
eta_e_av_dim = self.variables.get("X-averaged electrolyte ohmic losses [V]", 0)
718707
eta_c_av_dim = self.variables.get(
719708
"X-averaged concentration overpotential [V]", 0

pybamm/models/submodels/electrode/base_electrode.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,23 @@ def _get_standard_current_collector_potential_variables(self, phi_s_cn, phi_s_cp
130130
# Local potential difference
131131
V_cc = phi_s_cp - phi_s_cn
132132

133+
# terminal voltage (Note: phi_s_cn is zero at the negative tab)
134+
# Voltage is local current collector potential difference at the tabs, in 1D
135+
# this will be equal to the local current collector potential difference
136+
phi_s_cp_dim = U_ref + phi_s_cp * pot_scale
137+
V = pybamm.boundary_value(phi_s_cp, "positive tab")
138+
V_dim = pybamm.boundary_value(phi_s_cp_dim, "positive tab")
139+
133140
variables = {
134141
"Negative current collector potential": phi_s_cn,
135142
"Negative current collector potential [V]": phi_s_cn * pot_scale,
136143
"Positive current collector potential": phi_s_cp,
137-
"Positive current collector potential [V]": U_ref + phi_s_cp * pot_scale,
144+
"Positive current collector potential [V]": phi_s_cp_dim,
138145
"Local current collector potential difference": V_cc,
139146
"Local current collector potential difference [V]": U_ref
140147
+ V_cc * pot_scale,
148+
"Terminal voltage": V,
149+
"Terminal voltage [V]": V_dim,
141150
}
142151

143152
return variables

pybamm/models/submodels/external_circuit/voltage_control_external_circuit.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def set_algebraic(self, variables):
3535
# External circuit submodels are always equations on the current
3636
# Fix voltage to be equal to terminal voltage
3737
i_cell = variables["Total current density"]
38-
# TODO: change this to terminal voltage
39-
V = variables["Local current collector potential difference"]
38+
V = variables["Terminal voltage"]
4039
# TODO: find a way to get rid of 0 * i_cell
4140
self.algebraic[i_cell] = V - self.param.voltage_with_time + 0 * i_cell

pybamm/spatial_methods/zero_dimensional_method.py

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ def __init__(self, options=None):
2323
def build(self, mesh):
2424
self._mesh = mesh
2525

26+
def boundary_value_or_flux(self, symbol, discretised_child, bcs=None):
27+
"""
28+
In 0D, the boundary value is the identity operator.
29+
See :meth:`SpatialMethod.boundary_value_or_flux`
30+
"""
31+
return discretised_child
32+
2633
def mass_matrix(self, symbol, boundary_conditions):
2734
"""
2835
Calculates the mass matrix for a spatial method. Since the spatial method is

0 commit comments

Comments
 (0)