From 3018693d403186a022b9671067587b2f8a776b41 Mon Sep 17 00:00:00 2001 From: juddmehr Date: Sat, 28 Sep 2024 16:07:10 -0600 Subject: [PATCH] fix typos, minor adjustments --- src/analysis/analyses.jl | 11 ++++---- src/postprocess/boundary_layer.jl | 10 +++---- .../geometry/elliptic_grid_residuals.jl | 1 + src/preprocess/geometry/wake_geometry.jl | 11 ++++++++ src/process/solve.jl | 28 +++++++++++++------ src/utilities/options.jl | 6 ++-- 6 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/analysis/analyses.jl b/src/analysis/analyses.jl index 8489cef7..a15c9e67 100644 --- a/src/analysis/analyses.jl +++ b/src/analysis/analyses.jl @@ -10,7 +10,7 @@ return_inputs=false, ) -Analyze ducted_rotor, including preprocessing. +Analyze `ducted_rotor`, including preprocessing. # Arguments - `ducted_rotor::DuctedRotor` : DuctedRotor input object (see docstring for `DuctedRotor` type) @@ -109,7 +109,7 @@ end solve_container_caching=nothing, ) -Analyze ducted_rotor, assuming `setup_analysis` has been called and the outputs thereof are being passed in here. +Analyze `ducted_rotor`, assuming `setup_analysis` has been called and the outputs thereof are being passed in here. # Arguments - `ducted_rotor::DuctedRotor` : DuctedRotor input object (see docstring for `DuctedRotor` type) @@ -230,7 +230,7 @@ end return_inputs=false, ) -Analyze ducted_rotor, including preprocessing, for a set of operating points. +Analyze `ducted_rotor`, including preprocessing, for a set of operating points. # Arguments - `ducted_rotor::DuctedRotor` : DuctedRotor input object @@ -285,7 +285,8 @@ function analyze( #TODO: write a function that returns the same as outs below, but all zeros #TODO: probably just call the post-process function directly and return a reset_container! of the output return [],#zero_outputs(), - (; solve_parameter_tuple..., ivb, airfoils, idmaps, panels, problem_dimensions), + # (; solve_parameter_tuple..., ivb, airfoils, idmaps, panels, problem_dimensions), + (;), false end @@ -323,7 +324,7 @@ end solve_container_caching=nothing, ) -Analyze ducted_rotor, assuming `setup_analysis` has been called and the inputs are being passed in here. +Analyze `ducted_rotor`, assuming `setup_analysis` has been called and the inputs are being passed in here. # Arguments - `ducted_rotor::DuctedRotor` : DuctedRotor input object diff --git a/src/postprocess/boundary_layer.jl b/src/postprocess/boundary_layer.jl index 488499df..41352b7d 100644 --- a/src/postprocess/boundary_layer.jl +++ b/src/postprocess/boundary_layer.jl @@ -517,12 +517,12 @@ function solve_turbulent_boundary_layer_rk4!(f, init, params, svec; s_init_defau end if sep[1] == true - u1sep = FLOWMath(Cfs[(sepid - 1):sepid], us[1, (sepid - 1):sepid], 0.0) - u2sep = FLOWMath(Cfs[(sepid - 1):sepid], us[2, (sepid - 1):sepid], 0.0) - u3sep = FLOWMath(Cfs[(sepid - 1):sepid], us[3, (sepid - 1):sepid], 0.0) + u1sep = FLOWMath.akima(Cfs[(sepid - 1):sepid], us[1, (sepid - 1):sepid], 0.0) + u2sep = FLOWMath.akima(Cfs[(sepid - 1):sepid], us[2, (sepid - 1):sepid], 0.0) + u3sep = FLOWMath.akima(Cfs[(sepid - 1):sepid], us[3, (sepid - 1):sepid], 0.0) usep = [u1sep; u2sep; u3sep] - H12sep = FLOWMath(Cfs[(sepid - 1):sepid], H12s[(sepid - 1):sepid], 0.0) - ssep = FLOWMath(Cfs[(sepid - 1):sepid], svec[(sepid - 1):sepid], 0.0) + H12sep = FLOWMath.akima(Cfs[(sepid - 1):sepid], H12s[(sepid - 1):sepid], 0.0) + ssep = FLOWMath.akima(Cfs[(sepid - 1):sepid], svec[(sepid - 1):sepid], 0.0) else usep = us[:, end] H12sep = H12s[end] diff --git a/src/preprocess/geometry/elliptic_grid_residuals.jl b/src/preprocess/geometry/elliptic_grid_residuals.jl index 8b7d6814..1bf8e902 100644 --- a/src/preprocess/geometry/elliptic_grid_residuals.jl +++ b/src/preprocess/geometry/elliptic_grid_residuals.jl @@ -424,6 +424,7 @@ function solve_elliptic_grid(x, p) method=p.algorithm, autodiff=p.autodiff, linsolve=(x, A, b) -> x .= ImplicitAD.implicit_linear(A, b), + # linesearch=LineSearches.Backtracking(), ftol=p.atol, iterations=p.iteration_limit, show_trace=p.verbose, diff --git a/src/preprocess/geometry/wake_geometry.jl b/src/preprocess/geometry/wake_geometry.jl index d5160e2b..97b0ff75 100644 --- a/src/preprocess/geometry/wake_geometry.jl +++ b/src/preprocess/geometry/wake_geometry.jl @@ -375,6 +375,17 @@ function relax_grid!( println(tabchar^ntab * "Solving Elliptic Grid System using $(grid_solver_options.algorithm) Method") end + # # precondition + # relax_grid!( + # wake_grid; + # iteration_limit=grid_solver_options.iteration_limit, + # atol=grid_solver_options.atol, + # converged=grid_solver_options.converged, + # verbose=verbose, + # tabchar="\t", + # ntab=1, + # ) + # solve solve_elliptic_grid!( wake_grid; diff --git a/src/process/solve.jl b/src/process/solve.jl index 7a687a29..ce470bdd 100644 --- a/src/process/solve.jl +++ b/src/process/solve.jl @@ -98,7 +98,7 @@ function solve( TF = eltype(sensitivity_parameters) # resid = 999 * ones(TF, length(state_variables)) - resid = 999*ones(TF,2) + resid = 999 * ones(TF, 2) conv = @view(solver_options.converged[multipoint_index[]]) iter = @view(solver_options.iterations[multipoint_index[]]) .= 0 @@ -887,8 +887,13 @@ function solve( # If there is only one solver, or if the first solver converged, return the solution if length(solver_options.solvers) == 1 || solver_options.solvers[1].converged[const_cache.multipoint_index[]] - solver_options.converged[const_cache.multipoint_index[]] = solver_options.solvers[1].converged[const_cache.multipoint_index[]] - solver_options.iterations[const_cache.multipoint_index[]] = solver_options.solvers[1].iterations[const_cache.multipoint_index[]] + + # set converged flags for the first solver across all solvers + solver_options.converged[:, const_cache.multipoint_index[]] .= solver_options.solvers[1].converged[const_cache.multipoint_index[]] + + # set iteration count for only the first solver + solver_options.iterations[1, const_cache.multipoint_index[]] = solver_options.solvers[1].iterations[const_cache.multipoint_index[]] + return solution end @@ -902,16 +907,19 @@ function solve( initial_guess=initial_guess, ) + # set this and the remaining convergence flags + solver_options.converged[(s + 1):end, const_cache.multipoint_index[]] .= sopt.converged[const_cache.multipoint_index[]] + + # set this iteration count + solver_options.iterations[s + 1, const_cache.multipoint_index[]] = sopt.iterations[const_cache.multipoint_index[]] + + # if the solver converged, return if sopt.converged[const_cache.multipoint_index[]] - solver_options.converged[s + 1, const_cache.multipoint_index[]] = sopt.converged[const_cache.multipoint_index[]] - solver_options.iterations[s + 1, const_cache.multipoint_index[]] = sopt.iterations[const_cache.multipoint_index[]] return solution - else - solver_options.converged[s + 1, const_cache.multipoint_index[]] = solver_options.solvers[end].converged[const_cache.multipoint_index[]] - solver_options.iterations[s + 1, const_cache.multipoint_index[]] = solver_options.solvers[end].iterations[const_cache.multipoint_index[]] end end + # run final solver solution = solve( solver_options.solvers[end], sensitivity_parameters, @@ -919,8 +927,12 @@ function solve( initial_guess=initial_guess, ) + # set final convergence flag solver_options.converged[end, const_cache.multipoint_index[]] = solver_options.solvers[end].converged[const_cache.multipoint_index[]] + + # set final iteration count solver_options.iterations[end, const_cache.multipoint_index[]] = solver_options.solvers[end].iterations[const_cache.multipoint_index[]] + return solution else diff --git a/src/utilities/options.jl b/src/utilities/options.jl index 46420391..5697ffd9 100644 --- a/src/utilities/options.jl +++ b/src/utilities/options.jl @@ -636,9 +636,9 @@ Options for SLOR + Newton elliptic grid solver. - `iterations::AbstractArray{Int} = [0]` : iteration counter """ @kwdef struct GridSolverOptions{TB,TF,TI,TSym} <: GridSolverOptionsType - iteration_limit::TI = 100 - atol::TF = 1e-10 - algorithm::TSym = :trust_region + iteration_limit::TI = 10 + atol::TF = 2e-10 + algorithm::TSym = :newton autodiff::TSym = :forward converged::AbstractArray{TB} = [false] iterations::AbstractArray{TI} = [0]