diff --git a/CHANGELOG.md b/CHANGELOG.md index 783899e8..3f30a36a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ ### Changed +- `ObjAdapter.center_to_com!`, `calculate_inertia_tensor` and `calc_inertia_y_rotation` + are deprecated and will be removed in the next breaking release. Mesh mass properties + are computed by SymbolicAWEModels, which reads the mesh with `read_faces`. - Requires Julia 1.12 or 1.13; 1.10 and 1.11 keep resolving v5.1.1. ## VortexStepMethod v5.1.1 2026-09-12 diff --git a/docs/src/private_functions.md b/docs/src/private_functions.md index d7807c42..415c743f 100644 --- a/docs/src/private_functions.md +++ b/docs/src/private_functions.md @@ -246,6 +246,7 @@ find_circle_center_and_radius march_edges calculate_inertia_tensor center_to_com! +calc_inertia_y_rotation airfoils_from_yaml write_geometry_yaml resolve_aero_geometry diff --git a/src/obj_adapter/obj_geometry.jl b/src/obj_adapter/obj_geometry.jl index 0a5ac73a..e427d6f2 100644 --- a/src/obj_adapter/obj_geometry.jl +++ b/src/obj_adapter/obj_geometry.jl @@ -227,6 +227,11 @@ function create_interpolations(vertices, circle_center_z, radius, gamma_tip, R=I return (le_interp, te_interp, area_interp) end +function depwarn_inertia(name::Symbol) + Base.depwarn("`$name` is deprecated and will be removed in the next breaking release; " * + "SymbolicAWEModels computes mesh mass properties.", name) +end + """ center_to_com!(vertices, faces) @@ -242,8 +247,11 @@ Calculate center of mass of a mesh and translate vertices so that COM is at orig # Notes - Non-triangular faces are automatically triangulated into triangles - Assumes uniform surface density + +Deprecated; removed in the next breaking release. """ function center_to_com!(vertices, faces; prn=true) + depwarn_inertia(:center_to_com!) area_total = 0.0 com = zeros(3) @@ -298,8 +306,11 @@ Uses the thin shell approximation where: # Returns - 3×3 matrix representing the inertia tensor in kg⋅m² + +Deprecated; removed in the next breaking release. """ function calculate_inertia_tensor(vertices, faces, mass, com) + depwarn_inertia(:calculate_inertia_tensor) # Initialize inertia tensor I = zeros(3, 3) total_area = 0.0 @@ -338,7 +349,16 @@ function calculate_inertia_tensor(vertices, faces, mass, com) return (mass / total_area) * I / 3 end +""" + calc_inertia_y_rotation(I_b_tensor) + +Rotate the inertia tensor `I_b_tensor` about the y-axis until its xz product of inertia +vanishes. Returns the rotated tensor and the rotation matrix `R_b_p`. + +Deprecated; removed in the next breaking release. +""" function calc_inertia_y_rotation(I_b_tensor) + depwarn_inertia(:calc_inertia_y_rotation) # Function for nonlinear solver - off-diagonal element should be zero function eq!(F, theta, _) # Rotation matrix around y-axis @@ -368,5 +388,3 @@ function calc_inertia_y_rotation(I_b_tensor) @assert isapprox(I_diag[1,3], 0.0, atol=1e-5) return I_diag, R_b_p end - - diff --git a/test/Project.toml b/test/Project.toml index 5e1ffca3..7e0423ef 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -14,7 +14,6 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" MakieControlPlots = "6d616b69-6563-4f6e-8472-6f6c706c6f74" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" @@ -36,7 +35,6 @@ LinearAlgebra = "1" Logging = "1" MakieControlPlots = "0.1.5" Random = "1.10.0" -Serialization = "1" StaticArrays = "1" Statistics = "1" Test = "1" diff --git a/test/ram_geometry/test_kite_geometry.jl b/test/ram_geometry/test_kite_geometry.jl index 4c9fdc8d..8fe5d479 100644 --- a/test/ram_geometry/test_kite_geometry.jl +++ b/test/ram_geometry/test_kite_geometry.jl @@ -7,7 +7,6 @@ using VortexStepMethod.ObjAdapter: create_interpolations, find_circle_center_and calculate_inertia_tensor, center_to_com!, read_faces, calc_inertia_y_rotation using LinearAlgebra using Interpolations -using Serialization @testset "Kite Geometry Tests" begin work_dir = mktempdir() @@ -38,7 +37,7 @@ using Serialization vertices = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]] faces = [[1, 2, 3]] - com = center_to_com!(vertices, faces) + com = @test_deprecated center_to_com!(vertices, faces) expected_com = [-1/3, 0.0, -1/3] @test isapprox(com, expected_com, rtol=1e-5) @@ -50,7 +49,7 @@ using Serialization mass = 1.0 com = [1/3, 1/3, 0.0] - I = calculate_inertia_tensor(vertices, faces, mass, com) + I = @test_deprecated calculate_inertia_tensor(vertices, faces, mass, com) # Test properties of inertia tensor @test size(I) == (3,3) @@ -120,7 +119,7 @@ using Serialization write_aero_matrix(cd_polar_path, cd_matrix, deg2rad.(alphas), deg2rad.(d_trailing_edge_angles), "C_d") write_aero_matrix(cm_polar_path, cm_matrix, deg2rad.(alphas), deg2rad.(d_trailing_edge_angles), "C_m") - # Create and serialize obj file + # Create obj file faces = [[i, i+1, i+2] for i in 1:3:length(vertices)-2] open(test_obj_path, "w") do io for v in vertices @@ -139,15 +138,8 @@ using Serialization @test alphas_read ≈ deg2rad.(alphas) @test deltas_read ≈ deg2rad.(d_trailing_edge_angles) - # Create info file - info_path = test_obj_path[1:end-4] * "_info.bin" le_interp, te_interp, area_interp = create_interpolations(vertices, z_center, r, π/4, I(3)) - center_of_mass = center_to_com!(vertices, faces) - inertia_tensor = calculate_inertia_tensor(vertices, faces, 1.0, zeros(3)) - - serialize(info_path, (inertia_tensor, center_of_mass, I(3), r, π/4, - le_interp, te_interp, area_interp)) - + # Test interpolation at middle point @test isapprox([le_interp[i](0.0) for i in 1:3], [0.0, 0.0, r+z_center], atol=0.03) @test isapprox([te_interp[i](0.0) for i in 1:3], [1.0, 0.0, r+z_center], atol=0.03) @@ -157,7 +149,7 @@ using Serialization vertices, faces = read_faces(test_obj_path) center_of_mass = center_to_com!(vertices, faces) inertia_tensor_b = calculate_inertia_tensor(vertices, faces, 1.0, zeros(3)) - inertia_tensor_p, R_b_p = calc_inertia_y_rotation(inertia_tensor_b) + inertia_tensor_p, R_b_p = @test_deprecated calc_inertia_y_rotation(inertia_tensor_b) for v in vertices v .= R_b_p * v end