Hi Taylor,
I can't get this simulation of a simply-supported beam initially displaced to excite only its 2nd mode to run:
using GXBeam, LinearAlgebra
# Simply-supported beam subject to initial conditions
# beam properties
L = 1
EI = 1
I = 1
A = 1
ρ = 1
# create points
nelem = 20
x = range(0, L, length=nelem+1)
y = zero(x)
z = zero(x)
points = [[x[i],y[i],z[i]] for i = 1:length(x)]
lengths, points, midpoints, Cab = discretize_beam(L,[0, 0, 0],nelem)
# index of endpoints of each beam element
start = 1:nelem
stop = 2:nelem+1
# compliance matrix for each beam element
compliance = fill(Diagonal([0, 0, 0, 0, 1/EI, 0]), nelem)
# mass matrix for each beam element
mass = fill(Diagonal([ρ*A, ρ*A, ρ*A, 2*ρ*I, ρ*I, ρ*I]), nelem)
# create assembly
assembly = Assembly(points, start, stop; compliance=compliance, mass=mass)
# prescribed conditions
prescribed_conditions = (t) -> begin
Dict(
# simply supported left side
1 => PrescribedConditions(ux=0, uy=0, uz=0, theta_x=0, theta_z=0),
# simply supported right side
nelem+1 => PrescribedConditions(ux=0, uy=0, uz=0, theta_x=0, theta_z=0)
)
end
# initial conditions
delta = 1e-3 # small number to stay in the linear regime
u0 = [[0,0,delta*sin(2*pi*midpoints[i][1]/L)] for i = 1:length(midpoints)]
theta0 = [[0,-delta*2*pi/L*cos(2*pi*midpoints[i][1]/L),0] for i = 1:length(midpoints)]
# simulation time
t = 0:1e-3:0.25
# solve
system, history, converged = time_domain_analysis(assembly, t;
prescribed_conditions = prescribed_conditions,
u0=u0,
initialize=true,
iterations=50) #theta0=theta0
# Get displacements at 1/4 of the beam's length
point = nelem/4+1
field = [:u]
direction = [3]
w14_of_t = [getproperty(state.points[point[1]], field[1])[direction[1]] for state in history]
# Plot
using Plots
pyplot()
plot(xlabel = "Time (s)",
ylabel = "\$w\$ (\$m\$)",
grid = false,
overwrite_figure=false
)
plot!(t, w14_of_t, label="")
plot!(show=true)
# analytical solution
x_quarter = x[nelem/4]
omega2 = (2*pi/L)^2*sqrt(EI/(ρ*A);
w14_analytic = delta*cos(omega2*t)*sin(2*pi*x_quarter/L)
The initial conditions solver does not converge (reduced to 50 iterations or it just takes forever), for this one or any other type of initial conditions. As you can see, the initial displacements were provided as inputs, but setting both displacements and angles does not help either.
I managed to solve the problem in a separate code, by setting the initial conditions as prescribed conditions (boundary conditions) and solving the resulting problem as a static one. The solution states vector is then copied as a consistent set of initial states. The displacement solution should be like this:

I was just wondering if I'm doing something wrong with the inputs to the time domain analysis, and say that I'd be glad to help fix the issue (if there really is one).
Hi Taylor,
I can't get this simulation of a simply-supported beam initially displaced to excite only its 2nd mode to run:
The initial conditions solver does not converge (reduced to 50 iterations or it just takes forever), for this one or any other type of initial conditions. As you can see, the initial displacements were provided as inputs, but setting both displacements and angles does not help either.
I managed to solve the problem in a separate code, by setting the initial conditions as prescribed conditions (boundary conditions) and solving the resulting problem as a static one. The solution states vector is then copied as a consistent set of initial states. The displacement solution should be like this:
I was just wondering if I'm doing something wrong with the inputs to the time domain analysis, and say that I'd be glad to help fix the issue (if there really is one).