From d1366606b35f859daf2e02c2570251e7a78b9def Mon Sep 17 00:00:00 2001 From: localhorst Date: Sun, 4 Apr 2021 17:55:55 +0200 Subject: [PATCH] added jupyter notebook --- LiXX_Cell_Pack_Matcher.ipynb | 180 +++++++++++++++++++++++++++++++++++ README.md | 14 ++- 2 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 LiXX_Cell_Pack_Matcher.ipynb diff --git a/LiXX_Cell_Pack_Matcher.ipynb b/LiXX_Cell_Pack_Matcher.ipynb new file mode 100644 index 0000000..a31d9e3 --- /dev/null +++ b/LiXX_Cell_Pack_Matcher.ipynb @@ -0,0 +1,180 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "timely-rogers", + "metadata": {}, + "source": [ + "# LiXX_Cell_Pack_Matcher\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "temporal-pipeline", + "metadata": {}, + "outputs": [], + "source": [ + "l" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "outer-america", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[('B01', 2124), ('B02', 2005), ('B03', 2127), ('B04', 2099), ('B05', 2117), ('B06', 1999), ('B07', 1999), ('B08', 1999), ('B09', 1999), ('B10', 1999), ('B11', 1999), ('B12', 1999)]\n" + ] + } + ], + "source": [ + "cellList = [\n", + "('B01', 2124), \n", + "('B02', 2005),\n", + "('B03', 2127),\n", + "('B04', 2099),\n", + "('B05', 2117),\n", + "('B06', 1999),\n", + "('B07', 1999),\n", + "('B08', 1999),\n", + "('B09', 1999),\n", + "('B10', 1999),\n", + "('B11', 1999),\n", + "('B12', 1999)\n", + "];\n", + "\n", + "cellsParallel = int(2)\n", + "cellsSerial = int(6) # 6 for 6S LiXX and so on..\n", + "\n", + "if(cellsParallel*cellsSerial) != len(cellList):\n", + " print(\"Battery pack is not possible for this configuration\")\n", + "else:\n", + " print (cellList)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "southeast-enclosure", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "from itertools import combinations \n", + "import collections\n", + "\n", + "combCells = combinations(cellList, cellsParallel) #combine cells to parallel Pairs\n", + "combPacks = combinations(combCells, cellsSerial) #combine parallel Pairs to serial pack\n", + "\n", + "possiblePacks = []\n", + "possiblePacks.clear()\n", + "\n", + "for combPack in list(combPacks): \n", + " #print(\"combPack: \", combPack) \n", + " cellsPackList = []\n", + " cellsPackList.clear()\n", + " \n", + " for serialPair in combPack:\n", + " #print(\"CellPairsInThisPack: \", serialPair)\n", + " for cellsTmp in serialPair:\n", + " #print(\"CellInThisPair: \" , cellsTmp)\n", + " cellsPackList.append(cellsTmp);\n", + " if collections.Counter(cellsPackList) == collections.Counter(cellList):\n", + " #test if this pack is a possible solution\n", + " possiblePacks.append(combPack); \n", + " \n", + "bestSolution = (possiblePacks[0], 1000 );\n", + " \n", + "for possiblePack in possiblePacks:\n", + " #loop though a possible solution\n", + " #print(\"possiblePack: \", possiblePack);\n", + " \n", + " packMatchQuality = 0\n", + " \n", + " for serialPair in possiblePack:\n", + " #loop through the serial pairs\n", + " cellCapacityInThisPairList = []\n", + " cellCapacityInThisPairList.clear()\n", + " for cellsTmp in serialPair:\n", + " #loop through the cells in this serial paar\n", + " cellCapacityInThisPairList.append(cellsTmp[1]); #save capacity in list \n", + " \n", + " cv = lambda x: np.std(x, ddof=1) / np.mean(x) * 100\n", + " packMatchQuality = packMatchQuality + cv(np.array(cellCapacityInThisPairList))\n", + " \n", + " if bestSolution[1] > packMatchQuality:\n", + " bestSolution = (possiblePack, packMatchQuality );\n", + " \n", + "\n", + " \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "occupational-deadline", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Matching Quality: 0.9155148399305513\n", + "CellPairsInThisPack: (('B01', 2124), ('B03', 2127))\n", + "CellPairsInThisPack: (('B02', 2005), ('B06', 1999))\n", + "CellPairsInThisPack: (('B04', 2099), ('B05', 2117))\n", + "CellPairsInThisPack: (('B07', 1999), ('B08', 1999))\n", + "CellPairsInThisPack: (('B09', 1999), ('B10', 1999))\n", + "CellPairsInThisPack: (('B11', 1999), ('B12', 1999))\n" + ] + } + ], + "source": [ + "print (\"Matching Quality: \", bestSolution[1]) \n", + "\n", + "for serialPair in bestSolution[0]:\n", + " #loop through the serial pairs\n", + " print(\"CellPairsInThisPack: \", serialPair)\n", + "\n", + " \n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "informative-sequence", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/README.md b/README.md index 168c5f5..3cee97d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ -# LiXX_Cell_Pack_Matcher +# LiXX Cell Pack Matcher -Tool for finding the best configuration in a LiXX Battery Pack. Matches capacity in parallel cell groups from a serial pack. \ No newline at end of file +Tool for finding the best configuration in a LiXX Battery Pack. +Matches capacity in parallel cell groups from a serial pack. + +## Working +- Matches cells bases on capacity for varius Pack configuration. Set parallel and serial cell count respectively. +- Supports labels as identifier for cells. + +## Not Working +- Clould be faster, 6S2P needs more than 10min to compute +- Support internal cell resistance matching +- Support bigger cell pool for a pack that is needed