Question mintFactor Question

msligo

New member
Joined
Dec 27, 2018
Messages
29
Reaction score
0
Points
0
Hello,

I am currently studying the lemsystems.cpp file, and I came across the following two lines in the void LEM::SystemsInternalTimestep(double simdt) function (lines 1331 and 1332):

double mintFactor = __max(simdt / 20.0, 0.02);
double tFactor = __min(mintFactor, simdt);

I'm not entirely sure why a limit is being placed on tfactor, but based on the variable names I think these two lines might be doing the wrong thing.

The name mintFactor seems to imply that it is a minimum possible value for tfactor. However, in the next line it takes the minimum of mintFactor and simdt. This means that if simdt is smaller than mintFactor, tFactor will be smaller than mintFactor.

As an extreme example, imagine if simdt = 0.00001. In that case, mintFactor will be 0.02, since 0.02 is larger than simdt/20. Then tFactor is set to 0.00001, since it is smaller than mintFactor.


Is this an error, or have I misunderstood the purpose of mintFactor?

Many thanks,
msligo
 

indy91

Addon Developer
Addon Developer
Joined
Oct 26, 2011
Messages
1,226
Reaction score
591
Points
128
The purpose of this is to limit the timestep length for certain spacecraft systems and instead run their timestep functions multiple times per step, if necessary. The scheme also limits the number of iterations this does per one timestep. Assuming a framerate of 60fps, the effect will be the following:

-Up to 1.2x time acceleration the timestep functions are called once per step.
-From 1.2x to 24x time acceleration the timestep functions are called multiple times per step, limited to a step length of 0.02 seconds.
-For 24x and more the number of iterations through this loop is limited to 20, so the step length will increase again. The purpose of this is to not cause a big impact on the frame rate at large time accelerations.

This system has been used in the CSM and LM system timesteps for a long time, but in the LM the numbers have recently been changed to have effect at a much smaller time acceleration already. It is our temporary fix for instabilities in the LM ECS, which really doesn't like time acceleration whatsoever.
 
Top