#!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') # # Duhamel Integral # # ## Problem Data # In[29]: M = 600000 T = 0.6 z = 0.10 p0 = 400000 t0, t1, t2, t3 = 0.0, 1.0, 3.0, 6.0 # ## Natural Frequency, Damped Frequency # In[30]: wn = 2*np.pi/T wd = wn*np.sqrt(1-z**2) # ## Computation # # ### Preliminaries # # We chose a time step and we compute a number of constants of the integration procedure that depend on the time step # In[38]: dt = 0.05 edt = np.exp(-z*wn*dt) fac = dt/(2*M*wd) # We initialize a time variable # In[39]: t = dt*np.arange(1+int(t3/dt)) # We compute the load, the sines and the cosines of $\omega_D t$ and their products # In[40]: p = np.where(t<=t1, p0*(t-t0)/(t1-t0), np.where(t