Skip to content

Commit

Permalink
Polish docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
EdoAlvarezR committed Feb 26, 2023
1 parent 0e490ab commit 2332c3a
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 67 deletions.
31 changes: 24 additions & 7 deletions src/FLOWVLM_rotor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,15 @@ function save(self::Rotor, filename::String; addtiproot=true, airfoils=false,
return strn
end

"Sets a coordinate system for the rotor. If the user is calling this function,
give `user=true`, otherwise it won't do the automatic translation to blade c.s."
"""
setcoordsystem(rotor::Rotor, O::Vector, Oaxis::Matrix; user=false)
Redefines the local coordinate system of the rotor, where `O` is the new origin
and `Oaxis` is the matrix of unit vectors. If the user is calling this function,
give `user=true`, otherwise it will not do the automatic translation to blade
coordinate system.
"""
function setcoordsystem(self::Rotor, O::FArrWrap,
Oaxis::FMWrap; user=false, args...)
if user
Expand All @@ -378,7 +385,11 @@ function setcoordsystem(self::Rotor, O::FArrWrap,
_resetRotor(self; keep_RPM=true)
end

"Rotates the rotor `degs` degrees in the direction of rotation"
"""
rotate(rotor::Rotor, degs::Real)
Rotates the rotor by `degs` degrees in the direction of rotation (`rotor.CW`).
"""
function rotate(self::Rotor, degs::FWrap)
rotOaxis = gt.rotation_matrix(0.0, 0.0, (-1)^!self.CW*degs)
newOaxis = rotOaxis*self._wingsystem.Oaxis
Expand Down Expand Up @@ -426,7 +437,11 @@ function get_RPM(self::Rotor)
return self.RPM
end

"Returns total number of lattices on each blade"
"""
get_mBlade(rotor::Rotor)
Returns the number of horseshoes per blade
"""
function get_mBlade(self::Rotor)
return self.m
end
Expand All @@ -436,7 +451,11 @@ function get_blade(self::Rotor, blade_i::IWrap)
return get_wing(self, blade_i)
end

"Returns total number of lattices in the rotor"
"""
get_m(rotor::Rotor)
Returns the total number of horseshoes in the rotor
"""
function get_m(self::Rotor)
return get_m(self._wingsystem)
end
Expand Down Expand Up @@ -2088,7 +2107,6 @@ function _calc_distributedloads_lookuptable(ccbrotor::OCCBRotor,
return Np, Tp, uvec, vvec, gamma, cn, ct, cl, cd, thetaeffdeg, mu_drag
end

"Extension of WingSystem's `addwing()` function"
function addwing(self::Rotor, wing_name::String, wing; force=false, args...)
if !force
error("This function is preserved for development."*
Expand All @@ -2097,7 +2115,6 @@ function addwing(self::Rotor, wing_name::String, wing; force=false, args...)
addwing(self._wingsystem, wing_name, wing; args...)
end

"Extension of WingSystem's `get_wing()` function"
function get_wing(self::Rotor, args...; optargs...)
return get_wing(self._wingsystem, args...; optargs...)
end
Expand Down
90 changes: 44 additions & 46 deletions src/FLOWVLM_tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -416,20 +416,20 @@ end


"""
`simpleWing(b, ar, tr, twist, lambda, gamma; twist_tip=twist, n=20, r=2.0)`
Generates a single-section wing.
# Arguments
* b : (float) span.
* ar : (float) aspect ratio defined as the span over the tip's chord.
* tr : (float) taper ratio (tip chord / root chord).
* twist : (float) twist of the root in degrees.
* lambda : (float) sweep in degrees.
* gamma : (float) dihedral in degrees.
* (OPTIONALS)
* twist_tip : (float) twist of the tip if different than root.
* n : (int) number of horseshoes per side of the wing.
* r : (float) horseshoes' expansion ratio
simpleWing(b, ar, tr, twist, lambda, gamma; twist_tip=twist, n=20, r=2.0)
Generates a simple wing with constant twist, sweep, dihedral, and taper ratio.
# Arguments
* `b` : (float) span
* `ar` : (float) aspect ratio (span / tip chord)
* `tr` : (float) taper ratio (tip chord / root chord)
* `twist` : (float) twist of the root in degrees
* `lambda` : (float) sweep in degrees
* `gamma` : (float) dihedral in degrees
* `twist_tip` : (float) twist of the tip (if different than root)
* `n` : (int) number of horseshoes per semi-span
* `r` : (float) horseshoes' expansion ratio
"""
function simpleWing(b::FWrap, ar::FWrap, tr::FWrap,
twist::FWrap, lambda::FWrap, gamma::FWrap;
Expand Down Expand Up @@ -522,46 +522,44 @@ function ellipticWing(b::FWrap, croot::FWrap, twistroot::FWrap; elliptic="chord"
end

"""
`complexWing(b::Float64, AR::Float64, tr::Float64, n::Int64,
pos::Array{Float64,1}, twist::Array{Float64,1},
sweep::Array{Float64,1}, dihed::Array{Float64,1};
symmetric::Bool=true)`
complexWing(b, AR, tr, n, pos, twist, sweep, dihed; symmetric=true)
Returns a Wing object made of multiple sections with the specified dimensions.
Generates a wing with an abritrary distribution of twist, sweep, dihedral, and
chord length.
# Arguments
* `b::Float64` : Span.
* `AR::Float64` : Aspect ratio (span over tip chord).
* `n::Int64` : Number of lattices in semi-span.
* `pos::Array{Float64,1}` : Position of each chord along semi-span.
* `clen::Array{Float64,1}` : Length of each chord as a fraction of tip chord.
* `twist::Array{Float64,1}` : (deg) twist of each chord.
* `sweep::Array{Float64,1}` : (deg) sweep of each section.
* `dihed::Array{Float64,1}` : (deg) dihedral of each section.
* `b::Float64` : Span
* `AR::Float64` : Reference aspect ratio (span / tip chord)
* `n::Int64` : Number of horseshoes per semi-span
* `pos::Array{Float64,1}` : Position of stations along the semi-span
* `clen::Array{Float64,1}` : Chord length at each station (normalized by tip chord)
* `twist::Array{Float64,1}` : (deg) twist at each station
* `sweep::Array{Float64,1}` : (deg) sweep between each station
* `dihed::Array{Float64,1}` : (deg) dihedral between each station
# Optional Arguments
* `symmetric::Bool=true` : If false, returns only the semi-span.
* `chordalign::Float64=0.0` : Indicate position along chord length to align
chords. Give it 0 for alignment about leading
edge, 0.25 for alignment about quarter chord,
and 1.0 for alignment about trailing edge.
* `symmetric::Bool=true` : If false, generates only a half-span
* `chordalign::Float64=0.0` : Indicate position along chord length to align
chords. Give it 0 for alignment about leading
edge, 0.25 for alignment about quarter chord,
and 1.0 for alignment about trailing edge.
# Example
```julia
# Wing Parameters
b = 1.0 # (m) span
AR = 12.0 # Span over tip chord
n = 50 # Lattices in semi-span
# Chords
pos = Float64[0, 0.25, 0.75, 1] # Position of each chord along semi-span
clen = Float64[2, 1.5, 1.5, 1] # Length of each chord
twist = Float64[0, 0, -2, -4] # (deg) twist at each chord
sweep = Float64[10, 15, 35] # (deg) sweep of each section
dihed = Float64[2, 5, 7.5] # (deg) dihedral of each section
# Generates the wing
wing = vlm.complexWing(b, AR, n, pos, clen, twist, sweep, dihed)
# Wing dimensions
b = 1.0 # (m) span
AR = 12.0 # Span over tip chord
n = 50 # Horseshoes per semi-span
# Define chord, twist, sweep, and dihedral distributions
pos = [0, 0.25, 0.75, 1] # Position of stations along semi-span
clen = [2.0, 1.5, 1.5, 1] # Normalized chord length at each station
twist = [0.0, 0.0, -2.0, -4.0] # (deg) twist at each station
sweep = [10.0, 15.0, 35.0] # (deg) sweep between stations
dihed = [2.0, 5.0, 7.5] # (deg) dihedral between stations
# Generate the wing
wing = vlm.complexWing(b, AR, n, pos, clen, twist, sweep, dihed)
```
"""
function complexWing(b::FWrap, AR::FWrap, n::IWrap, pos::FArrWrap,
Expand Down
10 changes: 7 additions & 3 deletions src/FLOWVLM_wing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ function addchord(self::Wing,
end

"""
`setcoordsystem(self, O, Oaxis; check=true)`
setcoordsystem(wing::Wing, O::Vector, Oaxis::Matrix)
Redefines the local coordinate system of the wing, where `O` is the new origin
and `Oaxis` is the matrix [i; j; k] of unit vectors
and `Oaxis` is the matrix of unit vectors
"""
function setcoordsystem(self::Wing, O::FArrWrap,
Oaxis::FMWrap;
Expand Down Expand Up @@ -361,7 +361,11 @@ function getTE(self::Wing, n::IWrap)
return TE
end

"Returns total number of lattices in the wing"
"""
get_m(wing::Wing)
Returns the number of horseshoes in the wing
"""
function get_m(self::Wing)
return self.m
end
Expand Down
37 changes: 26 additions & 11 deletions src/FLOWVLM_wingsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
# WINGSYSTEM CLASS
################################################################################
"""
`WingSystem()`
Initiates a system of wings. All method applicable to a Wing object are
WingSystem(wings::Array{Union{Wing, WingSystem}}, wing_names::Array{String})
Initiates a system of wings. All methods applicable to a Wing object are
applicable to a WingSystem. When solved, it will calculate the interaction
between wings.
"""
Expand Down Expand Up @@ -33,9 +34,10 @@ mutable struct WingSystem
end

"""
`addwing(self::WingSystem, wing_name::String, wing::Wing)`
Adds a wing to the system with the position and orientation of local reference
being interpreted in relation to the local reference frame of the system.
addwing(self::WingSystem, wing_name::String, wing::Union{Wing, Rotor})
Adds a wing (or rotor) to the system. The local reference frame of the wing
then is then in relation to the local reference frame of the System.
"""
function addwing(self::WingSystem, wing_name::String, wing;
overwrite=false, reset=true)
Expand Down Expand Up @@ -65,10 +67,11 @@ function addwing(self::WingSystem, wing_name::String, wing;
end

"""
`setcoordsystem(self, O, Oaxis; check=true, wings=String[])`
setcoordsystem(system::WingSystem, O::Vector, Oaxis::Matrix; wings=String[])
Redefines the local coordinate system of the system, where `O` is the new origin
and `Oaxis` is the matrix [i; j; k] of unit vectors. It transforms the
coordinates of all the wings in the system accordingly.
and `Oaxis` is the matrix of unit vectors. It transforms the coordinates of all
wings in the system accordingly.
To change the local coordinate system of a specific wing relative to the
system's coordinate system, give the name of the wing in an array under argument
Expand Down Expand Up @@ -162,7 +165,11 @@ function getHorseshoe(self::WingSystem, m::IWrap; t::FWrap=0.0, extraVinf...)
return getHorseshoe(wing, _m; t=t, extraVinf...)
end

"Returns total number of lattices in the wing"
"""
get_m(system::WingSystem)
Returns the total number of horseshoes in the system
"""
function get_m(self::WingSystem)
m = 0
for wing in self.wings
Expand All @@ -171,7 +178,11 @@ function get_m(self::WingSystem)
return m
end

"Returns the wing in the system under the requested name"
"""
get_wing(self::WingSystem, wing_name::String)
Returns the wing of name `wing_name`.
"""
function get_wing(self::WingSystem, wing_name::String)
wing_i = findfirst(x->x==wing_name, self.wing_names)
return get_wing(self, wing_i)
Expand All @@ -185,7 +196,11 @@ function get_wing(self::WingSystem, wing_names::Array{String,1})
return wings
end

"Returns the i-th wing in the system"
"""
get_wing(self::WingSystem, wing_i::Int)
Returns the i-th wing.
"""
function get_wing(self::WingSystem, wing_i::IWrap)
return self.wings[wing_i]
end
Expand Down

0 comments on commit 2332c3a

Please sign in to comment.