Skip to content

Commit

Permalink
mode CMake linking
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektrikAkar committed Jul 26, 2024
1 parent 004c9ba commit 97728d3
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 37 deletions.
1 change: 1 addition & 0 deletions develop/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> Iolds in Module_p.cpp
- [ ] Use just one memory allocation, dynamically allocated memory space for Model_SPM.


### From SLIDE v2:
Expand Down
3 changes: 2 additions & 1 deletion src/cooling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ target_sources(cooling
data_storage/cool_data.hpp
)

target_include_directories(cooling PUBLIC .)
target_include_directories(cooling PUBLIC .)
target_link_libraries(cooling PRIVATE settings)
4 changes: 3 additions & 1 deletion src/factories/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
9 changes: 3 additions & 6 deletions src/factories/makeBattery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cmath>
#include <random>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ target_sources(modules
)

target_include_directories(modules PUBLIC .)
target_link_libraries(modules PUBLIC cooling cells Eigen3::Eigen)
target_link_libraries(modules PUBLIC cooling cells settings Eigen3::Eigen)
2 changes: 1 addition & 1 deletion src/modules/Module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
50 changes: 24 additions & 26 deletions src/procedures/Cycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -279,17 +277,17 @@ 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;

while (ttot < tlim) {
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 {
Expand Down
2 changes: 1 addition & 1 deletion src/system/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ target_sources(system
)

target_include_directories(system PUBLIC .)
target_link_libraries(system PRIVATE power_conversion)
target_link_libraries(system PRIVATE power_conversion settings)

0 comments on commit 97728d3

Please sign in to comment.