{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "# Tutorial 8 \\- Simulate a Multilayer Pouch 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 [geometryMultiLayerPouch.json](https://github.com/BattMoTeam/BattMo/blob/main/Examples/JsonDataFiles/geometryMultiLayerPouch.json).\n", "" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "source": [ "jsonfilename = 'Examples/JsonDataFiles/geometryMultiLayerPouch.json';\n", "jsonstruct_geometry = parseBattmoJson(jsonfilename);" ], "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. We can see that, in this example, we use 5 layers and two different lengths for the tabs (height value). At the moment, the two tabs share the same width. Implementing a separate width for each tab would require to modify the grid generator for this geometry. It is more a developper work but is definitely not out of reach.\n", "" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "source": [ "fjv = flattenJsonStruct(jsonstruct_geometry)" ], "outputs": [ { "data": { "text/plain": [ " parameter name parameter value \n", " ________________________________________________ ___________________\n", " {'Geometry.case' } {'multiLayerPouch'}\n", " {'Geometry.nLayers' } {[ 5]}\n", " {'Geometry.width' } {[ 0.1000]}\n", " {'Geometry.length' } {[ 0.1000]}\n", " {'Geometry.tab.width' } {[ 0.0500]}\n", " {'Geometry.tab.Nx' } {[ 3]}\n", " {'Geometry.tab.NegativeElectrode.length' } {[ 0.0400]}\n", " {'Geometry.tab.NegativeElectrode.Ny' } {[ 2]}\n", " {'Geometry.tab.PositiveElectrode.length' } {[ 0.0200]}\n", " {'Geometry.tab.PositiveElectrode.Ny' } {[ 2]}\n", " {'Geometry.Electrolyte.Nx' } {[ 2]}\n", " {'Geometry.Electrolyte.Ny' } {[ 4]}\n", " {'include_current_collectors' } {[ 1]}\n", " {'NegativeElectrode.Coating.thickness' } {[ 1.0000e-04]}\n", " {'NegativeElectrode.Coating.N' } {[ 3]}\n", " {'NegativeElectrode.CurrentCollector.thickness'} {[ 1.0000e-05]}\n", " {'NegativeElectrode.CurrentCollector.N' } {[ 2]}\n", " {'PositiveElectrode.Coating.thickness' } {[ 8.0000e-05]}\n", " {'PositiveElectrode.Coating.N' } {[ 3]}\n", " {'PositiveElectrode.CurrentCollector.thickness'} {[ 1.0000e-05]}\n", " {'PositiveElectrode.CurrentCollector.N' } {[ 2]}\n", " {'Separator.thickness' } {[ 5.0000e-05]}\n", " {'Separator.N' } {[ 3]}\n", "fjv = \n", " FlatJsonViewer with properties:\n", " flatjson: {23x2 cell}\n", " columnnames: {'parameter name' 'parameter value'}" ] }, "metadata": {}, "execution_count": 3, "output_type": "execute_result" } ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "source": [ "fjv.print();" ], "outputs": [ { "data": { "text/plain": [ " parameter name parameter value \n", " ________________________________________________ ___________________\n", " {'Geometry.case' } {'multiLayerPouch'}\n", " {'Geometry.nLayers' } {[ 5]}\n", " {'Geometry.width' } {[ 0.1000]}\n", " {'Geometry.length' } {[ 0.1000]}\n", " {'Geometry.tab.width' } {[ 0.0500]}\n", " {'Geometry.tab.Nx' } {[ 3]}\n", " {'Geometry.tab.NegativeElectrode.length' } {[ 0.0400]}\n", " {'Geometry.tab.NegativeElectrode.Ny' } {[ 2]}\n", " {'Geometry.tab.PositiveElectrode.length' } {[ 0.0200]}\n", " {'Geometry.tab.PositiveElectrode.Ny' } {[ 2]}\n", " {'Geometry.Electrolyte.Nx' } {[ 2]}\n", " {'Geometry.Electrolyte.Ny' } {[ 4]}\n", " {'include_current_collectors' } {[ 1]}\n", " {'NegativeElectrode.Coating.thickness' } {[ 1.0000e-04]}\n", " {'NegativeElectrode.Coating.N' } {[ 3]}\n", " {'NegativeElectrode.CurrentCollector.thickness'} {[ 1.0000e-05]}\n", " {'NegativeElectrode.CurrentCollector.N' } {[ 2]}\n", " {'PositiveElectrode.Coating.thickness' } {[ 8.0000e-05]}\n", " {'PositiveElectrode.Coating.N' } {[ 3]}\n", " {'PositiveElectrode.CurrentCollector.thickness'} {[ 1.0000e-05]}\n", " {'PositiveElectrode.CurrentCollector.N' } {[ 2]}\n", " {'Separator.thickness' } {[ 5.0000e-05]}\n", " {'Separator.N' } {[ 3]}" ] }, "metadata": {}, "execution_count": 4, "output_type": "execute_result" } ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "We load and parse the control protocol\n", "" ] }, { "cell_type": "code", "execution_count": 5, "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": 6, "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": 7, "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": 8, "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": 9, "metadata": {}, "source": [ "plotBatteryGrid(model)" ], "outputs": [ { "data": { "text/plain": [ "ans = \n", " Figure (13) with properties:\n", " Number: 13\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": 9, "output_type": "execute_result" } ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "source": [ "% make the axis tight and set the camera viewing angle\n", "axis tight\n", "view(45,45)" ], "outputs": [ { "data": { "text/html": [ "