Board index FlightGear Development Aircraft Flight dynamics model

Diamond DA42 IV new JSBSim model

Good sims require good FDMs (the "thing" that makes an aircraft behave like an aircraft).

Diamond DA42 IV new JSBSim model

Postby iamzac » Sun Dec 07, 2014 3:11 pm

Because the current Diamond DA42 model is based on the older first version of the plane I wanted to update it to the new IV version which is much faster and has better range.
I am new to FlightGear and this is the first time I try to make a model so the model is not very good but if you are interested you can download it here: https://www.dropbox.com/s/30qz9f7d6fnpah2/Diamond-Da42-IV.zip?dl=0

Why JSBSim?

I first tried updating the existing YASim model, I read the manual, Buckaroo's guide and posts on this forum and tried hundreds of configurations for about 2 weeks but I couldn't get it to perform correctly both at low and high altitude.
Every time I was optimizing the values for a particular altitude the values for other became completely wrong, or the lift and drag became ridiculous, or the fuel consumption was too high, or some weird bugs happened sometimes like suddenly accelerating at the speed of light when I tried some idrag and efficiency hacks to force it work, or some weird rpm changes, etc.
I tried both realistic values, and ridiculous values just to force it to work but no success.
So I tried using JSBSim.

The steps I took for making the model

1) First I used Aeromatic to build a model, using the most accurate data I could find.
I didn't know the wing incidence and the Htail arm or the Vtail arm, the rest of the data I had.
The aerodynamic model seems to be ok, but I can't know how good it is because I have no way of knowing how the real plane actually handles.
Probably it has a bit more drag and a bit less lift than the actual plane because Diamond DA42 IV seems to be very optimized to have very little drag and good lift compared to the average plane.
I also tried using JSBSimCommander but it didn't seem to be very helpful for what I needed as a beginner for a basic model, and Datcom+ seems to be too much since I can't judge anyway how good the aerodynamic model is, and Datcom+ doesn't seem to be able to help me with the engine and propeller problems I had.

2) I moved the center of mass in front of the center of lift, added the masses of the pilot, passengers and baggage, moved the engines and the propellers slightly in front of the center of mass, increased the capacity of the fuel tanks to about 76.4 gallons (the standard value is 50 gal but it has a long range tank option for 76.4 and I used this version for maximum range), and I changed the fuel type from AVGAS to Jet-A1.

3) I modified the engine and the propeller specifications to make them as close as possible to the real ones.

4) I updated the instruments and some various other systems to use the new JSBSim model like the maximum speed display for the new model, and many other small changes.
Until this step my new model was inside the same directory as the existing model but after reaching this step I had to move it to a new independent folder because there where too many files needing changes.

5) I begun tweaking the values inside the engine and the propeller files to optimize the speed, RPM and fuel consumption by making hundreds of repeated tests at altitudes of 2.000 ft and the cruise altitude of 16.000 ft and throttle 100%.

Problems

Since I usually fly all planes at 100% throttle I only optimized the speed values for when the throttle is at 100% so reducing the throttle causes extreme and unrealistic drops in speeds and RPM at high altitude.
My tweaking focused mainly on modifying C_THRUST and C_POWER tables so they are probably unrealistic because they compensate for other inaccuracies in the model which would have been to complicated (for me) to fix.
The problems that appear when decreasing throttle at high altitude are probably because unrealistic values for this variables, especially probably C_POWER is too high.

Another problem is that it should have auto-mixture but I tried implementing using a modified version of the nasal code from https://gitorious.org/da20-a1-katana/mainline/source/2fe77d8652b9463d941d9b4e07799cc443a587d5:Nasal/fuel.nas but it didn't work, I had some nil errors with some variables and I didn't continue debugging to find out what the error is because I was not sure anyway if this is the proper method and formula for making the optimum auto mixture.
So I set the mixture manually by using the "M/m" key and looking at the rpm value.
It is not displayed anywhere, you can find it only in the debug menu.
If someone knows how to make the auto-mixture work please tell me.
And if the method from the url above is accurate tell me so I can continue trying to find out what the error is and make it work.


Other small problems that where not caused by the new model and where inherited from the original Diamond DA42 model and I don't know how to fix are that you must use the mouse to change throttle and PgUp and PgDown don't work, also the shadow is not visible.
Another problem I don't know how to fix but doesn't seem to be important is that flaps move instantly.

I am not sure if the propeller diameter is 190 cm or 183 cm for this newer model, but since aeromatic prefers 183 as the maximum size for 3 blades I chose 183 cm.

Another small problems are that some displayed values like engine load, CHT, oil pressure, and voltage even though are taken from correct sources are not actually displayed exactly.
For example engine load displayed as let's say 55% is connected to the real engine load but is not actually 55%, because I don't know how to calculate the exact load without knowing what the actual maximum load of the simulated engine is, so I put this so that in flight it looks reasonable (with maximum throttle and brakes on is above 100% but after that it stays below 100%).
Also, just because let's say CHT is in the green area it doesn't mean it is ok, I just adjusted it to stay inside the displayed bar graph. And since JSBsim doesn't know about diesel engines probably that value is wrong anyway.
The displayed RPM used to be the engine RPM but now because the engine and the propeller RPM are different I changed it to display the propeller RPM because it seems more useful.

A few results

At altitude 2.000 ft the speed should be 165 kt at throttle 92% and 8.1 GPH.

My model has these values at 2.000 ft and mixture 1:

178.5 kt (too high) at 100% throttle and 7.6 GPH (too little) and 1896 propeller rpm (it should be probably 2300 rpm)
178 kt (too high) at 92% throttle and 7.5 GPH (too little) at 1891 propeller rpm (too low)
116.5 kt (too low) at 75% throttle and 3.0 GPH (to low) and 1451rpm (to low)

At the cruise altitude of 16.000 ft the speed should be 193 kt at 92% throttle and 176 kt at 75% throttle and the fuel consumption should be 10.4 GPH (I assume per engine) for 60% throttle.

My model has these values at 16.000 ft and mixture 0.626:

194 kt (very good, because this was my main target for optimizing the model) at throttle 100% and 2504 propeller rpm (I don't what value this should be. Maybe 2300? in that case it's too much) and 11.9 GPH per engine (probably ok)
161.5kt (too low) at throttle 92% 2156 RPM and 7.7 GPH
at throttle 0.75 it can't even maintain the 16.000 altitude

The maximum operating altitude is 18.000 ft, I don't know how it should perform at that altitude but I got at 100% throttle 187 kt at 2500 rpm and 11.1 GPH with a mixture of 0.5765.

I don't know what should happen above 18.000 ft but at 25.000 ft and 100% throttle I got 159 kt at 2464 rpm 8.7 GPH and mixture 0.4335.

This is how it should perform:
Image

You can find the main basic specifications inside some pdf files located here: http://www.diamond-air.at/twin-engine-aircraft/da42-vi.html (the main one is http://www.diamond-air.at/content/downloads/DA42-VI/DA42-VI_Factsheet_062014.pdf)
Further data I found in the flight manual (http://www.diamondaircraft.com/library/16/15/D42L-AFM-002%20%28Rev.%207%29.pdf) and the maintenance manual (http://support.diamond-air.at/fileadmin/uploads/files/after_sales_support/DA42_New_Generation/Airplane_Maintenance_Manual/Basic_Manual/70215-DA42-NG-AMM-r2.pdf) of older versions of the plane, I didn't found enough data for the current IV version so some of it I just guessed.
I also used data from http://austroengine.at/uploads/pdf/mod_products1/AE300_Technical_Data_Sheet.pdf and http://www.mt-propeller.com/pdf/datsheet/mtv-6.pdf and http://easa.europa.eu/system/files/dfu/EASA-TCDS-E.200_Austro_Engine_GmbH_E4_series_engines-06-24092013.pdf and http://www.advantageaustria.org/vn/events/Diamond.pdf, wikipedia pages for the plane (http://en.wikipedia.org/wiki/Diamond_DA42) and engine (http://en.wikipedia.org/wiki/Austro_Engine_E4), and other sources.

A few conclusions

Since the engines used by Diamond airplanes are unique being diesel engines and using jet fuel instead of avgas probably they can't be modeled perfectly in either JSBSim or YASim because they are made for tradional avgas engines that work differently by using the otto cycle and not the diesel cycle.
I don't know if my failure with YASim was mainly because this is a new kind of plane and needs the more detailed modeling of JSBSim or if YASim is in general not very good.

The documentation available for YASm is great for beginners, especially the Buckaroo's guide was very helpful, but the documentation available for JSBSim is very bad for beginners and probably assumes that the modeler already knows a lot about how engines work (which I don't) and has a very good knowledge of aerodynamics.

I have a request for experienced JSBSim modelers: please make some good documentation for beginners, explaining what every variable means: what it represents in real life (for example the variable X represents how large the X component is), what are some examples of real life planes for which that value is big, some examples where that value is low, what would happen if we increase or decrease that value when the plane is at low altitude, or high altitude, low speed, high subsonic speed, supersonic speed and how it affects the other variables like the fuel consumption, rpm, temperature, etc... with some examples.
Some data from the wiki might be wrong, for example it says:
"<volumetric-efficiency> controls how much air goes through the engine at a given RPM. Values below 1 for unboosted engines and values over 1 for boosted engines"
but in the case of Seneca II which is considered to have a very good model and is boosted the value is 0.6 so something must be wrong somewhere...

Future work

I don't know if I will continue working at improving the model.
I won't make any changes to the 3d model because I am not good at either 3d modeling or 2d drawing.

I think that the simplest things that if improved could make a big difference in looks if someone would change them would be: some "shine" for the outside surface, some texture for the inside floor and maybe the inside walls too, and a real map displayed where the map should be.

You are free to use it anyway you want, since it's a modification of GPL code it obviously remains GPL.
At the moment I am tired of repeating hundreds of trial and error tests to understand how each small variation of a variable affects everything else.
The documentation I have found so far is just not enough.
The biggest problem is the huge drop of power when reducing the throttle, I already tried fixing that but it ruins everything else I have done so far so since I am flying at 100% throttle anyway for the moment I stopped trying to fix it.
Another problem is that performance at low altitudes is too good but I focused my efforts for the cruise altitude because that's where most time will be spent.
I don't know how to further reduce the maximum speed at low altitude without reducing the speed at high altitude.
I think the key might be in tweaking the engine, especially the turbo part but I don't yet fully understand how the engine and especially the turbo works and I don't know how to change it so I only reduce the speed at low altitude and not at high altitude.
I also don't know how a real life engine should behave since I am not a pilot so it's hard for me to judge how it behaves.

Maybe someone more experienced can continue fixing the model.

Or if I get some answers at what I posted here maybe I will make some improvements.

My native language is not English so sorry if this message was not clear.
Last edited by iamzac on Fri Feb 13, 2015 1:44 pm, edited 4 times in total.
iamzac
 
Posts: 96
Joined: Fri Nov 07, 2014 8:52 am
OS: Windows / Kubuntu

Re: Diamond DA42 IV new JSBSim model

Postby daveculp » Sun Dec 07, 2014 5:38 pm

I've also noticed the huge drop in thrust when reducing throttle, but I've not looked into it deeply, in large part because I have little experience with prop driven airplanes. Does your airplane have a constant speed prop? I suppose we could test with a fixed pitch prop to see if the large thrust loss comes from the prop control. If that's not it then it could be an artifact of the lookup tables, or from the engine itself.

As for the auto mixture control, I use a simple system (too simple, most likely) to do this, and Ron Jensen has one also. I'm on a smartphone so can't post it here, but you could grab one of my prop planes from Dave's Hangar and find it in the Systems directory.

BTW, your English gets an A+ grade.
User avatar
daveculp
 
Posts: 505
Joined: Sun Feb 24, 2013 2:50 am
Location: Las Vegas, USA
Callsign: DCulp
Version: 2017.3.1
OS: Ubuntu 17.10

Re: Diamond DA42 IV new JSBSim model

Postby iamzac » Sun Dec 07, 2014 9:09 pm

Thank you for your auto-mixture solution!
It was much simpler than I imagined, and I also updated the version from the original download link.
Since I was no longer busy watching the RPM while climbing and playing with the mixture I noticed that the climb rate was way to high so I reduced it.
It's still a bit to high but further reducing it might unbalance everything and at least today I don't have time for more.
And now that I know about the systems tag I can do more interesting things in the future.

Yes, it has a constant speed prop.
And only after writing the above line and reading the wikipedia article I found out what that is so thank you again.
This means that all the RPM values are wrong and the model is much worse than I thought.
Like I said I am new to this.
I will see when I will have time what changes I need to make to implement this.
iamzac
 
Posts: 96
Joined: Fri Nov 07, 2014 8:52 am
OS: Windows / Kubuntu

Re: Diamond DA42 IV new JSBSim model

Postby Buckaroo » Sun Dec 07, 2014 9:45 pm

Howdy iamzac,

I think JSBsim is the best choice given all the information you have. YASim can give good results, but not for everything, and generally not where precision is required. And if using YASim for a propeller aircraft, I recommend discarding most of the YASim engine and fuel values. The only YASim values I use are RPM, torque, and a re-aligned mixture setting. I derive everything else from Nasal algorithms and tabular data.

For my own curiosity, I'd be interested to see your YASim FDM if you're willing to share it. I might be able to offer some thoughts or learn something.

-Buck
Callsign: Buckaro(o)
Author: Lockheed 1049H Constellation, Grumman Goose, MD-81, Edgley Optica, Velocity XL RG, YASim Guide
User avatar
Buckaroo
 
Posts: 475
Joined: Fri Jan 18, 2008 7:45 am
Location: Bloomington IN USA
Callsign: Buckaro(o)
Version: 2.10
OS: Windows & Linux

Re: Diamond DA42 IV new JSBSim model

Postby iamzac » Sun Dec 07, 2014 9:55 pm

Unfortunately I deleted it.
Unfortunately because when I made it I assumed that auto-mixture is the default behavior and you have to intentionally program mixture and only after starting work at the JSBSim model I found out I was wrong.
So my previous YASim model was probably better than I thought, I just didn't thought to try decreasing the mixture...

And now I found out about this constant speed propeller which again changes everything and makes all my work optimizing the propeller in JSBSim useless.... oh well.
I thought constant speed propeller is the opposite of variable pitch propeller and not a subset :)

Thank you for your great YASim guide, it was very useful!
iamzac
 
Posts: 96
Joined: Fri Nov 07, 2014 8:52 am
OS: Windows / Kubuntu

Re: Diamond DA42 IV new JSBSim model

Postby Buckaroo » Sun Dec 07, 2014 11:53 pm

Thanks, I appreciate the feedback on the guide. And if you learned good stuff working with JSBsim propeller optimizing, then maybe your work wasn't worthless? Most everything I've learned in Flightgear has been through my many many mistakes. ;)

I got curious about the original YASim DA42 FDM. Without spending much time on it, I found the original has a lot of settings that wouldn't be my first choice for this type of aircraft:

full fuel load at cruise
no wing incidence
no aerodynamic wing twist
a very high wing stall aoa and very narrow stall width
a symmetrical airfoil
an inverted ventral vertical stabilizer vstab
an attempt to set stabilizer incidence (YASim will ignore this)
a horizontal stabilizer that likely stalls before the wing
inverted engine gear ratio (gearing the propeller UP instead of down?!)
incorrect engine/prop RPMs (according to the type cert)

Probably you changed most or all of that for your model. Maybe somebody will work on the original FDM.

-Buck
Callsign: Buckaro(o)
Author: Lockheed 1049H Constellation, Grumman Goose, MD-81, Edgley Optica, Velocity XL RG, YASim Guide
User avatar
Buckaroo
 
Posts: 475
Joined: Fri Jan 18, 2008 7:45 am
Location: Bloomington IN USA
Callsign: Buckaro(o)
Version: 2.10
OS: Windows & Linux

Re: Diamond DA42 IV new JSBSim model

Postby hvengel » Mon Dec 08, 2014 1:13 am

For auto mixture you can try something like this:

Code: Select all
        <switch name="mixture/position">
            <default value= "10000" />  <!-- cut off -->
            <test logic="AND" value="atmosphere/delta">  <!-- emergency full rich -->
                fcs/mixture-cmd-norm  GE 0.90
                /engines/engine/running GT 0.90
                systems/engine/primed LE 0.10
            </test>
            <test logic="AND" value="1.0"> <!-- idle cut off and starting with the primer-->
                fcs/throttle-cmd-norm  GE 0.14
                fcs/throttle-cmd-norm  LE 0.18
                fcs/mixture-cmd-norm   LE 0.1
                systems/engine/primed  GE 0.90
            </test>
            <test logic="AND" value="1.0">    <!-- normal run -->
                fcs/mixture-cmd-norm  LT 0.90
                fcs/mixture-cmd-norm  GT 0.1
               <!-- /engines/engine/running GT 0.90
                systems/engine/primed LE 0.10 -->
            </test>
        </switch>

      <fcs_function name="mixture">
          <function>
            <product>
                <quotient>  <!-- invert mixture/position -->
                    <value> 1.0 </value>
                    <property> mixture/position </property>
                </quotient>
                <property> atmosphere/delta </property>
            </product>
          </function>
          <output>fcs/mixture-pos-norm</output>   
        </fcs_function>


The above is the auto mixture code from the P-51D. This will set the correct mixture from sea level to the aircraft's service ceiling (> 41,000ft). The pressure carburetor (IE. throttle body fuel injection unit) used on the Packard engine had a mixture control with three positions:

Emergency full rich - force sea level mixture in case of a failure.
Run - normal operating setting with automatic mixture.
Idle cut of - for shutting down the engine and for starting the engine using the primer.

The problem with YASim giving bad results with "optimizing the values for a particular altitude the values for other became completely wrong" is one I know all too well. This is an issue for aircraft with a wide performance envelope and is a very good reason for using JSBSim at least for some aircraft. In my case it was because YASim does not know anything about how to do transonic related stuff. So at high altitudes my aircraft normally operated at transonic speeds (IE. at 25,000ft normal cruise was at around Mach 0.64) and YASim did not do the correct things with respect to Mach drag. Getting Mach drag correct in JSBSim is a simple function of about 4 lines.

For you throttle vs. speed issue it sounds to me like you propeller curves are wrong (IE. too much thrust at full power) and that you have too much drag. There is a drag section in the JSBSim config file. One way to do some gross tuning is to modify your main drag function so that you can scale the drag (by multiplying the drag by a constant). By changing this constant you can get the over all drag in the right ball park. You can do the same thing with the main lift function if you think that the lift being generated is not OK.

Also keep in mind that Aeromatic, at best, generates what amounts to a starting template. So you will need to make lots of changes to get the results you want. JSBSim is not simple to use and requires a very good understanding of aerodynamics to get good results.

Also for aircraft with a wide envelope I found the propeller generated by Aeromatic to not be very good. It gave way too much thrust at low speeds/altitudes and not enough at high speeds/altitudes. I ended up using JavaProp for my propeller. There is more than one thread here where I and others describe how to use JavaProp and how we built propeller tables that were a better fit to our aircraft. So do a search on JavaProp.
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Re: Diamond DA42 IV new JSBSim model

Postby Bomber » Mon Dec 08, 2014 2:03 pm

Best to look in the FDM forum......
"If anyone ever tells you anything about an aeroplane which is so bloody complicated you can't understand it, take it from me - it's all balls" - R J Mitchel
Bomber
 
Posts: 1933
Joined: Fri Dec 14, 2007 8:06 pm
OS: Windows XP and 10

Re: Diamond DA42 IV new JSBSim model

Postby iamzac » Tue Dec 09, 2014 10:45 am

I made some small updates to the model: now the idle rpm is correct at least when on the ground, and some very very small improvements to the speed drop when reducing throttle at high altitude.

I could not find out how to make page up and page down control the throttle.

I looked at JavaProp and also tried some constant speed props from other models but no success, making this model work with a constant speed prop would basically mean changing everything so I will probably leave it like it is now.
My method of fixing other problems in the model by manually adjusting the values in the C_Thrust and C_Power tables by trial and error would just not work with a constant speed propeller because there are to many situations so the model would have to be very very good everywhere.

While playing with other propellers I saw that the large power drop when reducing throttle it's still there so I am assuming that either (most likely) my engine configuration is wrong or maybe JSBSim has problems because this is a very new and different type of engine (diesel) which is kind of small and with huge compression and other differences compared to the other engines.
Also the way I implemented the booster is probably wrong, but like I said before I didn't properly understood the documentation and I also don't know too much about how piston engines and turbo work.

So I learned a bit about how modelling works in flightgear but I guess that you need more knowledge to build a proper JSBSim model and a little bit of luck with YASim .

I was thinking of trying again to make the YASim model now that I know about the mixture mistake I made but this model seems fine to me right now, at least the cruise speed is ok, and when it's a little bit faster than it should at other altitudes that can be fixed by slightly reducing the throttle...
And for the throttle problem, I look at the fuel consumption and consider that to be the throttle indicator, if the fuel consumption drops to 60% for example when reducing the throttle I consider that the throttle is at 60% even if it probably is somewhere above 90%.

@Buckaroo: there are more things that are wrong in that model, one very obvious mistake is the dry mass. But it does manage to fly so... :)

Update: Now Page Up / Page Down work and also other key bindings that can be found in the help menu.
Last edited by iamzac on Wed Dec 10, 2014 4:56 pm, edited 1 time in total.
iamzac
 
Posts: 96
Joined: Fri Nov 07, 2014 8:52 am
OS: Windows / Kubuntu

Re: Diamond DA42 IV new JSBSim model

Postby Bomber » Tue Dec 09, 2014 7:32 pm

I have a request for experienced JSBSim modelers: please make some good documentation for beginners, explaining what every variable means: what it represents in real life (for example the variable X represents how large the X component is), what are some examples of real life planes for which that value is big, some examples where that value is low, what would happen if we increase or decrease that value when the plane is at low altitude, or high altitude, low speed, high subsonic speed, supersonic speed and how it affects the other variables like the fuel consumption, rpm, temperature, etc... with some examples.
Some data from the wiki might be wrong, for example it says:
"<volumetric-efficiency> controls how much air goes through the engine at a given RPM. Values below 1 for unboosted engines and values over 1 for boosted engines"
but in the case of Seneca II which is considered to have a very good model and is boosted the value is 0.6 so something must be wrong somewhere...


The jsbsim piston engine needs work on it, work is slower than needs to be but that's how the cookie crumbles.

To my mind only when experienced jsbsim modellers come together with a will to resolve the issues will FG see any improvements.

But heck there are others that will disagree.
"If anyone ever tells you anything about an aeroplane which is so bloody complicated you can't understand it, take it from me - it's all balls" - R J Mitchel
Bomber
 
Posts: 1933
Joined: Fri Dec 14, 2007 8:06 pm
OS: Windows XP and 10

Re: Diamond DA42 IV new JSBSim model

Postby Bomber » Tue Dec 09, 2014 9:47 pm

Have you considered contacting the engine manufacturer for the power to alt curve. And the prop manufacturer for its CT and CP graphs?
"If anyone ever tells you anything about an aeroplane which is so bloody complicated you can't understand it, take it from me - it's all balls" - R J Mitchel
Bomber
 
Posts: 1933
Joined: Fri Dec 14, 2007 8:06 pm
OS: Windows XP and 10

Re: Diamond DA42 IV new JSBSim model

Postby bfrogg » Wed Sep 02, 2015 12:47 pm

I'm trying to takeoff on DA-42 but engines don't start. Engines slowly rotates when I use key.

I use flightgear 2.0.0 and DA-42 ver. 0.95.
bfrogg
 
Posts: 1
Joined: Wed Sep 02, 2015 12:40 pm


Return to Flight dynamics model

Who is online

Users browsing this forum: No registered users and 2 guests