So... I've spent to much time trying to figure out a code that breaks the landing gear once a certain amount of Newtons/second is achieved. However im not sure if the last part does what I want it to do; this post also doubles as tutorial/archive.
So... what happens when someone lowers the landing gear beyond the maximum speed? It breaks yeah, however, we need to consider the speed (more speed = faster break time) and how much the landing gear was down (A fully lowered LandingGear does not experience the same force as a half-lowered).
How does it work? Say a Landing Gear has a maximum speed (in other terms the maximum force allowed), after that point it breaks after certain time due to fatigue.
So, how do we calculate that maximum force and that time?
Well, first we need to know how much force the landing gear experiences, if we assume is equivalent to the drag force then:
Drag = 1/2 * rho * v^2 * A * Cd
LGDragForce = 0.5*TotalDensity*pow(IAS,2)*ProjectedArea*CD
We need to find the density (rho); the velocity is the IAS; The area perpendicular to the airflow, if we assume our landing gear as a rectangle then we must find the projected area; finally we need the drag coefficient.
From the internet one can find graphs relating the aspect ratio of flat plates vs the measured drag coefficient, assuming that they follow a linear behaviour we could model them as a simple line equation y = mx + b
where m is the slope or (y2-y1)/(x2 - x1)
(where y represents the drag coefficient and x the angle of the flat plate) and b is the Drag coefficient at 0°. Thus:
CD = mx + b = 1/150 * PlateAngle + 0.9
(For this particular case, meaning at 90° the plate has a Cd = 1.5 and at 0° it is 0.9).
To calculate the PlateAngle we need to know the current position of the landing gear, assuming it follows a 90° path from 0° we can derive:
LandingGear up outputs 1, LandingGear down outputs 0, therefore -LandingGear + 1
outputs 0 and 1 when up and down respectively.
We now need to smooth the change to occur at a similar time of landingGear Deployment, and if 1 is 90° and 0 is 0° then:
smooth(LandinGear is down, speed) * 90° = smooth(-LandingGear + 1,.8)*90 = PlateAngle
The area is easy to calculate ProjectedArea = L*W*sin(PlateAngle)
The density (rho) can be found with the international standard atmosphere, however we also need to consider the latitude as temperature changes as we approach Avalanch airport or it increases at the Pyramids. From internet we get that density is:
TotalDensity = TotalPressure*1000/((TotalTemperature + 273)*(287.05))
Where:
TotalPressure = Altitude <=11000 ? 101.325*pow( (TotalTemperature+273)/288.8 , 5.256): ((101.325*pow( (TotalTemperature+273)/288.8 , 5.256))*exp(1.73 - 0.000157*Altitude)
(again from internet)
Where:
TotalTemperature = Altitude<=11000 ? TemperatureLatitude + ((Altitude/1000)*-6.5) : ( Altitude<=20000? TemperatureLatitude - 71.5 : ( Altitude<=32000 ? TemperatureLatitude - 71.5 + ((Altitude-20000)/1000) : (0) ) )
(More internet)
And:
TemperatureLatitude = ((Latitude >= -10000)&(Latitude<=64000) ? 27 - (Latitude/10000)*.5 : ( (Latitude>64000)&(Latitude<=100000) ? (68.6 - (Latitude/10000)*7 ) : (Latitude>=100000 ? 3.6 - (Latitude/10000)*.5 : ( (Latitude<-10000)&(Latitude>=-30000) ? 22.5 - (Latitude/10000)*5 : (36 - (Latitude/10000)*.5) ) ) )
This is the fun part, we can set how much temperature changes as a function of how north or south you are on the map, I've made it so that if you are on an island the temperature changes are small, while traveling from island to island has a bigger temperature gradient depending on how far apart they are.
Nice, we have Drag Force!... now what?
Well, we choose our maximum Landing Gear speed, in my case I've chosen 85 m/s roughly 190 mph.
Plug your initial conditions onto the formula, consider that the data should be that of the maximum operating condition, meaning fully deployed landing gear and at sea level:
Drag = 1/2 * rho * v^2 * A * Cd = 1/2 * 1.225 * 85^2 * 1 * 1.5 = 7766
With the drag now choose after how much time experiencing those 7766 Newtons does my landing Gear break? I've chosen 10 seconds, with all of the previous data we can finally set our Detacher group as:
clamp01(smooth( LGDragForce>=7766 , 1/((7766*10)/LGDragForce)))>=1
Breaking Down the code:
clamp01(smooth(Is the landing Gear experiencing the maximum design force? , 1/((7766 * Landing Gear break time at 7766 Newtons)/Current Drag Force experienced by the landing gear)))>=1
And... thats it, However as I said before I dunno if this last part is right, any tips and corrections are welcomed :3
You do not need to account for altitude if you're using IAS. IAS is instrumental airspeed, for SP IAS equal to
speed*exp(Altitude/-7640)
iirc.Last piece of code corrected a bit:
floor(smooth(max(0,Is LG experiencing the maximum design force?),
(Current Drag Force experienced by LG)/(impulse to break LG)))
(separated by linefeed because comment field doesn't let see it if it's on single line)
You need to clamp first part of smooth (since it's boolean) so it won't go below zero and won't ruin your timing. And then, since smooth won't go below 0,
floor(something)
will do same thing asclamp01(something)>=1
@11qazxc I knew it was off, TVM!