From e31e48289feec6dd910f8ed78d37473e80df6735 Mon Sep 17 00:00:00 2001 From: Cris Moen Date: Thu, 12 Sep 2024 15:19:06 -0400 Subject: [PATCH 1/3] SVector to MVector for 2nd order --- src/InstantFrame.jl | 58 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/src/InstantFrame.jl b/src/InstantFrame.jl index baeeb01..46d4810 100644 --- a/src/InstantFrame.jl +++ b/src/InstantFrame.jl @@ -93,6 +93,16 @@ end PointLoad(nothing) = PointLoad(labels=nothing, nodes=nothing, magnitudes=nothing) +@with_kw mutable struct SourceMass + + labels::Union{Array{String}, Nothing} + nodes::Union{Array{Int64}, Nothing} + magnitudes::Union{NamedTuple{(:MFX, :MFY, :MFZ, :MMX, :MMY, :MMZ), NTuple{6, Vector{Float64}}}, Nothing} + +end + +SourceMass(nothing) = SourceMass(labels=nothing, nodes=nothing, magnitudes=nothing) + @with_kw mutable struct ElementProperties L::Array{Float64} @@ -226,6 +236,7 @@ end support::Support uniform_load::UniformLoad point_load::PointLoad + source_mass::SourceMass analysis_type::String solution_tolerance::Union{Float64, Nothing} @@ -576,7 +587,8 @@ function nonlinear_solution(Kff, Ff, u1f) p = [Kff, Ff] - u1f = SVector{length(u1f)}(u1f) + # u1f = SVector{length(u1f)}(u1f) + u1f = MVector{length(u1f)}(u1f) # u1f_S = zeros(Float64, length(u1f)) # u1fSS = [u1f_S[i] for i in eachindex(u1f)] probN = NonlinearSolve.NonlinearProblem{false}(residual, u1f, p) @@ -749,7 +761,8 @@ function second_order_analysis(node, cross_section, material, connection, elemen Kff = Ke_ff + Kg_ff p = [Kff, Ff] - u1f = SVector{length(u1f)}(u1f) + # u1f = SVector{length(u1f)}(u1f) + u1f = MVector{length(u1f)}(u1f) probN = NonlinearSolve.NonlinearProblem{false}(residual, u1f, p) u2f = NonlinearSolve.solve(probN, NewtonRaphson(), reltol = solution_tolerance) @@ -827,10 +840,16 @@ function modal_vibration_analysis(node, cross_section, material, connection, ele Ke = InstantFrame.assemble_global_matrix(ke_global, element_properties.global_dof) + global_dof_source_masses = InstantFrame.define_global_dof_source_masses(node, source_mass) + m_local = [InstantFrame.define_local_3D_mass_matrix(element_properties.A[i], element_properties.L[i], element_properties.Io[i], element_properties.ρ[i]) for i in eachindex(element_properties.L)] m_global = [element_properties.Γ[i]'*m_local[i]*element_properties.Γ[i] for i in eachindex(element_properties.L)] M = InstantFrame.assemble_global_matrix(m_global, element_properties.global_dof) - + + for ii in eachindex(global_dof_source_masses) + M[ii,ii] += global_dof_source_masses[ii] + end + Ke_ff = Ke[free_global_dof, free_global_dof] Mff = M[free_global_dof, free_global_dof] @@ -849,14 +868,16 @@ function modal_vibration_analysis(node, cross_section, material, connection, ele solution = ModalSolution(ωn, ϕ) - model = Model(element_properties, nothing, equations, solution) + inputs = Inputs(node, cross_section, material, connection, element, support, source_mass, "modal info") + + model = Model(inputs, element_properties, nothing, equations, solution) return model end -function solve(node, cross_section, material, connection, element, support, uniform_load, point_load; analysis_type, solution_tolerance) +function solve(node, cross_section, material, connection, element, support, uniform_load, point_load, analysis_type, parameters) if analysis_type == "first order" @@ -868,7 +889,7 @@ function solve(node, cross_section, material, connection, element, support, unif elseif analysis_type == "second order" - model = second_order_analysis(node, cross_section, material, connection, element, support, uniform_load, point_load, solution_tolerance) + model = second_order_analysis(node, cross_section, material, connection, element, support, uniform_load, point_load, parameters.solution_tolerance) end @@ -1354,6 +1375,31 @@ function define_global_dof_point_loads(node, point_load) end +function define_global_dof_source_masses(node, source_mass) + + + num_dof_per_node = 6 + global_dof_source_masses = zeros(Float64, length(node.numbers)*num_dof_per_node) + + if !isnothing(source_mass.nodes) + + nodal_source_masses = reduce(hcat, collect(source_mass.magnitudes)) + + for i in eachindex(source_mass.nodes) + + node_index = findfirst(node_num->node_num == source_mass.nodes[i], node.numbers) + node_dof = range(1, num_dof_per_node) .+ num_dof_per_node * (node_index-1) + + global_dof_source_masses[node_dof] = nodal_source_masses[i, :] + + end + + end + + return global_dof_source_masses + +end + function calculate_element_local_axis_directions(Γ) From eaef164e3848f0ebfa86889dd4f70d517fb9ca6c Mon Sep 17 00:00:00 2001 From: tkrisnguyen <79130097+tkrisnguyen@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:20:24 +0700 Subject: [PATCH 2/3] Change default orientation of local 2-axis --- src/InstantFrame.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/InstantFrame.jl b/src/InstantFrame.jl index 46d4810..6f5bdb4 100644 --- a/src/InstantFrame.jl +++ b/src/InstantFrame.jl @@ -293,7 +293,7 @@ function define_local_elastic_stiffness_matrix(Iy, Iz, A, J, E, ν, L) for i = 1:12 - for j = 1:12 + for j = i+1:12 ke[j, i] = ke[i, j] @@ -404,7 +404,7 @@ function define_rotation_matrix(A, B, β) # # matrix of direction cosines # γ = RotX(-(ω+β)) * RotZ(-χ) * RotY(-ρ) # add β here to rotate local y-axis to orient cross-section in global coordinate system - ω = β + ω = β-pi/2 γ = RotYZX(ρ, χ, ω)' #transpose! From a7a04ad03bb878bc1dc67bb3c6b03ee2b39c0123 Mon Sep 17 00:00:00 2001 From: tkrisnguyen <79130097+tkrisnguyen@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:27:01 +0700 Subject: [PATCH 3/3] Update InstantFrame.jl --- src/InstantFrame.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/InstantFrame.jl b/src/InstantFrame.jl index 6f5bdb4..dbc0629 100644 --- a/src/InstantFrame.jl +++ b/src/InstantFrame.jl @@ -404,7 +404,7 @@ function define_rotation_matrix(A, B, β) # # matrix of direction cosines # γ = RotX(-(ω+β)) * RotZ(-χ) * RotY(-ρ) # add β here to rotate local y-axis to orient cross-section in global coordinate system - ω = β-pi/2 + ω = β γ = RotYZX(ρ, χ, ω)' #transpose!