Skip to content

Commit

Permalink
fix definition of roll, yaw, p, and r for standard positive sign. fix…
Browse files Browse the repository at this point in the history
…es stability derivatives (and rolling and yawing moments)
  • Loading branch information
andrewning committed Sep 29, 2022
1 parent ff132f2 commit aa9dc29
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ velocity-deficit.pdf
commands
output
avl3.35

.vscode
12 changes: 12 additions & 0 deletions src/nearfield.jl
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,10 @@ function body_forces(surfaces, properties, ref, fs, symmetric, frame)
reference_length = SVector(ref.b, ref.c, ref.b)
CM = CM ./ reference_length

# positive Mx corresponds to negative roll, and positive Mz corresponds to negative yaw
convention_change = [-1.0, 1.0, -1.0]
CM = CM .* convention_change

# switch to specified frame
CF, CM = body_to_frame(CF, CM, ref, fs, frame)

Expand Down Expand Up @@ -799,6 +803,14 @@ performed to obtain the panel forces.
CM_q = CM_q ./ reference_length
CM_r = CM_r ./ reference_length

# positive Mx corresponds to negative roll, and positive Mz corresponds to negative yaw
convention_change = [-1.0, 1.0, -1.0]
CM_a = CM_a .* convention_change
CM_b = CM_b .* convention_change
CM_p = CM_p .* convention_change
CM_q = CM_q .* convention_change
CM_r = CM_r .* convention_change

# pack up derivatives
dCF = (CF_a, CF_b, CF_p, CF_q, CF_r)
dCM = (CM_a, CM_b, CM_p, CM_q, CM_r)
Expand Down
8 changes: 8 additions & 0 deletions src/stability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ function body_derivatives(system)
CM_v = CM_b*b_v
CM_w = CM_a*a_w

# p and r are have opposite signs compared to Omega_x, Omega_z
CF_p *= -1; CM_p *= -1
CF_r *= -1; CM_r *= -1

# pack up derivatives as named tuples
dCF = (u=CF_u, v=CF_v, w=CF_w, p=CF_p, q=CF_q, r=CF_r)
dCM = (u=CM_u, v=CM_v, w=CM_w, p=CM_p, q=CM_q, r=CM_r)
Expand Down Expand Up @@ -131,6 +135,10 @@ function stability_derivatives(system)
CM_q = (CMs_qs*2*ref.V/ref.c) ./ reference_length
CM_r = (CMs_rs*2*ref.V/ref.b) ./ reference_length

# p and r are have opposite signs compared to Omega_x, Omega_z
CF_p *= -1; CM_p *= -1
CF_r *= -1; CM_r *= -1

# pack up derivatives as named tuples
dCF = (alpha=CF_a, beta=CF_b, p=CF_p, q=CF_q, r=CF_r)
dCM = (alpha=CM_a, beta=CM_b, p=CM_p, q=CM_q, r=CM_r)
Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ end
@test isapprox(CDiff, 0.0022852, atol=1e-5)
@test isapprox(Cm, -0.02101, atol=1e-4)
@test isapprox(CY, 0.0, atol=1e-5)
@test isapprox(Cl, 0.00644, atol=1e-4)
@test isapprox(Cn, -0.00012, atol=2e-4)
@test isapprox(Cl, -0.00644, atol=1e-4)
@test isapprox(Cn, 0.00012, atol=2e-4)
end

@testset "AVL - Run 11 - Wing Stability Derivatives" begin
Expand Down Expand Up @@ -802,11 +802,11 @@ end
@test isapprox(CYa, 0.0, atol=ztol)
@test isapprox(CYb, -0.000007, atol=1e-4)
@test isapprox(Cla, 0.0, atol=ztol)
@test isapprox(Clb, 0.025749, rtol=0.015)
@test isapprox(Clb, -0.025749, atol=0.001)
@test isapprox(Cma, -0.429247, rtol=0.01)
@test isapprox(Cmb, 0.0, atol=ztol)
@test isapprox(Cna, 0.0, atol=ztol)
# @test isapprox(Cnb, -0.000466, atol=1e-4)
@test isapprox(Cnb, 0.000466, atol=1e-3)
@test isapprox(Clp, -0.518725, rtol=0.01)
@test isapprox(Clq, 0.0, atol=ztol)
@test isapprox(Clr, 0.064243, rtol=0.01)
Expand Down

0 comments on commit aa9dc29

Please sign in to comment.