Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,584 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,973 people online right now. Registration is fast and FREE... Join Now!




Air density accuracy issues

 
Reply to this topicStart new topic

Air density accuracy issues

eLliDKraM
post 22 Nov, 2005 - 03:16 PM
Post #1


Pepè Le Pewn

Group Icon
Joined: 13 Aug, 2005
Posts: 6,565



Thanked 2 times

Dream Kudos: 225
My Contributions


I'm having a few issues thinking today. I'm trying to decide on the best (and simplest) way to approach this problem... I've been making a program that calculates the terminal velocity of a gigantic list of objects. One of the many variables of calculating the terminal velocity, however, is Air Density. Basically, as we all know air density changes due to temperature and pressure (mostly). So basically I'll worry about altitude... However, air density after just a few kilometers is almost cut in half meaning if I just used an "average" from whatever the user inputs as an altitude, convert that to kg/m^3 and take the average from that and sea level, I will have one hell of a % error. I'm wondering how I can have the user input just an altitude and have my program give some sort of output that's relatively accurate (under 5% error woiuld be great). Some sample densities I calculated would be roughly, at sea level, 1.2250 kg/m^3; 1 km, 1.1117 kg/m^3; and 2 km would be roughly 1.0066 kg/m^3. Let's say the user types in 2 kilometers, how might one go about getting a more accurate result than just using the average of sea level and 2 km?

This post has been edited by eLliDKraM: 22 Nov, 2005 - 07:35 PM
User is offlineProfile CardPM

Go to the top of the page


eLliDKraM
post 23 Nov, 2005 - 12:34 PM
Post #2


Pepè Le Pewn

Group Icon
Joined: 13 Aug, 2005
Posts: 6,565



Thanked 2 times

Dream Kudos: 225
My Contributions


If any parts of my problem need clarification, I'll be happy to do so.
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 23 Nov, 2005 - 12:50 PM
Post #3


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,158



Thanked 32 times

Dream Kudos: 25
My Contributions


You have a formula that you are using to calculate the pressure at various altitudes, correct? You can take the derivative of that formula (calculus) to give you the formula of the rate of change, and implement that. It should be fairly good approximation.

If you have caclulated the result yourself, however, why not implement the formula you are using into the program, and have it run everytime the user enters an altitude?
User is offlineProfile CardPM

Go to the top of the page

eLliDKraM
post 23 Nov, 2005 - 03:41 PM
Post #4


Pepè Le Pewn

Group Icon
Joined: 13 Aug, 2005
Posts: 6,565



Thanked 2 times

Dream Kudos: 225
My Contributions


Considering the formula when changing altitudes would be very horrible and extremely unfriendly to users, I have a book that tells me very precise air densities at certain altitudes. I was just going to use the book as reference like type in a bunch of constants or something and give them the air density values and do something or other and then I fall asleep. If I used the formula itself, I would have to ask the user for certain pressures and temperatures etc. That just wouldn't be fun, but if I could just prompt the user, "What height are you dropping the object from?" then bam, it eases the entire process.
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 23 Nov, 2005 - 03:47 PM
Post #5


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,158



Thanked 32 times

Dream Kudos: 25
My Contributions


Hmmm....in that case you can take one of two courses of action.

1. Calculate the density at a larger number of altitudes, and try and narrow the focus.

2. Calculate enough of the densities at varying altitudes to be able to figure a bit of a sliding scale (a la derivative from my first suggestion), and apply that percentage to the calculations you perform in the program.
User is offlineProfile CardPM

Go to the top of the page

eLliDKraM
post 23 Nov, 2005 - 04:10 PM
Post #6


Pepè Le Pewn

Group Icon
Joined: 13 Aug, 2005
Posts: 6,565



Thanked 2 times

Dream Kudos: 225
My Contributions


I'm sorry, I guess I don't understand #1^^
User is offlineProfile CardPM

Go to the top of the page

eLliDKraM
post 23 Nov, 2005 - 05:08 PM
Post #7


Pepè Le Pewn

Group Icon
Joined: 13 Aug, 2005
Posts: 6,565



Thanked 2 times

Dream Kudos: 225
My Contributions


Since I blow at understanding new concepts, how about I give you a theoretical (likely) situation:

user inputs 5 km

i might have a list of constants defined.

5 km = 0.7364 (units in kg/m^3)
4 km = 0.8194
3 km = 0.9092
2 km = 1.0066
1 km = 1.1117
0 km (sea level) = 1.2250

So let's say I have all the constants listed up until, let's say the top of the troposphere, so integers up to 10km would be defined and this guy entered 5, what might you do to semi-accurately get the terminal velocity out of that (pretending that this is our only variable, we'll have other variables but I can control them; this variable is being a little bugger though).
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/20/08 03:34AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month