Commit 9f56fc15 authored by Elias Barbers's avatar Elias Barbers
Browse files

version 2.22.0

parent cd6e1d0e
Pipeline #329096 passed with stages
in 91 minutes and 54 seconds
Version 2.22.0
===========
- Output filenames for the thermal matlab filter can be set in the XML file
- The simulink converter has a function to discretize the generated model
- The average current can be used in the formulas for cyclic aging with the symbol "meanI"
- Fixed a bug that crashed the program when the matlab filter reached its maximum number of samples
Version 2.21.2
===========
- Fix a bug in the simulink converter that leads to incorrect voltages over rmphn elements
......
......@@ -5,8 +5,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
cmake_policy(SET CMP0009 NEW)
set(ISEAFrameVERSION_MAJOR 2)
set(ISEAFrameVERSION_MINOR 21)
set(ISEAFramePATCH_LEVEL 2)
set(ISEAFrameVERSION_MINOR 22)
set(ISEAFramePATCH_LEVEL 0)
set(ISEAFrameNAME "Refactor")
set(ARCH_TYPE
"64"
......@@ -21,6 +21,7 @@ option(CREATE_RELEASE_DIRS
OFF)
option(BUILD_FOR_RT "Build a version for the realtime system" OFF)
option(USE_BOOST_THREADS "Use multithreading for the thermal model" OFF)
option(USE_EXCEPTIONS "Use exceptions" ON)
set(MATIRX_IMPLEMENTATION
Eigen
CACHE STRING "Choose matrix implementation")
......@@ -66,13 +67,13 @@ if(WIN_HOST)
if(USE_SIMULINK)
set(MATLAB_INCLUDE_DIR
"C:/Program Files/matlab/R2018b/extern/include"
"C:/Program Files/matlab/R2019b/extern/include"
CACHE STRING "Path to matlab header files")
set(SIMULINK_INCLUDE_DIR
"C:/Program Files/matlab/R2018b/simulink/include"
"C:/Program Files/matlab/R2019b/simulink/include"
CACHE STRING "Path to simulink header files")
set(MATLAB_LINK_DIR
"C:/Program Files/matlab/R2018b/extern/lib/win64/microsoft"
"C:/Program Files/matlab/R2019b/extern/lib/win64/microsoft"
CACHE STRING "Path to matlab library files")
endif(USE_SIMULINK)
......@@ -80,12 +81,17 @@ else()
if(${USE_DEBUG_GDB})
add_compile_options(-ggdb)
endif()
add_link_options("-Wl,-rpath=./")
add_compile_options(-fPIC)
endif()
if(BUILD_FOR_RT)
set(USE_BOOST_THREADS
OFF
CACHE BOOL "Use multithreading for the thermal model" FORCE)
set(USE_EXCEPTIONS
OFF
CACHE BOOL "Use exceptions" FORCE)
set(NUMERIC_DEFINITIONS
${NUMERIC_DEFINITIONS}
......@@ -136,10 +142,14 @@ if(BUILD_FOR_RT)
-DBOOST_NO_SFINAE_EXPR
-DBOOST_NO_TWO_PHASE_NAME_LOOKUP
-D__NO_STRING__)
else()
set(COMMON_DEFINITIONS ${COMMON_DEFINITIONS} __EXCEPTIONS__)
endif()
if(USE_EXCEPTIONS)
set(COMMON_DEFINITIONS ${COMMON_DEFINITIONS} __EXCEPTIONS__)
else()
set(COMMON_DEFINITIONS ${COMMON_DEFINITIONS} BOOST_NO_EXCEPTIONS)
endif(USE_EXCEPTIONS)
if(USE_BOOST_THREADS)
set(NUMERIC_DEFINITIONS ${NUMERIC_DEFINITIONS} -DBOOST_THREAD
-DBOOST_HAS_THREADS)
......@@ -162,44 +172,11 @@ find_package(Boost REQUIRED)
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} Boost::boost)
find_package(MATIO REQUIRED)
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} ${MATIO_LIBRARIES})
find_package(Threads REQUIRED)
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} Threads::Threads)
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} tinyxml2)
if(USE_SIMULINK)
set(MATLAB_INCLUDE_DIR
/usr/local/MATLAB/R2019b/extern/include
CACHE STRING "Path to matlab header files")
set(SIMULINK_INCLUDE_DIR
/usr/local/MATLAB/R2019b/simulink/include
CACHE STRING "Path to simulink header files")
set(MATLAB_LINK_DIR
/usr/local/MATLAB/R2019b/bin/glnxa64
CACHE STRING "Path to matlab library files")
if(WIN_HOST)
set(SIMULINK_LIBRARIES libmex libmx libmat libmwlapack libmwblas libeng)
else()
set(SIMULINK_LIBRARIES mex mx mwlapack mwblas eng)
endif()
add_library(Simulink INTERFACE IMPORTED)
target_include_directories(Simulink INTERFACE ${MATLAB_INCLUDE_DIR}
${SIMULINK_INCLUDE_DIR})
target_link_directories(Simulink INTERFACE ${MATLAB_LINK_DIR})
target_link_libraries(Simulink INTERFACE ${SIMULINK_LIBRARIES})
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} Simulink)
if(LINUX_TARGET)
add_compile_options(-fPIC)
endif()
endif(USE_SIMULINK)
# used by subdirectories to copy DLLs for windows to the binary output dir when
# building the target
function(copy_windows_files_to_dir binary_dir)
......@@ -215,7 +192,8 @@ endfunction(copy_windows_files_to_dir)
function(add_release_files target files_to_copy)
if(CREATE_RELEASE_DIRS)
add_custom_command(
TARGET ${target} POST_BUILD
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${files_to_copy}
$<TARGET_PROPERTY:${target},RUNTIME_OUTPUT_DIRECTORY>)
endif()
......@@ -229,12 +207,4 @@ add_subdirectory(standalone)
add_subdirectory(src/export/mex)
add_subdirectory(src/unittests)
add_subdirectory(doxygen)
# check if external dependencies have been added in the subdirectories
if(NEED_SIMULINK)
set(USE_SIMULINK
ON
CACHE BOOL "link to simulink libraries" FORCE)
endif()
mark_as_advanced(USE_SIMULINK)
add_subdirectory(src/cinterface)
......@@ -70,9 +70,12 @@ Parts of the framework are used in the following projects:
1. Toolbox Speichersysteme, Energy Storage Toolbox
* Förderkennzeichen: 64.65.69-EM-2011A
2. Offenes Batterie-Alterungs-Tool zur Lebensdauerprognose von Batteriepacks unter Berücksichtigung von Unsicherheiten und Streuung von Zellqualität,
2. Offenes Batterie-Alterungs-Tool zur Lebensdauerprognose von Batteriepacks unter Berücksichtigung von Unsicherheiten und Streuung von Zellqualität
* Förderkennzeichen: 0325905
3. E2Fuels – Modellgestützte Optimierung und Lebenszyklusanalyse batteriehybrider, maritimer Antriebssysteme
* Förderkennzeichen: 03EIV011F
Authors
===========
Please acknowledge the [authors](DevelopmentTeam.md).
......
......@@ -25,6 +25,7 @@ function PrintHelp
PrintMessage "-w\t\tIf on linux, build a release for windows."
PrintMessage "-b <builddir>\t\tSpecify the build dir. Default is \"build\""
PrintMessage "-c\t\tOnly configure, do not start the build process."
PrintMessage "-j <n>\t\tUse n threads for building. Default is 20."
}
function RunCMake
......@@ -64,7 +65,8 @@ function main
WIN_TARGET=0
ONLY_CONFIGURE=0
BUILDDIR=build
while getopts "hwb:c" opt; do
THREADS=20
while getopts "hwb:cj:" opt; do
case "$opt" in
h) PrintHelp
exit 0
......@@ -75,6 +77,8 @@ function main
;;
c) ONLY_CONFIGURE=1
;;
j) THREADS=$OPTARG
;;
esac
done
......@@ -113,9 +117,9 @@ function main
then
if [ $WIN_HOST -eq 1 ]
then
cmake --build $BUILDDIR --target all
cmake --build $BUILDDIR
else
cmake --build $BUILDDIR --target all -- -j 20
cmake --build $BUILDDIR --target all -- -j ${THREADS}
fi
fi
}
......
#FROM https://github.com/cvjena/nice-core/blob/master/cmake/FindMATIO.cmake
# BASED ON https://github.com/cvjena/nice-core/blob/master/cmake/FindMATIO.cmake
# Find the MATIO headers and library.
#
# MATIO_INCLUDE_DIRS - where to find matio.h, etc.
# MATIO_LIBRARIES - List of libraries.
# MATIO_FOUND - True if matio found.
# MATIO_INCLUDE_DIRS - where to find matio.h, etc. MATIO_LIBRARIES - List of
# libraries. MATIO_FOUND - True if matio found.
FIND_PATH(MATIO_INCLUDE_DIR NAMES matio.h PATHS ${FRAMEWORK_EXTENSION_FOLDER}/include/ $ENV{HOME}/include)
FIND_LIBRARY(MATIO_LIBRARY NAMES matio${ARCH_TYPE} libmatio${ARCH_TYPE} matio libmatio PATHS ${FRAMEWORK_EXTENSION_FOLDER}/lib/ $ENV{HOME}/lib)
find_path(
MATIO_INCLUDE_DIR
NAMES matio.h
PATHS ${FRAMEWORK_EXTENSION_FOLDER}/include/
${FRAMEWORK_EXTENSION_FOLDER}/include/matio $ENV{HOME}/include)
find_library(
MATIO_LIBRARY
NAMES matio${ARCH_TYPE} libmatio${ARCH_TYPE} matio libmatio
PATHS ${FRAMEWORK_EXTENSION_FOLDER}/lib/ $ENV{HOME}/lib)
MARK_AS_ADVANCED(MATIO_INCLUDE_DIR)
MARK_AS_ADVANCED(MATIO_LIBRARY)
mark_as_advanced(MATIO_INCLUDE_DIR)
mark_as_advanced(MATIO_LIBRARY)
# handle the QUIETLY and REQUIRED arguments and set MATIO_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MATIO DEFAULT_MSG MATIO_LIBRARY MATIO_INCLUDE_DIR)
# handle the QUIETLY and REQUIRED arguments and set MATIO_FOUND to TRUE if all
# listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MATIO DEFAULT_MSG MATIO_LIBRARY
MATIO_INCLUDE_DIR)
IF(MATIO_FOUND)
SET(MATIO_LIBRARIES ${MATIO_LIBRARY} ${HDF5_LIBRARIES})
SET(MATIO_INCLUDE_DIRS ${MATIO_INCLUDE_DIR} ${HDF5_INCLUDE_DIR})
ELSE(MATIO_FOUND)
SET(MATIO_LIBRARIES)
SET(MATIO_INCLUDE_DIRS)
ENDIF(MATIO_FOUND)
if(MATIO_FOUND)
set(MATIO_LIBRARIES ${MATIO_LIBRARY} ${HDF5_LIBRARIES})
set(MATIO_INCLUDE_DIRS ${MATIO_INCLUDE_DIR})
add_library(matio::matio UNKNOWN IMPORTED)
set_target_properties(
matio::matio
PROPERTIES IMPORTED_LOCATION "${MATIO_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MATIO_INCLUDE_DIRS}")
else(MATIO_FOUND)
set(MATIO_LIBRARIES)
set(MATIO_INCLUDE_DIRS)
endif(MATIO_FOUND)
......@@ -141,8 +141,8 @@ The calendric aging is used by adding an element with the class attribute "Calen
XML Tag | Type | Unit | Explanation
----------------------------------------|---------------|-----------|----------------------------------------------------------------------------------------
TimeExponent | double | | Exponent n in the formulas used to calculate the calendric aging
FormulaCapacity | string | | Formula used to calculate the value of alpha. The symbols V and T can be used for the cell's voltage and temperature
FormulaResistance | string | | Formula used to calculate the value of alpha. The symbols V and T can be used for the cell's voltage and temperature
FormulaCapacity | string | | Formula used to calculate the value of alpha. The symbols V, T and SOC can be used for the cell's voltage, temperature and SOC
FormulaResistance | string | | Formula used to calculate the value of alpha. The symbols V, T and SOC can be used for the cell's voltage, temperature and SOC
MinAlphaCapacity | double | | Minimum value for the stress factor. If a lower value is calculated, this value is used instead.
MinAlphaResistance | double | | Minimum value for the stress factor. If a lower value is calculated, this value is used instead.
InitialCapacityFactor | double | 0 - 1 | Initial value for the capacity factor. Optional, default = 1.
......@@ -157,8 +157,8 @@ XML Tag | Type | Unit | Explanatio
----------------------------------------|---------------|-----------|----------------------------------------------------------------------------------------
ChargeExponentCapacity | double | | Exponent n in the formula used to calculate the capacity for the cyclic aging
ChargeExponentResistance | double | | Exponent n in the formula used to calculate the resistance for the cyclic aging
FormulaCapacity | string | | Formula used to calculate the value of beta. The symbols meanV and deltaDOD can be used for the cell's average voltage and depth of discharge
FormulaResistance | string | | Formula used to calculate the value of beta. The symbols meanV and deltaDOD can be used for the cell's average voltage and depth of discharge
FormulaCapacity | string | | Formula used to calculate the value of beta. The symbols meanV, deltaDOD, meanSOC and meanI can be used for the cell's average voltage, depth of discharge, average SOC and average current
FormulaResistance | string | | Formula used to calculate the value of beta. The symbols meanV, deltaDOD, meanSOC and meanI can be used for the cell's average voltage, depth of discharge, average SOC and average current
MinBetaCapacity | double | | Minimum value for the stress factor. If a lower value is calculated, this value is used instead.
MinBetaResistance | double | | Minimum value for the stress factor. If a lower value is calculated, this value is used instead.
InitialCapacityFactor | double | 0 - 1 | Initial value for the capacity factor. Optional, default = 1.
......
......@@ -45,10 +45,10 @@
</Filter1>
<Filter2 class="MatlabFilter">
<Filename>Patch_Temperatures.mat</Filename>
<VerticesFile>Patch_Vertices.mat</VerticesFile>
<VolumesFile>Patch_Volumes.mat</VolumesFile>
<VolumesNameFile>Patch_VolumeNames.mat</VolumesNameFile>
<AreasFile>Patch_Areas.mat</AreasFile>
<VerticesFile>Patch_Vertices.csv</VerticesFile>
<VolumesFile>Patch_Volumes.csv</VolumesFile>
<VolumeNamesFile>Patch_VolumeNames.csv</VolumeNamesFile>
<AreasFile>Patch_Areas.csv</AreasFile>
</Filter2>
</Thermal>
<Aging>
......
......@@ -38,10 +38,10 @@
</Filter1>
<Filter2 class="MatlabFilter">
<Filename>Patch_Temperatures.mat</Filename>
<VerticesFile>Patch_Vertices.mat</VerticesFile>
<VolumesFile>Patch_Volumes.mat</VolumesFile>
<VolumesNameFile>Patch_VolumeNames.mat</VolumesNameFile>
<AreasFile>Patch_Areas.mat</AreasFile>
<VerticesFile>Patch_Vertices.csv</VerticesFile>
<VolumesFile>Patch_Volumes.csv</VolumesFile>
<VolumeNamesFile>Patch_VolumeNames.csv</VolumeNamesFile>
<AreasFile>Patch_Areas.csv</AreasFile>
</Filter2>
</Thermal>
</Observer>
......@@ -268,4 +268,4 @@
<Pack ref="MyR2RC"/>
</Children>
</RootElement>
</Configuration>
\ No newline at end of file
</Configuration>
function [] = Discretize(system)
if nargin == 0
system = 'BuildMatrixModel';
end
integrators = find_system(system, 'BlockType', 'Integrator');
for i = 1:length(integrators)
block = integrators{i};
blockSystem = block(1 : find(block == '/', 1, 'last') - 1);
position = get_param(block, 'Position');
name = get_param(block, 'Name');
connections = get_param(block, 'PortConnectivity');
reset = get_param(block, 'ExternalReset');
initSource = get_param(block, 'InitialConditionSource');
initValue = get_param(block, 'InitialCondition');
limitOutput = get_param(block, 'LimitOutput');
upperLimit = get_param(block, 'UpperSaturationLimit');
lowerLimit = get_param(block, 'LowerSaturationLimit');
for j = 1:length(connections)
conn = connections(j);
if isempty(conn.DstPort)
for k = 1:length(conn.SrcBlock)
srcName = get_param(conn.SrcBlock(k), 'Name');
delete_line(blockSystem, [srcName '/' num2str(conn.SrcPort(k)+1)], [name '/' conn.Type]);
end
else
for k = 1:length(conn.DstBlock)
dstName = get_param(conn.DstBlock(k), 'Name');
delete_line(blockSystem, [name '/' conn.Type], [dstName '/' num2str(conn.DstPort(k)+1)]);
end
end
end
delete_block(block);
add_block('simulink/Discrete/Discrete-Time Integrator', block, 'Position', position);
set_param(block, 'ExternalReset', reset);
set_param(block, 'InitialConditionSource', initSource);
set_param(block, 'InitialCondition', initValue);
set_param(block, 'LimitOutput', limitOutput);
set_param(block, 'UpperSaturationLimit', upperLimit);
set_param(block, 'LowerSaturationLimit', lowerLimit);
for j = 1:length(connections)
conn = connections(j);
if isempty(conn.DstPort)
for k = 1:length(conn.SrcBlock)
srcName = get_param(conn.SrcBlock(k), 'Name');
add_line(blockSystem, [srcName '/' num2str(conn.SrcPort(k)+1)], [name '/' conn.Type], 'autorouting', 'on');
end
else
for k = 1:length(conn.DstBlock)
dstName = get_param(conn.DstBlock(k), 'Name');
add_line(blockSystem, [name '/' conn.Type], [dstName '/' num2str(conn.DstPort(k)+1)], 'autorouting', 'on');
end
end
end
end
......@@ -19,6 +19,10 @@ if ~isfield( component, origsystemstr )
end
componentCounter = component.(origsystemstr);
if (symbolicString == "")
symbolicString = '0';
end
% componentCounter = size(GetAllComponents(system), 1);
position = [60 min(32767-60, 60+componentCounter*120) 120 min(32767,120+componentCounter*120)];
destination = [system '/Component' num2str(componentCounter)];
......
......@@ -3,6 +3,7 @@ add_custom_target(framework)
# list of directories inside src that should not be included
set(UNINCLUDE
${UNINCLUDE}
${PROJECT_SOURCE_DIR}/src/cinterface/
${PROJECT_SOURCE_DIR}/src/unittest
${PROJECT_SOURCE_DIR}/src/simulink_mock/
${PROJECT_SOURCE_DIR}/src/thermal/executable
......@@ -17,7 +18,6 @@ set(NUMERIC_UNINCLUDE ${NUMERIC_UNINCLUDE})
set(SYMBOLIC_UNINCLUDE
${SYMBOLIC_UNINCLUDE}
${PROJECT_SOURCE_DIR}/src/cinterface/
${PROJECT_SOURCE_DIR}/src/export/baseExport
${PROJECT_SOURCE_DIR}/src/export/electrical_simulink_model
${PROJECT_SOURCE_DIR}/src/export/esbVisualizer
......@@ -123,8 +123,8 @@ endforeach(f ${TMP_SOURCE})
if(BUILD_NUMERIC)
set(libname_NUMERIC ISEAFrameNumeric)
add_library(${libname_NUMERIC} ${NUMERIC_SOURCE} ${NUMERIC_HEADERS})
target_link_libraries(${libname_NUMERIC} ${COMMON_LIBRARIES}
${NUMERIC_LIBRARIES})
target_link_libraries(${libname_NUMERIC} PUBLIC ${COMMON_LIBRARIES}
${NUMERIC_LIBRARIES} ${MATIO_LIBRARIES})
target_compile_definitions(${libname_NUMERIC} PUBLIC ${COMMON_DEFINITIONS}
${NUMERIC_DEFINITIONS})
add_dependencies(framework ${libname_NUMERIC})
......@@ -133,7 +133,7 @@ endif()
if(BUILD_SYMBOLIC)
set(libname_SYMBOLIC ISEAFrameSymbolic)
add_library(${libname_SYMBOLIC} ${SYMBOLIC_SOURCE} ${SYMBOLIC_HEADERS})
target_link_libraries(${libname_SYMBOLIC} ${COMMON_LIBRARIES}
target_link_libraries(${libname_SYMBOLIC} PUBLIC ${COMMON_LIBRARIES}
${SYMBOLIC_LIBRARIES})
target_compile_definitions(${libname_SYMBOLIC} PUBLIC ${COMMON_DEFINITIONS}
${SYMBOLIC_DEFINITIONS})
......
......@@ -5,11 +5,12 @@
namespace aging
{
CalendarianAging::CalendarianAging( const double agingStepTime, const double minAlphaCapacity,
const double minAlphaResistance, const std::string& formulaAlphaCapacity,
const std::string& formulaAlphaResistance, const double initialCapacityFactor,
const double initialResistanceFactor, const bool isEnabled, const double timeExponent )
: EmpiricalAging( agingStepTime, minAlphaCapacity, minAlphaResistance, formulaAlphaCapacity, formulaAlphaResistance,
CalendarianAging::CalendarianAging( const double agingStepTime, const double minAlphaCapacity, const double minAlphaResistance,
const boost::shared_ptr< object::Object< double > >& alphaCapacity,
const boost::shared_ptr< object::Object< double > >& alphaResistance,
const double initialCapacityFactor, const double initialResistanceFactor,
const bool isEnabled, const double timeExponent )
: EmpiricalAging( agingStepTime, minAlphaCapacity, minAlphaResistance, alphaCapacity, alphaResistance,
initialCapacityFactor, initialResistanceFactor, isEnabled )
, mTimeExponent( timeExponent )
, mActualVoltage( 0.0 )
......@@ -17,14 +18,6 @@ CalendarianAging::CalendarianAging( const double agingStepTime, const double min
, mActualSoc( 0.0 )
, mTimeSinceLastAgingStep( 0.0 )
{
// Assigns the parameter name and the associated variable to the expressionparser
std::vector< std::pair< const char*, double& > > expressionParserContent;
expressionParserContent.push_back( std::pair< const char*, double& >( "V", mActualVoltage ) );
expressionParserContent.push_back( std::pair< const char*, double& >( "T", mActualTemperature ) );
expressionParserContent.push_back( std::pair< const char*, double& >( "SOC", mActualSoc ) );
this->mExpressionParserStressFactorCapacity.AddContent( formulaAlphaCapacity, expressionParserContent );
this->mExpressionParserStressFactorResistance.AddContent( formulaAlphaResistance, expressionParserContent );
}
size_t CalendarianAging::GetType() const { return AgingType::CALENDARIAN; }
......@@ -44,8 +37,8 @@ void CalendarianAging::CalculateAging( const TwoportState& twoportState, double
mActualTemperature = mTemperatureValues[i];
mActualSoc = mSocValues[i];
dt = mTimeValues[i] - previousTime;
alphaCap = this->mExpressionParserStressFactorCapacity.GetSolution();
alphaRes = this->mExpressionParserStressFactorResistance.GetSolution();
alphaCap = this->mCapacityStressFactor->GetValue();
alphaRes = this->mResistanceStressFactor->GetValue();
if ( alphaCap < this->mMinStressFactorCapacity )
alphaCap = this->mMinStressFactorCapacity;
if ( alphaRes < this->mMinStressFactorResistance )
......
......@@ -8,6 +8,14 @@
#include "../state/thermal_state.h"
#include "empirical_aging.h"
class TestCalendarianAging;
namespace factory
{
template < typename T >
class AgingClassWrapper;
}
namespace aging
{
......@@ -15,12 +23,15 @@ namespace aging
/// underlying cell
class CalendarianAging : public EmpiricalAging
{
friend factory::AgingClassWrapper< CalendarianAging >;
friend TestCalendarianAging;
public:
/// Constructor
CalendarianAging( const double agingStepTime, const double minAlphaCapacity, const double minAlphaResistance,
const std::string& formulaAlphaCapacity, const std::string& formulaAlphaResistance,
const double initialCapacityFactor, const double initialResistanceFactor, const bool isEnabled,
const double timeExponent );
const boost::shared_ptr< object::Object< double > >& alphaCapacity,
const boost::shared_ptr< object::Object< double > >& alphaResistance, const double initialCapacityFactor,
const double initialResistanceFactor, const bool isEnabled, const double timeExponent );
/// Derived from AgingBase
virtual size_t GetType() const;
......
......@@ -5,25 +5,20 @@
namespace aging
{
CyclicalAging::CyclicalAging( const double agingStepTime, const double minBetaCapacity, const double minBetaResistance,
const std::string& formulaBetaCapacity, const std::string& formulaBetaResistance,
const boost::shared_ptr< object::Object< double > >& alphaCapacity,
const boost::shared_ptr< object::Object< double > >& alphaResistance,
const double initialCapacityFactor, const double initialResistanceFactor, const bool isEnabled,
const double chargeThroughputExponentCapacity, const double chargeThroughputExponentResistance )
: EmpiricalAging( agingStepTime, minBetaCapacity, minBetaResistance, formulaBetaCapacity, formulaBetaResistance,
: EmpiricalAging( agingStepTime, minBetaCapacity, minBetaResistance, alphaCapacity, alphaResistance,
initialCapacityFactor, initialResistanceFactor, isEnabled )
, mChargeThroughputExponentCapacity( chargeThroughputExponentCapacity )
, mChargeThroughputExponentResistance( chargeThroughputExponentResistance )
, mActualDod( 0.0 )
, mActualVoltage( 0.0 )
, mActualSoc( 0.0 )
, mActualCurrent( 0.0 )
, mTimeSinceLastAgingStep( 0.0 )
{
std::vector< std::pair< const char*, double& > > expressionParserContent;
expressionParserContent.push_back( std::pair< const char*, double& >( "deltaDOD", mActualDod ) );
expressionParserContent.push_back( std::pair< const char*, double& >( "meanV", mActualVoltage ) );
expressionParserContent.push_back( std::pair< const char*, double& >( "meanSOC", mActualSoc ) );
this->mExpressionParserStressFactorCapacity.AddContent( formulaBetaCapacity, expressionParserContent );
this->mExpressionParserStressFactorResistance.AddContent( formulaBetaResistance, expressionParserContent );
}
size_t CyclicalAging::GetType() const { return AgingType::CYCLICAL; }
......@@ -41,18 +36,23 @@ void CyclicalAging::CalculateAging( const TwoportState& twoportState, double tim
this->mStressFactorCapacity = 0.0;
this->mStressFactorResistance = 0.0;
for ( size_t i = 0; i < cycles.size(); i++ )
for ( const rainflow::Cycle& cycle : cycles )
{
mActualDod = cycles[i].mDepth;
mActualSoc = cycles[i].mMeanValue;
mActualVoltage = GetAverageVoltage( this->mTimeValues[cycles[i].mStartIndex], this->mTimeValues[cycles[i].mEndIndex] );
double betaCapacity = this->mExpressionParserStressFactorCapacity.GetSolution();
double betaResistance = this->mExpressionParserStressFactorResistance.GetSolution();
double cycleStart = this->mTimeValues[cycle.mStartIndex];
double cycleEnd = this->mTimeValues[cycle.mEndIndex];
double cycleChargeThroughput = cycle.mDepth * capacity * cycle.mCycleCount;
mActualDod = cycle.mDepth;
mActualSoc = cycle.mMeanValue;
// convert CTP to As and double it to get the integral over the absolute value of the current
mActualCurrent = ( cycleChargeThroughput * 2 * 3600 ) / ( cycleEnd - cycleStart );
mActualVoltage = GetAverageVoltage( cycleStart, cycleEnd );
double betaCapacity = this->mCapacityStressFactor->GetValue();
double betaResistance = this->mResistanceStressFactor->GetValue();
if ( betaCapacity < this->mMinStressFactorCapacity )
betaCapacity = this->mMinStressFactorCapacity;
if ( betaResistance < this->mMinStressFactorResistance )
betaResistance = this->mMinStressFactorResistance;
double cycleChargeThroughput = mActualDod * capacity * cycles[i].mCycleCount;
this->mStressFactorCapacity += betaCapacity * cycleChargeThroughput;
this->mStressFactorResistance += betaResistance * cycleChargeThroughput;
chargeThroughput += cycleChargeThroughput;
......
......@@ -11,6 +11,14 @@
#include <algorithm>
class TestCyclicalAging;
namespace factory
{
template < typename T >
class AgingClassWrapper;
}
namespace aging
{
......@@ -18,10 +26,14 @@ namespace aging
/// cell
class CyclicalAging : public EmpiricalAging
{
friend factory::AgingClassWrapper< CyclicalAging >;
friend TestCyclicalAging;
public:
/// Constructor
CyclicalAging( const double agingStepTime, const double minBetaCapacity, const double minBetaResistance,
const std::string& formulaBetaCapacity, const std::string& formulaBetaResistance,
const boost::shared_ptr< object::Object< double > >& alphaCapacity,
const boost::shared_ptr< object::Object< double > >& alphaResistance,
const double initialCapacityFactor, const double initialResistanceFactor, const bool isEnabled,
const double chargeThroughputExponentCapacity, const double chargeThroughputExponentResistance );
......@@ -49,6 +61,7 @@ class CyclicalAging : public EmpiricalAging
double mActualDod; // [%/100]
double mActualVoltage; // [V]
double mActualSoc; // [%/100]
double mActualCurrent; // [A]
double mTimeSinceLastAgingStep; // [s]
std::vector< double > mTimeValues; // [s]
......
#include "empirical_aging.h"
namespace aging
{
EmpiricalAging::EmpiricalAging( const double agingStepTime, const double minStressFactorCapacity,
const double minStressFactorResistance, const std::string& formulaStressFactorCapacity,
const std::string& formulaStressFactorResistance, const double initialCapacityFactor,