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) diff --git a/test/test_orientation.jl b/test/test_orientation.jl index 84a9b984..b60b99e5 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 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" @@ -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 + upwind_dir_ = rad2deg(upwind_dir(s)) + 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