Skip to content

Commit f60f32c

Browse files
authored
Docu (#16)
* Update docu * Some progress * Some updates * Improve docu * Improve docstrings * Document clear * More docu * Update docu * API complete * Add docu * Update CHANGELOG.md * Update docu * Update CI.yml * Remove KiteUtils * Next try * Add file to .gitignore * Add Project.toml * Enable push_preview * Update settings.yaml * Add settings.md * Update docu * Update API --------- Co-authored-by: Uwe Fechner <u.fechner-1@tudelft.nl>
1 parent 312786f commit f60f32c

File tree

15 files changed

+410
-10
lines changed

15 files changed

+410
-10
lines changed

.github/workflows/CI.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,23 @@ jobs:
5454
- uses: codecov/codecov-action@v5
5555
with:
5656
files: lcov.info
57+
docs:
58+
name: Documentation
59+
runs-on: ubuntu-latest
60+
timeout-minutes: 40
61+
steps:
62+
- uses: actions/checkout@v4
63+
- uses: julia-actions/setup-julia@v2
64+
- uses: julia-actions/cache@v2
65+
- uses: julia-actions/julia-buildpkg@v1
66+
- uses: julia-actions/julia-docdeploy@v1
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
70+
- run: |
71+
julia --project=docs -e '
72+
using Documenter: DocMeta, doctest
73+
using AtmosphericModels
74+
DocMeta.setdocmeta!(AtmosphericModels, :DocTestSetup, :(using AtmosphericModels); recursive=true)
75+
doctest(AtmosphericModels)'
76+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ data/windfield_4050_500_1.0_8.2.npz
66
examples/Manifest.toml
77
examples/Manifest-v1.10.toml
88
examples/Manifest-v1.11.toml
9+
docs/build
10+
docs/Manifest.toml

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
- BREAKING: When constructing an atmospheric model, you MUST pass the parameter set::Settings. This ensures that all parts of the simulation use the same settings struct, and that you can run different simulations with different settings in parallel.
55

66
## Added
7-
- The function `get_wind(am, x, y, z, t)` which returns a wind vector for the given position and time. It creates a 3D wind field if it does not exist in the data folder. The parameters of this wind field are configured in `settings.yaml`.
7+
- The function `get_wind(am, x, y, z, t)` which returns a wind vector for the given position and time. It creates a 3D wind field if it does not exist in the data folder. The parameters of this wind field are configured in `settings.yaml`.
8+
- Documenter generated documentation.

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1616

1717
[compat]
1818
ControlPlots = "0.2.7"
19+
Documenter = "1.13.0"
1920
FFTW = "1.9.0"
2021
HypergeometricFunctions = "0.3"
2122
KiteUtils = "0.6, 0.7, 0.8, 0.9, 0.10"
@@ -30,8 +31,9 @@ julia = "1.10, 1.11"
3031
[extras]
3132
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3233
ControlPlots = "23c2ee80-7a9e-4350-b264-8e670f12517c"
34+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3335
Remez = "2e7db186-766a-50e7-8928-5c30181fb135"
3436
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3537

3638
[targets]
37-
test = ["Test", "BenchmarkTools", "Remez", "ControlPlots"]
39+
test = ["Test", "BenchmarkTools", "Remez", "ControlPlots", "Documenter"]

data/settings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ winch:
108108

109109
environment:
110110
v_wind: 5.324 # wind speed at reference height [m/s]
111-
v_wind_ref: [5.324, 0.0] # wind speed vector at reference height [m/s]
111+
upwind_dir: -90.0 # upwind direction [deg]
112112
temp_ref: 15.0 # temperature at reference height [°C]
113113
height_gnd: 0.0 # height of groundstation above see level [m]
114114
h_ref: 6.0 # reference height for the wind speed [m]

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
AtmosphericModels = "c59cac55-771d-4f45-b14d-1c681463a295"
3+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

docs/make.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using AtmosphericModels
2+
using Pkg
3+
if ("TestEnv" keys(Pkg.project().dependencies))
4+
if ! ("Documenter" keys(Pkg.project().dependencies))
5+
using TestEnv; TestEnv.activate()
6+
end
7+
end
8+
using Documenter
9+
10+
DocMeta.setdocmeta!(AtmosphericModels, :DocTestSetup, :(using AtmosphericModels); recursive=true)
11+
12+
makedocs(;
13+
modules=[AtmosphericModels],
14+
authors="Uwe Fechner <uwe.fechner.msc@gmail.com> and contributors",
15+
repo="https://github.com/OpenSourceAWE/KiteUtils.jl/blob/{commit}{path}#{line}",
16+
sitename="AtmosphericModels.jl",
17+
checkdocs=:none,
18+
format=Documenter.HTML(;
19+
repolink = "https://github.com/OpenSourceAWE/AtmosphericModels.jl",
20+
prettyurls=get(ENV, "CI", "false") == "true",
21+
canonical="https://OpenSourceAWE.github.io/AtmosphericModels.jl",
22+
assets=String[],
23+
),
24+
pages=[
25+
"Home" => "index.md",
26+
"API" => "api.md",
27+
"Settings" => "settings.md",
28+
],
29+
)
30+
31+
deploydocs(;
32+
repo="github.com/OpenSourceAWE/AtmosphericModels.jl",
33+
devbranch="main",
34+
push_preview=true,
35+
)

docs/src/api.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
```@meta
2+
CurrentModule = AtmosphericModels
3+
```
4+
5+
## Introduction
6+
Most functions need an instance of the struct `AtmosphericModel` as first parameter,
7+
which can be created using the following code:
8+
```julia
9+
using AtmosphericModels, KiteUtils
10+
11+
set_data_path("data")
12+
set = load_settings("system.yaml")
13+
am::AtmosphericModel = AtmosphericModel(set)
14+
```
15+
This requires that the files `system.yaml` and `settings.yaml` exist in the folder `data`. See also [Settings](@ref).
16+
17+
## Types
18+
19+
### Exported types
20+
```@docs
21+
ProfileLaw
22+
AtmosphericModel
23+
AtmosphericModel(set::Settings; nowindfield::Bool=false)
24+
```
25+
### Private types
26+
```@docs
27+
WindField
28+
```
29+
30+
## Functions
31+
32+
### Wind shear and air density calculation
33+
```@docs
34+
clear
35+
calc_rho
36+
calc_wind_factor
37+
```
38+
### Wind turbulence calculation
39+
```@docs
40+
get_wind
41+
rel_turbo
42+
new_windfield
43+
new_windfields
44+
```

docs/src/index.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
```@meta
2+
CurrentModule = AtmosphericModels
3+
```
4+
# AtmosphericModels
5+
This package provides functions for modelling the influence of the atmosphere on wind energy systems. It models the air density, the vertical wind profile and the wind turbulence. Further functions to import measured data are planned.
6+
7+
## Installation
8+
Install [Julia 1.10](http://www.julialang.org) or later, if you haven't already. You can add AtmosphericModels from Julia's package manager, by typing
9+
```julia
10+
using Pkg
11+
pkg"add AtmosphericModels"
12+
```
13+
at the Julia prompt.
14+
15+
### Running the tests
16+
Launch Julia using this project and run the tests:
17+
```julia
18+
julia --project
19+
using Pkg
20+
Pkg.test("AtmosphericModels")
21+
```
22+
23+
### Running the examples
24+
If you check out the project using git, you can more easily run the examples:
25+
```
26+
git clone https://github.com/OpenSourceAWE/AtmosphericModels.jl
27+
cd AtmosphericModels.jl
28+
```
29+
Launch Julia using this project and run the example menu:
30+
```julia
31+
julia --project
32+
include("examples/menu.jl")
33+
```
34+
The first time will take some time, because the graphic libraries will get installed, the second time it is fast.
35+
36+
## Usage
37+
### Calculate the height dependant wind speed
38+
```julia
39+
using AtmosphericModels
40+
am = AtmosphericModel()
41+
42+
const profile_law = Int(EXPLOG)
43+
height = 100.0
44+
wf = calc_wind_factor(am, height, profile_law)
45+
```
46+
The result is the factor with which the ground wind speed needs to be multiplied
47+
to get the wind speed at the given height.
48+
49+
![Wind Profile](wind_profile.png)
50+
51+
The `EXPLOG` profile law is the fitted linear combination of the exponential and the log law.
52+
53+
### Using the turbulent wind field
54+
You can get a wind vector as function of x,y,z and time using the following code:
55+
```julia
56+
using AtmosphericModels, KiteUtils
57+
58+
set_data_path("data")
59+
set = load_settings("system.yaml")
60+
am::AtmosphericModel = AtmosphericModel(set)
61+
62+
@info "Ground wind speed: $(am.set.v_wind) m/s"
63+
64+
wf::WindField = WindField(am, am.set.v_wind)
65+
x, y, z = 20.0, 0.0, 200.0
66+
t = 0.0
67+
vx, vy, vz = get_wind(wf, am, x, y, z, t)
68+
@time get_wind(am, x, y, z, t)
69+
@info "Wind at x=$(x), y=$(y), z=$(z), t=$(t): v_x=$(vx), v_y=$(vy), v_z=$(vz)"
70+
@info "Wind speed: $(sqrt(vx^2 + vy^2 + vz^2)) m/s"
71+
```
72+
It is suggested to check out the code using git before executing this example,
73+
because it requires that a data directory with the correct files `system.yaml`
74+
and `settings.yaml` exists. See below how to do that.
75+
76+
### Plot a wind profile
77+
```julia
78+
using AtmosphericModels, KiteUtils, ControlPlots
79+
am = AtmosphericModel(se())
80+
81+
heights = 6:1000
82+
wf = [calc_wind_factor(am, height, Int(EXPLOG)) for height in heights]
83+
84+
plot(heights, wf, xlabel="height [m]", ylabel="wind factor")
85+
```
86+
87+
```julia
88+
using AtmosphericModels, ControlPlots, KiteUtils
89+
am = AtmosphericModel(se())
90+
AtmosphericModels.se().alpha = 0.234 # set the exponent of the power law
91+
92+
heights = 6:200
93+
wf = [calc_wind_factor(am, height, Int(EXP)) for height in heights]
94+
95+
plot(heights, wf, xlabel="height [m]", ylabel="wind factor")
96+
```
97+
98+
### Air density
99+
```julia
100+
using AtmosphericModels, BenchmarkTools, KiteUtils
101+
am = AtmosphericModel(se())
102+
@benchmark calc_rho(am, height) setup=(height=Float64((6.0+rand()*500.0)))
103+
```
104+
This gives 4.85 ns as result. Plot the air density:
105+
```julia
106+
heights = 6:1000
107+
rhos = [calc_rho(am, height) for height in heights]
108+
plot(heights, rhos, legend=false, xlabel="height [m]", ylabel="air density [kg/m³]")
109+
```
110+
![Airdensity](airdensity.png)
111+
112+
## Further reading
113+
These models are described in detail in [Dynamic Model of a Pumping Kite Power System](http://arxiv.org/abs/1406.6218).
114+
115+
## Licence
116+
This project is licensed under the MIT License. Please see the below WAIVER in association with the license.
117+
118+
## WAIVER
119+
Technische Universiteit Delft hereby disclaims all copyright interest in the package “AtmosphericModels.jl” (models for airborne wind energy systems) written by the Author(s).
120+
121+
Prof.dr. H.G.C. (Henri) Werij, Dean of Aerospace Engineering
122+
123+
## See also
124+
- [Research Fechner](https://research.tudelft.nl/en/publications/?search=Uwe+Fechner&pageSize=50&ordering=rating&descending=true)
125+
- The application [KiteViewer](https://github.com/ufechner7/KiteViewer)
126+
- the package [KiteUtils](https://github.com/ufechner7/KiteUtils.jl)
127+
- the packages [KiteModels](https://github.com/ufechner7/KiteModels.jl) and [WinchModels](https://github.com/aenarete/WinchModels.jl) and [KitePodModels](https://github.com/aenarete/KitePodModels.jl)
128+
- the packages [KiteControllers](https://github.com/aenarete/KiteControllers.jl) and [KiteViewers](https://github.com/aenarete/KiteViewers.jl)
129+

0 commit comments

Comments
 (0)