Skip to content

Commit

Permalink
minor cleanup while trying to locate new bug
Browse files Browse the repository at this point in the history
  • Loading branch information
juddmehr committed Apr 16, 2024
1 parent 66005dc commit 39d07d8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 33 deletions.
6 changes: 1 addition & 5 deletions src/preprocess/geometry/wake_geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,6 @@ function generate_wake_grid(
tip_gap1,
zwake;
grid_solver_options=GridSolverOptions(),
# atol=1e-14,
# iteration_limit=100,
# relaxation_iteration_limit=3,
# relaxation_atol=1e-14,
verbose=false,
silence_warnings=true,
)
Expand All @@ -210,7 +206,7 @@ function generate_wake_grid(
Rtip1,
tip_gap1,
zwake;
grid_solver_options=GridSolverOptions(),
grid_solver_options=grid_solver_options,
verbose=verbose,
silence_warnings=silence_warnings,
)
Expand Down
4 changes: 2 additions & 2 deletions src/process/aerodynamics/body_aerodynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ function calculate_body_vortex_strengths!(
end
end

# return ImplicitAD.implicit_linear(A_bb, gamb; lsolve=ldiv!, Af=A_bb_LU)
gamb .= ImplicitAD.implicit_linear(A_bb, rhs; lsolve=ldiv!, Af=A_bb_LU)
return gamb

# gamb .= A_bb_LU \ rhs
# return gamb
end

end
25 changes: 13 additions & 12 deletions src/process/aerodynamics/rotor_aerodynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ end
function calculate_rotor_source_strengths!(sigr, Wmag_rotor, chords, B, cd)

# Loop through rotors
for irotor in eachindex(B)
for irotor in axes(sigr,2)

# Loop through blade panel nodes
for inode in axes(sigr, 1)
Expand Down Expand Up @@ -286,32 +286,33 @@ function calculate_blade_element_coefficients!(
for ir in 1:nr

# extract blade element properties
B = @view(be.B[irotor]) # number of blades
fliplift = @view(be.fliplift[irotor])
c = @view(be.chords[ir, irotor]) # chord length
stagger = @view(be.stagger[ir, irotor])
solidity = @view(be.solidity[ir, irotor])
# TODO: consider not renaming these to avoid the small allocation
B = be.B[irotor] # number of blades
fliplift = be.fliplift[irotor]
c = be.chords[ir, irotor] # chord length
stagger = be.stagger[ir, irotor]
solidity = be.solidity[ir, irotor]

# calculate angle of attack
beta1[ir, irotor], alpha[ir, irotor] = calculate_inflow_angles(
# Wz rather Wm used here in DFDC, presumable because the blade elements are definied in the z-r plane rather than the meridional direction
# Wm_rotor[ir, irotor], Wtheta_rotor[ir, irotor], stagger
Wz_rotor[ir, irotor],
Wtheta_rotor[ir, irotor],
stagger[],
stagger,
)

# get local Reynolds number
reynolds[ir, irotor] = calc_reynolds(
c,
Wmag_rotor[ir, irotor],
operating_point.rhoinf[1],
operating_point.muinf[1],
operating_point.rhoinf[],
operating_point.muinf[],
)
# c * abs(Wmag_rotor[ir, irotor]) * operating_point.rhoinf / operating_point.muinf

# get local Mach number
mach[ir, irotor] = Wmag_rotor[ir, irotor] / operating_point.asound[1]
mach[ir, irotor] = Wmag_rotor[ir, irotor] / operating_point.asound[]

# - Update cl and cd values - #
# be.cl[ir], be.cd[ir] = lookup_clcd(
Expand All @@ -322,8 +323,8 @@ function calculate_blade_element_coefficients!(
c,
B,
Wmag_rotor[ir, irotor],
solidity[],
stagger[],
solidity,
stagger,
alpha[ir, irotor],
beta1[ir, irotor],
reynolds[ir, irotor],
Expand Down
5 changes: 4 additions & 1 deletion src/process/aerodynamics/wake_aerodynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ function calculate_induced_velocities_on_wakes!(
post=false,
)

# reset induced velocities on wake
vz_wake .= 0
vr_wake .= 0

# get number of rotors
nbe, nrotor = size(sigr)

Expand Down Expand Up @@ -109,7 +113,6 @@ end
"""
"""
function calculate_wake_velocities!(Cm_wake, vz_wake, vr_wake, gamw, sigr, gamb, ivw, Vinf)

# - Get induced velocities on wake - #
calculate_induced_velocities_on_wakes!(
vz_wake,
Expand Down
2 changes: 1 addition & 1 deletion src/process/residuals/systemresidual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function estimate_states!(
solve_containers.sigr,
@view(solve_containers.gamb[1:(idmaps.body_totnodes)]),
ivw,
operating_point.Vinf[1],
operating_point.Vinf[],
)

# return estimated states
Expand Down
17 changes: 5 additions & 12 deletions src/utilities/airfoils/airfoil_utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,13 @@ end
"""
"""
function split_bodies!(
casing_vec,
nacelle_vec,
cb_vec,
casing_zpts,
nacelle_zpts,
cb_zpts,
vec,
controlpoint,
casing_vec, nacelle_vec, cb_vec, casing_zpts, nacelle_zpts, cb_zpts, vec, controlpoint
)

# get dimensions
casing_ids = 1:size(casing_vec,1)
nacelle_ids = casing_ids[end]+1:casing_ids[end]+size(nacelle_vec,1)
cb_ids = nacelle_ids[end]+1:nacelle_ids[end]+ size(cb_vec,1)
# get dimensions
casing_ids = 1:size(casing_vec, 1)
nacelle_ids = (casing_ids[end] + 1):(casing_ids[end] + size(nacelle_vec, 1))
cb_ids = (nacelle_ids[end] + 1):(nacelle_ids[end] + size(cb_vec, 1))

casing_vec .= @view(vec[casing_ids, :])
nacelle_vec .= @view(vec[nacelle_ids, :])
Expand Down

0 comments on commit 39d07d8

Please sign in to comment.