Atmosphere module

As an example of F# usage for calculations and demonstration of module creation I decided to publish here my code for Standard Atmosphere (atmex 3.0). You can download code or library below.

(* using light syntax *)
#light
(* module name *)
module AtmosphereLib74
 
(* a structure for storing atmosphere parameters *)
(*
 *  Of course, I could use tuple float * float * float * float,
 *  but at http://blogs.msdn.com/jomo_fisher/archive/2008/09/16/f-performance-tweaking.aspx
 *  I read, what returning structures insted of tuples is more efficient
 *)
type AtmosphereParameters =
    struct
        val height : float
        val pressure : float
        val density : float
        val temperature : float
        val sonic : float
        new (h,p,d,t,s) = {height=h; pressure=p; density=d; temperature=t; sonic=s}
    end
 
let getAtmosphere h =
    (*
     calculations of pressure, density, temp, sonic
    *)
    (* and here I create and return a structure *)
    AtmosphereParameters(h,pressure,density,temp,sonic)

You can download this example as a code or as a compiled library.

To use any kind of libraries you should just add reference to it into your project and use it’s namespace.

Leave a comment

Your comment