I would like to solve:
[\mathbf{M} \ddot{ \mathbf{U} }+ \mathbf{C} \dot{ \mathbf{U} }+ \mathbf{K} \mathbf{U} = \mathbf{P}(t)]
Or, in state-space form:
[\dot{\mathbf{Y}}=f(\mathbf{Y},t)]
where:
[\mathbf{Y} = \left[ \begin{array}{ c} \mathbf{U} \ \dot{ \mathbf{U} \end{array} \right] ]
and:
[f( \mathbf{Y} ,t)= \left[ \begin{array}{ c} \dot{ \mathbf{U} }\ \mathbf{M}^{-1} \mathbf{P} (t)- \mathbf{M} ^{-1} \mathbf{C} \dot{ \mathbf{U} }- \mathbf{M} ^{-1} \mathbf{K} \mathbf{U} \end{array} \right] ]
I tried the following code in Julia, using
\mathbf{M} = \left[ \begin{array}{ cc} 2&0\ 0&1 \end{array} \right];
\mathbf{C} = \left[ \begin{array}{ cc} 0&0\ 0& 0 \end{array} \right];
\mathbf{K} = \left[ \begin{array}{ cc} 96&-32\ -32& 32 \end{array} \right];
\mathbf{P} (t)= \left[ \begin{array}{ c} 10\ 10 \end{array} \right]
.
using DifferentialEquations
function eq(t,u,du)
v=reshape([u...],Int(length(u)/2),2)
du=reshape([v[:,2];-[10;10]-M\C*v[:,2]-M\K*v[:,1]],length(u))
end
u0=[0;0;0;0];
tspan=(0.0,10.0);
prob=ODEProblem(eq,u0,tspan)
sol=solve(prob)
But running these lines of code results to this error:
ERROR: InexactError()
I am using Julia ver. 0.5.2.
Please help me. Thank you.