Skip to content

Commit

Permalink
Clean up duplicate/ old files (#6)
Browse files Browse the repository at this point in the history
* del old airtable

* del old blax

* air --> airfoil_data + add additional airfoils
  • Loading branch information
askprash authored Dec 15, 2023
1 parent fb682ed commit 4d534b3
Show file tree
Hide file tree
Showing 14 changed files with 4,554 additions and 998 deletions.
2 changes: 1 addition & 1 deletion docs/src/aero/drag.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ aerodynamics.blsys(simi,lami,wake,direct, Mach, uinv,
cfm, cfm_thm, cfm_dsm, cfm_uem,
dim, dim_thm, dim_dsm, dim_uem)
aerodynamics.blax2(ndim, n,ite, xi, bi, rni, uinv, Reyn, Mach, fexcr)
aerodynamics.blax(ndim, n,ite, xi, bi, rni, uinv, Reyn, Mach, fexcr)
aerodynamics.blvar(simi,lami,wake, Reyn,Mach, fexcr,
x, θ ,δs ,ue )
Expand Down
5 changes: 2 additions & 3 deletions src/aero/aero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jdim::Int = 360

# Aerofoil calculations
include("airfoil.jl")
include("airtable2.jl")
include("airtable.jl")
include("airfun.jl")

__abs_path_prefix__ = dirname(@__DIR__)
airfoil_data = joinpath(__abs_path_prefix__,"air/C.air")
airfoil_data = joinpath(__abs_path_prefix__,"airfoil_data/C.air")

airsection = airtable(airfoil_data);

Expand All @@ -53,7 +53,6 @@ include("wingsc.jl")
include("fusebl.jl")
include("axisol.jl")
include("blax.jl")
include("blax2.jl")
include("blsys.jl")

# Trefftz plane CDi calcs
Expand Down
2 changes: 1 addition & 1 deletion src/aero/airfun.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export airfun
"""
airfun(cl, τ, Mach, air::airfoil)
Looks up airfoil performance data at specified conditions, as precomputed and found in `./src/air/C.air`.
Looks up airfoil performance data at specified conditions, as precomputed and found in `./src/airfoil_data/`.
!!! details "🔃 Inputs and Outputs"
**Inputs:**
Expand Down
101 changes: 79 additions & 22 deletions src/aero/airtable.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
using Dierckx

"""
Reads airfoil file and outputs a matrix and spline objects
airtable(fname)
Reads airfoil file and outputs the matrix and splines as an `airfoil`.
The airfoil data is stored as a function of three variables, typically
Mach number ``\\mathrm{Ma}``, lift coefficient ``c_l``, and thickness to chord ratio ``\\tau``.
cdf(Ma, cl, τ), cdp(Ma, cl, τ), cm(Ma, cl, τ)
!!! details "🔃 Inputs and Outputs"
**Inputs:**
- `fname::String`: Path to file.
!!! compat "Future Changes"
Deprecated by faster [`airtable`](@ref) in `airtable2.jl`. Will be removed in a future revision.
**Outputs:**
- `airf::TASOPT.aerodynamics.airfoil`: struct with airfoil performance characteristics.
"""
function airtable(fname)

# Read file
f = open(fname)
# Read airfoil data
f = open(fname)

nAMa::Int, nAcl::Int, nAτ::Int, nAfun::Int = [parse(Int,ss) for ss in split(readline(f))]

AMa = zeros(nAMa)
Acl = zeros(nAcl)
= zeros(nAτ)
AMa = zeros(nAMa) # array of Mach numbers in database
Acl = zeros(nAcl) # array of cl in database
= zeros(nAτ) # array of t/c in database
A = zeros(nAMa, nAcl, nAτ, nAfun)

@inbounds for i = 1:nAMa
Expand All @@ -29,7 +38,7 @@ function airtable(fname)
Aτ[i] = parse(Float64, readline(f))
end

#Read in Reynolds number
# Read in Reynolds number
ARe = parse(Float64, readline(f))

#Read in airfoil data
Expand All @@ -41,21 +50,69 @@ function airtable(fname)
end
end

close(f)
close(f)

# Create spline objects to make it faster for airfun.jl since this does not need to be computed each time
# ---------------------
A_M = zeros(nAMa, nAcl, nAτ, nAfun)
A_τ = zeros(nAMa, nAcl, nAτ, nAfun)
A_cl = zeros(nAMa, nAcl, nAτ, nAfun)
A_M_τ = zeros(nAMa, nAcl, nAτ, nAfun)
A_M_cl = zeros(nAMa, nAcl, nAτ, nAfun)
A_cl_τ = zeros(nAMa, nAcl, nAτ, nAfun)
A_M_cl_τ = zeros(nAMa, nAcl, nAτ, nAfun)
# Iterate over the 3 functions - cdf, cdp and cm
for l = 1:nAfun
for k = 1:nAτ
for j = 1:nAcl
A_M[:, j, k, l] = spline(AMa, A[:, j, k, l]) # This gets the derivatives ∂cdf/∂M, ∂cdp/∂M, ∂cm/∂M
end
end

∂cdf_∂M = Array{Spline1D, 2}(undef, nAcl, nAτ)
∂cdp_∂M = Array{Spline1D, 2}(undef, nAcl, nAτ)
∂cm_∂M = Array{Spline1D, 2}(undef, nAcl, nAτ)
for k = 1:nAτ
for i = 1:nAMa
# for j = 1:nAcl
f = A[i, :, k, l]
f_M = A_M[i, :, k, l]
A_cl[i, :, k, l] = spline(Acl, f)
A_M_cl[i, :, k, l] = spline(Acl, f_M)
end
end

@inbounds for k = 1:nAτ
@inbounds for j = 1:nAcl
∂cdf_∂M[j, k] = Spline1D(AMa, A[:,j,k,1], k = 3)
∂cdp_∂M[j, k] = Spline1D(AMa, A[:,j,k,2], k = 3)
∂cm_∂M[j, k] = Spline1D(AMa, A[:,j,k,3], k = 3)
for j = 1:nAcl
for i = 1:nAMa
f = A[i, j, :, l]
f_M = A_M[i, j, :, l]
A_τ[i, j, :, l] = spline(Aτ, f)
A_M_τ[i, j, :, l] = spline(Aτ, f_M)
end
end

for i = 1:nAMa
for j = 1:nAcl
f = A_cl[i, j, :, l]
f_M = A_M_cl[i, j, :, l]
A_cl_τ[i, j, :, l] = spline(Aτ, f)
A_M_cl_τ[i, j, :, l] = spline(Aτ, f_M)
end
for k = 1:nAτ
f = A_τ[i, :, k, l]
f_M = A_M_τ[i, :, k, l]
A_cl_τ[i, :, k, l] = 0.5*( A_cl_τ[i, :, k, l] + spline(Acl, f))
A_M_cl_τ[i, :, k, l] = 0.5*(A_M_cl_τ[i, :, k, l] + spline(Acl, f_M))
end
end

return nAMa, nAcl, nAτ, nAfun, AMa, Acl, Aτ, A, ∂cdf_∂M, ∂cdp_∂M, ∂cm_∂M

end

return airfoil(AMa, Acl, Aτ, ARe,
A,
A_M,
A_τ,
A_cl,
A_M_τ,
A_M_cl,
A_cl_τ,
A_M_cl_τ)
end

120 changes: 0 additions & 120 deletions src/aero/airtable2.jl

This file was deleted.

Loading

0 comments on commit 4d534b3

Please sign in to comment.