{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "# Tutorial 3 \\- Modify Structural Parameters\n", "\n", "## Introduction\n", "\n", "In this tutorial, we will use a P2D model to simulate the effects of changing structural parameters (like electrode thickness or porosity) on cell discharge. After completing this tutorial, you should have a working knowledge of:\n", "\n", "- Basics of how structural properties are defined in BattMo\n", "- How changing the thickness of one electrode can affect the overall capacity of the cell\n", "- How to setup and execute a parameter sweep\n", "\n", "We'll use the same model from Tutorial 1.\n", "" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "source": [ "jsonstruct = parseBattmoJson('Examples/jsondatafiles/sample_input.json');" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Explore the Structural Parameters\n", "\n", "Structural parameters are defined in the JSON parameter file and parsed into the MATLAB structure. Once the JSON parameter file has been read into MATLAB as a jsonstruct, its properties can be modified programmatically.\n", "\n", "\n", "Let's begin by exploring the parameters of the negative electrode coating with the following command:\n", "" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "source": [ "disp(jsonstruct.NegativeElectrode.Coating)" ], "outputs": [ { "data": { "text/plain": [ " thickness: 6.4000e-05\n", " N: 10\n", " effectiveDensity: 1900\n", " bruggemanCoefficient: 1.5000\n", " ActiveMaterial: [1x1 struct]\n", " Binder: [1x1 struct]\n", " ConductingAdditive: [1x1 struct]" ] }, "metadata": {}, "execution_count": 2, "output_type": "execute_result" } ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Here, we can see that the structural and material properties of the coating are defined. Let's try increasing the thickness of the negative electrode from 64 µm to 72 µm.\n", "" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "source": [ "jsonstruct.NegativeElectrode.Coating.thickness = 72*micro;" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Now we can run the simulation and plot the discharge curve against the discharged capacity of the cell.\n", "" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "source": [ "% instantiate an empty figure\n", "figure()\n", "output = runBatteryJson(jsonstruct);" ], "outputs": [ ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "retrieve the states from the simulation result\n", "" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "source": [ "states = output.states;\n", "\n", "% extract the time, voltage, and current quantities\n", "time = cellfun(@(state) state.time, states);\n", "voltage = cellfun(@(state) state.('Control').E, states);\n", "current = cellfun(@(state) state.('Control').I, states);\n", "\n", "% calculate the capacity\n", "capacity = time .* current;\n", "\n", "% plot the discharge curve in the figure\n", "plot((capacity/(hour*milli)), voltage, '-', 'linewidth', 3)\n", "xlabel('Capacity / mA \\cdot h')\n", "ylabel('Voltage / V')\n", "legend('t_{NE} = 72 µm')" ], "outputs": [ { "data": { "text/html": [ "
\"figure_0.png\"
" ] }, "metadata": {}, "execution_count": 5, "output_type": "execute_result" } ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup and Run a Parameter Sweep\n", "\n", "Now we can setup another parameter sweep to explore the effects of reducing the thickness of the negative electrode coating. Let's try simuating the cell performance with coating thickness values of 16 µm, 32 µm, and 64 µm. As in the previous tutorial, we will first create a vector contianing the desired thickness values. Then we will use a for\\-loop to iterate through the thickness values, modify the value in the jsonstruct, and run the simulation. We will then plot the results together for comparison.\n", "" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "source": [ "% create a vector of diffent thickness values\n", "thickness = [16, 32, 64].*micro;\n", "\n", "% instantiate and empty cell array to store the outputs of the simulations\n", "output = cell(size(thickness));\n", "\n", "% instantiate an empty figure\n", "figure()\n", "\n", "% use a for-loop to iterate through the vector of c-rates\n", "for i = 1 : numel(thickness)\n", " % modify the value for the c-rate in the control definition and update\n", " % the total duration of the simulation accordingly\n", " jsonstruct.NegativeElectrode.Coating.thickness = thickness(i);\n", "\n", " % run the simulation and store the results in the output cell array\n", " output{i} = runBatteryJson(jsonstruct);\n", "\n", " % retrieve the states from the simulation result\n", " states = output{i}.states;\n", "\n", " % extract the time and voltage quantities\n", " time = cellfun(@(state) state.time, states);\n", " voltage = cellfun(@(state) state.('Control').E, states);\n", " current = cellfun(@(state) state.('Control').I, states);\n", "\n", " % calculate the capacity\n", " capacity = time .* current;\n", "\n", " % plot the discharge curve in the figure\n", " plot((capacity/(hour*milli)), voltage, '-', 'linewidth', 3)\n", " hold on\n", "end" ], "outputs": [ ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "source": [ "hold off\n", "xlabel('Capacity / mA \\cdot h')\n", "ylabel('Voltage / V')\n", "legend('t_{NE} = 16 µm', 't_{NE} = 32 µm', 't_{NE} = 64 µm')" ], "outputs": [ { "data": { "text/html": [ "
\"figure_1.png\"
" ] }, "metadata": {}, "execution_count": 7, "output_type": "execute_result" } ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "The results of this parameter sweep show that reducing the thickness of the negative electrode to 32 µm and 16 µm reduces its capacity such that it becomes the limiting factor in the overall capacity of the cell. Note that in real Li\\-ion batteries, the capacity of the negative electrode is usually oversized with respect to the capacity of the positive electrode to avoid dangerous lithium plating.\n", "\n", "## Summary\n", "\n", "In this tutorial, we explored how to modify structural parameters in BattMo. We first learned that structural properties of the electrodes are defined in the structure (e.g. NegativeElectrode.Coating). From there, it is possible to change individual parameter values and simulate the effects on the cell discharge. We then reviewed how to setup a parameter sweep and explored how changing the thickness of the negative electrode coating affects the overall capacity of the cell.\n", "\n", "" ] } ], "metadata": { "kernelspec": { "display_name": "MATLAB (matlabkernel)", "language": "matlab", "name": "matlab" }, "language_info": { "file_extension": ".m", "mimetype": "text/matlab", "name": "matlab", "nbconvert_exporter": "matlab", "pygments_lexer": "matlab", "version": "24.1.0.2689473" } }, "nbformat": 4, "nbformat_minor": 4 }