LCOV - code coverage report
Current view: top level - src/cells - Cell.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 19 24 79.2 %
Date: 2023-04-08 04:19:02 Functions: 17 22 77.3 %

          Line data    Source code
       1             : /**
       2             :  * @file Cell.hpp
       3             :  * @brief Cell class definition
       4             :  * @author Jorn Reniers, Volkan Kumtepeli
       5             :  * @date 22 Nov 2019
       6             :  */
       7             : 
       8             : #pragma once
       9             : 
      10             : #include "cell_limits.hpp"
      11             : #include "../settings/settings.hpp"
      12             : #include "../StorageUnit.hpp"
      13             : #include "../types/Histogram.hpp"
      14             : #include "../types/data_storage/CellData.hpp"
      15             : #include "../types/Status.hpp"
      16             : #include "../utility/utility.hpp"
      17             : 
      18             : #include <cassert>
      19             : #include <iostream>
      20             : #include <fstream>
      21             : #include <cstring>
      22             : #include <cmath>
      23             : #include <string>
      24             : #include <vector>
      25             : #include <span>
      26             : 
      27             : namespace slide {
      28             : 
      29             : /**
      30             :  * @brief Abstract Class representing a single battery cell.
      31             :  */
      32             : class Cell : public StorageUnit
      33             : {
      34             : protected:
      35             :   double capNom{ 16 }; //!< capacity [Ah].
      36             : 
      37             :   CellData<settings::DATASTORE_CELL> cellData; //!< Cell data storage.
      38             : 
      39             : public:
      40             :   constexpr static CellLimits limits{ defaultCellLimits }; // Default cell limits. #TODO make it changable.
      41             : 
      42         172 :   Cell() : StorageUnit("cell") {}
      43             : 
      44             :   Cell(const std::string &ID_) : StorageUnit(ID_) {}
      45         181 :   virtual ~Cell() = default;
      46             : 
      47    16792798 :   double Cap() const final override { return capNom; }
      48           2 :   void setCapacity(double capacity) { capNom = capacity; }
      49             : 
      50    12001962 :   constexpr double Vmin() const override { return limits.Vmin; }
      51      595104 :   constexpr double VMIN() const override { return limits.VMIN; }
      52      595226 :   constexpr double VMAX() const override { return limits.VMAX; }
      53    12847956 :   constexpr double Vmax() const override { return limits.Vmax; }
      54          13 :   constexpr double Tmax() { return limits.Tmax; }
      55          13 :   constexpr double Tmin() { return limits.Tmin; }
      56             : 
      57           0 :   double getVhigh() final { return V(); } //!< return the voltage of the cell with the highest voltage
      58      796204 :   double getVlow() final { return V(); }  //!< return the voltage of the cell with the lowest voltage
      59             : 
      60             :   virtual Status setSOC(double SOCnew, bool checkV = true, bool print = true) = 0;
      61             :   virtual double SOC() = 0;
      62     1499315 :   virtual double getThotSpot() override { return T(); }
      63         147 :   size_t getNcells() override final { return 1; } //!< this is a single cell
      64             : 
      65    12599825 :   virtual Status checkCurrent(bool checkV, bool print) noexcept
      66             :   {
      67             :     double v;
      68    12599825 :     Status Vstatus = checkV ? checkVoltage(v, print) : Status::Success;
      69             :     //!< #TODO Current checking part is missing!
      70    12599825 :     return Vstatus;
      71             :   }
      72             : 
      73             :   /**
      74             :    * @brief Check the voltage status of the cell.
      75             :    * @param v Reference to the voltage value.
      76             :    * @param print Boolean flag to indicate whether to print the result or not.
      77             :    * @return Status of the voltage check.
      78             :    */
      79    11961170 :   virtual Status checkVoltage(double &v, bool print) noexcept override { return free::check_voltage(v, *this); }
      80             : 
      81             : 
      82             :   //!< thermal model
      83             :   //!< virtual double getThermalSurface() = 0; //!< todo not implemented
      84             : 
      85             :   /**
      86             :    * @brief Calculate the thermal model of the cell.
      87             :    * @param Nneighb Number of neighboring cells.
      88             :    * @param Tneighb Pointer to an array of neighboring cells' temperatures.
      89             :    * @param Kneighb Pointer to an array of neighboring cells' thermal conductivities.
      90             :    * @param Aneighb Pointer to an array of neighboring cells' contact areas.
      91             :    * @param tim Time duration for the thermal model calculation.
      92             :    * @return Cell temperature after thermal model calculation.
      93             :    * @note The thermal model is not implemented yet. Requires something similar to an SPM cell
      94             :    * (keep track of heat generation and time) and then solve the ODE here.
      95             :    */
      96           0 :   virtual double thermalModel(int Nneighb, double Tneighb[], double Kneighb[], double Aneighb[], double tim) override
      97             :   {
      98           0 :     return T();
      99             :   }
     100             : 
     101             :   //!< dataStorage
     102      806970 :   virtual void storeData() override { cellData.storeData(*this); }                                  //!< Add another data point in the array.
     103          10 :   virtual void writeData(const std::string &prefix) override { cellData.writeData(*this, prefix); } // #TODO *this may be Cell not actual type.
     104             : 
     105           0 :   virtual ThroughputData getThroughputs() { return {}; }
     106             : 
     107           0 :   virtual std::array<double, 4> getVariations() const noexcept { return {}; } // #TODO will be deleted in future.
     108             : };
     109             : 
     110             : } // namespace slide

Generated by: LCOV version 1.14