From 5721e9930e5c609403bfe615f1add8c2dbc76d80 Mon Sep 17 00:00:00 2001 From: dvanwolffelaar Date: Thu, 24 Oct 2024 14:21:58 +0200 Subject: [PATCH 1/5] azimuth wind tests --- test/test_orientation.jl | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/test/test_orientation.jl b/test/test_orientation.jl index 84a9b984..465d73c3 100644 --- a/test/test_orientation.jl +++ b/test/test_orientation.jl @@ -272,6 +272,44 @@ end @test isapprox(elevation, 0, atol=1e-4, rtol=1e-4) @test isapprox(heading, 0, atol=1e-4, rtol=1e-4) end + +# Kite is same place and orientation as base orientation, rotate the windframe x axis 45 degrees to the west" +@testset "upwind_dir dir 45 azimuth wind" begin + s = create_kite_model((0, 0, 1), (-1, 0, 0), (0, -1, 0), # Orientation + (0, 1, 0), # Pos + 45+180) # upwind_dir + azimuth = rad2deg(calc_azimuth(s)) + azimuth_north = rad2deg(calc_azimuth_north(s)) + + @test isapprox(azimuth, 45, atol=1e-4, rtol=1e-4) + @test isapprox(azimuth_north, 0, atol=1e-4, rtol=1e-4) +end + +# Kite is same place and orientation as base orientation, rotate the windframe x axis 60 degrees to the west" +@testset "upwind_dir dir 60 azimuth wind" begin + s = create_kite_model((0, 0, 1), (-1, 0, 0), (0, -1, 0), # Orientation + (0, 1, 0), # Pos + 60+180) # upwind_dir + azimuth = rad2deg(calc_azimuth(s)) + azimuth_north = rad2deg(calc_azimuth_north(s)) + + @test isapprox(azimuth, 60, atol=1e-4, rtol=1e-4) + @test isapprox(azimuth_north, 0, atol=1e-4, rtol=1e-4) +end + +# Kite is same place and orientation as base orientation, rotate the windframe x axis 60 degrees to the east" +@testset "upwind_dir dir -60 azimuth wind" begin + s = create_kite_model((0, 0, 1), (-1, 0, 0), (0, -1, 0), # Orientation + (0, 1, 0), # Pos + -60+180) # upwind_dir + azimuth = rad2deg(calc_azimuth(s)) + azimuth_north = rad2deg(calc_azimuth_north(s)) + + @test isapprox(azimuth, -60, atol=1e-4, rtol=1e-4) + @test isapprox(azimuth_north, 0, atol=1e-4, rtol=1e-4) + +end end nothing - \ No newline at end of file + +calc_azimuth \ No newline at end of file From 1200d4916c2cb4c7bbe74ab07630626a68b8bbcd Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Fri, 25 Oct 2024 17:54:16 +0200 Subject: [PATCH 2/5] mark failing tests as broken --- test/test_orientation.jl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/test_orientation.jl b/test/test_orientation.jl index 465d73c3..824e6301 100644 --- a/test/test_orientation.jl +++ b/test/test_orientation.jl @@ -280,8 +280,8 @@ end 45+180) # upwind_dir azimuth = rad2deg(calc_azimuth(s)) azimuth_north = rad2deg(calc_azimuth_north(s)) - - @test isapprox(azimuth, 45, atol=1e-4, rtol=1e-4) + # println("azimuth: ", azimuth) # 90 + @test_broken isapprox(azimuth, 45, atol=1e-4, rtol=1e-4) @test isapprox(azimuth_north, 0, atol=1e-4, rtol=1e-4) end @@ -292,8 +292,9 @@ end 60+180) # upwind_dir azimuth = rad2deg(calc_azimuth(s)) azimuth_north = rad2deg(calc_azimuth_north(s)) + # println("azimuth: ", azimuth) # 90 - @test isapprox(azimuth, 60, atol=1e-4, rtol=1e-4) + @test_broken isapprox(azimuth, 60, atol=1e-4, rtol=1e-4) @test isapprox(azimuth_north, 0, atol=1e-4, rtol=1e-4) end @@ -305,7 +306,7 @@ end azimuth = rad2deg(calc_azimuth(s)) azimuth_north = rad2deg(calc_azimuth_north(s)) - @test isapprox(azimuth, -60, atol=1e-4, rtol=1e-4) + @test_broken isapprox(azimuth, -60, atol=1e-4, rtol=1e-4) @test isapprox(azimuth_north, 0, atol=1e-4, rtol=1e-4) end From d2990debc5f8e6e2de4c83fc0abb34a287b30239 Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Sat, 26 Oct 2024 17:44:26 +0200 Subject: [PATCH 3/5] make upwind_dir a named argument --- src/KPS4_3L.jl | 2 +- src/KiteModels.jl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/KPS4_3L.jl b/src/KPS4_3L.jl index f9e33fe9..73482043 100644 --- a/src/KPS4_3L.jl +++ b/src/KPS4_3L.jl @@ -427,7 +427,7 @@ end function next_step!(s::KPS4_3L; set_values=zeros(KVec3), v_wind_gnd=s.set.v_wind, upwind_dir=-pi/2, dt=1/s.set.sample_freq) s.iter = 0 - set_v_wind_ground!(s, calc_height(s), v_wind_gnd, upwind_dir) + set_v_wind_ground!(s, calc_height(s), v_wind_gnd; upwind_dir) if isnothing(s.get_pos) s.v_wind_gnd_idx = parameter_index(s.integrator.f, :v_wind_gnd) s.v_wind_idx = parameter_index(s.integrator.f, :v_wind) diff --git a/src/KiteModels.jl b/src/KiteModels.jl index 611b58c0..876811c5 100644 --- a/src/KiteModels.jl +++ b/src/KiteModels.jl @@ -197,13 +197,13 @@ Return the vector of the wind speed at the height of the kite. function v_wind_kite(s::AKM) s.v_wind end """ - set_v_wind_ground!(s::AKM, height, v_wind_gnd=s.set.v_wind, upwind_dir=0.0) + set_v_wind_ground!(s::AKM, height, v_wind_gnd=s.set.v_wind; upwind_dir=0.0) Set the vector of the wind-velocity at the height of the kite. As parameter the height, the ground wind speed [m/s] and the upwind direction [radians] are needed. Is called by the function next_step!. """ -function set_v_wind_ground!(s::AKM, height, v_wind_gnd=s.set.v_wind, upwind_dir=-pi/2) +function set_v_wind_ground!(s::AKM, height, v_wind_gnd=s.set.v_wind; upwind_dir=-pi/2) if height < 6.0 height = 6.0 end @@ -573,7 +573,7 @@ function next_step!(s::AKM, integrator; set_speed = nothing, set_torque=nothing, s.sync_speed = set_speed s.set_torque = set_torque s.t_0 = integrator.t - set_v_wind_ground!(s, calc_height(s), v_wind_gnd, upwind_dir) + set_v_wind_ground!(s, calc_height(s), v_wind_gnd; upwind_dir) s.iter = 0 if s.set.solver == "IDA" Sundials.step!(integrator, dt, true) From 20bce0c199760ce8f0160caf57c6020bd9f99aa6 Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Sat, 26 Oct 2024 17:44:49 +0200 Subject: [PATCH 4/5] fixed 3 tests, but one new broken test --- test/test_orientation.jl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/test_orientation.jl b/test/test_orientation.jl index 824e6301..f9355b9a 100644 --- a/test/test_orientation.jl +++ b/test/test_orientation.jl @@ -48,7 +48,7 @@ function create_kite_model(x, y, z, pos, upwind_dir_deg) s.y = y s.z = z - KiteModels.set_v_wind_ground!(s, pos[begin+2], deg2rad(upwind_dir_deg)) + KiteModels.set_v_wind_ground!(s, pos[begin+2]; upwind_dir=deg2rad(upwind_dir_deg)) s.pos[end-2][begin] = pos[begin] s.pos[end-2][begin+1] = pos[begin+1] @@ -246,7 +246,7 @@ end @test isapprox(azimuth_north, 0, atol=1e-4, rtol=1e-4) @test isapprox(elevation, 0, atol=1e-4, rtol=1e-4) - @test isapprox(heading, 0, atol=1e-4, rtol=1e-4) + @test_broken isapprox(heading, 0, atol=1e-4, rtol=1e-4) end # Kite is same place and orientation as base orientation, rotate the windframe x axis 60 degrees to the west" @@ -280,8 +280,7 @@ end 45+180) # upwind_dir azimuth = rad2deg(calc_azimuth(s)) azimuth_north = rad2deg(calc_azimuth_north(s)) - # println("azimuth: ", azimuth) # 90 - @test_broken isapprox(azimuth, 45, atol=1e-4, rtol=1e-4) + @test isapprox(azimuth, 45, atol=1e-4, rtol=1e-4) @test isapprox(azimuth_north, 0, atol=1e-4, rtol=1e-4) end @@ -290,11 +289,11 @@ end s = create_kite_model((0, 0, 1), (-1, 0, 0), (0, -1, 0), # Orientation (0, 1, 0), # Pos 60+180) # upwind_dir + upwind_dir_ = rad2deg(upwind_dir(s)) azimuth = rad2deg(calc_azimuth(s)) azimuth_north = rad2deg(calc_azimuth_north(s)) - # println("azimuth: ", azimuth) # 90 - @test_broken isapprox(azimuth, 60, atol=1e-4, rtol=1e-4) + @test isapprox(azimuth, 60, atol=1e-4, rtol=1e-4) @test isapprox(azimuth_north, 0, atol=1e-4, rtol=1e-4) end @@ -306,7 +305,7 @@ end azimuth = rad2deg(calc_azimuth(s)) azimuth_north = rad2deg(calc_azimuth_north(s)) - @test_broken isapprox(azimuth, -60, atol=1e-4, rtol=1e-4) + @test isapprox(azimuth, -60, atol=1e-4, rtol=1e-4) @test isapprox(azimuth_north, 0, atol=1e-4, rtol=1e-4) end From 71f8cf08553708e2fe762b58c16056cf7566c7dc Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Sat, 26 Oct 2024 19:01:40 +0200 Subject: [PATCH 5/5] fix test failure --- test/test_orientation.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_orientation.jl b/test/test_orientation.jl index f9355b9a..b60b99e5 100644 --- a/test/test_orientation.jl +++ b/test/test_orientation.jl @@ -246,7 +246,7 @@ end @test isapprox(azimuth_north, 0, atol=1e-4, rtol=1e-4) @test isapprox(elevation, 0, atol=1e-4, rtol=1e-4) - @test_broken isapprox(heading, 0, atol=1e-4, rtol=1e-4) + @test isapprox(heading, 0, atol=1e-4, rtol=1e-4) || isapprox(heading, 360, atol=1e-4, rtol=1e-4) end # Kite is same place and orientation as base orientation, rotate the windframe x axis 60 degrees to the west"