Skip to content

Commit cec73cd

Browse files
authored
Merge pull request #214 from ufechner7/transform
- Adds a Transform struct, which is used in the SystemStructure to describe the orientation of the structure. - Adds images to the documentation, which were removed when @example was removed. - Improves the docs and docstrings
2 parents 2294f23 + a12c598 commit cec73cd

18 files changed

+359
-143
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
LocalPreferences.toml
12
*.arrow
23
*.bin
34
*.xopp

AUTHORS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SPDX-License-Identifier: MIT
77
This project was started by Uwe Fechner in 2022 with the goal to make the results
88
of his PhD thesis on the simulation and control of kite power systems, re-coded in a fast and modern programming language, available to the public.
99

10-
Bart van de Lint joined the project in 2024. His major contribution is the first modelling toolkit (MTK) based model, a ram-air kite model.
10+
Bart van de Lint joined the project in 2024. His major contribution is the first ModelingToolkit (MTK) based model, a ram-air kite model.
1111

1212
## Developers
1313
- Uwe Fechner, Delft/ Den Haag, The Netherlands - original author of the `KPS3` and `KPS4` kite models

Manifest-v1.10.toml.default

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.10.9"
44
manifest_format = "2.0"
5-
project_hash = "e5116e83aee3763e3ebd89b0de5522b585f68fec"
5+
project_hash = "098d81951e8c706049a0f77aa39c5c7b3d03fe19"
66

77
[[deps.ADTypes]]
88
git-tree-sha1 = "e2478490447631aedba0823d4d7a80b2cc8cdb32"
@@ -611,9 +611,9 @@ uuid = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
611611
version = "1.0.5"
612612

613613
[[deps.EnzymeCore]]
614-
git-tree-sha1 = "7d7822a643c33bbff4eab9c87ca8459d7c688db0"
614+
git-tree-sha1 = "8272a687bca7b5c601c0c24fc0c71bff10aafdfd"
615615
uuid = "f151be2c-9106-41f4-ab19-57ee4f262869"
616-
version = "0.8.11"
616+
version = "0.8.12"
617617
weakdeps = ["Adapt"]
618618

619619
[deps.EnzymeCore.extensions]
@@ -786,9 +786,9 @@ uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9"
786786
version = "0.1.5"
787787

788788
[[deps.InlineStrings]]
789-
git-tree-sha1 = "6a9fde685a7ac1eb3495f8e812c5a7c3711c2d5e"
789+
git-tree-sha1 = "8594fac023c5ce1ef78260f24d1ad18b4327b420"
790790
uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
791-
version = "1.4.3"
791+
version = "1.4.4"
792792
weakdeps = ["ArrowTypes", "Parsers"]
793793

794794
[deps.InlineStrings.extensions]
@@ -889,9 +889,9 @@ version = "0.3.8"
889889

890890
[[deps.KiteUtils]]
891891
deps = ["Arrow", "CSV", "DocStringExtensions", "LinearAlgebra", "OrderedCollections", "Parameters", "Parsers", "Pkg", "PrecompileTools", "RecursiveArrayTools", "ReferenceFrameRotations", "Rotations", "StaticArrays", "StructArrays", "StructTypes", "YAML"]
892-
git-tree-sha1 = "ef1ab34bdb8c1bcf06f99b4364cae5df1be6936a"
892+
git-tree-sha1 = "93659cbb96514bafd053ae0e81d08d15248040e9"
893893
uuid = "90980105-b163-44e5-ba9f-8b1c83bb0533"
894-
version = "0.10.10"
894+
version = "0.10.11"
895895

896896
[[deps.Krylov]]
897897
deps = ["LinearAlgebra", "Printf", "SparseArrays"]
13.5 KB
Binary file not shown.
20.9 KB
Binary file not shown.

docs/src/ram_air_kite.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Segment
1818
Tether
1919
Winch
2020
Group
21+
Wing
22+
Transform
2123
SystemStructure
2224
```
2325

docs/src/tether_during_sim.png

39.2 KB
Loading

docs/src/tether_sys_struct.png

18 KB
Loading

docs/src/tutorial_system_structure.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ set = se("system_ram.yaml")
2020
set.segments = 20
2121
dynamics_type = DYNAMIC
2222
```
23+
2324
Then, we define vectors of the system structure types we are going to use. For this simple example we only need points and segments.
25+
2426
```julia
2527
points = Point[]
2628
segments = Segment[]
2729

28-
points = push!(points, Point(1, [0.0, 0.0, set.l_tether], STATIC; wing_idx=0))
30+
points = push!(points, Point(1, zeros(3), STATIC; wing_idx=0))
2931
```
32+
3033
The first point we add is a static point. There are four different [`DynamicsType`](@ref)s to choose from: `STATIC`, `QUASI_STATIC`, `DYNAMIC` and `WING`. `STATIC` just means that the point doesn't move. `DYNAMIC` is a point modeled with acceleration, while `QUASI_STATIC` constrains this acceleration to be zero at all times. A `WING` point is connected to a rigid wing body.
3134

3235
Now we can add `DYNAMIC` points and connect them to each other with segments. `BRIDLE` segments don't need to have a tether, because they have a constant unstretched length.
@@ -35,28 +38,35 @@ segment_idxs = Int[]
3538
for i in 1:set.segments
3639
global points, segments
3740
point_idx = i+1
38-
pos = [0.0, 0.0, set.l_tether] - set.l_tether / set.segments * [0.0, 0.0, i]
41+
pos = [0.0, 0.0, i * set.l_tether / set.segments]
3942
push!(points, Point(point_idx, pos, dynamics_type; wing_idx=0))
4043
segment_idx = i
4144
push!(segments, Segment(segment_idx, (point_idx-1, point_idx), BRIDLE))
4245
push!(segment_idxs, segment_idx)
4346
end
4447
```
45-
From these arrays of points and segments we can create a [`SystemStructure`](@ref), which can be plotted in 2d to quickly investigate if the model is correct.
48+
49+
In order to describe the initial orientation of the structure, we define a [`Transform`](@ref) with an elevation (-80 degrees), azimuth and heading, and a base position `[0.0, 0.0, 50.0]`.
50+
```julia
51+
transforms = [Transform(1, deg2rad(-80), 0.0, 0.0, [0.0, 0.0, 50.0], points[1].idx;
52+
rot_point_idx=points[end].idx)]
53+
```
54+
55+
From the points, segments and transform we create a [`SystemStructure`](@ref), which can be plotted in 2d to quickly investigate if the model is correct.
4656
```julia
47-
sys_struct = SystemStructure("tether"; points, segments)
57+
sys_struct = SystemStructure("tether", set; points, segments, transforms)
4858
plot(sys_struct, 0.0)
49-
plt.gcf()
5059
```
60+
![SystemStructure visualization](tether_sys_struct.png)
5161

5262
If the system looks good, we can easily model it, by first creating a [`SymbolicAWEModel`](@ref), initializing it and stepping through time.
5363
```julia
54-
model = SymbolicAWEModel(set, sys_struct)
64+
sam = SymbolicAWEModel(set, sys_struct)
5565

56-
init_sim!(model; remake=false)
57-
for i in 1:100
58-
plot(model, i/set.sample_freq)
59-
next_step!(model; dt=1/set.sample_freq)
66+
init_sim!(sam; remake=false)
67+
for i in 1:80
68+
plot(sam, i/set.sample_freq)
69+
next_step!(sam)
6070
end
61-
plt.gcf()
6271
```
72+
![Tether during simulation](tether_during_sim.png)

examples/ram_air_kite.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ toc()
4747
# plot(sam.sys_struct, 0.0; zoom=false, front=false)
4848

4949
# Initialize at elevation
50-
sam.sys_struct.winches[2].tether_length += 0.2
51-
sam.sys_struct.winches[3].tether_length += 0.2
50+
set.l_tethers[2] += 0.2
51+
set.l_tethers[3] += 0.2
5252
init_sim!(sam; remake=false, reload=false)
5353
sys = sam.sys
5454

@@ -63,7 +63,7 @@ sys_state = SysState(sam)
6363
t = 0.0
6464
runtime = 0.0
6565
integ_runtime = 0.0
66-
bias = set.quasi_static ? 0.45 : 0.35
66+
bias = set.quasi_static ? 0.45 : 0.40
6767
t0 = sam.integrator.t
6868

6969
try
@@ -147,3 +147,5 @@ p = plotx(sl.time,
147147
display(p)
148148

149149
@info "Performance:" times_realtime=(total_time/2)/runtime integrator_times_realtime=(total_time/2)/integ_runtime
150+
151+
# 55x realtime (PLOT=false, CPU: Intel i9-9980HK (16) @ 5.000GHz)

0 commit comments

Comments
 (0)