-
Notifications
You must be signed in to change notification settings - Fork 1
/
freqSDoF.py
52 lines (50 loc) · 1.76 KB
/
freqSDoF.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'''
Anis Mohammed vengasseri
anis.mhd@gmail.com
https://github.com/anismhd
This a module to evaluate response of SDoF system in frequency domain
'''
from numpy import zeros,pi,real
from numpy.fft import fft, fftfreq, ifft
def freqSDoF(M, C, K, F, dT):
force_DFT = fft(F)
freq = 2.0*pi*fftfreq(len(F),dT)
Hw = 1/(-M*freq**2+C*freq*1j+K)
response_DFT = Hw*force_DFT
return real(ifft(response_DFT)),real(ifft((0+freq*1j)*response_DFT)),real(ifft((0+freq*1j)**2*response_DFT))
if __name__ == "__main__":
def modifide_input(string,error_msg,dtype='str'):
if not(dtype in ['int','float','float64','str']):
print "Unknown data type... returning Nothing"
return None
while True:
inp = raw_input(string)
if dtype == 'int':
try:
return int(inp)
except ValueError:
print error_msg
if dtype == 'float':
try:
return float(inp)
except ValueError:
print error_msg
if dtype == 'float64':
try:
return float64(inp)
except ValueError:
print error_msg
if dtype == 'str':
try:
return str(inp)
except ValueError:
print error_msg
import matplotlib.pyplot as plt
import numpy as np
import sys
import os
print "\n\n\tThis is a python module to analyse SDoF system subjected to arbitrary forcing in frequency domain"
print "\tby\t ANIS MOHAMMED VENGASSERI"
print "\t\t anis.mhd@gmail.com"
print "\t\t https://github.com/anismhd"
print "\t The SDoF system system are solved in frequency domain..."