Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azimuth wind tests #86

Merged
merged 5 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/KPS4_3L.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/KiteModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
44 changes: 41 additions & 3 deletions test/test_orientation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"
Expand All @@ -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


calc_azimuth
Loading