Skip to content

Commit

Permalink
get tests and docs updated with new input structure
Browse files Browse the repository at this point in the history
  • Loading branch information
juddmehr committed Sep 21, 2024
1 parent d80df0d commit 76c88f5
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 89 deletions.
2 changes: 1 addition & 1 deletion docs/src/DuctAPE/advanced_usage/outputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Sometimes, it may be desireable to return the pre-process objects, including:
In this case, we can use the `return_inputs` keyword argument when calling the `analyze` function to return a named tuple containing those pre-process objects.

```julia
outs, ins, success_flag = dt.analyze(ducted_rotor; return_inputs=true)
outs, ins, success_flag = dt.analyze(ducted_rotor, operating_point, reference_parameters; return_inputs=true)
```
2 changes: 2 additions & 0 deletions docs/src/DuctAPE/advanced_usage/precompilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ The precompiled caches can be passed in via keyword arguments to the analysis fu
```@docs; canonical=false
DuctAPE.analyze(
ducted_rotor::DuctedRotor,
operating_point::OperatingPoint,
reference_parameters::ReferenceParameters,
options::Options=set_options())
```
1 change: 0 additions & 1 deletion docs/src/DuctAPE/api/private_utilities.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## Utility Functions
```@docs
DuctAPE.promote_ducted_rotor_type
DuctAPE.update_operating_point!
DuctAPE.isscalar
DuctAPE.dot
DuctAPE.norm
Expand Down
4 changes: 2 additions & 2 deletions docs/src/DuctAPE/api/public_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Depth = 5

## Input Types
```@docs
DuctAPE.DuctedRotor
DuctAPE.PanelingConstants
DuctAPE.Rotor
DuctAPE.DuctedRotor
DuctAPE.OperatingPoint
DuctAPE.PanelingConstants
DuctAPE.ReferenceParameters
```

Expand Down
91 changes: 45 additions & 46 deletions docs/src/DuctAPE/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,30 +282,6 @@ plot!( # hide
In addition there are untested cascade types with similar structure to CCBlades airfoil types called `DTCascade`.
Furthermore, there is an experimental actuator disk model implemented via the `ADM` airfoil type in C4Blade.

### Operating Point

Next we will assemble the operating point which contains information about the freestream as well as the rotor rotation rate(s).

```@docs; canonical=false
DuctAPE.OperatingPoint
```

```@example tutorial
# Freestream
Vinf = 0.0 # hover condition
rhoinf = 1.226
asound = 340.0
muinf = 1.78e-5
# Rotation Rate
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 = 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.
Expand Down Expand Up @@ -345,6 +321,44 @@ paneling_constants = DuctAPE.PanelingConstants(
)
nothing # hide
```
### Assembling the DuctedRotor

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

```@example tutorial
# assemble ducted_rotor object
ducted_rotor = DuctAPE.DuctedRotor(
duct_coordinates,
centerbody_coordinates,
rotor,
paneling_constants,
)
nothing # hide
```

### Operating Point

Next we will assemble the operating point which contains information about the freestream as well as the rotor rotation rate(s).

```@docs; canonical=false
DuctAPE.OperatingPoint
```

```@example tutorial
# Freestream
Vinf = 0.0 # hover condition
rhoinf = 1.226
asound = 340.0
muinf = 1.78e-5
# Rotation Rate
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 = DuctAPE.OperatingPoint(Vinf, rhoinf, muinf, asound, Omega)
nothing # hide
```

### Reference Parameters

Expand All @@ -366,22 +380,6 @@ reference_parameters = DuctAPE.ReferenceParameters([Vref], [Rref])
nothing # hide
```

### Assembling the DuctedRotor

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

```@example tutorial
# assemble ducted_rotor object
ducted_rotor = DuctAPE.DuctedRotor(
duct_coordinates,
centerbody_coordinates,
rotor,
operating_point,
paneling_constants,
reference_parameters,
)
nothing # hide
```

## Set Options

Expand All @@ -403,11 +401,11 @@ With the ducted_rotor input build, and the options selected, we are now ready to
This is done simply with the `analyze` function which dispatches the appropriate analysis, solve, and post-processing functions based on the selected options.

```@docs; canonical=false
DuctAPE.analyze(::DuctAPE.DuctedRotor, ::DuctAPE.Options)
DuctAPE.analyze(::DuctAPE.DuctedRotor, ::DuctAPE.OperatingPoint, ::DuctAPE.ReferenceParameters, ::DuctAPE.Options)
```

```@example tutorial
outs, success_flag = DuctAPE.analyze(ducted_rotor, options)
outs, success_flag = DuctAPE.analyze(ducted_rotor, operating_point, reference_parameters, options)
nothing # hide
```

Expand All @@ -429,7 +427,7 @@ outs.totals.CQ
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},ducted_rotor::DuctedRotor,options::Options) where TO<:OperatingPoint
DuctAPE.analyze(ducted_rotor::DuctedRotor,operating_point::AbstractVector{TO},reference_parameters::ReferenceParameters,options::Options) where TO<:OperatingPoint
```

Running a multi-point analysis on the example geometry given there, it might look something like this:
Expand All @@ -444,13 +442,13 @@ n = RPM / 60.0 # rotation rate in revolutions per second
Vinfs = Js * n * D
# - Set Operating Points - #
ops = [deepcopy(operating_point) for i in 1:length(Vinfs)]
operating_points = [deepcopy(operating_point) for i in 1:length(Vinfs)]
for (iv, v) in enumerate(Vinfs)
ops[iv].Vinf[] = v
operating_points[iv].Vinf[] = v
end
# - Run Multi-point Analysis - #
outs_vec, success_flags = DuctAPE.analyze(ops, ducted_rotor, DuctAPE.set_options(ops))
outs_vec, success_flags = DuctAPE.analyze(ducted_rotor, operating_points, reference_parameters, DuctAPE.set_options(operating_points))
nothing #hide
```

Expand Down Expand Up @@ -516,6 +514,7 @@ nothing #hide
And then we can plot the data to compare DFDC and DuctAPE.

```@example tutorial
using Plots
# set up efficiency plot
pe = plot(; xlabel="Advance Ratio", ylabel="Efficiency")
Expand Down
5 changes: 3 additions & 2 deletions src/analysis/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ function setup_analysis(
)

# copy over operating point
for f in fieldnames(typeof(ducted_rotor.operating_point))
solve_parameter_tuple.operating_point[f] .= getfield(ducted_rotor.operating_point, f)
for f in fieldnames(typeof(operating_point))
solve_parameter_tuple.operating_point[f] .= getfield(operating_point, f)
end

##### ----- PERFORM PREPROCESSING COMPUTATIONS ----- #####
Expand All @@ -134,6 +134,7 @@ function setup_analysis(
solve_parameter_tuple.linsys,
solve_parameter_tuple.wakeK,
ducted_rotor,
operating_point,
prepost_containers,
problem_dimensions;
grid_solver_options=options.grid_solver_options,
Expand Down
12 changes: 8 additions & 4 deletions src/preprocess/preprocess.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,8 @@ end

"""
precompute_parameters(
ducted_rotor;
ducted_rotor,
operating_point;
grid_solver_options=GridSolverOptions(),
integration_options=IntegrationOptions(),
autoshiftduct=true,
Expand All @@ -1144,7 +1145,8 @@ end
Out of place main pre-processing function that computes all the required parameters for the solve.
# Arguments
- `ducted_rotor::DuctedRotor` : A Propuslor object
- `ducted_rotor::DuctedRotor` : A DuctedRotor object
- `operating_point::OperatingPoint` : A OperatingPoint object
# Keyword Arguments
- `grid_solver_options::GridSolverOptionsType=GridSolverOptions()` : A GridSolverOptionsType object
Expand Down Expand Up @@ -1181,7 +1183,8 @@ Out of place main pre-processing function that computes all the required paramet
- `problem_dimensions::ProblemDimensions` : A ProblemDimensions object
"""
function precompute_parameters(
ducted_rotor;
ducted_rotor,
operating_point;
grid_solver_options=GridSolverOptions(),
integration_options=IntegrationOptions(),
autoshiftduct=true,
Expand Down Expand Up @@ -1388,6 +1391,7 @@ end
linsys,
wakeK,
ducted_rotor,
operating_point,
prepost_containers,
problem_dimensions;
grid_solver_options=GridSolverOptions(),
Expand All @@ -1410,6 +1414,7 @@ function precompute_parameters!(
linsys,
wakeK,
ducted_rotor,
operating_point,
prepost_containers,
problem_dimensions;
grid_solver_options=GridSolverOptions(),
Expand All @@ -1429,7 +1434,6 @@ function precompute_parameters!(
centerbody_coordinates,
rotor,
paneling_constants,
operating_point,
) = ducted_rotor

# - Unpack preprocess containers - #
Expand Down
4 changes: 1 addition & 3 deletions src/utilities/inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function Rotor(
end

"""
DuctedRotor(duct_coordinates, centerbody_coordinates, rotor, operating_point, paneling_constants, reference_parameters)
DuctedRotor(duct_coordinates, centerbody_coordinates, rotor, paneling_constants)
# Arguments
Expand All @@ -169,10 +169,8 @@ end
struct DuctedRotor{
Td<:AbstractMatrix,
Tcb<:AbstractMatrix,
Top<:OperatingPoint,
Tpc<:PanelingConstants,
Trp<:Rotor,
Tref<:ReferenceParameters,
}
duct_coordinates::Td
centerbody_coordinates::Tcb
Expand Down
21 changes: 0 additions & 21 deletions test/data/basic_two_rotor_for_test_NEW.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,5 @@ ducted_rotor = dt.DuctedRotor(
duct_coordinates,
centerbody_coordinates,
rotor,
operating_point,
paneling_constants,
reference_parameters,
)
#
#
#
#
#
# plot(
# duct_coordinates[:, 1],
# duct_coordinates[:, 2] .- 0.75;
# aspectratio=1,
# marker=true,
# label="",
# )
# plot!(hub_coordinates[:, 1], hub_coordinates[:, 2]; marker=true, label="")

# for i in 1:length(rotorzloc)
# plot!([rotorzloc[i], rotorzloc[i]], [Rhub, Rtip]; marker=true, label="", color=3)
# end
# plot!()

6 changes: 2 additions & 4 deletions test/iteration_step_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ println("\nITERATION STEP THROUGH TESTS")
rp_duct_coordinates,
rp_centerbody_coordinates,
rotor,
operating_point,
paneling_constants,
reference_parameters,
)

options = dt.DFDC_options(;
Expand Down Expand Up @@ -97,8 +95,8 @@ println("\nITERATION STEP THROUGH TESTS")
)

# copy over operating point
for f in fieldnames(typeof(ducted_rotor.operating_point))
solve_parameter_tuple.operating_point[f] .= getfield(ducted_rotor.operating_point, f)
for f in fieldnames(typeof(operating_point))
solve_parameter_tuple.operating_point[f] .= getfield(operating_point, f)
end

# generate inputs
Expand Down
Loading

0 comments on commit 76c88f5

Please sign in to comment.