@@ -387,11 +387,14 @@ function generate_polar_data(
387387 end
388388
389389 # Update inflow conditions
390- wing_aero. va = [
391- cos (α) * cos (β),
392- sin (β),
393- sin (α)
394- ] * Umag
390+ set_va! (
391+ wing_aero,
392+ [
393+ cos (α) * cos (β),
394+ sin (β),
395+ sin (α)
396+ ] * Umag
397+ )
395398
396399 # Solve and store results
397400 results = solve (solver, wing_aero, gamma_distribution[i, :])
@@ -488,32 +491,87 @@ function plot_polars(
488491 end
489492 end
490493
491- # Create plots
492- layout = @layout [grid (2 ,2 )]
493- plt = plot (layout= layout, size= (1000 , 1000 ), title= title)
494+ # Create plots with 2x2 layout
495+ plt = plot (
496+ layout= (2 ,2 ),
497+ size= (1000 , 1000 ),
498+ plot_title= title
499+ )
494500
495501 # Number of computational results (excluding literature)
496502 n_solvers = length (solver_list)
497503
498504 # Plot CL vs angle
499- plot! (plt[1 ]) # Use plt[1] instead of subplot!(plt, 1)
505+ plot! (plt[1 ])
500506 for (i, (polar_data, label)) in enumerate (zip (polar_data_list, label_list))
501507 style = i ≤ n_solvers ? (:solid , :star , 7 ) : (:solid , :circle , 5 )
502508 plot! (plt[1 ], polar_data[1 ], polar_data[2 ],
503509 label= label, linestyle= style[1 ], marker= style[2 ], markersize= style[3 ])
510+
511+ # Limit y-range if CL > 10
512+ if maximum (polar_data[2 ]) > 10
513+ ylims! (plt[1 ], (- 0.5 , 2.0 ))
514+ end
504515 end
505- title! (plt[1 ], L " C_L vs %$angle_type" )
516+ title! (plt[1 ], L " C_L \t extrm{ vs } %$angle_type" )
506517 xlabel! (plt[1 ], " $angle_type [deg]" )
507518 ylabel! (plt[1 ], L " C_L" )
508-
509- # Continue with CD, CS, and CL-CD plots similarly...
510- # [Additional subplots omitted for brevity]
511-
519+
520+ # Plot CD vs angle
521+ plot! (plt[2 ])
522+ for (i, (polar_data, label)) in enumerate (zip (polar_data_list, label_list))
523+ style = i ≤ n_solvers ? (:solid , :star , 7 ) : (:solid , :circle , 5 )
524+ plot! (plt[2 ], polar_data[1 ], polar_data[3 ],
525+ label= label, linestyle= style[1 ], marker= style[2 ], markersize= style[3 ])
526+
527+ # Limit y-range if CD > 10
528+ if maximum (polar_data[3 ]) > 10
529+ ylims! (plt[2 ], (- 0.2 , 0.5 ))
530+ end
531+ end
532+ title! (plt[2 ], L " C_D \t extrm{ vs } %$angle_type" )
533+ xlabel! (plt[2 ], " $angle_type [deg]" )
534+ ylabel! (plt[2 ], L " C_D" )
535+
536+ # Plot CS vs angle (if available)
537+ plot! (plt[3 ])
538+ for (i, (polar_data, label)) in enumerate (zip (polar_data_list, label_list))
539+ # Check if CS data is available (length > 3)
540+ if length (polar_data) > 3
541+ style = i ≤ n_solvers ? (:solid , :star , 7 ) : (:solid , :circle , 5 )
542+ plot! (plt[3 ], polar_data[1 ], polar_data[4 ],
543+ label= label, linestyle= style[1 ], marker= style[2 ], markersize= style[3 ])
544+ end
545+ end
546+ title! (plt[3 ], L " C_S \t extrm{ vs } %$angle_type" )
547+ xlabel! (plt[3 ], " $angle_type [deg]" )
548+ ylabel! (plt[3 ], L " C_S" )
549+
550+ # Plot CL vs CD
551+ plot! (plt[4 ])
552+ for (i, (polar_data, label)) in enumerate (zip (polar_data_list, label_list))
553+ style = i ≤ n_solvers ? (:solid , :star , 7 ) : (:solid , :circle , 5 )
554+ plot! (plt[4 ], polar_data[2 ], polar_data[3 ], # Note: CD on x-axis, CL on y-axis
555+ label= label, linestyle= style[1 ], marker= style[2 ], markersize= style[3 ])
556+
557+ # Limit ranges if values > 10
558+ if maximum (polar_data[2 ]) > 10 || maximum (polar_data[3 ]) > 10
559+ ylims! (plt[4 ], (- 0.5 , 2.0 ))
560+ xlims! (plt[4 ], (- 0.2 , 0.5 ))
561+ end
562+ end
563+ title! (plt[4 ], L " C_L \t extrm{ vs } C_D \t extrm{ (over } %$angle_type \t extrm{ range)}" )
564+ xlabel! (plt[4 ], L " C_D" )
565+ ylabel! (plt[4 ], L " C_L" )
566+
567+ # Save and show plot
512568 if is_save
513569 save_plot (plt, save_path, title, data_type= data_type)
514570 end
515571
516572 if is_show
517573 show_plot (plt)
518574 end
575+
576+ return plt
519577end
0 commit comments