{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "# Tutorial 9 \\- Simulate a cylindrical cell\n", "\n", "## Introduction\n", "\n", "In this tutorial, we simulate a multilayer pouch cell. We use the same material property as in the other tutorials\n", "" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "source": [ "jsonstruct_material = parseBattmoJson('Examples/jsondatafiles/sample_input.json');" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Next, we load and parse a json file where we have chosen some parameters for the multilayer pouch domain. Note that all the parameters are described in a json schema, see [Geometry.schema.json](https://github.com/BattMoTeam/BattMo/blob/main/Utilities/JsonSchemas/Geometry.schema.json), even if the simplest way to proceed is to start with an example, in this case given by [4680\\-geometry.json](https://github.com/BattMoTeam/BattMo/blob/main/Examples/JsonDataFiles/4680-geometry.json).\n", "" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "source": [ "jsonfilename = 'Examples/JsonDataFiles/4680-geometry.json';\n", "jsonstruct_geometry = parseBattmoJson(jsonfilename);" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "We change some parameters to get a smaller model and simulation time.\n", "" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "source": [ "jsonstruct_geometry.Geometry.outerRadius = jsonstruct_geometry.Geometry.innerRadius + 4*milli*meter;\n", "jsonstruct_geometry.Geometry.numberOfDiscretizationCellsVertical = 2;\n", "jsonstruct_geometry.Geometry.numberOfDiscretizationCellsAngular = 20;" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "We use [FlatJsonViewer.m](https://github.com/BattMoTeam/BattMo/blob/main/Utilities/JsonUtils/FlatJsonViewer.m) to flatten the json structure and print it to screen.\n", "" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "source": [ "fjv = flattenJsonStruct(jsonstruct_geometry);" ], "outputs": [ { "data": { "text/plain": [ " parameter name parameter value\n", " __________________________________________________________ _______________\n", " {'include_current_collectors' } {[ 1]} \n", " {'Geometry.case' } {'jellyRoll' } \n", " {'Geometry.innerRadius' } {[ 0.0020]} \n", " {'Geometry.outerRadius' } {[ 0.0060]} \n", " {'Geometry.height' } {[ 0.0700]} \n", " {'Geometry.numberOfDiscretizationCellsVertical' } {[ 2]} \n", " {'Geometry.numberOfDiscretizationCellsAngular' } {[ 20]} \n", " {'NegativeElectrode.Coating.thickness' } {[9.4000e-05]} \n", " {'NegativeElectrode.Coating.N' } {[ 3]} \n", " {'NegativeElectrode.Coating.SolidDiffusion.N' } {[ 5]} \n", " {'NegativeElectrode.CurrentCollector.thickness' } {[2.5000e-05]} \n", " {'NegativeElectrode.CurrentCollector.N' } {[ 3]} \n", " {'NegativeElectrode.CurrentCollector.tabparams.usetab' } {[ 1]} \n", " {'NegativeElectrode.CurrentCollector.tabparams.width' } {[ 0.0035]} \n", " {'NegativeElectrode.CurrentCollector.tabparams.fractions'} {6x1 double } \n", " {'PositiveElectrode.Coating.thickness' } {[8.4000e-05]} \n", " {'PositiveElectrode.Coating.N' } {[ 3]} \n", " {'PositiveElectrode.Coating.SolidDiffusion.N' } {[ 5]} \n", " {'PositiveElectrode.CurrentCollector.thickness' } {[1.0000e-05]} \n", " {'PositiveElectrode.CurrentCollector.N' } {[ 3]} \n", " {'PositiveElectrode.CurrentCollector.tabparams.usetab' } {[ 1]} \n", " {'PositiveElectrode.CurrentCollector.tabparams.width' } {[ 0.0035]} \n", " {'PositiveElectrode.CurrentCollector.tabparams.fractions'} {6x1 double } \n", " {'Separator.thickness' } {[1.0000e-05]} \n", " {'Separator.N' } {[ 3]}" ] }, "metadata": {}, "execution_count": 4, "output_type": "execute_result" } ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "source": [ "fjv.print();" ], "outputs": [ { "data": { "text/plain": [ " parameter name parameter value\n", " __________________________________________________________ _______________\n", " {'include_current_collectors' } {[ 1]} \n", " {'Geometry.case' } {'jellyRoll' } \n", " {'Geometry.innerRadius' } {[ 0.0020]} \n", " {'Geometry.outerRadius' } {[ 0.0060]} \n", " {'Geometry.height' } {[ 0.0700]} \n", " {'Geometry.numberOfDiscretizationCellsVertical' } {[ 2]} \n", " {'Geometry.numberOfDiscretizationCellsAngular' } {[ 20]} \n", " {'NegativeElectrode.Coating.thickness' } {[9.4000e-05]} \n", " {'NegativeElectrode.Coating.N' } {[ 3]} \n", " {'NegativeElectrode.Coating.SolidDiffusion.N' } {[ 5]} \n", " {'NegativeElectrode.CurrentCollector.thickness' } {[2.5000e-05]} \n", " {'NegativeElectrode.CurrentCollector.N' } {[ 3]} \n", " {'NegativeElectrode.CurrentCollector.tabparams.usetab' } {[ 1]} \n", " {'NegativeElectrode.CurrentCollector.tabparams.width' } {[ 0.0035]} \n", " {'NegativeElectrode.CurrentCollector.tabparams.fractions'} {6x1 double } \n", " {'PositiveElectrode.Coating.thickness' } {[8.4000e-05]} \n", " {'PositiveElectrode.Coating.N' } {[ 3]} \n", " {'PositiveElectrode.Coating.SolidDiffusion.N' } {[ 5]} \n", " {'PositiveElectrode.CurrentCollector.thickness' } {[1.0000e-05]} \n", " {'PositiveElectrode.CurrentCollector.N' } {[ 3]} \n", " {'PositiveElectrode.CurrentCollector.tabparams.usetab' } {[ 1]} \n", " {'PositiveElectrode.CurrentCollector.tabparams.width' } {[ 0.0035]} \n", " {'PositiveElectrode.CurrentCollector.tabparams.fractions'} {6x1 double } \n", " {'Separator.thickness' } {[1.0000e-05]} \n", " {'Separator.N' } {[ 3]}" ] }, "metadata": {}, "execution_count": 5, "output_type": "execute_result" } ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "We load and parse the control protocol\n", "" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "source": [ "jsonfilename = fullfile('Examples', 'jsondatafiles', 'cc_discharge_control.json');\n", "jsonstruct_control = parseBattmoJson(jsonfilename);" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "We load and parse the simulation settings. This is optional. Typically, reasonable choices are made by default.\n", "" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "source": [ "jsonfilename = fullfile('Examples', 'jsondatafiles', 'simulation_parameters.json');\n", "jsonstruct_simparams = parseBattmoJson(jsonfilename);" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Now, we can merge these parameter definitions into a single parameter set to obtain a jsonstruct that has all the input needed by the simulator.\n", "" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "source": [ "jsonstruct = mergeJsonStructs({jsonstruct_geometry , ...\n", " jsonstruct_material , ...\n", " jsonstruct_control , ...\n", " jsonstruct_simparams}, 'warn', false);" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup the model for inspection\n", "\n", "When we run the simulation using function [runBatteryJson.m](https://github.com/BattMoTeam/BattMo/blob/main/Examples/JsonInput/runBatteryJson.m), the model is setup. In the case where we want to setup the model for inspection, prior to simulation, we can use the function [setupModelFromJson.m](https://github.com/BattMoTeam/BattMo/blob/main/Utilities/JsonUtils/setupModelFromJson.m)\n", "" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "source": [ "model = setupModelFromJson(jsonstruct);" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "We use the [plotBatteryGrid.m](https://github.com/BattMoTeam/BattMo/blob/main/Utilities/Visualization/plotBatteryGrid.m) function to show the grid\n", "" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "source": [ "plotBatteryGrid(model)" ], "outputs": [ { "data": { "text/plain": [ "ans = \n", " Figure (16) with properties:\n", " Number: 16\n", " Name: ''\n", " Color: [1 1 1]\n", " Position: [1411 753 618 463]\n", " Units: 'pixels'\n", " Use GET to show all properties" ] }, "metadata": {}, "execution_count": 10, "output_type": "execute_result" } ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "source": [ "% make the axis tight and set the camera viewing angle\n", "axis tight\n", "view(45,45)" ], "outputs": [ { "data": { "text/html": [ "