我想找到具有2個自由度的簡單動力系統的響應,由ODE定義:m ddx(t) + k ddx(t) = f(t)
。該系統被激勵力f1 = f01 * sin(omega*t)
在點1:積分多自由度運動方程
import numpy as np
m1 = 10
m2 = 8
k1 = 1e6
k2 = 3e6
k3 = 7e6
m = np.diag([m1,m2])
k = np.array([[k1 + k2, -k2],
[-k2, k2 + k3]])
omega = 500 # excitation angular frequency
的質量矩陣逆:
minv = np.linalg.inv(m)
的
的質量和剛度矩陣定義如下整合功能:
def cantilever_beam_ode_with_external_excitation(t, initial_state):
"""
ODE for a cantilever beam with external excitation (force())
EoM: m ddx + k x = f
"""
# unpack the state vector
x = initial_state[0] # vector
xd = initial_state[1] # vector, unimportant, since no damping
f = force(t)
xdd = minv.dot(-k.dot(x) + f)
# return the two state derivatives
return [xd, xdd]
def force(t):
force = np.zeros(m.shape[0])
f0 = 100
force[0] = f0 * np.sin(omega*t)
return force
的積分參數和整合:
# initial conditions
x0 = np.zeros(m.shape[0])
dx0 = np.zeros(m.shape[0])
initial_state = (x0, dx0)
integrator = 'vode'
state_ode_f = integrate.ode(cantilever_beam_ode_with_external_excitation)
state_ode_f.set_integrator(integrator, nsteps=500, rtol=1e-3, atol=1e-5, first_step=1e-2)
t_start = 0
t_final = 1
state_ode_f.set_initial_value(initial_state, t_start)
time = np.array([t_start])
velocity = np.expand_dims(initial_state[0], axis=0)
acceleration = np.expand_dims(initial_state[1], axis=0)
print("#\t Time\t\t Timestep \t state_ode_f.successful()")
i = 1
while state_ode_f.t < (t_final):
state_ode_f.integrate(t_final, step=True)
time = np.append(time, state_ode_f.t)
velocity = np.append(velocity, np.expand_dims(state_ode_f.y[0], axis=0), axis=0)
acceleration = np.append(acceleration, np.expand_dims(state_ode_f.y[1], axis = 0), axis=0)
print("{0} \t {1:0.5f}\t {2:0.4e} \t {3}".format(i, state_ode_f.t, time[-1] - time[-2], state_ode_f.successful()))
i += 1
我收到以下消息的結果:
C:\Anaconda3\python.exe D:/faks/LADISK/python/CMS_sparse/integrators/FEM_simple.py
C:\Anaconda3\lib\site-packages\scipy\integrate\_ode.py:853: UserWarning: vode: Illegal input detected. (See printed message.)
# Time Timestep state_ode_f.successful()
'Unexpected istate=%s' % istate))
4500 0.00000 0.0000e+00 False
DVODE-- RWORK length needed, LENRW (=I1), exceeds LRW (=I2)
In above message, I1 = 116 I2 = 52
4501 0.00000 0.0000e+00 False
DVODE-- RWORK length needed, LENRW (=I1), exceeds LRW (=I2)
In above message, I1 = 116 I2 = 52
4502 0.00000 0.0000e+00 False
DVODE-- RWORK length needed, LENRW (=I1), exceeds LRW (=I2)
In above message, I1 = 116 I2 = 52
4503 0.00000 0.0000e+00 False
DVODE-- RWORK length needed, LENRW (=I1), exceeds LRW (=I2)
In above message, I1 = 116 I2 = 52
...
就如何解決該問題的任何想法,歡迎。
謝謝!
你確定你的包裝和國家訴拆包ector /矩陣總是給出預期的結果? – LutzL