DESCRIPTION stdatm.vbs is a demo wrapper of atmospheric ambient condition calculations in VBScript. It displays temperature, density, and pressure ratios at altitudes matching some chosen from pages E-31 and E32 of CAtxtAppE7.pdf, the 1997.01.21 dated PDF of Appendix E in "Applied Computational Aerodynamics. The atmosphere and formatdata functions, and the typeAmbient class, are the actual point of the script, and can easily be reused. This allows easy calculation and manipulation of atmospheric data, targeted at people who are interested in aerospace technologies. Making a simple call to the atmosphere function with an altitude returns a structured object containing the atmospheric conditions, which can then be retrieved by name. MOTIVATION Using scripting, particularly on Windows, may seem like a very bizarre choice if your primary focus is performance. That is rarely the case with certain critical elements of numeric models, though. What distinguishes many of the interesting fundamental problems is the fact that they cannot be reduced analytically, but a handful of computations will give a reasonable approximation of an answer. From that perspective, scripting becomes interesting: a 10-significant figures accuracy calculation of data for an altitude might take a human who doesn't make mistakes 20 minutes. The same calculation might be done in 650 microseconds on a P3-600 in VBScript, and 50 microseconds in a compiled, optimized Fortran executable. When looking at this from the standpoint of interactive work, the possible order of magnitude difference between the binary and the script versions of solution is insignificant: it would take close to a thousand data point calculations to cause a barely perceptible difference in speed. This is of course precisely the niche that applications such as MatLab fill. Windows scripting for this is of some interest as well, though. It is available freely on PCs running Windows. It usually requires no extra installation work. It can easily be used within WSH, a browser, or any other active host. It allows "low level" algorithm coding, which can then be ported in full or in part to a compiled version. Interestingly, it can also be faster than traditional compiled applications that have light duty cycles during debugging and design. There is no need for an explicit cycle of recompilation and execution at each step. KEY ELEMENTS atmosphere [function] This is a straightforward port of W.H. Mason's FORTRAN77 STDATM subroutine to VBScript. All calculations are in metric units. Given an altitude in meters, atmosphere will calculate key parameters - air temperature, air density, air pressure, speed of sound, STP-relative temp/pressure/density, Reynolds number, and viscosity - and return a typeAmbient object (see below) which acts as a package for the data. typeAmbient [class] This is a very simple class consisting only of properties for the altitude: density, dynamicPressure, mach, pressure, ratioDensity, ratioPressure, ratioTemperature, reynoldsPerMachLength, temperature, viscosity They can be set and retrieved by name, and a class instance passed as their container. formatdata [function] Although VBScript includes some functions for output data formatting, it provides nothing for doing this based on a desired displayed precision. The formatdata function takes a numeric value and a desired number of digits of precision, and returns a number formatted for this. ENVIRONMENT As is, the demo script runs on any version of Windows with WSH installed, using the VBScript engine. The structures can of course also be used within Internet Explorer, MSHTA, or the Windows Script Control. Code can be ported to VB 5/6/.NET with minimal effort, focused around making the "typeAmbient" class into a real data structure. The following would work: (VB5/6 model) Type Ambient density As Double dynamicPressure As Double mach As Double pressure As Double ratioDensity As Double ratioPressure As Double ratioTemperature As Double reynoldsPerMachLength As Double temperature As Double viscosity As Double End Type BUGS None known, but has not had robust testing. Note that implicit type coercion can cause problems under some circumstances. AUTHOR VBScript adaptation by Alex Angelopoulos (aka@mvps.org). Based on the atmospheric model implementation by W.H. Mason Of Virginia Tech. COPYRIGHT Made available under the terms of the GNU Lesser GPL.