PDA

View Full Version : Controlling the Wind in X-Plane-Part 1,II,and III



txnetcop
March 18th, 2015, 18:01
Controlling the Wind in X-Plane
By Chuck Bodeen

Just suppose you are sitting at the end of runway 09 at KCYS (http://www.cheyenneairport.com/), Cheyenne Wyoming Regional, and you want to simulate a takeoff into head wind.

http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-18293300-1425663775_thumb.jpg (http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-18293300-1425663775.jpg)

While I want to keep this article on topic, my memories of Cheyenne [my birthplace] have taken over. Before World War II, my father was a Douglas DC-3 (http://en.wikipedia.org/wiki/Douglas_DC-3) mechanical inspector for United Air Lines and worked in a hangar at <A>. We lived in a house at <B> which was (at the beginning of the War) bought by the government, moved into town, and replaced by a couple of large hangars where, "The tail gun position [on B-17s] underwent one major revision, based on a design proposed by workers at the United Air Lines Cheyenne Modification Center — hence, the Cheyenne Turret (http://en.wikipedia.org/wiki/Tail_gunner#mediaviewer/File:B17_tail_turret.jpg). "
In the summer, as a young man, I had a job renting seat cushions at <C> for the annual Frontier Days Rodeo (http://www.cfdrodeo.com/rodeo-main/) . Runway13-31 <D> did not exist and 9700 foot 09-27 was only about half that long…which was plenty for the DC-3s which needed only about 6000 feet <E> for takeoff on a hot day at 6160 feet MSL.
I well remember the day the first DC-4 (http://en.wikipedia.org/wiki/Douglas_DC-4) came in. That eventually put an end to the need for the DC-3 facility at Cheyenne as well as my Dad’s job.

Using X-Plane as it is

The heading of runway 09 is 85 degrees magnetic; 95 degrees true. Let’s say the wind is coming from 90 degrees – with a slight crosswind component.

http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-58009100-1425663824_thumb.jpg (http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-58009100-1425663824.jpg)

On the X-Plane “environment/weather page you will find the input area on the left. I used this to create the wind speed profile on the right. The solid red lines are interpolations between the input data points. The dotted lines are constant wind speed extensions. The blue represent what the actual profile might have been.
The rules are that the lowest-altitude must be at least 1000 feet. The other two must be separated by at least 1000 feet. This is explained rather briefly here (http://wiki.x-plane.com/Chapter_4:_Flight#Wind_Layers).
I’m going to concentrate this discussion to wind speed because wind shear or “gradient (http://en.wikipedia.org/wiki/Wind_gradient)” is necessary for “Dynamic Soaring (http://en.wikipedia.org/wiki/Dynamic_soaring)”…and that’s what brought me to the current subject. I have kept the direction constant because the majority of technical papers on DS and wind shear do that.

Dynamic Soaring is used by the albatross to fly for as far as 1500 km at a time without flapping a wing and by radio controlled glider pilots to reach speeds over 500 mph. An article on that subject will be coming…eventually.

Besides wind speed, X-Plane can set gust increase, shear direction, and turbulence.

Gusts:
On the X-Plane.org forum, “Bret S” (http://forums.x-plane.org/index.php?showtopic=67872) explains that this feature “adds random wind gusts up to the value you set…and in the direction of the wind that you set.”

“Morten” posted a comment on gusts and shear direction variation:
It starts with this video (http://www.xplanefreeware.net/morten/DIV/wind.mov) of a panel flying through gusty air and says:
“As you can see, XP pretty much does what it should and stays within the peaks.
That’s not the problem. The problem is the RATE/FREQUENCY it does this it!
It can go between peaks multiple times per second! If this was the real world I doubt there would be many sailboats or light aircraft around...”

Shear directionAustin Meyer says this, “ Interpolate between the shear should probably be labeled as “variation”, since I actually change in direction over TIME, NOT SPACE. So you enter the direction and speed variation at each altitude, and x-plane interpolates in between them.The wind changes slowly and smoothly over at least 1,000 feet… far too little shear to use.The shear is the variation in direction… it changes on a frequency of about 1 or 2 seconds or so.. It is a random change, so could not be used to drive an airplane, I think”

Turbulence
Still on the Forums, Andy Goldstein (http://home.earthlink.net/~x-plane/FAQ-Author.html) says “The turbulence calibration has been a sore point for years. Best as I can make out, the turbulence scale goes from 0 to 10, and each unit represents 10 kt variation in wind speed. Also, the turbulence is continuous chop, vs the intermittent bumps you normally get in real life. Put together, a little goes a long way.
And Chris Serio (http://developer.x-plane.com/author/cjserio/) adds: “I received many bug reports about turbulence this week. Austin responded by making some tweaks which will be in the future 10.04Beta2. When it's released it should be a step in the right direction though I haven't had a chance to try it myself.”
For the applications in which I am interested the first thing I had to accomplish was to eliminate the 1000 foot spacing restriction. The datarefs used to set the three altitudes and set direction and speed are writable:
sim/weather/wind_altitude_msl_m[0] float y meters = 0 The center altitude of this layer of wind in MSL meters.
sim/weather/wind_altitude_msl_m[1] float y meters = 0 The center altitude of this layer of wind in MSL meters.
sim/weather/wind_altitude_msl_m[2] float y meters = 0 The center altitude of this layer of wind in MSL meters.
sim/weather/wind_direction_degt[0] float y [0 - 360) The direction the wind is blowing from in degrees from true north clockwise.
sim/weather/wind_direction_degt[1] float y [0 - 360) The direction the wind is blowing from in degrees from true north clockwise.
sim/weather/wind_direction_degt[2] float y [0 - 360) The direction the wind is blowing from in degrees from true north clockwise.
sim/weather/wind_speed_kt[0] float y kts = 0 The wind speed in knots.
sim/weather/wind_speed_kt[1] float y kts = 0 The wind speed in knots.
sim/weather/wind_speed_kt[2] float y kts = 0 The wind speed in knots.



http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-17627100-1425663944_thumb.jpg (http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-17627100-1425663944.jpg)

With the use of a plugin, the wind profile parameters can be released from the 1,000 foot spacing rule. Using altitudes, direction, and speeds fairly complex wind profiles can be produced. Of course, this means that we’ll need a C++ plugin or a Python script, but once we make that move there is a world of possibilities.


http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-60014300-1425663952_thumb.jpg (http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-60014300-1425663952.jpg)

This diagram shows what you can do by varying both the speed and direction of the wind. Notice that the 1000 foot rule need not be enforced.

Continued tomorrow...

txnetcop
March 19th, 2015, 14:24
What else can we do?

http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-99623700-1425663964_thumb.jpg (http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-99623700-1425663964.jpg)

Different technical papers represent the wind speed profile with altitude by various methods. One depends upon the logarithm of the altitude. Another depends upon that and its ratio to the log of a reference point. The most simple representation in of the form Uexp = Uref (Z/ Z ref)Pwhere U is the wind speed, Z is the altitude and P is a suitable constant. The subscript ref refers to a known point on the curve. The graph above shows that any of these will probably be acceptable because the researchers (and we simmers) don’t know the real profile anyway.

Out of the box, the three wind layers are MSL. Using a plugin, they could be made to use the current ground elevation as the base instead of sea level. This could be dynamic – changing as the plane flies over the deserts and mountains.

But here is a remaining problem. No matter what we do with a plugin, X-Plane is going to keep using linear interpolation between our three altitudes. The results of the interpolation are stored within the program and we are not allowed to change them by using datarefs.

http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-92035300-1425663991_thumb.jpg (http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-92035300-1425663991.jpg)

Since we can write to the wind-altitudes, we can set altitude (1) to the current altitude of the plane and altitudes (0) and (2) just a little below and above. Then, evaluate anydesired wind profile at the three points and let X-Plane perform linear interpolation.

Here is an outline of how to use the exponential wind profile in X-Plane. It is assumed that the directions of the wind are all the same and have already been set. You can translate it into C++ or Python.

Get elev
Alt(1) = elev
Alt(2) = elev + 20
Alt(0) = elev – 20
For J = 0,2
Speed( J ) = speed_ref * [ Alt( J )/Alt_ref] ^ power
Continue…..

The Leeside Problem
http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-12137300-1425679060_thumb.jpg (http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-12137300-1425679060.jpg)
11
Radio controlled glider pilots use the leeside of a hill for their exciting flights. It is not exactly clear how the wind behaves in that situation. Close to the ground, there may be flow in the opposite direction from the main part of the wind. The albatross has a similar situation when it dips down between waves.

http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-00817200-1425679078_thumb.jpg (http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-00817200-1425679078.jpg)
12
About 22 miles south of KLAS, Las Vegas, is the small town of Jean and OL7 airport where there is a lot of conventional glider activity on the north side of some hills. Jean “Lake” dry most of the year. When I was taking flying lessons in a Cessna 172 from Henderson Executive airport, KHND, I would practice stalls over the lake so that if we fell to earth we would hurt no one me and my instructor. I also had three hours of rather exciting glider instruction there.

Part III Tomorrow

txnetcop
March 20th, 2015, 19:16
About 22 miles south of KLAS, Las Vegas, is the small town of Jean and OL7 airport where there is a lot of conventional glider activity on the north side of some hills. Jean “Lake” dry most of the year. When I was taking flying lessons in a Cessna 172 from Henderson Executive airport, KHND, I would practice stalls over the lake so that if we fell to earth we would hurt no one me and my instructor. I also had three hours of rather exciting glider instruction there.

http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-37512600-1425664027_thumb.jpg (http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-37512600-1425664027.jpg)

Since the lake is very flat and the hills are rather extreme, this is a good place to see how X-Plane will treat the winds. The vertical part of the wind is automatically set by X-Plane by referencing the underlying topography.
Austin Meyer says, “We move the wind up the slopes of the mountains, and down on the other side! Without mountains, there is still vertical speed… but it is random, and goes up as much as down” I have written all of my X-Plane modifying code in Python which is more forgiving
than C++. So now I have a crude autopilot which does two things:
t need to guide
it over those hills;
one foot).
Here are a few lines from my Python script which create the autopilot: These two lines keep the plane flying in the same direction: XPLMSetDataf(self.DR_vx, -153.) # west component XPLMSetDataf(self.DR_vz, 129.) # south component These lines establish the AGL limits: self.AGL_mean = 50 # set desired AGL level self.AGL_low = self.AGL_mean - 1.0 self.AGL_high = self.AGL_mean + 1.0 self.AGL_change = .5 Then, in the flight loop…

self.AGL = XPLMGetDataf(self.DR_agl) * 3.280839 # convert meters to feet if (self.AGL < self.AGL_low): XPLMSetDataf(self.DR_Y, self.Y + self.AGL_change) if (self.AGL > self.AGL_high): XPLMSetDataf(self.DR_Y, self.Y - self.AGL_change) http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-89220700-1425679095_thumb.jpg (http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-89220700-1425679095.jpg)
Here are the results of a two similar flights over the hill just north of Jean. The top graph is for a horizontal wind speed of 25 knots and the bottom is for 50 knots. The black lines are ground elevation and the blue lines are vertical wind speed produced automatically by X-Plane. The horizontal scale is time in seconds.
The red areas are vertical flow in the DOWNWARD direction. The vertical flow speed is affected by both the shape of the hill and the speed of the prevailing horizontal wind – which does not change unless we program it to do so. Exactly how Austin Meyer set up X-Plane to behave this way is still a mystery, but it will certainly have an effect on modeling the flight of radio controlled gliders.
When we simulate an albatross doing dynamic soaring over the ocean there will be no significant vertical wind speed because X-Plane winds do not interact with waves. In fact, I tried flying south from KEYW (Key West, Florida) and the vertical speed over the flat sea was more or less steady at -0.115 m/s.

http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-13537900-1425674964_thumb.jpg (http://forums.x-plane.org/uploads/monthly_03_2015/post-1379-0-13537900-1425674964.jpg)

Here are the results of a short flight at Jean Lake using the “real weather” option in X-Plane. The vertical wind speed is still affected by the elevation of the terrain but also retains some random variation which seems to be generated by X-Plane.

If you are a stickler for extreme detail, the plugin could make the wind profile a function of time…but I’ll leave you to figure that out.

Wind shear calculators
These use the metric system.
Log law only (http://wind-data.ch/tools/profile.php?lng=en)
Power and log laws 1 (http://es.ucsc.edu/~jnoble/wind/extrap/)
Power and log laws 2 (http://www.saecanet.com/calculation_page/000403_000532_wind_shear_law.php)

References
Log_wind_profile (http://en.wikipedia.org/wiki/Log_wind_profile)
Wind_profile_power_law (http://en.wikipedia.org/wiki/Wind_profile_power_law)


Concluding remarks:
Please excuse the poor formatting in places in this article. Somehow, my desktop computer "forgot" how to control a few things here at XP.ORG.
If you want to try your hand at Python, just Google "Sandy Barbour Python" and download his wonderful interface system.




Edited by chuck bodeen, 06 March 2015 - 04:43 PM.