From 97728d38ebab4df4e7498fb3bb63e7f79a959b04 Mon Sep 17 00:00:00 2001 From: Volkan Kumtepeli Date: Fri, 26 Jul 2024 02:22:35 +0100 Subject: [PATCH] mode CMake linking --- develop/TODO.md | 1 + src/cooling/CMakeLists.txt | 3 ++- src/factories/CMakeLists.txt | 4 ++- src/factories/makeBattery.cpp | 9 +++---- src/modules/CMakeLists.txt | 2 +- src/modules/Module.hpp | 2 +- src/procedures/Cycler.cpp | 50 +++++++++++++++++------------------ src/system/CMakeLists.txt | 2 +- 8 files changed, 36 insertions(+), 37 deletions(-) diff --git a/develop/TODO.md b/develop/TODO.md index cc0822c..a84d163 100644 --- a/develop/TODO.md +++ b/develop/TODO.md @@ -133,6 +133,7 @@ - [ ] setSUs and assigning unique pointers then testing individually is very difficult. Clearly a design problem. - [ ] getNSUs may slow down time to time. - [ ] std::vector Iolds in Module_p.cpp +- [ ] Use just one memory allocation, dynamically allocated memory space for Model_SPM. ### From SLIDE v2: diff --git a/src/cooling/CMakeLists.txt b/src/cooling/CMakeLists.txt index 32c96fe..e87b8e6 100644 --- a/src/cooling/CMakeLists.txt +++ b/src/cooling/CMakeLists.txt @@ -18,4 +18,5 @@ target_sources(cooling data_storage/cool_data.hpp ) -target_include_directories(cooling PUBLIC .) \ No newline at end of file +target_include_directories(cooling PUBLIC .) +target_link_libraries(cooling PRIVATE settings) \ No newline at end of file diff --git a/src/factories/CMakeLists.txt b/src/factories/CMakeLists.txt index 301718e..c38ff96 100644 --- a/src/factories/CMakeLists.txt +++ b/src/factories/CMakeLists.txt @@ -8,10 +8,12 @@ target_sources(factories makeBattery.hpp ) -target_include_directories(factories PUBLIC .) +target_include_directories(factories PUBLIC .) target_link_libraries(factories PRIVATE cells modules + procedures + settings ) diff --git a/src/factories/makeBattery.cpp b/src/factories/makeBattery.cpp index 95e2dcb..b141335 100644 --- a/src/factories/makeBattery.cpp +++ b/src/factories/makeBattery.cpp @@ -8,12 +8,9 @@ #include "makeBattery.hpp" #include "cells.hpp" -#include "../modules/Module_s.hpp" -#include "../modules/Module_p.hpp" -#include "../procedures/Cycler.hpp" -#include "../procedures/Procedure.hpp" -// #include "unit_tests.hpp" -#include "../settings/settings.hpp" +#include "modules.hpp" +#include "procedures.hpp" +#include "settings.hpp" #include #include diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 9052d61..9a6d274 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -13,4 +13,4 @@ target_sources(modules ) target_include_directories(modules PUBLIC .) -target_link_libraries(modules PUBLIC cooling cells Eigen3::Eigen) \ No newline at end of file +target_link_libraries(modules PUBLIC cooling cells settings Eigen3::Eigen) \ No newline at end of file diff --git a/src/modules/Module.hpp b/src/modules/Module.hpp index f69cb82..0c87f1a 100644 --- a/src/modules/Module.hpp +++ b/src/modules/Module.hpp @@ -10,7 +10,7 @@ #include "../StorageUnit.hpp" #include "../cooling/cooling.hpp" #include "../types/State.hpp" -#include "../settings/settings.hpp" +#include "settings.hpp" #include "../utility/utility.hpp" diff --git a/src/procedures/Cycler.cpp b/src/procedures/Cycler.cpp index af32b50..c9c7405 100644 --- a/src/procedures/Cycler.cpp +++ b/src/procedures/Cycler.cpp @@ -62,16 +62,15 @@ Status Cycler::rest(double tlim, double dt, int ndt_data, ThroughputData &th) if (boolStoreData) storeData(); //!< Variables - double dti = dt; //!< length of time step i - double ttot = 0; //!< total time done - int idat = 0; //!< consecutive number of time steps done without storing data - int nOnce = 1; //!< number of time steps we take at once, will change dynamically - int nOnceMax = 10; //!< allow maximum this number of steps to be taken at once - //!< careful with thermal stability. Thermal model only calculated every nOnce*dt - //!< so that can be in the unstable region for large batteries with cooling systems - //!< so don't have nOnceMax above 10 (even though once everything is in equilibrium, you could take much larger steps) - - bool ninc = true; //!< can nonce increase this iteration? + double dti = dt; //!< length of time step i + double ttot = 0; //!< total time done + int idat = 0; //!< consecutive number of time steps done without storing data + int nOnce = 1; //!< number of time steps we take at once, will change dynamically + int nOnceMax = 10; //!< allow maximum this number of steps to be taken at once + //!< careful with thermal stability. Thermal model only calculated every nOnce*dt + //!< so that can be in the unstable region for large batteries with cooling systems + //!< so don't have nOnceMax above 10 (even though once everything is in equilibrium, you could take much larger steps) + if (boolStoreData) nOnceMax = std::min(nOnceMax, ndt_data); //!< if we store data, never take more than the interval at which you want to store the voltage @@ -120,9 +119,9 @@ Status Cycler::rest(double tlim, double dt, int ndt_data, ThroughputData &th) nOnce = std::clamp(nOnce, 1, nOnceMax); //!< respect min and maximum - } //!< end time integration + } //!< end time integration - succ = su->setCurrent(0, false, true); // #TODO do it one last time otherwise after timeStep_CC currents change! + succ = su->setCurrent(0, false, true); // #TODO do it one last time otherwise after timeStep_CC currents change! if (isStatusBad(succ)) { if constexpr (settings::printBool::printCrit) std::cerr << "Error in Cycler::rest, stopped time integration for unclear reason after " @@ -208,30 +207,29 @@ Status Cycler::CC(double I, double vlim, double tlim, double dt, int ndt_data, T if (boolStoreData) storeData(); - double vi{}; //!< voltage now + double vi{}; //!< voltage now auto succNow = setCurrent(I, vlim, vi); if (!isStatusSuccessful(succNow)) return succNow; //!< stop if we could not successfully set the current auto succ = Status::ReachedTimeLimit; //!< Variables - double dti = dt; //!< length of time step i - double ttot{}; //!< total time done + double dti = dt; //!< length of time step i + double ttot{}; //!< total time done - int idat = 0; //!< consecutive number of time steps done without storing data - int nOnce = 1; //!< number of time steps we take at once, will change dynamically - int nOnceMax = 2; //!< allow maximum this number of steps to be taken at once - if (boolStoreData) //!< if we store data, never take more than the interval at which you want to store the voltage + int idat = 0; //!< consecutive number of time steps done without storing data + int nOnce = 1; //!< number of time steps we take at once, will change dynamically + int nOnceMax = 2; //!< allow maximum this number of steps to be taken at once + if (boolStoreData) //!< if we store data, never take more than the interval at which you want to store the voltage nOnceMax = std::min(nOnceMax, ndt_data); - bool allowUp = true; //!< do we allow nOnce to increase? while (ttot < tlim) { auto succNow = setCurrent(I, vlim, vi); // #TODO this was not here I added to get nice results from if (!isStatusSuccessful(succNow)) - return succNow; //!< stop if we could not successfully set the current + return succNow; //!< stop if we could not successfully set the current - dti = std::min(dti, tlim - ttot); //!< the last time step, ensure we end up exactly at the right time + dti = std::min(dti, tlim - ttot); //!< the last time step, ensure we end up exactly at the right time //!< take a number of time steps try { @@ -279,9 +277,9 @@ Status Cycler::CV(double Vset, double Ilim, double tlim, double dt, int ndt_data if ((std::abs(Ii) < Ilim)) return Status::ReachedCurrentLimit; - int idat = 0; //!< consecutive number of time steps done without storing data - double dti = dt; //!< length of time step i - double ttot = 0; //!< total time done + int idat = 0; //!< consecutive number of time steps done without storing data + double dti = dt; //!< length of time step i + double ttot = 0; //!< total time done auto succ{ Status::ReachedTimeLimit }; //!< time limit; @@ -289,7 +287,7 @@ Status Cycler::CV(double Vset, double Ilim, double tlim, double dt, int ndt_data auto succNow = su->setVoltage(Vset); if (!isStatusOK(succNow)) return succNow; //!< stop if we could not successfully set the current - dti = std::min(dti, tlim - ttot); //!< change length of the time step in the last iteration to get exactly tlim seconds + dti = std::min(dti, tlim - ttot); //!< change length of the time step in the last iteration to get exactly tlim seconds //!< take a time step try { diff --git a/src/system/CMakeLists.txt b/src/system/CMakeLists.txt index aa070a1..92e56d4 100644 --- a/src/system/CMakeLists.txt +++ b/src/system/CMakeLists.txt @@ -9,4 +9,4 @@ target_sources(system ) target_include_directories(system PUBLIC .) -target_link_libraries(system PRIVATE power_conversion) \ No newline at end of file +target_link_libraries(system PRIVATE power_conversion settings) \ No newline at end of file