Altitude of spe

agentgonzo

Grounded since '09
Addon Developer
Joined
Feb 8, 2008
Messages
1,649
Reaction score
4
Points
38
Location
Hampshire, UK
Website
orbiter.quorg.org
Does anyone know of a way to get the altitude above a planet at which the atmospheric pressure will be a given value? oapiGetPlanetAtmParams will give you the pressure at a given altitude, which I could use to do trial-and-error to get, but presumably using ATMCONST that oapiGetPlanetAtmConstants returns will enable me to calculate this altitude directly?

Thanks for any help.


Edit: Not sure what happened with the title of the thread.
 

tblaxland

O-F Administrator
Administrator
Addon Developer
Webmaster
Joined
Jan 1, 2008
Messages
7,320
Reaction score
25
Points
113
Location
Sydney, Australia
ATMCONST is only suitable for use on simplified plant atmospheres whereas planets such as Earth, Mars and Venus have more complicated atmospheres coded into their dll's. When you call oapiGetPlanetAtmParams it generates a callback to the planet dll which returns the temp, pressure and density.

There is information in the Orbiter SDK API_Guide.pdf on atmospheres. This would allow you to calculate altitude as a function of pressure for what ever planet you are above. The problem with this approach is that your calculations would no longer be valid if the atmospheric model for a planet changes in its dll. The only way you would detect a change would be to put a sanity check in there to make sure your calculations match the result from oapiGetPlanetAtmParams, but it is not very elegant.
 

Ursus

Rocket Tinker
Addon Developer
Joined
Oct 20, 2007
Messages
176
Reaction score
2
Points
18
Location
46N 123W
A search algorithm, based on the binary search, perhaps? (Actually, that's probably what you meant by "trial-and-error".) Come to think of it, such an algorithm might take too long to be run at every time step... especially if you wanted to get really accurate.
 

tblaxland

O-F Administrator
Administrator
Addon Developer
Webmaster
Joined
Jan 1, 2008
Messages
7,320
Reaction score
25
Points
113
Location
Sydney, Australia
A search algorithm, based on the binary search, perhaps? (Actually, that's probably what you meant by "trial-and-error".) Come to think of it, such an algorithm might take too long to be run at every time step... especially if you wanted to get really accurate.
I can't see any reason to run it every time step, given that the atmosphere won't be changing.

@agentgonzo

1. Is the pressure you are interested in going to change in realtime? If not, you could actually do a binary search (using the approximate default exponential pressure decay as a seed) in InitModule and save the result for later use.

2. Is this related to the work you are doing on LaunchMFD? If so, wouldn't dynamic pressure be more of a concern?
 

agentgonzo

Grounded since '09
Addon Developer
Joined
Feb 8, 2008
Messages
1,649
Reaction score
4
Points
38
Location
Hampshire, UK
Website
orbiter.quorg.org
A binary search it is then (that was what I had in mind by trial-and-error). It won't change, so I can just run it in the class constructor (better than InitModule as better encapsulation).

It's related to the work on LaunchMFD and I was thinking about using it for the transition altitude between pitchover and PEG. I was using atmospheric pressure as it's constant. Dynamic pressure would be a better representation, but for the time being and initial development I was just going to use atmospheric pressure to get me going, and add in support for dynamic pressure when I got the simpler model working (iterative development). I'm trying to restrict the number of input variables in the system. Expect a question about dynamic pressure in a month or so!
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,623
Reaction score
2,341
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
You can use the exponential approximation for small steps. For example on Earth, you can calculate the pressure pretty well with exponential approximations in 5 km steps.
 
Top