def test_update_initial_state_of_charge(self): # Load parameters to be tested parameters = pybamm.standard_parameters_lead_acid parameter_values = pybamm.lead_acid.BaseModel().default_parameter_values param_eval = pybamm.print_parameters(parameters, parameter_values) param_eval = {k: v[0] for k, v in param_eval.items()} # Update initial state of charge parameter_values.update({"Initial State of Charge": 0.2}) param_eval_update = pybamm.print_parameters(parameters, parameter_values) param_eval_update = {k: v[0] for k, v in param_eval_update.items()} # Test that relevant parameters have changed as expected self.assertLess(param_eval_update["q_init"], param_eval["q_init"]) self.assertLess(param_eval_update["c_e_init"], param_eval["c_e_init"]) self.assertLess( param_eval_update["epsilon_n_init"], param_eval["epsilon_n_init"] ) self.assertEqual( param_eval_update["epsilon_s_init"], param_eval["epsilon_s_init"] ) self.assertLess( param_eval_update["epsilon_p_init"], param_eval["epsilon_p_init"] ) self.assertGreater( param_eval_update["curlyU_n_init"], param_eval["curlyU_n_init"] ) self.assertGreater( param_eval_update["curlyU_p_init"], param_eval["curlyU_p_init"] )
def test_all_defined(self): parameters = pybamm.standard_parameters_lead_acid parameter_values = pybamm.lead_acid.BaseModel().default_parameter_values output_file = "lead_acid_parameters.txt" pybamm.print_parameters(parameters, parameter_values, output_file) # test print_parameters with dict and without C-rate del parameter_values["Cell capacity [A.h]"] parameters = { "C_e": pybamm.standard_parameters_lead_acid.C_e, "sigma_n": pybamm.standard_parameters_lead_acid.sigma_n, } pybamm.print_parameters(parameters, parameter_values)
def test_parameters_defaults_lead_acid(self): # Load parameters to be tested parameters = pybamm.standard_parameters_lead_acid parameter_values = pybamm.lead_acid.BaseModel().default_parameter_values param_eval = pybamm.print_parameters(parameters, parameter_values) param_eval = {k: v[0] for k, v in param_eval.items()} # Diffusional C-rate should be smaller than C-rate self.assertLess(param_eval["C_e"], param_eval["C_rate"]) # Dimensionless electrode conductivities should be large self.assertGreater(param_eval["sigma_n"], 10) self.assertGreater(param_eval["sigma_p"], 10) # Dimensionless double-layer capacity should be small self.assertLess(param_eval["C_dl_n"], 1e-3) self.assertLess(param_eval["C_dl_p"], 1e-3) # Volume change positive in negative electrode and negative in positive # electrode self.assertLess(param_eval["DeltaVsurf_n"], 0) self.assertGreater(param_eval["DeltaVsurf_p"], 0)
def test_functions_lead_acid(self): # Load parameters to be tested parameters = { "D_e_1": pybamm.standard_parameters_lead_acid.D_e(pybamm.Scalar(1), pybamm.Scalar(0)), "kappa_e_0": pybamm.standard_parameters_lead_acid.kappa_e( pybamm.Scalar(0), pybamm.Scalar(0)), "chi_1": pybamm.standard_parameters_lead_acid.chi(pybamm.Scalar(1)), "chi_0.5": pybamm.standard_parameters_lead_acid.chi(pybamm.Scalar(0.5)), "U_n_1": pybamm.standard_parameters_lead_acid.U_n(pybamm.Scalar(1), pybamm.Scalar(0)), "U_n_0.5": pybamm.standard_parameters_lead_acid.U_n(pybamm.Scalar(0.5), pybamm.Scalar(0)), "U_p_1": pybamm.standard_parameters_lead_acid.U_p(pybamm.Scalar(1), pybamm.Scalar(0)), "U_p_0.5": pybamm.standard_parameters_lead_acid.U_p(pybamm.Scalar(0.5), pybamm.Scalar(0)), } # Process parameter_values = pybamm.ParameterValues( chemistry=pybamm.parameter_sets.Sulzer2019) param_eval = pybamm.print_parameters(parameters, parameter_values) param_eval = {k: v[0] for k, v in param_eval.items()} # Known values for dimensionless functions self.assertEqual(param_eval["D_e_1"], 1) self.assertEqual(param_eval["kappa_e_0"], 0) # Known monotonicity for dimensionless functions self.assertGreater(param_eval["chi_1"], param_eval["chi_0.5"]) self.assertLess(param_eval["U_n_1"], param_eval["U_n_0.5"]) self.assertGreater(param_eval["U_p_1"], param_eval["U_p_0.5"])
# # Print parameters for lead-acid models # import pybamm parameters = pybamm.standard_parameters_lead_acid parameter_values = pybamm.lead_acid.BaseModel().default_parameter_values output_file = "results/2019_08_sulzer_thesis/parameters.txt" pybamm.print_parameters(parameters, parameter_values, output_file)