|
| 1 | +import pybamm |
| 2 | + |
| 3 | +print("Setting up asymmetric radial cooling simulation for a cylinder...") |
| 4 | +model_3d = pybamm.lithium_ion.Basic3DThermalSPM( |
| 5 | + options={"cell geometry": "cylindrical", "dimensionality": 3} |
| 6 | +) |
| 7 | + |
| 8 | +# Use parameters for a cylindrical 18650 cell |
| 9 | +parameter_values = pybamm.ParameterValues("Chen2020") |
| 10 | + |
| 11 | +# Define our cooling scenario |
| 12 | +h_cooling = 20 # W.m-2.K-1 -> Cooling on the outside surface |
| 13 | +h_insulation = 0.1 # W.m-2.K-1 -> Insulation on other surfaces |
| 14 | + |
| 15 | +parameter_values.update( |
| 16 | + { |
| 17 | + "Inner cell radius [m]": 0.005, |
| 18 | + "Outer cell radius [m]": 0.018, |
| 19 | + # Apply cooling to the outer radial surface |
| 20 | + "Outer radius heat transfer coefficient [W.m-2.K-1]": h_cooling, |
| 21 | + # Insulate the inner radius and the flat top/bottom faces |
| 22 | + "Inner radius heat transfer coefficient [W.m-2.K-1]": h_insulation, |
| 23 | + "Bottom face heat transfer coefficient [W.m-2.K-1]": h_insulation, |
| 24 | + "Top face heat transfer coefficient [W.m-2.K-1]": h_insulation, |
| 25 | + }, |
| 26 | + check_already_exists=False, |
| 27 | +) |
| 28 | + |
| 29 | +# Use a high discharge rate to generate significant heat |
| 30 | +experiment = pybamm.Experiment([("Discharge at 4C until 2.5V")]) |
| 31 | + |
| 32 | +var_pts = { |
| 33 | + "x_n": 20, |
| 34 | + "x_s": 20, |
| 35 | + "x_p": 20, |
| 36 | + "r_n": 30, |
| 37 | + "r_p": 30, |
| 38 | + "r_macro": None, |
| 39 | + "z": None, |
| 40 | +} |
| 41 | +submesh_types = model_3d.default_submesh_types |
| 42 | +submesh_types["cell"] = pybamm.ScikitFemGenerator3D( |
| 43 | + "cylinder", h="0.01" |
| 44 | +) # very fine mesh |
| 45 | + |
| 46 | +sim = pybamm.Simulation( |
| 47 | + model_3d, |
| 48 | + parameter_values=parameter_values, |
| 49 | + var_pts=var_pts, |
| 50 | + experiment=experiment, |
| 51 | + submesh_types=submesh_types, |
| 52 | +) |
| 53 | +print("Solving... (this may take a minute)") |
| 54 | +solution = sim.solve() |
| 55 | +print("Solve complete.") |
| 56 | + |
| 57 | +print("Generating plots...") |
| 58 | +final_time = solution.t[-1] |
| 59 | + |
| 60 | +# Plot the overall voltage and average temperature |
| 61 | +solution.plot(["Voltage [V]", "Volume-averaged cell temperature [K]"]) |
| 62 | + |
| 63 | +# Create detailed heatmaps at the final timestep |
| 64 | +print(f"\n--- Displaying heatmaps at t={final_time:.0f}s ---") |
| 65 | + |
| 66 | +# Plot the r-z plane to show the radial gradient (hot core, cool edge) |
| 67 | +pybamm.plot_3d_cross_section( |
| 68 | + solution, |
| 69 | + "Cell temperature [K]", |
| 70 | + None, # Use the last time step |
| 71 | + plane="rz", |
| 72 | + position=0.5, |
| 73 | + show_mesh=True, |
| 74 | + mesh_color="white", |
| 75 | + mesh_alpha=0.4, |
| 76 | + mesh_linewidth=0.7, |
| 77 | +) |
| 78 | + |
| 79 | +# Plot the polar xy-plane to show the temperature at a mid-height slice |
| 80 | +pybamm.plot_3d_cross_section( |
| 81 | + solution, |
| 82 | + "Cell temperature [K]", |
| 83 | + None, # Use the last time step |
| 84 | + plane="xy", |
| 85 | + position=0.5, |
| 86 | + show_mesh=True, |
| 87 | + mesh_color="white", |
| 88 | + mesh_alpha=0.4, |
| 89 | + mesh_linewidth=0.7, |
| 90 | +) |
| 91 | + |
| 92 | +# Plot a 3D heatmap of the temperature distribution |
| 93 | +pybamm.plot_3d_heatmap( |
| 94 | + solution, t=final_time, marker_size=5, variable="Cell temperature [K]" |
| 95 | +) |
0 commit comments