Merge pull request #491 from JoePfeiffer/fix-exception
Clamp pitch and yaw damping moments to avoid numerical instability
This commit is contained in:
commit
b41af82c90
@ -718,16 +718,20 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
|||||||
// Calculate pitch and yaw damping moments
|
// Calculate pitch and yaw damping moments
|
||||||
double mul = getDampingMultiplier(configuration, conditions,
|
double mul = getDampingMultiplier(configuration, conditions,
|
||||||
conditions.getPitchCenter().x);
|
conditions.getPitchCenter().x);
|
||||||
double pitch = conditions.getPitchRate();
|
double pitchRate = conditions.getPitchRate();
|
||||||
double yaw = conditions.getYawRate();
|
double yawRate = conditions.getYawRate();
|
||||||
double vel = conditions.getVelocity();
|
double velocity = conditions.getVelocity();
|
||||||
|
|
||||||
vel = MathUtil.max(vel, 1);
|
|
||||||
|
|
||||||
mul *= 3; // TODO: Higher damping yields much more realistic apogee turn
|
mul *= 3; // TODO: Higher damping yields much more realistic apogee turn
|
||||||
|
|
||||||
total.setPitchDampingMoment(mul * MathUtil.sign(pitch) * pow2(pitch / vel));
|
// find magnitude of damping moments, and clamp so they can't
|
||||||
total.setYawDampingMoment(mul * MathUtil.sign(yaw) * pow2(yaw / vel));
|
// exceed magnitude of pitch and yaw moments
|
||||||
|
double pitchDampingMomentMagnitude = MathUtil.min(mul * pow2(pitchRate / velocity), total.getCm());
|
||||||
|
double yawDampingMomentMagnitude = MathUtil.min(mul * pow2(yawRate / velocity), total.getCyaw());
|
||||||
|
|
||||||
|
// multiply by sign of pitch and yaw rates
|
||||||
|
total.setPitchDampingMoment(MathUtil.sign(pitchRate) * pitchDampingMomentMagnitude);
|
||||||
|
total.setYawDampingMoment(MathUtil.sign(yawRate) * yawDampingMomentMagnitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: MEDIUM: Are the rotation etc. being added correctly? sin/cos theta?
|
// TODO: MEDIUM: Are the rotation etc. being added correctly? sin/cos theta?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user