Menu

#2658 Nan flood can be triggered by YASim configuration element

2020.3
New
nobody
None
Medium
2021-09-16
2021-09-12
No

If the 'lift' attribute of a flap element in YASim configuration file is set to 1 then a divide y zero will be triggered in src/FDM/YASim /Surface.cpp at #356 in Surface::controlDrag

float Surface::controlDrag(float lift, float drag)
{
    // Negative flap deflections don't affect drag until their lift
    // multiplier exceeds the "camber" (cz0) of the surface.  Use a
    // synthesized "fp" number instead of the actual flap position.
    float fp = _flapPos;
    if(fp < 0) {
        fp = -fp;
        fp -= _cz0/(_flapLift-1);
        if(fp < 0) fp = 0;
    }

In the attached configuration file for the Lancair-235 the VStab's flap0 ( the rudder ) lift is set to 1.
When the rudder control input, joystick, moves positive a NaN flood results.
Changing the lift to non 1.0 makes the problem go away. Patching the code to remove the 1 subracted makes the problem go away.
The default setting for any flap lift is 1.0

3 Attachments

Discussion

  • Huntley Palmer

    Huntley Palmer - 2021-09-12
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +1,3 @@
    +Surface.cpp (11.9 kB; text/x-c++src)
    +diff-Surface.cpp (675 Bytes; text/x-c++src)
     lancair235-yasim-bad.xml (10.0 kB; text/xml)
    
     
  • James Turner

    James Turner - 2021-09-12

    This would be good to fix, but how do we decide which way to change it? Especially, I wonder where the '-1' term comes from?

     
  • Huntley Palmer

    Huntley Palmer - 2021-09-12

    lift factor defaults to 1 and is 1 normalised, 1G. In other parts of this section it is converted to a 'gain' factor so has the 1 subtracted but here, for cambered flap, subtracting in the divisor makes an arbitrarily big mask of negative incidence drag by configuring a lift number close enough to 1.0

    I think the intent here is to mask the drag from a cambered flap's negative incidence. This would be for wing flap extension or -ve joystick left rudder: for a cambered flap the 'position' is delayed by a degree equal to the camber, Cz degree. lessened by the flap's overall lift effect. Cz / ( flapLift ) maybe works here ?

     
  • James Turner

    James Turner - 2021-09-15

    What's the magnitude of flapLift, typically? (Apologies for the dumb questions, I don't know this code). I'm trying to work out if, in practice, the magnitude of flapLift is large enough that the -1 is irrelevant. But if it's typicaly < 2.0, then we will change from dividing by a value smaller than 1.0 to one larger than 1.0, and that will have a large corresponding impact on 'fp'.

     
  • Huntley Palmer

    Huntley Palmer - 2021-09-15

    Quoting Buckaroo, 1.3 to 1.4 is reasonable. It's not the flap lift's magnitude, but closeness to 1.0 since the difference us used as a divisor.

     
  • James Turner

    James Turner - 2021-09-16

    Could we check if flapLift is approximately 1.0 and if so, skip the divide-by-flapList-minus-1 entriely? Since a value close to 1.0 means no change, right?

    But, eg taking the value as 1.3, we're currently dividing by 0.3, which is effectively multiplying by 3.33 .. so values close to 1.0 (eg 1.1) would cause a factor of 10x or more increase. This all feels a bit weird to me.

     
  • Huntley Palmer

    Huntley Palmer - 2021-09-16

    I agree, I can't see the code as written being correct, you don't want to divide by lift-1 :

    Having the Cz divided simply by lift makes intuitive sense in that we are looking to mask any drag for a small negative extension of cambered flap.

    The bad news is, the 777 configuration includes a vstab, labelled apu, with all-zero dimensions, including lift=0

    I'd think, test for divided by zero but divide by flapLift, not flaplift - one . Add a condition that camber must be non-zero as well as incidence is negative. It will shorten the code and look after the 777
    `
    float Surface::controlDrag(float lift, float drag)
    {
    // Negative flap deflections don't affect drag until their lift
    // multiplier exceeds the "camber" (cz0) of the surface. Use a
    // synthesized "fp" number instead of the actual flap position.
    // for rudder symmetry ensure Vstab flap0 camber is set to zero
    float fp = _flapPos;
    if ( (fp < 0) && !( _cz == 0)) {
    fp = -fp;
    // fp -= _cz0/(_flapLift - 1);
    fp -= _cz0/(_flapLift);
    if(fp < 0) fp = 0;
    }

    `

     
  • Huntley Palmer

    Huntley Palmer - 2021-09-16

    I should correct the above to include non-zero test for flapLift itself; the 777 example shows the lift can get wrongly configured as zero.

    float Surface::controlDrag(float lift, float drag)
    {
        // Negative flap deflections don't affect drag until their lift
        // multiplier exceeds the "camber" (cz0) of the surface.  Use a
        // synthesized "fp" number instead of the actual flap position.
        //     for rudder symmetry ensure Vstab flap0 camber is set to zero
        float fp = _flapPos;
        if ( (fp < 0) && !( _cz == 0) && !(_flapLift == 0)) {
            fp = -fp;
            // fp -= _cz0/(_flapLift - 1);
            fp -= _cz0/(_flapLift);
            if(fp < 0) fp = 0;
        }
    
     

Log in to post a comment.

MongoDB Logo MongoDB