{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "# Tutorial 6 \\- Simulate Thermal Performance\n", "\n", "## Introduction\n", "\n", "In this tutorial, we will use a P4D model to simulate the thermal performance. We'll use the same model from Tutorial 1\n", "\n", "## Setup material properties" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "source": [ "jsonstruct_material = parseBattmoJson('Examples/jsondatafiles/sample_input.json');\n", "jsonstruct_material.include_current_collectors = true;" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup the geometry\n", "\n", "We use a 3D geometry where it is easier to visualize the thermal effects.\n", "" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "source": [ "jsonstruct_geometry = parseBattmoJson('Examples/JsonDataFiles/geometry3d.json');\n", "disp(jsonstruct_geometry)" ], "outputs": [ { "data": { "text/plain": [ " include_current_collectors: 1\n", " Geometry: [1x1 struct]\n", " NegativeElectrode: [1x1 struct]\n", " PositiveElectrode: [1x1 struct]\n", " Separator: [1x1 struct]\n", " ThermalModel: [1x1 struct]" ] }, "metadata": {}, "execution_count": 2, "output_type": "execute_result" } ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "We merge the json structure. We get a warning for each field that gets different values from the given inputs. The rule is that the first input takes precedence, the warning can be switched off be setting the 'warn' option to false in the call to mergeJsonStructs.\n", "" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "source": [ "jsonstruct = mergeJsonStructs({jsonstruct_geometry , ...\n", " jsonstruct_material});" ], "outputs": [ { "data": { "text/plain": [ "mergeJsonStructs: Parameter Geometry.case is assigned twice with different values. Value from first jsonstruct is used.\n", "mergeJsonStructs: Parameter NegativeElectrode.Coating.thickness is assigned twice with different values. Value from first jsonstruct is used.\n", "mergeJsonStructs: Parameter NegativeElectrode.Coating.N is assigned twice with different values. Value from first jsonstruct is used.\n", "mergeJsonStructs: Parameter NegativeElectrode.CurrentCollector.N is assigned twice with different values. Value from first jsonstruct is used.\n", "mergeJsonStructs: Parameter PositiveElectrode.Coating.thickness is assigned twice with different values. Value from first jsonstruct is used.\n", "mergeJsonStructs: Parameter PositiveElectrode.Coating.N is assigned twice with different values. Value from first jsonstruct is used.\n", "mergeJsonStructs: Parameter PositiveElectrode.CurrentCollector.N is assigned twice with different values. Value from first jsonstruct is used.\n", "mergeJsonStructs: Parameter Separator.thickness is assigned twice with different values. Value from first jsonstruct is used.\n", "mergeJsonStructs: Parameter Separator.N is assigned twice with different values. Value from first jsonstruct is used.\n", "mergeJsonStructs: Parameter ThermalModel.externalHeatTransferCoefficient is assigned twice with different values. Value from first jsonstruct is used." ] }, "metadata": {}, "execution_count": 3, "output_type": "execute_result" } ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "source": [ "\n", "jsonstruct.use_thermal = true;" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "We setup the model using the json structure.\n", "" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "source": [ "model = setupModelFromJson(jsonstruct);" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Run the simulation\n", "\n", "We run the simulation. We have used here a standard discharge control at C\\-Rate=1.\n", "" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "source": [ "output = runBatteryJson(jsonstruct);" ], "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualisation of the results\n", "\n", "We plot the voltage versus time for the simulation.\n", "" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "source": [ "time = output.time;\n", "E = output.E;\n", "\n", "set(0, 'defaulttextfontsize', 15);\n", "set(0, 'defaultaxesfontsize', 15);\n", "set(0, 'defaultlinelinewidth', 3);\n", "\n", "figure\n", "plot(time/hour, E)\n", "title('Voltage / V');\n", "xlabel('time / h');\n", "ylabel('voltage / V');" ], "outputs": [ { "data": { "text/html": [ "