Skip to content

Commit

Permalink
update docs/docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
juddmehr committed Aug 27, 2024
1 parent f6ab8c7 commit 7fedaa5
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 180 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ DuctAPE is a code for the aerodynamic evaluation of axisymmetric ducted propulso
It is strongly influenced by the underlying [theory](https://web.mit.edu/drela/Public/web/dfdc/DFDCtheory12-31.pdf) of Ducted Fan Design Code [(DFDC)](https://web.mit.edu/drela/Public/web/dfdc/), utilizing a linear axisymmetric vortex panel method for duct and center body, blade element lifting line rotor representation, and psuedo wake-screw wake model axisymmetrically smeared onto an elliptic grid for efficient computation.

DuctAPE has been developed specifically for applications in gradient-based optimization settings. <!-- add citations later -->
The selected solver methods have been chosen to balance code efficiency as well as robustness while simultaneously allowing for efficient automatic differentiation through DuctAPE employing [ImplicitAD.jl](https://flow.byu.edu/ImplicitAD.jl/dev/).
At the same time, the basic functionality of a DFDC-like solve approach has been maintained for the interested user.
The default solver methods have been chosen to balance code efficiency as well as robustness while simultaneously allowing for efficient automatic differentiation through DuctAPE employing [ImplicitAD.jl](https://flow.byu.edu/ImplicitAD.jl/dev/).
3 changes: 2 additions & 1 deletion docs/src/DuctAPE/advanced_usage/outputs.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Available Outputs

The output tuple contains many items.
The [`post_process`](@ref "DuctAPE.post_process") function docstring lists them:
The [`post_process`](@ref "DuctAPE.post_process") function docstring lists them.
The purpose of showing this function here is not for you to manually run the fuction or apply any advanced usage, but simply rather for you to see what the available outputs are, as several of them may apply to advanced usage cases.

```@docs; canonical=false
DuctAPE.post_process
Expand Down
44 changes: 44 additions & 0 deletions docs/src/DuctAPE/advanced_usage/precompilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,50 @@ You may run all these simultaneously using the `initialize_all_caches` function.
DuctAPE.initialize_all_caches
```

As an example of how to run this function, we'll grab [solver options](@ref "Aerodynamics Solvers") and [oaneling constants](@ref "Paneling Constants") from previous examples

```@julia
# - grab an object of SolverOptionsType defined in a previous example - #
aero_solver_options = DuctAPE.NLsolveOptions(;
algorithm=:newton,
atol=1e-10,
iteration_limite=30,
linesearch_method=LineSearches.BackTracking, #don't include parentheses on method handle
linesearch_kwargs=(; order=3, maxstep=1e6),
additional_kwargs=(; autoscale=false),
)
# - grab an object of PanelingConstants type from the Getting Started tutorial - #
# number of panels for the duct inlet
nduct_inlet = 30
# number of panels for the center body inlet
ncenterbody_inlet = 30
# number of panels from:
# - rotor to duct trailing edge
# - duct trailing edge to center body trailing edge
# - center body trailing edge to end of wake
npanels = [30, 1, 30]
# the duct trailing edge is ahead of the centerbody trailing edge.
dte_minus_cbte = -1.0
# number of wake sheets (one more than blade elements to use)
nwake_sheets = 11
# non-dimensional wake length aft of rear-most trailing edge
wake_length = 0.8
# assemble paneling constants
paneling_constants = DuctAPE.PanelingConstants(
nduct_inlet, ncenterbody_inlet, npanels, dte_minus_cbte, nwake_sheets, wake_length
)
# - Initialize Caches - #
prepost_container_caching, solve_parameter_caching, solve_container_caching = DuctAPE.initialize_all_caches(aero_solver_options, paneling_constants)
```

## How to pass the caches into an analysis

The precompiled caches can be passed in via keyword arguments to the analysis functions. If they are not, they are generated as the first step in the analysis.
Expand Down
81 changes: 41 additions & 40 deletions docs/src/DuctAPE/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ Pages = ["tutorial.md"]
Depth = 5
```

The following is a basic tutorial on how to set up the inputs to, and run, an analysis of a ducted fan in DuctAPE.
The following is a basic tutorial on how to set up and run an analysis of a ducted fan in DuctAPE.

```@setup tutorial
include("../assets/plots_default.jl")
gr()
```

We begin by loading the package, and optionally create a shorthand name.
We begin by loading the package:

```@example tutorial
using DuctAPE
const dt = DuctAPE
nothing # hide
```

Expand All @@ -31,7 +30,8 @@ DuctAPE.Propulsor

### Body Geometry

We begin by defining a matrix of coordinates for the duct and another for the centerbody geometries, for example:
We begin by defining a matrix of coordinates for the duct and another for the centerbody geometries.
For example:

```@example tutorial
duct_coordinates = [
Expand Down Expand Up @@ -139,24 +139,24 @@ nothing # hide
```

```@example tutorial
pg = plot(
duct_coordinates[:, 1],
duct_coordinates[:, 2];
aspectratio=1,
color=1,
linewidth=2,
label="Duct",
xlabel="z",
ylabel="r",
legend=:left,
pg = plot( # hide
duct_coordinates[:, 1], # hide
duct_coordinates[:, 2]; # hide
aspectratio=1, # hide
color=1, # hide
linewidth=2, # hide
label="Duct", # hide
xlabel="z", # hide
ylabel="r", # hide
legend=:left, # hide
) # hide
plot!(
pg,
centerbody_coordinates[:, 1],
centerbody_coordinates[:, 2];
color=2,
linewidth=2,
label="Center Body",
plot!( # hide
pg, # hide
centerbody_coordinates[:, 1], # hide
centerbody_coordinates[:, 2]; # hide
color=2, # hide
linewidth=2, # hide
label="Center Body", # hide
) # hide
```

Expand Down Expand Up @@ -249,7 +249,7 @@ afparams = DuctAPE.c4b.DFDCairfoil(;
airfoils = fill(afparams, length(r)) # specify the airfoil array
# assemble rotor parameters
rotorstator_parameters = dt.RotorStatorParameters(
rotorstator_parameters = DuctAPE.RotorStatorParameters(
[B],
[rotorzloc],
r,
Expand All @@ -265,14 +265,14 @@ nothing # hide
```

```@example tutorial
plot!(
pg,
rotorzloc * ones(length(r)),
r .* Rtip;
seriestype=:scatter,
markersize=3,
markerstrokewidth=0,
label="Blade Elements",
plot!( # hide
pg, # hide
rotorzloc * ones(length(r)), # hide
r .* Rtip; # hide
seriestype=:scatter, # hide
markersize=3, # hide
markerstrokewidth=0, # hide
label="Blade Elements", # hide
) # hide
```

Expand Down Expand Up @@ -302,13 +302,14 @@ RPM = 8000.0
Omega = RPM * pi / 30 # if using RPM, be sure to convert to rad/s
# utilizing the constructor function to put things in vector types
operating_point = dt.OperatingPoint(Vinf, rhoinf, muinf, asound, Omega)
operating_point = DuctAPE.OperatingPoint(Vinf, rhoinf, muinf, asound, Omega)
nothing # hide
```

### Paneling Constants

The `PanelingConstants` object contains the constants required for DuctAPE to re-panel the provided geometry into a format compatible with the solve structure.
Specifically, the DuctAPE solver makes some assumptions on the relative positioning of the body surfaces relative to the wakes and each other; and this is most easily guarenteed by a re-paneling of the provided body surface geometry.
The `PanelingConstants` object is also used to build all of the preallocated caches inside DuctAPE, which can be done up-front if desired.
Note that there is some functionality in place for cases when the user wants to keep their own specified geometry, but this functionality should be used with caution and only by users who are certain their provided geometry is in the compatible format. See the [Examples](@ref "Circumventing the Automated Geometry Re-paneling") for an example.

Expand Down Expand Up @@ -339,7 +340,7 @@ nwake_sheets = 11
wake_length = 0.8
# assemble paneling constants
paneling_constants = dt.PanelingConstants(
paneling_constants = DuctAPE.PanelingConstants(
nduct_inlet, ncenterbody_inlet, npanels, dte_minus_cbte, nwake_sheets, wake_length
)
nothing # hide
Expand All @@ -361,17 +362,17 @@ Vref = 50.0
Rref = Rtip
# assemble reference parameters
reference_parameters = dt.ReferenceParameters([Vref], [Rref])
reference_parameters = DuctAPE.ReferenceParameters([Vref], [Rref])
nothing # hide
```

### All Together
### Assembling the Propulsor

We are now posed to construct the `Propulsor` input type.

```@example tutorial
# assemble propulsor object
propulsor = dt.Propulsor(
propulsor = DuctAPE.Propulsor(
duct_coordinates,
centerbody_coordinates,
rotorstator_parameters,
Expand All @@ -391,7 +392,7 @@ DuctAPE.set_options
```

```@example tutorial
options = dt.set_options()
options = DuctAPE.set_options()
```

For more advanced option selection, see the examples and API reference.
Expand All @@ -406,13 +407,13 @@ DuctAPE.analyze(::DuctAPE.Propulsor, ::DuctAPE.Options)
```

```@example tutorial
outs, success_flag = dt.analyze(propulsor, options)
outs, success_flag = DuctAPE.analyze(propulsor, options)
nothing # hide
```

### Single Run Outputs

There are many outputs contained in the named tuple output from the `analyze` function (see the [post_process() docstring](@ref DuctAPE.post_process)), but some that may be of immediate interest include:
There are many outputs contained in the named tuple output from the `analyze` function (see the [post_process docstring](@ref DuctAPE.post_process)), but some that may be of immediate interest include:

```@example tutorial
# Total Thrust Coefficient
Expand All @@ -425,7 +426,7 @@ outs.totals.CQ

## Run a Multi-Point Analysis

In the case that one wants to run the same geometry at several different operating points, for example: for a range of advance ratios, there is another dispatch of the `analyze` function that takes in an input, `multipoint`, that is a vector of operating points.
In the case that one wants to run the same geometry at several different operating points, for example: for a range of advance ratios, there is another dispatch of the `analyze` function that accepts an input, `multipoint`, that is a vector of operating points.

```@docs; canonical=false
DuctAPE.analyze(multipoint::AbstractVector{TO},propulsor::Propulsor,options::Options) where TO<:OperatingPoint
Expand Down Expand Up @@ -455,7 +456,7 @@ nothing #hide

There are a few things to note here.
1. We want to make sure that the operating point objects we put into the input vector are unique instances.
2. We need to use the dispatch of `set_options` that takes in the operating point vector to set up the right number of things in the background (like convergence flags for each operating point).
2. We need to use the dispatch of `set_options` that accepts the operating point vector to set up the right number of things in the background (like convergence flags for each operating point).
3. The outputs of the analysis are vectors of the same outputs for a single analysis.

### Multi-point Outputs
Expand Down
16 changes: 8 additions & 8 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# DuctAPE.jl [[Duct](#)ed [A](#)xisymmetric [P](#)ropulsor [E](#)valuation]

Authors: Judd Mehr,
Author: Judd Mehr

Contributers: Taylor McDonnell,
Contributer: Taylor McDonnell

DuctAPE is a code for the aerodynamic evaluation of axisymmetric ducted propulsors designed for incompressible (low mach) applications.
It is strongly influenced by the underlying [theory](https://web.mit.edu/drela/Public/web/dfdc/DFDCtheory12-31.pdf) of Ducted Fan Design Code [(DFDC)](https://web.mit.edu/drela/Public/web/dfdc/), utilizing a linear axisymmetric vortex panel method for duct and center body, blade element lifting line rotor representation, and wake model axisymmetrically smeared onto an elliptic grid for efficient computation.
Expand All @@ -12,16 +12,16 @@ DuctAPE has been developed specifically for applications in gradient-based optim
### Installation

```julia
pkg> add DuctAPE
pkg> add https://github.com/byuflowlab/DuctAPE.jl.git
```

### Documentation

- Start with [Getting Started](@ref) to get up and running.
- The Advanced Usage tab includes several pages of additional information for customizing your usage.
- The API tab contains public and private method descriptions.
- The Theory tab contain several pages on the underlying theory of DuctAPE.
- The C$^4$Blade tab contains documentation for the C$^4$Blade submodule used for airfoil/cascade management within DuctAPE as well as state initialization.
- [Getting Started](@ref) will have you up and running quickly.
- The [Advanced Usage](@ref "Advanced Option Selection") tab includes several pages of additional information for customizing your usage.
- The [API](@ref "Public API") tab contains public and private method descriptions.
- The [Theory](@ref) tab contain several pages on the underlying theory of DuctAPE.
- The [C$^4$Blade](@ref "C$^\textrm{4}$Blade [[C](#)ascade [C](#)ompatible [CCBlade](https://flow.byu.edu/CCBlade.jl/stable/)]") tab contains documentation for the C$^4$Blade submodule used for airfoil/cascade management within DuctAPE as well as state initialization.

### Citing

Expand Down
6 changes: 3 additions & 3 deletions src/utilities/caching/allocate_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ OR
- `problem_dimensions::ProblemDimensions` : a ProblemDimensions object
# Keyword Arguments
- `fd_chunk_size::Int=12` : chunk size to use for PreallocationTools caches. Note that the automated chuck size for DuctAPE will always be the ForwardDiff threshold of 12 due to the size of the system, so it will be best to leave this at the default unless further development allows for chunk size selection for individual solvers.
- `fd_chunk_size::Int=12` : chunk size to use for PreallocationTools caches. Note that the automated chunk size for DuctAPE will always be the ForwardDiff threshold of 12 due to the size of the system, so it will be best to leave this at the default unless further development allows for chunk size selection for individual solvers.
- `levels::Int=1` : levels for nested duals. Note that since ImplicitAD is being used for all solves, there should be no need for more than 1 level.
Expand Down Expand Up @@ -620,7 +620,7 @@ OR
- `problem_dimensions::ProblemDimensions` : a ProblemDimensions object used for sizing
# Keyword Arguments
- `fd_chunk_size::Int=12` : chunk size to use for PreallocationTools caches. Note that the automated chuck size for DuctAPE will always be the ForwardDiff threshold of 12 due to the size of the system, so it will be best to leave this at the default unless further development allows for chunk size selection for individual solvers.
- `fd_chunk_size::Int=12` : chunk size to use for PreallocationTools caches. Note that the automated chunk size for DuctAPE will always be the ForwardDiff threshold of 12 due to the size of the system, so it will be best to leave this at the default unless further development allows for chunk size selection for individual solvers.
- `levels::Int=1` : levels for nested duals. Note that since ImplicitAD is being used for all solves, there should be no need for more than 1 level.
# Returns
Expand Down Expand Up @@ -1048,7 +1048,7 @@ OR
- `problem_dimensions::ProblemDimensions` : a ProblemDimensions object
# Keyword Arguments
- `fd_chunk_size::Int=12` : chunk size to use for PreallocationTools caches. Note that the automated chuck size for DuctAPE will always be the ForwardDiff threshold of 12 due to the size of the system, so it will be best to leave this at the default unless further development allows for chunk size selection for individual solvers.
- `fd_chunk_size::Int=12` : chunk size to use for PreallocationTools caches. Note that the automated chunk size for DuctAPE will always be the ForwardDiff threshold of 12 due to the size of the system, so it will be best to leave this at the default unless further development allows for chunk size selection for individual solvers.
- `levels::Int=1` : levels for nested duals. Note that since ImplicitAD is being used for all solves, there should be no need for more than 1 level.
# Returns
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/caching/caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Convenience function to initialize all caches before calling analysis.
- `paneling_constants::PanelingConstants` : PanelingConstants object upon which all cache sizing depends
# Keyword Arguments
- `fd_chunk_size::Int=12` : chunk size to use for PreallocationTools caches. Note that the automated chuck size for DuctAPE will always be the ForwardDiff threshold of 12 due to the size of the system, so it will be best to leave this at the default unless further development allows for chunk size selection for individual solvers.
- `fd_chunk_size::Int=12` : chunk size to use for PreallocationTools caches. Note that the automated chunk size for DuctAPE will always be the ForwardDiff threshold of 12 due to the size of the system, so it will be best to leave this at the default unless further development allows for chunk size selection for individual solvers.
- `levels::Int=1` : levels for nested duals. Note that since ImplicitAD is being used for all solves, there should be no need for more than 1 level.
Expand Down
6 changes: 1 addition & 5 deletions src/utilities/inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
Propulsor operating point information.
Note that the actual struct requires the inputs to be arrays, but there is a constructor function that will take in scalars and automatically build the array-based struct.
Also note that even though each field is required to be a vector, only `Omega` should have more than one entry, and only then if there are more than one rotor. The purpose behind having vector rather than constant scalar inputs here is for ease of redefinition in an optimization setting when freestream design variables may be present.
# Arguments
- `Vinf::AbstractVector{Float}` : Freestream velocity magnitude (which is only in the axial direction).
Expand Down Expand Up @@ -113,7 +109,7 @@ Note that the actual struct requires the inputs to be arrays, but there is a con
- `twists::AbstractArray{Float}` : Blade element angles, in radians.
- `tip_gap::AbstractVector{Float}` : Currently unused, do not set to anything other than zeros.
- `airfoils::AbstractArray{AFType}` : Airfoil types describing the airfoil polars for each blade element. Currently only fully tested with `C4Blade.DFDCairfoil` types.
- `fliplift::AbstractVector{Bool}` : flag to indicate if the airfoil lift values should be flipped or not.
- `fliplift::AbstractVector{Bool}` : Flag to indicate if the airfoil lift values should be flipped or not.
"""
struct RotorStatorParameters{
Tb<:AbstractVector,
Expand Down
Loading

0 comments on commit 7fedaa5

Please sign in to comment.