Skip to content

Commit 298062d

Browse files
committed
#186 attempt at resolving windows issues
1 parent 90ff624 commit 298062d

File tree

2 files changed

+57
-73
lines changed

2 files changed

+57
-73
lines changed

test/body_aerodynamics/test_body_aerodynamics.jl

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -414,39 +414,23 @@ end
414414
end
415415

416416
@testset "set_va! with VSMSettings" begin
417-
# Use module-specific test data files
418-
wing_file = test_data_path("body_aerodynamics", "test_wing.yaml")
419-
settings_file = create_temp_wing_settings("body_aerodynamics", "test_wing.yaml"; alpha=10.0, beta=5.0, wind_speed=15.0)
420-
417+
settings_file = create_temp_wing_settings("body_aerodynamics", "test_wing.yaml";
418+
alpha=10.0, beta=5.0, wind_speed=15.0)
421419
try
422-
# Test set_va! with VSMSettings
423-
settings = VSMSettings(settings_file)
424-
wing = Wing(settings)
425-
body_aero = BodyAerodynamics([wing])
426-
427-
# Set velocity using convenience method
420+
settings = VSMSettings(settings_file)
421+
wing = Wing(settings)
422+
body_aero = BodyAerodynamics([wing])
423+
428424
set_va!(body_aero, settings)
429-
430-
# Calculate expected velocity vector
431-
α = deg2rad(10.0)
432-
β = deg2rad(5.0)
433-
wind_speed = 15.0
434-
expected_va = wind_speed * [
435-
cos(α)*cos(β), # X_b (forward)
436-
sin(β), # Y_b (right)
437-
sin(α)*cos(β) # Z_b (down)
438-
]
439-
440-
# Verify that all panels have the correct velocity
441-
for panel in body_aero.panels
442-
@test panel.va expected_va atol=1e-10
425+
426+
α, β, wind_speed = deg2rad(10.0), deg2rad(5.0), 15.0
427+
expected_va = wind_speed .* [cos(α)*cos(β), sin(β), sin(α)*cos(β)]
428+
429+
for p in body_aero.panels
430+
@test p.va expected_va atol=1e-10
443431
end
444-
445-
# Verify body_aero._va is set correctly
446432
@test body_aero._va expected_va atol=1e-10
447-
448433
finally
449-
# Cleanup
450-
rm(settings_file; force=true)
434+
isfile(settings_file) && rm(settings_file; force=true)
451435
end
452-
end
436+
end

test/test_data_utils.jl

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -65,50 +65,49 @@ settings_file = create_temp_wing_settings("body_aerodynamics", "test_wing.yaml";
6565
rm(settings_file)
6666
```
6767
"""
68-
function create_temp_wing_settings(module_name, wing_file;
69-
name="test_wing",
70-
n_panels=4,
71-
n_groups=2,
72-
spanwise_panel_distribution="COSINE",
73-
spanwise_direction=[0.0, 1.0, 0.0],
74-
remove_nan=true,
75-
aerodynamic_model_type="VSM",
76-
density=1.225,
77-
type_initial_gamma_distribution="ZEROS",
78-
alpha=10.0,
79-
beta=5.0,
80-
wind_speed=15.0)
81-
82-
# Use wing_file path directly if it's already an absolute path, otherwise construct it
83-
wing_file_path = if isabspath(wing_file)
84-
wing_file
85-
else
86-
test_data_path(module_name, wing_file)
87-
end
88-
89-
settings_content = """
90-
wings:
91-
- name: "$name"
92-
geometry_file: "$wing_file_path"
93-
n_panels: $n_panels
94-
n_groups: $n_groups
95-
spanwise_panel_distribution: $spanwise_panel_distribution
96-
spanwise_direction: $spanwise_direction
97-
remove_nan: $remove_nan
98-
99-
solver_settings:
100-
aerodynamic_model_type: $aerodynamic_model_type
101-
density: $density
102-
type_initial_gamma_distribution: $type_initial_gamma_distribution
103-
104-
condition:
105-
alpha: $alpha
106-
beta: $beta
107-
wind_speed: $wind_speed
108-
"""
109-
68+
function create_temp_wing_settings(module_name, wing_file;
69+
name="test_wing",
70+
n_panels=4,
71+
n_groups=2,
72+
spanwise_panel_distribution="COSINE",
73+
spanwise_direction=[0.0, 1.0, 0.0],
74+
remove_nan=true,
75+
aerodynamic_model_type="VSM",
76+
density=1.225,
77+
type_initial_gamma_distribution="ZEROS",
78+
alpha=10.0,
79+
beta=5.0,
80+
wind_speed=15.0,
81+
)
82+
wing_file_path = isabspath(wing_file) ? wing_file : test_data_path(module_name, wing_file)
83+
wing_file_path = replace(normpath(wing_file_path), '\\' => '/')
84+
85+
doc = Dict(
86+
"wings" => [Dict(
87+
"name" => name,
88+
"geometry_file" => wing_file_path,
89+
"n_panels" => n_panels,
90+
"n_groups" => n_groups,
91+
"spanwise_panel_distribution" => spanwise_panel_distribution,
92+
"spanwise_direction" => spanwise_direction,
93+
"remove_nan" => remove_nan,
94+
)],
95+
"solver_settings" => Dict(
96+
"aerodynamic_model_type" => aerodynamic_model_type,
97+
"density" => density,
98+
"type_initial_gamma_distribution" => type_initial_gamma_distribution,
99+
),
100+
"condition" => Dict(
101+
"alpha" => alpha,
102+
"beta" => beta,
103+
"wind_speed" => wind_speed,
104+
),
105+
)
106+
110107
temp_file = joinpath(tempdir(), "temp_wing_settings_$(randstring(8)).yaml")
111-
write(temp_file, settings_content)
108+
open(temp_file, "w") do io
109+
YAML.write(io, doc)
110+
end
112111
return temp_file
113112
end
114113

@@ -154,3 +153,4 @@ function get_complete_settings_file(module_name)
154153
return create_temp_wing_settings(module_name, basename(get_standard_wing_file(module_name)))
155154
end
156155
end
156+

0 commit comments

Comments
 (0)