@@ -424,16 +424,16 @@ Constructor for a [RamAirWing](@ref) that allows to use an `.obj` and a `.dat` f
424424 used in the xfoil polar generation
425425- wind_vel=10.0: Apparent wind speed in m/s, used in the xfoil polar generation
426426- mass=1.0: Mass of the wing in kg, used for the inertia calculations
427- - `n_panels`=54 : Number of panels.
427+ - `n_panels`=56 : Number of panels.
428428- `n_sections`=n_panels+1: Number of sections (there is a section on each side of each panel.)
429429- `spanwise_distribution`=UNCHANGED: see: [PanelDistribution](@ref)
430430- `spanwise_direction`=[0.0, 1.0, 0.0]
431431- `remove_nan::Bool`: Wether to remove the NaNs from interpolations or not
432432"""
433433function RamAirWing (obj_path, dat_path; alpha= 0.0 , crease_frac= 0.75 , wind_vel= 10. , mass= 1.0 ,
434- n_panels= 54 , n_sections= n_panels+ 1 , spanwise_distribution= UNCHANGED,
434+ n_panels= 56 , n_sections= n_panels+ 1 , spanwise_distribution= UNCHANGED,
435435 spanwise_direction= [0.0 , 1.0 , 0.0 ], remove_nan= true , align_to_principal= false ,
436- alpha_range= deg2rad .(- 5 : 1 : 20 ), delta_range= deg2rad .(- 5 : 1 : 20 ), interp_steps= 40
436+ alpha_range= deg2rad .(- 5 : 1 : 20 ), delta_range= deg2rad .(- 5 : 1 : 20 ), interp_steps= n_sections
437437 )
438438
439439 ! isapprox (spanwise_direction, [0.0 , 1.0 , 0.0 ]) && throw (ArgumentError (" Spanwise direction has to be [0.0, 1.0, 0.0], not $spanwise_direction " ))
@@ -517,6 +517,38 @@ function RamAirWing(obj_path, dat_path; alpha=0.0, crease_frac=0.75, wind_vel=10
517517 end
518518end
519519
520+ function smooth_deform! (wing:: RamAirWing , theta_angles:: AbstractVector , delta_angles:: AbstractVector )
521+ ! (wing. n_panels % length (theta_angles) == 0 ) && throw (ArgumentError (" Number of angles has to be a multiple of number of panels" ))
522+ panels = wing. panels
523+ theta_dist = wing. theta_dist
524+ delta_dist = wing. delta_dist
525+
526+ dist_idx = 1
527+ for angle_idx in eachindex (theta_angles)
528+ for _ in 1 : (wing. n_panels ÷ length (theta_angles))
529+ theta_dist[dist_idx] = theta_angles[angle_idx]
530+ delta_dist[dist_idx] = delta_angles[angle_idx]
531+ dist_idx += 1
532+ end
533+ end
534+ @assert (dist_idx == wing. n_panels)
535+
536+ window_size = wing. n_panels ÷ length (theta_angles)
537+ if length (panels) > window_size
538+ smoothed = copy (theta_dist)
539+ for i in (window_size÷ 2 + 1 ): (length (panels) - window_size÷ 2 )
540+ smoothed[i] = mean (theta_dist[(i - window_size÷ 2 ): (i + window_size÷ 2 )])
541+ end
542+ theta_dist .= smoothed
543+ for i in (window_size÷ 2 + 1 ): (length (panels) - window_size÷ 2 )
544+ smoothed[i] = mean (delta_dist[(i - window_size÷ 2 ): (i + window_size÷ 2 )])
545+ end
546+ delta_dist .= smoothed
547+ end
548+ deform! (wing)
549+ return nothing
550+ end
551+
520552"""
521553 deform!(wing::RamAirWing, theta_dist::AbstractVector, delta_dist::AbstractVector; width)
522554
@@ -536,6 +568,10 @@ function deform!(wing::RamAirWing, theta_dist::AbstractVector, delta_dist::Abstr
536568 wing. theta_dist .= theta_dist
537569 wing. delta_dist .= delta_dist
538570
571+ deform! (wing)
572+ end
573+
574+ function deform! (wing:: RamAirWing )
539575 local_y = zeros (MVec3)
540576 chord = zeros (MVec3)
541577 normal = zeros (MVec3)
0 commit comments