# AtmosphericModels

## Installation

Download Julia 1.9 or later, if you haven't already. You can add AtmosphericModels from Julia's package manager, by typing

using Pkg
pkg"add AtmosphericModels"

at the Julia prompt.

## Exported types

AtmosphericModel
@enum ProfileLaw EXP=1 LOG=2 EXPLOG=3 FAST_EXP=4 FAST_LOG=5 FAST_EXPLOG=6

## Exported functions

clear(s::AM)
calc_rho(s::AM, height)
calc_wind_factor(am::AM, height, profile_law::Int64=am.set.profile_law)

## Wind profile

The EXPLOG profile law is the fitted linear combination of the exponentional and the log law.

## Usage

using AtmosphericModels
am = AtmosphericModel()
const profile_law = Int(EXPLOG)
height = 100.0
wf = calc_wind_factor(am, height, profile_law)

The result is the factor with which the ground wind speed needs to be multiplied to get the wind speed at the given height.

## Plot a wind profile

using AtmosphericModels, Plots
am = AtmosphericModel()
heights = 6:1000
wf = [calc_wind_factor(am, height, Int(EXPLOG)) for height in heights]
plot(heights, wf, legend=false, xlabel="height [m]", ylabel="wind factor")

## Benchmark

using AtmosphericModels, BenchmarkTools
am = AtmosphericModel()
@benchmark calc_wind_factor(am, height, Int(EXPLOG)) setup=(height=Float64((6.0+rand()*500.0)))

Profile law | time [ns] |
---|---|

EXP | 12 |

LOG | 16 |

EXPLOG | 33 |

FAST_EXP | 6.6 |

FAST_LOG | 6.6 |

FAST_EXPLOG | 6.6 |

The FAST versions are an approximations with an error of less than $1.5 \cdot 10^{-5}$ and are correct only for the default values of h_ref, z0 and alpha.

## Air density

using AtmosphericModels, BenchmarkTools
am = AtmosphericModel()
@benchmark calc_rho(am, height) setup=(height=Float64((6.0+rand()*500.0)))

This gives 4.85 ns as result. Plot the air density:

heights = 6:1000
rhos = [calc_rho(am, height) for height in heights]
plot(heights, rhos, legend=false, xlabel="height [m]", ylabel="air density [kg/m³]")

## Running the test scripts

First, add TestEnv to your global environment.

julia
using Pkg
Pkg.add("TestEnv")
exit()

Then you can run Julia using this project and run the tests:

julia --project
using TestEnv
TestEnv.activate()
include("test/bench.jl")
include("calc_approximations.jl")
include("runtests.jl")

## Further reading

These models are described in detail in Dynamic Model of a Pumping Kite Power System.

## See also

- Research Fechner
- The application KiteViewer
- the package KiteUtils
- the packages KiteModels and WinchModels and KitePodModels
- the packages KiteControllers and KiteViewers