1 #include "LogTimeScaleController.hpp" 6 LogTimeScaleController::LogTimeScaleController(
13 bool writeTimeScaleFieldnames,
17 : AdaptiveTimeScaleController(
24 writeTimeScaleFieldnames,
26 mLogThresh = logThresh;
27 mLogSlope = -(logThresh - mBaseMax) / log(logSlope);
31 LogTimeScaleController::calcTimesteps(
double timeValue, std::vector<double>
const &rawTimeScales) {
32 mOldTimeScaleInfo = mTimeScaleInfo;
33 mTimeScaleInfo.mTimeScaleTrue = rawTimeScales;
34 for (
int b = 0; b < mBatchWidth; b++) {
35 double E_dt = mTimeScaleInfo.mTimeScaleTrue[b];
36 double E_0 = mOldTimeScaleInfo.mTimeScaleTrue[b];
37 double dE_dt_scaled = (E_0 - E_dt) / mTimeScaleInfo.mTimeScale[b];
43 if ((dE_dt_scaled <= 0.0) || (E_0 <= 0) || (E_dt <= 0)) {
44 mTimeScaleInfo.mTimeScale[b] = mBaseMin;
45 mTimeScaleInfo.mTimeScaleMax[b] = mBaseMax;
48 double tau_eff_scaled = E_0 / dE_dt_scaled;
51 mTimeScaleInfo.mTimeScale[b] = mTauFactor * tau_eff_scaled;
52 if (mTimeScaleInfo.mTimeScale[b] >= mTimeScaleInfo.mTimeScaleMax[b]) {
54 mGrowthFactor * exp(-(mTimeScaleInfo.mTimeScaleMax[b] - mBaseMax) / mLogSlope);
55 mTimeScaleInfo.mTimeScale[b] = mTimeScaleInfo.mTimeScaleMax[b];
56 mTimeScaleInfo.mTimeScaleMax[b] = (1 + growthFactor) * mTimeScaleInfo.mTimeScaleMax[b];
60 return mTimeScaleInfo.mTimeScale;