Question Help with Lift Coefficient function

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,055
Reaction score
642
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
Dear friends of the Orbiter forum.

Once again I am determined to move forward and not give up despite the problems I encounter in the development of my add-ons. However, I encounter the same problem again in the development of my latest creation (KleinVision's AirCar). As well as in the development of the XB-70 Valkyrie.
So far my latest flying creation, the I.Ae 37 works like a miracle because I barely touched the values of the VLiftCoeff function. However, I realize that I implemented it wrong.

The problem is not knowing how to adapt/program/or create a function that calculates the vertical or horizontal lift.

That's why I make this thread to ask for help in the particular cases that I have to do these functions to see if they can help me by correcting code, or suggesting ideas. Everything and everyone is welcome.

I apologize in advance for my ignorance, since I do not have high education, but I will try my best to implement the ideas you give me.

Or maybe there is a more "universal" way to do those VLiftCoeff and HLiftCoeff functions.

Next are the questions...
 

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,055
Reaction score
642
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
Well this is my first question,
I have this data about the car-plane that I am programming.

C++:
const double AIRCAR_EMPTYMASS = 1100; //Empty mass in kg.


const double AIRCAR_FUELMASS = 100; //Fuel mass in kg.


const VECTOR3 AIRCAR_CS = {6.43, 19.44, 3.69};  //Aircar cross sections calculated with Shipedit.exe


const VECTOR3 AIRCAR_PMI = {2.33, 3.08, 1.53}; //Aircar Principal Moments of Inertia calculated with Shipedit.exe in m^2.


const double AIRCAR_VLIFT_C = 1.2; //Chord lenght in meters.


const double AIRCAR_VLIFT_S = 6.1407; //Wing area in m^2.


const double AIRCAR_VLIFT_A = 0.9696; //Wing aspect ratio.


Vertical Lift Coefficient function (from DeltaGlider) with some tweaks to make it use my variables.
C++:
// 1. vertical lift component (wings and body)
void VLiftCoeff (VESSEL *v, double aoa, double M, double Re, void *context, double *cl, double *cm, double *cd)
{
    const int nabsc = 9;
    static const double AOA[nabsc] = {-180*RAD,-60*RAD,-30*RAD, -2*RAD, 15*RAD,20*RAD,25*RAD,60*RAD,180*RAD};
    static const double CL[nabsc]  = {       0,      0,   -0.4,      0,    0.7,     1,   0.8,     0,      0};
    static const double CM[nabsc]  = {       0,      0,  0.014, 0.0039, -0.006,-0.008,-0.010,     0,      0};
    int i;
    for (i = 0; i < nabsc-1 && AOA[i+1] < aoa; i++);
    if (i < nabsc - 1) {
        double f = (aoa - AOA[i]) / (AOA[i + 1] - AOA[i]);
        *cl = CL[i] + (CL[i + 1] - CL[i]) * f;  // aoa-dependent lift coefficient
        *cm = CM[i] + (CM[i + 1] - CM[i]) * f;  // aoa-dependent moment coefficient
    }
    else {
        *cl = CL[nabsc - 1];
        *cm = CM[nabsc - 1];
    }
    double saoa = sin(aoa);
    double pd = 0.015 + 0.4*saoa*saoa;  // profile drag
    *cd = pd + oapiGetInducedDrag (*cl, AIRCAR_VLIFT_A, 0.7) + oapiGetWaveDrag (M, 0.75, 1.0, 1.1, 0.04);
    // profile drag + (lift-)induced drag + transonic/supersonic wave (compressibility) drag
}

C++:
//Main wings lift surfaces
    hwing = CreateAirfoil3(LIFT_VERTICAL, _V(0, 0, 0), VLiftCoeff, 0, AIRCAR_VLIFT_C, AIRCAR_VLIFT_S, AIRCAR_VLIFT_A);

    CreateAirfoil3(LIFT_HORIZONTAL, (Elevators_mobile_parts_Location), HLiftCoeff, 0, AIRCAR_HLIFT_C, AIRCAR_HLIFT_S, AIRCAR_HLIFT_A);


    //Control surfaces...

    hlaileron = CreateControlSurface3(AIRCTRL_AILERON, 0.0911, 0.2, Axis_aileron_left_Location, AIRCTRL_AXIS_XNEG,1, anim_raileron);

    hraileron = CreateControlSurface3(AIRCTRL_AILERON, 0.0911, 0.2, Axis_aileron_right_Location, AIRCTRL_AXIS_XPOS,1, anim_laileron);

    CreateControlSurface3(AIRCTRL_ELEVATOR, 0.8008, 0.2, Axis_elevator_Location, AIRCTRL_AXIS_XPOS, 1, anim_elevator);

    CreateControlSurface3(AIRCTRL_ELEVATORTRIM, 0.8008, 0.1, Axis_elevator_Location, AIRCTRL_AXIS_XPOS, 1, anim_elevator_trim);

    CreateControlSurface3(AIRCTRL_RUDDER, 0.0924, 0.2, Axis_rudder_left_Location, AIRCTRL_AXIS_YPOS,
    1, anim_left_rudder);

    CreateControlSurface3(AIRCTRL_RUDDER, 0.0924, 0.2, Axis_rudder_right_Location, AIRCTRL_AXIS_YPOS,
    1, anim_right_rudder);

My plane-car doesn't take off. What should I change?
 
Last edited:

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,358
Reaction score
3,292
Points
138
Location
Massachusetts
I don't know if your wings are meant to be rectangular, but assuming they are, the following numbers are suspect:

const double AIRCAR_VLIFT_C = 1.2; //Chord lenght in meters.
const double AIRCAR_VLIFT_S = 6.1407; //Wing area in m^2.
const double AIRCAR_VLIFT_A = 0.9696; //Wing aspect ratio.

If the wing area is 6.1407 m2 and the chord is 1.2 m, that implies that the span should be 6.1407 m2/1.2m = 5.11 m. That would make the aspect ratio ((5.11m)^2)/6.1407m2 = 4.26, not about 0.9696. An aspect ratio of 1 is a rather short and stubby wing.
 

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,055
Reaction score
642
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
I don't know if your wings are meant to be rectangular, but assuming they are, the following numbers are suspect:

const double AIRCAR_VLIFT_C = 1.2; //Chord lenght in meters.
const double AIRCAR_VLIFT_S = 6.1407; //Wing area in m^2.
const double AIRCAR_VLIFT_A = 0.9696; //Wing aspect ratio.

If the wing area is 6.1407 m2 and the chord is 1.2 m, that implies that the span should be 6.1407 m2/1.2m = 5.11 m. That would make the aspect ratio ((5.11m)^2)/6.1407m2 = 4.26, not about 0.9696. An aspect ratio of 1 is a rather short and stubby wing.

Thanks for pointing out that error. To calculate the Wing Aspect I used this calculator https://calculator.academy/wing-aspect-ratio-calculator/, but I must have made a mistake when converting meters to ft (which is what the calculator requires).

However, the AirCar does not take off. Later I will compile versions for Windows again so you can try it.
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,358
Reaction score
3,292
Points
138
Location
Massachusetts
I'd check that your elevator is working and applying a pitching force. If you can't increase the angle of attack, you may never get enough lift to get airborne.

You could also set the CL at 0 degrees angle of attack to something like 1.0 and see if the car lifts off then. With the vehicle mass it should lift off at about 55-60 m/s.
 

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,055
Reaction score
642
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
I'd check that your elevator is working and applying a pitching force. If you can't increase the angle of attack, you may never get enough lift to get airborne.

You could also set the CL at 0 degrees angle of attack to something like 1.0 and see if the car lifts off then. With the vehicle mass it should lift off at about 55-60 m/s.
Right now I'm on Windows with the Orbiter force viewer trying to see what forces act on takeoff. Indeed it seems that it is not able to provide enough lift and does not take off. In addition to that I am changing the values of the touchdown points to see if they are exerting drag.
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,358
Reaction score
3,292
Points
138
Location
Massachusetts
Right now I'm on Windows with the Orbiter force viewer trying to see what forces act on takeoff. Indeed it seems that it is not able to provide enough lift and does not take off. In addition to that I am changing the values of the touchdown points to see if they are exerting drag.
How fast can you get the vessel moving on the ground?
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,358
Reaction score
3,292
Points
138
Location
Massachusetts
Yes, but I think it's caused by the extreme lag I'm having on Windows 10. I guess it must be registering the pitch up key being pressed. I'm also going to try it on Orbiter Linux to see if it does the same.
Have you used SetRotDrag? That will dampen pitch, yaw, and roll rates.
 

francisdrake

Addon Developer
Addon Developer
Joined
Mar 23, 2008
Messages
1,075
Reaction score
890
Points
128
Website
francisdrakex.deviantart.com
Attached is a spreadsheet I use to visualize the lift-vs-drag function.

The curves for DeltaGlider and Atlantis are given for reference.
Their lift-vs-drag functions are only reliable for an angle of attack (AoA) of -45° to + 45°.

In the Lifting Body sheet the blue lift line is derived from literature.
Unfortunately this lift - in combination with a rather small wing area - is too small.
So I corrected (exaggerated) the lift (yellow line).

Also gave it a + bias: Even with 0° AoA it provides some lift.
This seems reasonable for a shape with a flat bottom and a curved upper side.
The touchdown speed for this configuration is ~140 m/s with an AoA of 20-30°.
This landing speed is still high, but at least the vessel does not plummet out of the sky.
For comparison, Atlantis lands at 100 - 110 m/s .
___
You can copy one of these sheets and insert the values you like.

To get your car flying I would do this:
  • Give the lift a + bias, to produce lift with 0° AoA.
  • Increase the wing area significantly, like 4x.
  • Add a trim:
SetTrimScale (0.2);
CreateControlSurface (AIRCTRL_ELEVATORTRIM, 3.0, 1.75, _V( 0, 0.2, -3), AIRCTRL_AXIS_XPOS);
Trim up before starting your takeoff run.

Lift-vs-Drag.jpg
 

Attachments

  • Lift vs drag.zip
    4.9 KB · Views: 3

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,055
Reaction score
642
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
Have you used SetRotDrag? That will dampen pitch, yaw, and roll rates.
I have not tried it, in my previous development (the I.Ae 37) it worked acceptably by smoothly changing the values of the control surfaces.


Attached is a spreadsheet I use to visualize the lift-vs-drag function.

The curves for DeltaGlider and Atlantis are given for reference.
Their lift-vs-drag functions are only reliable for an angle of attack (AoA) of -45° to + 45°.

In the Lifting Body sheet the blue lift line is derived from literature.
Unfortunately this lift - in combination with a rather small wing area - is too small.
So I corrected (exaggerated) the lift (yellow line).

Also gave it a + bias: Even with 0° AoA it provides some lift.
This seems reasonable for a shape with a flat bottom and a curved upper side.
The touchdown speed for this configuration is ~140 m/s with an AoA of 20-30°.
This landing speed is still high, but at least the vessel does not plummet out of the sky.
For comparison, Atlantis lands at 100 - 110 m/s .
___
You can copy one of these sheets and insert the values you like.

To get your car flying I would do this:
  • Give the lift a + bias, to produce lift with 0° AoA.
  • Increase the wing area significantly, like 4x.
  • Add a trim:
SetTrimScale (0.2);
CreateControlSurface (AIRCTRL_ELEVATORTRIM, 3.0, 1.75, _V( 0, 0.2, -3), AIRCTRL_AXIS_XPOS);
Trim up before starting your takeoff run.

View attachment 35631
Thank you very much @francisdrake!
I'm going to carefully study your spreadsheet and what you told me. I think that in your answer I have the key to make not only the AirCar fly, but also the Valkyrie.

The good news so far is that I have managed to get the AirCar off the ground but it still spins wildly on every pitch input. The next step will be to correctly implement the spreadsheet values.
 

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,055
Reaction score
642
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
Well, now the AirCar takes off and flies "normally", except that I have to make some corrections every 2 or 3 seconds with the trim to keep it stable. Anyway, it improved a lot by implementing the values from the spreadsheet that @francisdrake sent me.

But I am happy with the result and will continue looking for ways to make it more stable. That was the error that @Urwumpe had pointed out, the excess torque, am I correct?
For now I'm solving it somehow with SetRotDrag as @Thunder Chicken pointed out.

I am currently updating the GitHub repository (Linux and Windows). So the following changes will be reflected:

C++:
const double AIRCAR_MAXMAINTH = 10e3;
const VECTOR3 AIRCAR_RD = {5, 5, 5}; //Rotation drag coefficients.

const double AIRCAR_VLIFT_C = 4.8; //Chord lenght in meters.
//const double AIRCAR_VLIFT_C = 1.2; //Chord lenght in meters.

const double AIRCAR_VLIFT_S = 24.5628; //Wing area in m^2.
//const double AIRCAR_VLIFT_S = 6.1407; //Wing area in m^2.

const double AIRCAR_VLIFT_A = 1.211; //Wing aspect ratio.
//const double AIRCAR_VLIFT_A = 4.26; //Wing aspect ratio.

C++:
void AIRCAR::clbkSetClassCaps(FILEHANDLE cfg){

    THRUSTER_HANDLE th_main;

    //Physical vessel resources
    SetSize(AIRCAR_SIZE);
    SetEmptyMass(AIRCAR_EMPTYMASS);
    SetMaxWheelbrakeForce(2e5);
    SetCrossSections(AIRCAR_CS);
    SetPMI(AIRCAR_PMI);
    SetRotDrag(AIRCAR_RD);
    SetTouchdownPoints(tdvtx_wheels, wheels);

    //Propellant resources
    PROPELLANT_HANDLE GAS = CreatePropellantResource(AIRCAR_FUELMASS);

    //Main engine
    th_main = CreateThruster((Propeller_Location), _V(0, 0, 1), AIRCAR_MAXMAINTH, GAS, AIRCAR_ISP);
    CreateThrusterGroup(&th_main, 1, THGROUP_MAIN);


    //Main wings lift surfaces
    hwing = CreateAirfoil3(LIFT_VERTICAL, _V(0, 1.1359, 0), VLiftCoeff, 0, AIRCAR_VLIFT_C, AIRCAR_VLIFT_S, AIRCAR_VLIFT_A);

    CreateAirfoil3(LIFT_HORIZONTAL, (Elevators_mobile_parts_Location), HLiftCoeff, 0, AIRCAR_HLIFT_C, AIRCAR_HLIFT_S, AIRCAR_HLIFT_A);


    //Control surfaces...

    hlaileron = CreateControlSurface3(AIRCTRL_AILERON, 3.0, 0.75, Axis_aileron_left_Location, AIRCTRL_AXIS_XNEG,1, anim_raileron);

    hraileron = CreateControlSurface3(AIRCTRL_AILERON, 3.0, 0.75, Axis_aileron_right_Location, AIRCTRL_AXIS_XPOS,1, anim_laileron);

    CreateControlSurface3(AIRCTRL_ELEVATOR, 3.0, 0.75, _V( 0, 0.2, -3), AIRCTRL_AXIS_XPOS, 1, anim_elevator);

    //CreateControlSurface3(AIRCTRL_ELEVATORTRIM, 0.8008, 1, Axis_elevator_Location, AIRCTRL_AXIS_XPOS, 1, anim_elevator_trim);
    SetTrimScale (0.2);
    CreateControlSurface (AIRCTRL_ELEVATORTRIM, 3.0, 0.75, _V( 0, 0.2, -3), AIRCTRL_AXIS_XPOS, anim_elevator_trim);

    CreateControlSurface3(AIRCTRL_RUDDER, 3.0, 0.75, Axis_rudder_left_Location, AIRCTRL_AXIS_YPOS,
    1, anim_left_rudder);

    CreateControlSurface3(AIRCTRL_RUDDER, 3.0, 0.75, Axis_rudder_right_Location, AIRCTRL_AXIS_YPOS,
    1, anim_right_rudder);

    //Add mesh
    AddMesh("KleinVision_AirCar");
}
 

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,358
Reaction score
3,292
Points
138
Location
Massachusetts
Well, now the AirCar takes off and flies "normally", except that I have to make some corrections every 2 or 3 seconds with the trim to keep it stable. Anyway, it improved a lot by implementing the values from the spreadsheet that @francisdrake sent me.

But I am happy with the result and will continue looking for ways to make it more stable. That was the error that @Urwumpe had pointed out, the excess torque, am I correct?
For now I'm solving it somehow with SetRotDrag as @Thunder Chicken pointed out.

I am currently updating the GitHub repository (Linux and Windows). So the following changes will be reflected:

C++:
const double AIRCAR_MAXMAINTH = 10e3;
const VECTOR3 AIRCAR_RD = {5, 5, 5}; //Rotation drag coefficients.

const double AIRCAR_VLIFT_C = 4.8; //Chord lenght in meters.
//const double AIRCAR_VLIFT_C = 1.2; //Chord lenght in meters.

const double AIRCAR_VLIFT_S = 24.5628; //Wing area in m^2.
//const double AIRCAR_VLIFT_S = 6.1407; //Wing area in m^2.

const double AIRCAR_VLIFT_A = 1.211; //Wing aspect ratio.
//const double AIRCAR_VLIFT_A = 4.26; //Wing aspect ratio.

C++:
void AIRCAR::clbkSetClassCaps(FILEHANDLE cfg){

    THRUSTER_HANDLE th_main;

    //Physical vessel resources
    SetSize(AIRCAR_SIZE);
    SetEmptyMass(AIRCAR_EMPTYMASS);
    SetMaxWheelbrakeForce(2e5);
    SetCrossSections(AIRCAR_CS);
    SetPMI(AIRCAR_PMI);
    SetRotDrag(AIRCAR_RD);
    SetTouchdownPoints(tdvtx_wheels, wheels);

    //Propellant resources
    PROPELLANT_HANDLE GAS = CreatePropellantResource(AIRCAR_FUELMASS);

    //Main engine
    th_main = CreateThruster((Propeller_Location), _V(0, 0, 1), AIRCAR_MAXMAINTH, GAS, AIRCAR_ISP);
    CreateThrusterGroup(&th_main, 1, THGROUP_MAIN);


    //Main wings lift surfaces
    hwing = CreateAirfoil3(LIFT_VERTICAL, _V(0, 1.1359, 0), VLiftCoeff, 0, AIRCAR_VLIFT_C, AIRCAR_VLIFT_S, AIRCAR_VLIFT_A);

    CreateAirfoil3(LIFT_HORIZONTAL, (Elevators_mobile_parts_Location), HLiftCoeff, 0, AIRCAR_HLIFT_C, AIRCAR_HLIFT_S, AIRCAR_HLIFT_A);


    //Control surfaces...

    hlaileron = CreateControlSurface3(AIRCTRL_AILERON, 3.0, 0.75, Axis_aileron_left_Location, AIRCTRL_AXIS_XNEG,1, anim_raileron);

    hraileron = CreateControlSurface3(AIRCTRL_AILERON, 3.0, 0.75, Axis_aileron_right_Location, AIRCTRL_AXIS_XPOS,1, anim_laileron);

    CreateControlSurface3(AIRCTRL_ELEVATOR, 3.0, 0.75, _V( 0, 0.2, -3), AIRCTRL_AXIS_XPOS, 1, anim_elevator);

    //CreateControlSurface3(AIRCTRL_ELEVATORTRIM, 0.8008, 1, Axis_elevator_Location, AIRCTRL_AXIS_XPOS, 1, anim_elevator_trim);
    SetTrimScale (0.2);
    CreateControlSurface (AIRCTRL_ELEVATORTRIM, 3.0, 0.75, _V( 0, 0.2, -3), AIRCTRL_AXIS_XPOS, anim_elevator_trim);

    CreateControlSurface3(AIRCTRL_RUDDER, 3.0, 0.75, Axis_rudder_left_Location, AIRCTRL_AXIS_YPOS,
    1, anim_left_rudder);

    CreateControlSurface3(AIRCTRL_RUDDER, 3.0, 0.75, Axis_rudder_right_Location, AIRCTRL_AXIS_YPOS,
    1, anim_right_rudder);

    //Add mesh
    AddMesh("KleinVision_AirCar");
}
A bit of a cheat to help stability is to put the location of the airfoil above the center of mass, whether the wing is physically located there or not. Instead of _V(0, 1.1359, 0) you might consider something like _V(0, +2, 0). The mass of the vessel will "hang" below the wing and be pretty stable.
 
Last edited:

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,055
Reaction score
642
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
A bit of a cheat to help stability is to put the location of the airfoil above the center of mass, whether the wing is physically located there or not. Instead of _V(0, 1.1359, 0) you might consider something like _V(0, 0, +2). The mass of the vessel will "hang" below the wing and be pretty stable.
I will come back in a second...

------------EDIT-----------
Here is the video with the AirCar with the newly updated airfoil value.

I'm going to play with the Z position value of the airfoil to see what happens.
The error that is seen at the beginning of the simulation, that is, the car is floating and when I apply thrust it falls, has only happened to me in Linux and I have a way to fix it.
 
Last edited:

Thunder Chicken

Fine Threads since 2008
Donator
Joined
Mar 22, 2008
Messages
4,358
Reaction score
3,292
Points
138
Location
Massachusetts
The error that is seen at the beginning of the simulation, that is, the car is floating and when I apply thrust it falls, has only happened to me in Linux and I have a way to fix it.
At the start of the simulation the touchdown points aren't established. If you just touch the thrusters they will be established. Let the vessel come to rest, then update the scenario with its current position.

It appears that lift is no longer a problem, but stability still is. It looks like it really wants to fly backwards. Double check your elevator and rudder locations and ensure they are well behind the center of mass.

I'm going to play with the Z position value of the airfoil to see what happens.
I actually meant the Y position, not X. Your coordinates for your airfoil look OK, but it may improve stability if you increase the Y location some more.
 
Last edited:
Top