A Simple VBA Tutorial: Newmark’s dynamic solutions of a 2 dof mass spring damper system.

This code solves a two dof mass spring damper system using a Newmark’s time stepping solution. This is a direct dynamics solution in the time domain and may be extended to a systam with more then 2 degrees of freedom.

The Theory:-

Is quite involved so refer to “The Finite Element Method” by Thomas J.R. Hughes, but the implementation is fairly straight forward as follows.

1) For our example we take g=0.5 and b=0.25 which are integration parameters and a time step dt= 0.01.

2) we are going to solve (M+g*dt*C+b*dt^2*K)*a_{n+1}=-C*vb_{n+1}-K*db_{n+1} where M,C,K are the mass, damping and stiffness matrices.

3) from (M+g*dt*C+b*dt^2*K) we get our effective stiffness matrix and we invert this so we can calculate the new acceleration vector from the effective force.

4) -C*vb_{n+1}-K*db_{n+1} gives us the effective force where :-

db_{n+1}=d_{n}+dt*v_{n}+0.5*dt^2*(1-2*b)*a_{n}

vb_{n+1}=v_{n}+(1-g)*dt*a_{n}

we start with dn our displacement vector set to initial conditions [0.1] and v_{n} and a_{n} set to [0,]0]

5) we calculate our effective force from 4 starting with our initial conditions (d_{n},v_{n},a_{n}) multiplying this by 3 the inverse of the effective stiffness matrix we get are new acceleration vector a_{n+1}.

6) We now calculate the new displacement and velocity vectors from a_{n+1} as :-

d_{n+1}=db_{n+1} + b*dt^2*a_{n+1}

v_{n+1}=vb_{n+1} + g*dt^2*a_{n+1}

7) now we goto 4 where d_{n} and v_{n} are now the newly calculated d_{n+1} v_{n+1}