From cf53ff1d9e74eda7e68bc65b5dea5c18f7fcf872 Mon Sep 17 00:00:00 2001 From: DrSOKane Date: Mon, 5 Jun 2023 12:17:24 +0100 Subject: [PATCH] fixed tests --- .../scripts/compare_lithium_ion_half_cell.py | 6 +- pybamm/expression_tree/averages.py | 2 +- .../full_battery_models/base_battery_model.py | 24 +++----- .../lithium_ion/basic_dfn_half_cell.py | 5 -- .../lithium_ion/electrode_soh_half_cell.py | 12 ++-- .../full_battery_models/lithium_ion/mpm.py | 2 +- .../full_battery_models/lithium_metal/dfn.py | 2 +- .../submodels/interface/sei/base_sei.py | 39 ++++++------ pybamm/parameters/lithium_ion_parameters.py | 8 +-- .../size_distribution_parameters.py | 60 +++++++++---------- pybamm/simulation.py | 2 +- .../base_lithium_ion_half_cell_tests.py | 2 +- .../test_basic_half_cell_models.py | 4 +- .../test_simulation_with_experiment.py | 2 +- .../test_base_battery_model.py | 22 ++----- .../base_lithium_ion_half_cell_tests.py | 2 +- .../test_lithium_ion/test_basic_models.py | 8 +-- .../test_lithium_ion/test_electrode_soh.py | 4 +- .../test_lithium_ion/test_mpm_half_cell.py | 18 +++--- .../test_lithium_ion/test_spme_half_cell.py | 2 +- .../test_parameters_with_default_models.py | 2 +- .../test_size_distribution_parameters.py | 12 ++-- tests/unit/test_plotting/test_quick_plot.py | 4 +- 23 files changed, 108 insertions(+), 136 deletions(-) diff --git a/examples/scripts/compare_lithium_ion_half_cell.py b/examples/scripts/compare_lithium_ion_half_cell.py index b6396724f4..c38c819483 100644 --- a/examples/scripts/compare_lithium_ion_half_cell.py +++ b/examples/scripts/compare_lithium_ion_half_cell.py @@ -7,9 +7,9 @@ # load models models = [ - pybamm.lithium_ion.SPM({"working electrode": "positive"}), - pybamm.lithium_ion.SPMe({"working electrode": "positive"}), - pybamm.lithium_ion.DFN({"working electrode": "positive"}), + pybamm.lithium_ion.SPM({"half-cell": "true"}), + pybamm.lithium_ion.SPMe({"half-cell": "true"}), + pybamm.lithium_ion.DFN({"half-cell": "true"}), ] # create and run simulations diff --git a/pybamm/expression_tree/averages.py b/pybamm/expression_tree/averages.py index 6ada30d47a..e063b16c2a 100644 --- a/pybamm/expression_tree/averages.py +++ b/pybamm/expression_tree/averages.py @@ -273,7 +273,7 @@ def r_average(symbol): # "positive electrode", take the r-average of the child then broadcast back elif isinstance(symbol, pybamm.SecondaryBroadcast) and symbol.domains[ "secondary" - ] in [["positive electrode"], ["negative electrode"], ["working electrode"]]: + ] in [["positive electrode"], ["negative electrode"]]: child = symbol.orphans[0] child_av = pybamm.r_average(child) return pybamm.PrimaryBroadcast(child_av, symbol.domains["secondary"]) diff --git a/pybamm/models/full_battery_models/base_battery_model.py b/pybamm/models/full_battery_models/base_battery_model.py index 4ea4611133..440a129bd2 100644 --- a/pybamm/models/full_battery_models/base_battery_model.py +++ b/pybamm/models/full_battery_models/base_battery_model.py @@ -49,6 +49,10 @@ class BatteryModelOptions(pybamm.FuzzyDict): * "electrolyte conductivity" : str Can be "default" (default), "full", "leading order", "composite" or "integrated". + * "half-cell" : str + Can be "false" (default) for a standard battery or "true" for a + half-cell where the negative electrode is replaced with a lithium metal + counter electrode. * "hydrolysis" : str Whether to include hydrolysis in the model. Only implemented for lead-acid models. Can be "false" (default) or "true". If "true", then @@ -168,10 +172,6 @@ class BatteryModelOptions(pybamm.FuzzyDict): solve an algebraic equation for it. Default is "false", unless "SEI film resistance" is distributed in which case it is automatically set to "true". - * "working electrode": str - Which electrode(s) intercalates and which is counter. If "both" - (default), the model is a standard battery. Otherwise can be "negative" - or "positive" to indicate a half-cell model. * "x-average side reactions": str Whether to average the side reactions (SEI growth, lithium plating and the respective porosity change) over the x-axis in Single Particle @@ -199,6 +199,7 @@ def __init__(self, extra_options): "composite", "integrated", ], + "half-cell": ["false", "true"], "hydrolysis": ["false", "true"], "intercalation kinetics": [ "symmetric Butler-Volmer", @@ -262,7 +263,6 @@ def __init__(self, extra_options): "surface form": ["false", "differential", "algebraic"], "thermal": ["isothermal", "lumped", "x-lumped", "x-full"], "total interfacial current density as a state": ["false", "true"], - "working electrode": ["both", "negative", "positive"], "x-average side reactions": ["false", "true"], } @@ -495,7 +495,7 @@ def __init__(self, extra_options): "mechanics model" ) - if options["working electrode"] != "both": + if options["half-cell"] == "true": if options["thermal"] == "x-full": raise pybamm.OptionError( "X-full thermal submodel is not compatible with half-cell models" @@ -506,10 +506,6 @@ def __init__(self, extra_options): f"X-lumped thermal submodels do not yet support {n}D " "current collectors in a half-cell configuration" ) - elif options["SEI on cracks"] == "true": - raise NotImplementedError( - "SEI on cracks not yet implemented for half-cell models" - ) if options["particle phases"] != "1": if not ( @@ -530,7 +526,7 @@ def __init__(self, extra_options): # Check options are valid for option, value in options.items(): - if option in ["working electrode"]: + if option in ["half-cell"]: # is this exception still necessary? pass else: if isinstance(value, str) or option in [ @@ -597,11 +593,9 @@ def phases(self): @cached_property def whole_cell_domains(self): - if self["working electrode"] == "positive": + if self["half-cell"] == "true": return ["separator", "positive electrode"] - elif self["working electrode"] == "negative": - return ["negative electrode", "separator"] - elif self["working electrode"] == "both": + else: return ["negative electrode", "separator", "positive electrode"] @property diff --git a/pybamm/models/full_battery_models/lithium_ion/basic_dfn_half_cell.py b/pybamm/models/full_battery_models/lithium_ion/basic_dfn_half_cell.py index cda7c02731..47916c2ffc 100644 --- a/pybamm/models/full_battery_models/lithium_ion/basic_dfn_half_cell.py +++ b/pybamm/models/full_battery_models/lithium_ion/basic_dfn_half_cell.py @@ -38,11 +38,6 @@ class BasicDFNHalfCell(BaseModel): def __init__(self, options=None, name="Doyle-Fuller-Newman half cell model"): super().__init__(options, name) - if self.options["working electrode"] not in ["negative", "positive"]: - raise ValueError( - "The option 'working electrode' should be either 'positive'" - " or 'negative'" - ) pybamm.citations.register("Marquis2019") # `param` is a class containing all the relevant parameters and functions for # this model. These are purely symbolic at this stage, and will be set by the diff --git a/pybamm/models/full_battery_models/lithium_ion/electrode_soh_half_cell.py b/pybamm/models/full_battery_models/lithium_ion/electrode_soh_half_cell.py index 75f9878fff..1cc0293298 100644 --- a/pybamm/models/full_battery_models/lithium_ion/electrode_soh_half_cell.py +++ b/pybamm/models/full_battery_models/lithium_ion/electrode_soh_half_cell.py @@ -25,21 +25,17 @@ class ElectrodeSOHHalfCell(pybamm.BaseModel): expansion. Journal of Power Sources, 427, 101-111. """ - def __init__(self, working_electrode, name="Electrode-specific SOH model"): - self.working_electrode = working_electrode + def __init__(self, name="Electrode-specific SOH model"): pybamm.citations.register("Mohtat2019") super().__init__(name) - param = pybamm.LithiumIonParameters({"working electrode": working_electrode}) + param = pybamm.LithiumIonParameters({"half-cell": "true"}) x_100 = pybamm.Variable("x_100", bounds=(0, 1)) x_0 = pybamm.Variable("x_0", bounds=(0, 1)) Q_w = pybamm.InputParameter("Q_w") T_ref = param.T_ref - if working_electrode == "negative": # pragma: no cover - raise NotImplementedError - elif working_electrode == "positive": - U_w = param.p.prim.U - Q = Q_w * (x_100 - x_0) + U_w = param.p.prim.U + Q = Q_w * (x_100 - x_0) V_max = param.voltage_high_cut V_min = param.voltage_low_cut diff --git a/pybamm/models/full_battery_models/lithium_ion/mpm.py b/pybamm/models/full_battery_models/lithium_ion/mpm.py index 3286a9c03f..9b42007bdc 100644 --- a/pybamm/models/full_battery_models/lithium_ion/mpm.py +++ b/pybamm/models/full_battery_models/lithium_ion/mpm.py @@ -53,6 +53,6 @@ def __init__(self, options=None, name="Many-Particle Model", build=True): def default_parameter_values(self): default_params = super().default_parameter_values default_params = pybamm.get_size_distribution_parameters( - default_params, electrode=self.options["working electrode"] + default_params, halfcell=self.options["half-cell"] ) return default_params diff --git a/pybamm/models/full_battery_models/lithium_metal/dfn.py b/pybamm/models/full_battery_models/lithium_metal/dfn.py index a7ab8b99e2..eb11345c90 100644 --- a/pybamm/models/full_battery_models/lithium_metal/dfn.py +++ b/pybamm/models/full_battery_models/lithium_metal/dfn.py @@ -29,7 +29,7 @@ def __init__( self, options=None, name="Doyle-Fuller-Newman lithium metal model", build=True ): options = options or {} - options["working electrode"] = "positive" + options["half-cell"] = "positive" super().__init__(options, name, build=False) if build: diff --git a/pybamm/models/submodels/interface/sei/base_sei.py b/pybamm/models/submodels/interface/sei/base_sei.py index 479bc44e70..6b08214ff4 100644 --- a/pybamm/models/submodels/interface/sei/base_sei.py +++ b/pybamm/models/submodels/interface/sei/base_sei.py @@ -30,40 +30,45 @@ def __init__(self, param, options, phase="primary", cracks=False): def get_coupled_variables(self, variables): # Update some common variables + zero_av = pybamm.PrimaryBroadcast(0, "current collector") + zero = pybamm.FullBroadcast(0, "positive electrode", "current collector") if self.reaction_loc != "interface": - j_sei_av = variables[ - f"X-averaged {self.reaction_name}interfacial current density [A.m-2]" - ] - j_sei = variables[ - f"{self.reaction_name}interfacial current density [A.m-2]" - ] variables.update( { f"X-averaged negative electrode {self.reaction_name}interfacial " - "current density [A.m-2]": j_sei_av, + "current density": variables[ + f"X-averaged {self.reaction_name}interfacial current density" + ], + f"Negative electrode {self.reaction_name}interfacial current " + "density": variables[ + f"{self.reaction_name}interfacial current density" + ], f"Negative electrode {self.reaction_name}interfacial current " - "density [A.m-2]": j_sei, + "density [A.m-2]": variables[ + f"{self.reaction_name}interfacial current density [A.m-2]" + ], } ) + variables.update( + self._get_standard_volumetric_current_density_variables(variables) + ) - zero_av = pybamm.PrimaryBroadcast(0, "current collector") - zero = pybamm.FullBroadcast(0, "positive electrode", "current collector") variables.update( { + f"X-averaged positive electrode {self.reaction} " + "interfacial current density": zero_av, + f"Positive electrode {self.reaction} " + "interfacial current density": zero, f"Positive electrode {self.reaction} " "interfacial current density [A.m-2]": zero, f"X-averaged positive electrode {self.reaction} " - "volumetric interfacial current density [A.m-2]": zero_av, + "volumetric interfacial current density": zero_av, f"Positive electrode {self.reaction} " - "volumetric interfacial current density [A.m-3]": zero, + "volumetric interfacial current density": zero, } ) - variables.update( - self._get_standard_volumetric_current_density_variables(variables) - ) - return variables def _get_standard_thickness_variables(self, L_inner, L_outer): @@ -157,7 +162,7 @@ def _get_standard_concentration_variables(self, variables): else: # m * (mol/m4) = mol/m3 (n is a bulk quantity) a = variables[ - f"Negative electrode {self.phase_name}" + f"{Domain} electrode {self.phase_name}" "surface area to volume ratio [m-1]" ] L_to_n_inner = a / phase_param.V_bar_inner diff --git a/pybamm/parameters/lithium_ion_parameters.py b/pybamm/parameters/lithium_ion_parameters.py index 43901eff2b..799bcb3561 100644 --- a/pybamm/parameters/lithium_ion_parameters.py +++ b/pybamm/parameters/lithium_ion_parameters.py @@ -16,14 +16,14 @@ class LithiumIonParameters(BaseParameters): A dictionary of options to be passed to the parameters. The options that can be set are listed below. + * "half-cell": str + Can be "false" (default) for a standard battery or "true" for a + half-cell where the negative electrode is replaced with a lithium metal + counter electrode. * "particle shape" : str, optional Sets the model shape of the electrode particles. This is used to calculate the surface area to volume ratio. Can be "spherical" (default). TODO: implement "cylindrical" and "platelet". - * "working electrode": str - Which electrode(s) intercalates and which is counter. If "both" - (default), the model is a standard battery. Otherwise can be "negative" - or "positive" to indicate a half-cell model. """ diff --git a/pybamm/parameters/size_distribution_parameters.py b/pybamm/parameters/size_distribution_parameters.py index c45bd3b11e..4eb0c34618 100644 --- a/pybamm/parameters/size_distribution_parameters.py +++ b/pybamm/parameters/size_distribution_parameters.py @@ -16,7 +16,7 @@ def get_size_distribution_parameters( R_min_p=None, R_max_n=None, R_max_p=None, - electrode="both", + halfcell="false", ): """ A convenience method to add standard area-weighted particle-size distribution @@ -60,7 +60,7 @@ def get_size_distribution_parameters( "positive" to indicate a half-cell model, in which case size distribution parameters are only added for a single electrode. """ - if electrode in ["both", "negative"]: + if halfcell == "false": # Radii from given parameter set R_n_typ = param["Negative particle radius [m]"] @@ -89,35 +89,33 @@ def f_a_dist_n(R): }, check_already_exists=False, ) - if electrode in ["both", "positive"]: - # Radii from given parameter set - R_p_typ = param["Positive particle radius [m]"] - - # Set the mean particle radii - R_p_av = R_p_av or R_p_typ - - # Minimum radii - R_min_p = R_min_p or np.max([0, 1 - sd_p * 5]) - - # Max radii - R_max_p = R_max_p or (1 + sd_p * 5) - - # Area-weighted particle-size distribution - def f_a_dist_p(R): - return lognormal(R, R_p_av, sd_p * R_p_av) - - param.update( - { - "Positive area-weighted mean particle radius [m]": R_p_av, - "Positive area-weighted particle-size " - + "standard deviation [m]": sd_p * R_p_av, - "Positive minimum particle radius [m]": R_min_p * R_p_av, - "Positive maximum particle radius [m]": R_max_p * R_p_av, - "Positive area-weighted " - + "particle-size distribution [m-1]": f_a_dist_p, - }, - check_already_exists=False, - ) + # Radii from given parameter set + R_p_typ = param["Positive particle radius [m]"] + + # Set the mean particle radii + R_p_av = R_p_av or R_p_typ + + # Minimum radii + R_min_p = R_min_p or np.max([0, 1 - sd_p * 5]) + + # Max radii + R_max_p = R_max_p or (1 + sd_p * 5) + + # Area-weighted particle-size distribution + def f_a_dist_p(R): + return lognormal(R, R_p_av, sd_p * R_p_av) + + param.update( + { + "Positive area-weighted mean particle radius [m]": R_p_av, + "Positive area-weighted particle-size " + + "standard deviation [m]": sd_p * R_p_av, + "Positive minimum particle radius [m]": R_min_p * R_p_av, + "Positive maximum particle radius [m]": R_max_p * R_p_av, + "Positive area-weighted " + "particle-size distribution [m-1]": f_a_dist_p, + }, + check_already_exists=False, + ) return param diff --git a/pybamm/simulation.py b/pybamm/simulation.py index 9ae217552e..003193012e 100644 --- a/pybamm/simulation.py +++ b/pybamm/simulation.py @@ -934,7 +934,7 @@ def _get_esoh_solver(self, calc_esoh): calc_esoh is False or isinstance(self.model, pybamm.lead_acid.BaseModel) or isinstance(self.model, pybamm.equivalent_circuit.Thevenin) - or self.model.options["working electrode"] != "both" + or self.model.options["half-cell"] == "true" ): return None diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py index 0c203c9fc7..ebb6f334c9 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py @@ -7,7 +7,7 @@ class BaseIntegrationTestLithiumIonHalfCell: def run_basic_processing_test(self, options, **kwargs): - options["working electrode"] = "positive" + options["half-cell"] = "true" model = self.model(options) modeltest = tests.StandardModelTest(model, **kwargs) modeltest.test_all(skip_output_tests=True) diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_basic_half_cell_models.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_basic_half_cell_models.py index c13efff621..0738a96cbd 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_basic_half_cell_models.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_basic_half_cell_models.py @@ -10,7 +10,7 @@ class TestBasicHalfCellModels(TestCase): def test_runs_Xu2019(self): - options = {"working electrode": "positive"} + options = {"half-cell": "true"} model = pybamm.lithium_ion.BasicDFNHalfCell(options=options) # create geometry @@ -40,7 +40,7 @@ def test_runs_Xu2019(self): def test_runs_OKane2022(self): # load model - options = {"working electrode": "positive"} + options = {"half-cell": "true"} model = pybamm.lithium_ion.BasicDFNHalfCell(options=options) # create geometry diff --git a/tests/unit/test_experiments/test_simulation_with_experiment.py b/tests/unit/test_experiments/test_simulation_with_experiment.py index a48f6f08e8..d3caf4c887 100644 --- a/tests/unit/test_experiments/test_simulation_with_experiment.py +++ b/tests/unit/test_experiments/test_simulation_with_experiment.py @@ -583,7 +583,7 @@ def test_run_experiment_half_cell(self): experiment = pybamm.Experiment( [("Discharge at C/20 until 3.5V", "Charge at 1C until 3.8 V")] ) - model = pybamm.lithium_ion.SPM({"working electrode": "positive"}) + model = pybamm.lithium_ion.SPM({"half-cell": "true"}) sim = pybamm.Simulation( model, experiment=experiment, diff --git a/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py b/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py index ee51f864c4..01f975024b 100644 --- a/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py +++ b/tests/unit/test_models/test_full_battery_models/test_base_battery_model.py @@ -23,6 +23,7 @@ 'current collector': 'uniform' (possible: ['uniform', 'potential pair', 'potential pair quite conductive']) 'dimensionality': 0 (possible: [0, 1, 2]) 'electrolyte conductivity': 'default' (possible: ['default', 'full', 'leading order', 'composite', 'integrated']) +'half-cell': 'false' (possible: ['false', 'true']) 'hydrolysis': 'false' (possible: ['false', 'true']) 'intercalation kinetics': 'symmetric Butler-Volmer' (possible: ['symmetric Butler-Volmer', 'asymmetric Butler-Volmer', 'linear', 'Marcus', 'Marcus-Hush-Chidsey']) 'interface utilisation': 'full' (possible: ['full', 'constant', 'current-driven']) @@ -44,7 +45,6 @@ 'surface form': 'differential' (possible: ['false', 'differential', 'algebraic']) 'thermal': 'x-full' (possible: ['isothermal', 'lumped', 'x-lumped', 'x-full']) 'total interfacial current density as a state': 'false' (possible: ['false', 'true']) -'working electrode': 'both' (possible: ['both', 'negative', 'positive']) 'x-average side reactions': 'false' (possible: ['false', 'true']) """ # noqa: E501 @@ -291,13 +291,6 @@ def test_options(self): # SEI on cracks with self.assertRaisesRegex(pybamm.OptionError, "SEI on cracks"): pybamm.BaseBatteryModel({"SEI on cracks": "bad SEI on cracks"}) - with self.assertRaisesRegex(NotImplementedError, "SEI on cracks not yet"): - pybamm.BaseBatteryModel( - { - "SEI on cracks": "true", - "working electrode": "positive", - } - ) # plating model with self.assertRaisesRegex(pybamm.OptionError, "lithium plating"): @@ -350,15 +343,13 @@ def test_options(self): # thermal half-cell with self.assertRaisesRegex(pybamm.OptionError, "X-full"): - pybamm.BaseBatteryModel( - {"thermal": "x-full", "working electrode": "positive"} - ) + pybamm.BaseBatteryModel({"thermal": "x-full", "half-cell": "true"}) with self.assertRaisesRegex(pybamm.OptionError, "X-lumped"): pybamm.BaseBatteryModel( { "dimensionality": 2, "thermal": "x-lumped", - "working electrode": "positive", + "half-cell": "true", } ) @@ -456,16 +447,11 @@ def test_domain_phase_options(self): self.assertEqual(options.positive.secondary["particle mechanics"], "none") def test_whole_cell_domains(self): - options = BatteryModelOptions({"working electrode": "positive"}) + options = BatteryModelOptions({"half-cell": "true"}) self.assertEqual( options.whole_cell_domains, ["separator", "positive electrode"] ) - options = BatteryModelOptions({"working electrode": "negative"}) - self.assertEqual( - options.whole_cell_domains, ["negative electrode", "separator"] - ) - options = BatteryModelOptions({}) self.assertEqual( options.whole_cell_domains, diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py index 24ccd55d79..8684708c3e 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_half_cell_tests.py @@ -7,7 +7,7 @@ class BaseUnitTestLithiumIonHalfCell: def check_well_posedness(self, options): if self.model is not None: - options["working electrode"] = "positive" + options["half-cell"] = "true" model = self.model(options) model.check_well_posedness() diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_basic_models.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_basic_models.py index 6808709d92..a7b868c6ff 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_basic_models.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_basic_models.py @@ -19,12 +19,12 @@ def test_spm_well_posed(self): model.check_well_posedness() def test_dfn_half_cell_well_posed(self): - options = {"working electrode": "positive"} + options = {"half-cell": "true"} model = pybamm.lithium_ion.BasicDFNHalfCell(options=options) model.check_well_posedness() def test_dfn_half_cell_simulation_with_experiment_error(self): - options = {"working electrode": "positive"} + options = {"half-cell": "true"} model = pybamm.lithium_ion.BasicDFNHalfCell(options=options) experiment = pybamm.Experiment( [("Discharge at C/10 for 10 hours or until 3.5 V")] @@ -36,9 +36,7 @@ def test_dfn_half_cell_simulation_with_experiment_error(self): pybamm.Simulation(model, experiment=experiment) def test_basic_dfn_half_cell_simulation(self): - model = pybamm.lithium_ion.BasicDFNHalfCell( - options={"working electrode": "positive"} - ) + model = pybamm.lithium_ion.BasicDFNHalfCell(options={"half-cell": "true"}) param = pybamm.ParameterValues("OKane2022") param["Current function [A]"] = 2.5 sim = pybamm.Simulation(model=model, parameter_values=param) diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_electrode_soh.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_electrode_soh.py index 1fae0db77d..75112745ba 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_electrode_soh.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_electrode_soh.py @@ -139,9 +139,9 @@ def test_error(self): class TestElectrodeSOHHalfCell(TestCase): def test_known_solution(self): - model = pybamm.lithium_ion.ElectrodeSOHHalfCell("positive") + model = pybamm.lithium_ion.ElectrodeSOHHalfCell() - param = pybamm.LithiumIonParameters({"working electrode": "positive"}) + param = pybamm.LithiumIonParameters({"half-cell": "true"}) parameter_values = pybamm.ParameterValues("Xu2019") sim = pybamm.Simulation(model, parameter_values=parameter_values) diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm_half_cell.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm_half_cell.py index 364120c741..93c5afea44 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm_half_cell.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_mpm_half_cell.py @@ -8,18 +8,18 @@ class TestMPM(TestCase): def test_well_posed(self): - options = {"thermal": "isothermal", "working electrode": "positive"} + options = {"thermal": "isothermal", "half-cell": "true"} model = pybamm.lithium_ion.MPM(options) model.check_well_posedness() # Test build after init - model = pybamm.lithium_ion.MPM({"working electrode": "positive"}, build=False) + model = pybamm.lithium_ion.MPM({"half-cell": "true"}, build=False) model.build_model() model.check_well_posedness() def test_default_parameter_values(self): # check default parameters are added correctly - model = pybamm.lithium_ion.MPM({"working electrode": "positive"}) + model = pybamm.lithium_ion.MPM({"half-cell": "true"}) self.assertEqual( model.default_parameter_values[ "Positive area-weighted mean particle radius [m]" @@ -28,19 +28,19 @@ def test_default_parameter_values(self): ) def test_lumped_thermal_model_1D(self): - options = {"thermal": "lumped", "working electrode": "positive"} + options = {"thermal": "lumped", "half-cell": "true"} model = pybamm.lithium_ion.MPM(options) model.check_well_posedness() def test_particle_uniform(self): - options = {"particle": "uniform profile", "working electrode": "positive"} + options = {"particle": "uniform profile", "half-cell": "true"} model = pybamm.lithium_ion.MPM(options) model.check_well_posedness() def test_differential_surface_form(self): options = { "surface form": "differential", - "working electrode": "positive", + "half-cell": "true", } model = pybamm.lithium_ion.MPM(options) model.check_well_posedness() @@ -48,12 +48,12 @@ def test_differential_surface_form(self): class TestMPMExternalCircuits(TestCase): def test_well_posed_voltage(self): - options = {"operating mode": "voltage", "working electrode": "positive"} + options = {"operating mode": "voltage", "half-cell": "true"} model = pybamm.lithium_ion.MPM(options) model.check_well_posedness() def test_well_posed_power(self): - options = {"operating mode": "power", "working electrode": "positive"} + options = {"operating mode": "power", "half-cell": "true"} model = pybamm.lithium_ion.MPM(options) model.check_well_posedness() @@ -65,7 +65,7 @@ def external_circuit_function(variables): options = { "operating mode": external_circuit_function, - "working electrode": "positive", + "half-cell": "true", } model = pybamm.lithium_ion.MPM(options) model.check_well_posedness() diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py index f1930df026..16d4128fb1 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme_half_cell.py @@ -1,6 +1,6 @@ # # Tests for the lithium-ion half-cell SPMe model -# This is achieved by using the {"working electrode": "positive"} option +# This is achieved by using the {"half-cell": "true"} option # import pybamm import unittest diff --git a/tests/unit/test_parameters/test_parameter_sets/test_parameters_with_default_models.py b/tests/unit/test_parameters/test_parameter_sets/test_parameters_with_default_models.py index 062d5caa24..398ab32ad5 100644 --- a/tests/unit/test_parameters/test_parameter_sets/test_parameters_with_default_models.py +++ b/tests/unit/test_parameters/test_parameter_sets/test_parameters_with_default_models.py @@ -31,7 +31,7 @@ def test_parameter_values_with_model(self): "ORegan2022": pybamm.lithium_ion.DFN(), "Prada2013": pybamm.lithium_ion.DFN(), "Ramadass2004": pybamm.lithium_ion.DFN(), - "Xu2019": pybamm.lithium_ion.DFN({"working electrode": "positive"}), + "Xu2019": pybamm.lithium_ion.DFN({"half-cell": "true"}), } # Loop over each parameter set, testing that parameters can be set diff --git a/tests/unit/test_parameters/test_size_distribution_parameters.py b/tests/unit/test_parameters/test_size_distribution_parameters.py index 8f8851bfaa..d07df9f8d1 100644 --- a/tests/unit/test_parameters/test_size_distribution_parameters.py +++ b/tests/unit/test_parameters/test_size_distribution_parameters.py @@ -13,15 +13,15 @@ def test_parameter_values(self): values = pybamm.lithium_ion.BaseModel().default_parameter_values param = pybamm.LithiumIonParameters() - # add distribution parameter values for negative electrode - values = pybamm.get_size_distribution_parameters(values, electrode="negative") + # add distribution parameter values for positive electrode + values = pybamm.get_size_distribution_parameters(values, halfcell="true") - # check positive parameters aren't there yet + # check negative parameters aren't there yet with self.assertRaises(KeyError): - values["Positive maximum particle radius [m]"] + values["Negative maximum particle radius [m]"] - # now add distribution parameter values for positive electrode - values = pybamm.get_size_distribution_parameters(values, electrode="positive") + # now add distribution parameter values for negative electrode + values = pybamm.get_size_distribution_parameters(values, halfcell="false") # check parameters diff --git a/tests/unit/test_plotting/test_quick_plot.py b/tests/unit/test_plotting/test_quick_plot.py index db7de574dc..6acf78b861 100644 --- a/tests/unit/test_plotting/test_quick_plot.py +++ b/tests/unit/test_plotting/test_quick_plot.py @@ -303,7 +303,7 @@ def test_loqs_spme(self): for model in [ pybamm.lithium_ion.SPMe(), pybamm.lead_acid.LOQS(), - pybamm.lithium_ion.SPMe({"working electrode": "positive"}), + pybamm.lithium_ion.SPMe({"half-cell": "true"}), ]: geometry = model.default_geometry param = model.default_parameter_values @@ -343,7 +343,7 @@ def test_loqs_spme(self): # test quick plot of particle for spme if ( model.name == "Single Particle Model with electrolyte" - and model.options["working electrode"] != "positive" + and model.options["half-cell"] == "false" ): output_variables = [ "X-averaged negative particle concentration [mol.m-3]",