Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.80 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. """Noise Control Assignment 2
  4.   Jack Bryant, Rylan Norcross, Chuen Ken Ng"""
  5.  
  6. # Import modules that are needed at a later date
  7.  
  8. import numpy as np
  9. import matplotlib.pyplot as plt
  10.  
  11. # Known Parameters
  12.                                     #Units
  13. """Properties of Air"""
  14. c0 = 343                            #Metres per Second
  15. rho0 = 1.2                          #Kilograms per Metre Cubed
  16.  
  17. """Properties of the floor panel (in this case the aluminium plate)"""
  18.  
  19. width = 2.7                         #Metres
  20. length = 2.5                        #Metres
  21. area = width*length                 #Metres Squared
  22. dampingLF = 0.1                     #Arbitary
  23. thickness = 4e-3                    #Metres
  24. density = 2700.                     #Kilograms per Metre Cubed
  25. massFloor = density*area*thickness  #Kilograms
  26. muFloor = massFloor/thickness       #Kilograms per Metre Squared
  27. youngsModulus = 69e9
  28.  
  29. """Properties of the engine"""
  30.  
  31. massEngine = 1700.                  #Kilograms
  32. resonanceFreqEngine = 6.            #Hertz
  33.  
  34. """Experimental data"""
  35.  
  36. #Frequencies used in Hz
  37. freq = [31.5, 63, 125, 250, 500, 1000, 2000, 4000, 8000]
  38. #Angular Frequencies used in rad/s
  39. angularFreq = [2*np.pi*x for x in freq]
  40. #Measured SPL of Engine at each Frequence in dB
  41. engineSPL = [95, 104, 109.5, 110.5, 109, 111, 109.5, 104.5, 98]
  42. #Measured vertical vibration spectrum of engine at each Frequency in dB
  43. engineAcceleration = [143, 146, 147, 146.5, 150.5, 158, 162.5, 163.5, 163]
  44. #Measured noise spectrum due to rolling noise at each Frequency in dB
  45. noiseSPL =[90, 85, 72, 61, 57, 52, 50, 44, 38]
  46.  
  47. # Sound Reduction Index
  48.  
  49. def stiffnessPerUnitAreaCalculator(E, L):
  50.     s = E/L
  51.     return s
  52.  
  53. def soundReductionIndexPlotter(mu, frequency, angularFrequency, rho, c, s, lossfactor):
  54.     angularResonantFrequency = np.sqrt(s/mu)
  55.     resonantFrequency = angularResonantFrequency/(2*np.pi)
  56.     print ""
  57.     print "Resonance Frequency = " + str(resonantFrequency)
  58.     print ""
  59.     soundReductionIndices = []
  60.     for w in angularFrequency:
  61.         fluidLoadingParameter = w * mu / (rho * c)
  62.         if w < angularResonantFrequency:
  63.             soundReductionIndex = 20*np.log10(s/(2*w*rho*c))
  64.             soundReductionIndices.append(soundReductionIndex)
  65.         else:
  66.             if w == angularResonantFrequency:
  67.                 # Stiffness controlled
  68.                 a = (s * lossfactor / w) / (2 * rho * c)
  69.                 b = fluidLoadingParameter
  70.                 c = s / (w * rho * c)
  71.                 transmissionCoefficient = 1 / ((1 + a) ** 2 + 0.25 * ((b - c) ** 2))
  72.             else:
  73.                 transmissionCoefficient = (1 + (fluidLoadingParameter / 2) ** 2) ** -1
  74.             soundReductionIndex = 10*np.log10(1/transmissionCoefficient)
  75.             soundReductionIndices.append(soundReductionIndex)
  76.     plt.figure()
  77.     plt.plot(frequency, soundReductionIndices)
  78.     plt.xscale('log')
  79.     plt.xlabel("Frequency (Hz)")
  80.     plt.ylabel("Sound Reduction Index (dB)")
  81.     plt.grid()
  82.     plt.show()
  83.  
  84. # Rylan
  85.  
  86. def dBToAccel(AdB=engineAcceleration):
  87.     accelerations = []
  88.     for a in AdB:
  89.         A = (10 ** (a / 10.0)) * 10e-6
  90.         accelerations.append(A)
  91.     return accelerations
  92.  
  93.  
  94. def plotAcceleration(frequencies=freq):
  95.     fig1 = plt.figure()
  96.     fig1.add_subplot(111)
  97.     plt.plot(np.log10(frequencies), dBToAccel())
  98.     plt.xlabel("Frequency (Hz)")
  99.     plt.ylabel("Acceleration (m/s^2)")
  100.     plt.title("Acceleration")
  101.     plt.grid()
  102.     return None
  103.  
  104.  
  105. def accelToVel(radialFreqs=angularFreq, accelerations=dBToAccel()):
  106.     # Assuming A's are peak acceleration values at each frequency f
  107.     velocities = []
  108.     for w, A in zip(radialFreqs, accelerations):
  109.         V = A / w
  110.         velocities.append(V)
  111.     return velocities
  112.  
  113.  
  114. def plotVelocity(frequencies=freq):
  115.     fig2 = plt.figure()
  116.     fig2.add_subplot(111)
  117.     plt.plot(np.log10(frequencies), accelToVel())
  118.     plt.xlabel("Frequency (Hz)")
  119.     plt.ylabel("Velocity (m/s)")
  120.     plt.title("Veloctiy")
  121.     plt.grid()
  122.     return None
  123.  
  124. plotAcceleration()
  125. plotVelocity()
  126.  
  127. def YZbeam(radialFreqs=angularFreq, E=youngsModulus, rho=density):
  128.     b = 75 * 1e-3  # width of beam
  129.     d = 180 * 1e-3  # height of beam
  130.     I = b * (d ** 3.0) / 12
  131.     A = b * d
  132.     mobilities = []
  133.     impedances = []
  134.     for w in radialFreqs:
  135.         zbeam = 2 * (1 + 1j) * (w ** 0.5) * ((E * I) ** (0.25)) * ((rho * A) ** (0.75))
  136.         impedances.append(zbeam)
  137.         ybeam = 1 / zbeam
  138.         mobilities.append(ybeam)
  139.     return mobilities, impedances
  140.  
  141.  
  142. def mountsKTotal(fnat=resonanceFreqEngine, m=massEngine):
  143.     """Caclulates the total stiffness of the two mounts"""
  144.     wnat = fnat * 2 * np.pi  # rad/s
  145.     kmounttot = (wnat ** 2.0) * m
  146.     return kmounttot
  147.  
  148.  
  149. def YZmounts(radialFreqs=angularFreq):
  150.     # mounts modelled as a spring mobility and Impedance
  151.     mobilities = []
  152.     impedances = []
  153.     k = mountsKTotal()
  154.     for w in radialFreqs:
  155.         Ys = (1j * w) / k
  156.         mobilities.append(Ys)
  157.         Zs = 1 / Ys
  158.         impedances.append(Zs)
  159.     return mobilities, impedances
  160.  
  161.  
  162. def YZengine(radialFreqs=angularFreq, m=massEngine):
  163.     # engine modelled as a mass mobility and Impedance
  164.     mobilities = []
  165.     impedances = []
  166.     for w in radialFreqs:
  167.         Ye = -1j / (w * m)
  168.         mobilities.append(Ye)
  169.         Ze = 1 / Ye
  170.         impedances.append(Ze)
  171.     return mobilities, impedances
  172.  
  173. # Vibration Isolation
  174.  
  175. def freeVelocity(fnat=resonanceFreqEngine, m=massEngine, radialFreqs=angularFreq, acceleration=engineAcceleration):
  176.     Y,Z = YZengine(radialFreqs, m)
  177.     force = [m*a for a in acceleration]
  178.     freeVelocity = [abs(f*mob) for f,mob in zip(Y,force)]
  179.     return freeVelocity
  180.  
  181. freeVelocities = freeVelocity()
  182. print ""
  183. print "Free Velocities"
  184. print freeVelocities
  185. print ""
  186.  
  187. def vibrationPower(fnat=resonanceFreqEngine, m=massEngine, radialFreqs=angularFreq, acceleration=engineAcceleration):
  188.     freeVel = freeVelocity()
  189.     squareFreeVel = [x**2 for x in freeVel]
  190.     rmsFreeVel = (sum(squareFreeVel)/len(squareFreeVel))**0.5
  191.     Yr,Zr = YZbeam(radialFreqs, m)
  192.     W = [np.real(z)*(rmsFreeVel**2) for z in Zr]
  193.     return W
  194.  
  195. def meanSquareVel(fnat=resonanceFreqEngine, m=massEngine, radialFreqs=angularFreq, acceleration=engineAcceleration, areaLength=10):
  196.     S = 10*width
  197.     power = vibrationPower()
  198.     meanSquareVelocity = [w/(dampingLF*]
  199.  
  200. # Radiation Efficiency
  201.  
  202. def radiationEfficiency(rho, c, S, V0, vnormal):
  203.     v = 1/2 * (V0**2)
  204.     W = rho*c*(v)*S
  205.     efficiency = W/(rho*c*S*(vnormal**2))
  206.     return efficiency
  207.  
  208. # Plot Def
  209.  
  210. def plots():
  211.     fig1 = plt.figure()
  212.     fig1.add_subplot(111)
  213.     plt.title("Mobility plots for the mounts, beams and engine")
  214.     plt.plot(freq, 20 * np.log10(np.abs(YZbeam()[0])), label='Beam mobility')
  215.     plt.plot(freq, 20 * np.log10(np.abs(YZmounts()[0])), label='Mount mobility')
  216.     plt.plot(freq, 20 * np.log10(np.abs(YZengine()[0])), label='Engine mobility')
  217.     plt.grid()
  218.     plt.legend(fontsize='small', loc='best')
  219.     plt.xlabel('Log Frequency (Hz)')
  220.     plt.ylabel('Mobility (dB)')
  221.     plt.semilogx()
  222.     fig2 = plt.figure()
  223.     fig2.add_subplot(111)
  224.     plt.title("Impedance plots for the mounts, beams and engine")
  225.     plt.plot(freq, 20 * np.log10(np.abs(YZbeam()[1])), label='Beam impedance')
  226.     plt.plot(freq, 20 * np.log10(np.abs(YZmounts()[1])), label='Mount impedance')
  227.     plt.plot(freq, 20 * np.log10(np.abs(YZengine()[1])), label='Engine impedance')
  228.     plt.grid()
  229.     plt.legend(fontsize='small', loc='best')
  230.     plt.xlabel('Log Frequency (Hz)')
  231.     plt.ylabel('Impedance (dB)')
  232.     plt.semilogx()
  233.  
  234.     plt.show()
  235.  
  236.  
  237. # Function Calling
  238.  
  239. x,y = YZbeam()
  240. print x
  241.  
  242. stiff = stiffnessPerUnitAreaCalculator(youngsModulus, length)
  243. soundReductionIndexPlotter(muFloor, freq, angularFreq, rho0, c0, stiff, dampingLF)
  244.  
  245. plots()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement