Calculation of time history excitation


In [1]:
#importing the required modules
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import random
from math import pi, sin, log

In [2]:
#time and frequency vectors
t = np.arange(0, 30, 0.01)
f = np.arange(2, 45, 2**(1.0/6.0)) #frequency change by 1/6 octave

#Aux variables definition
ZPA = 0.4
A = np.empty(len(f))
fi = np.empty(len(f))

#Amplitudes
for k in range(len(f)):
    A[k] = random.random()*ZPA
    
#Random angle
for k in range(len(f)):
    fi[k] = random.random()*pi/2
Formula for time history excitation

In [3]:
a = np.empty(len(t))

for l in range(len(t)):
    r = 0
    for b in range(len(f)):
        r = r + A[b]*sin(2*pi*f[b]*t[l]+fi[b])
    a[l] = r

In [4]:
plt.figure(1)
plt.subplot(111)
plt.plot(t,a)
plt.title("Synthetized time history")
plt.xlabel("Time [s]")
plt.ylabel("Acceleration [g]")
plt.grid(True)

plt.figure(2)
plt.subplot(211)
plt.plot(f, A, 'rs')
plt.title("Amplitude and Phase Angle @ frequency")
plt.ylabel("Amplitude [g]")
plt.grid(True)

plt.subplot(212)
plt.plot(f, fi, 'gs')
plt.xlabel("Frequency [Hz]")
plt.ylabel("Phase angle [rad]")
plt.grid(True)

plt.figure(3)
plt.subplot(111)
plt.semilogy(range(len(f)), f, 'y^')
plt.grid(True)
plt.title('Frequency change by 1/6 octave')
plt.xlabel('step')
plt.ylabel('Frequency [Hz]')


Out[4]:
<matplotlib.text.Text at 0x1057de950>

In [5]: