Exemple #1
0
"""
Monopole source is a good approximation for speaker mounted on the wall
of the duct if the wavelength of sound wave is much longer than the width
of duct.
"""

from __future__ import division
import numpy as np
import duct

freq = 50

#s = duct.MonopoleSource(position=1, generator=duct.PulseGenerator(amp=1, delay=0))
s = duct.MonopoleSource(position=1,
                        generator=duct.SineGenerator(q=0.001, freq=freq))

duct.animate([s])
Exemple #2
0
freq = 50
waveLength = duct.c0 / freq

qp = 1
primSrc = duct.MonopoleSource(position=1,
                              generator=duct.SineGenerator(qp, freq),
                              name='Primary source')

d = 0.5
L = waveLength * 3/4
k = 2*np.pi / waveLength

qs2 = -qp * np.exp(-1j*k*L) / (2j*np.sin(k*d))
qs1 = -qs2 * np.exp(-1j*k*d)

secSrc1 = duct.MonopoleSource(position=1+L,
                              generator=duct.SineGenerator(qs1, freq),
                              name='Secondary source 1')
secSrc2 = duct.MonopoleSource(position=1+L+d,
                              generator=duct.SineGenerator(qs2, freq),
                              name='Secondary source 2')
duct.animate([primSrc, secSrc1, secSrc2])

    





"""
alternative means of generating sound
"""

from __future__ import division
import numpy as np
import duct


duct.xMax = 10

freq = 50

f = 1
s = duct.DipoleSource(position=4, generator=duct.SineGenerator(f/(duct.ro0*duct.c0), freq))
#s = duct.DipoleSource(position=4, generator=duct.PulseGenerator(amp=1/(duct.ro0*duct.c0), delay=0))


duct.animate([s])




Exemple #4
0
# sine waves
if 0:
    freq = 50
    waveLength = duct.c0 / freq
    k = 2 * np.pi / waveLength

    q1 = 1
    #L = waveLength/2 # cancelation in both directions
    L = waveLength * 5 / 8
    #L = waveLength * 3/4
    #L = waveLength

    q2 = -q1 * np.exp(-1j * k * L)  # necessary for calculation
    primSrc = duct.MonopoleSource(position=1,
                                  generator=duct.SineGenerator(q1, freq))
    secSrc = duct.MonopoleSource(position=1 + L,
                                 generator=duct.SineGenerator(q2, freq))

# pulse
else:
    primSrc = duct.MonopoleSource(position=3,
                                  generator=duct.PulseGenerator(amp=1,
                                                                delay=0))
    L = 2
    delay = L / duct.c0
    secSrc = duct.MonopoleSource(position=3 + L,
                                 generator=duct.PulseGenerator(amp=-1,
                                                               delay=delay))

duct.animate([primSrc, secSrc])
Primary source radiates two rectangular pulses with opposite amplitude.
The result is ping pong pictured in figure 5.15 in the book.
"""

from __future__ import division
import numpy as np
import duct

duct.xMax = 10

L = 3
d = 1
amp = 0.01
primSrc_pulse1 = duct.MonopoleSource(position=1,
                                     generator=duct.PulseGenerator(amp),
                                     name='Primary source, 1st pulse')
primSrc_pulse2 = duct.MonopoleSource(position=1,
                                     generator=duct.PulseGenerator(
                                         -amp, 2 * d / duct.c0),
                                     name='Primary source, 2st pulse')
secSrc1 = duct.MonopoleSource(position=1 + L,
                              generator=duct.PulseGenerator(
                                  amp, (L + 2 * d) / duct.c0),
                              name='Secondary source 1')
secSrc2 = duct.MonopoleSource(position=1 + L + d,
                              generator=duct.PulseGenerator(
                                  -amp, (L + d) / duct.c0),
                              name='Secondary source 2')
duct.animate([primSrc_pulse1, primSrc_pulse2, secSrc1, secSrc2])
from __future__ import division
import numpy as np
import duct


duct.xMax = 10

freq = 50
waveLength = duct.c0 / freq
k = 2*np.pi / waveLength

qp = 0.01
primSrc = duct.MonopoleSource(position=1, generator=duct.SineGenerator(qp, freq),
                              name='Primary source')

L = waveLength * 3/4

f = - duct.ro0 * duct.c0 * qp/2 * np.exp(-1j*k*L)
qs = -qp/2 * np.exp(-1j*k*L)

secMonoSrc = duct.MonopoleSource(position=1+L, generator=duct.SineGenerator(qs, freq),
                                 name='Secondary monopole source')
secDipoleSrc = duct.DipoleSource(position=1+L, generator=duct.SineGenerator(f/(duct.ro0*duct.c0), freq),
                                 name='Secondary dipole source')

duct.animate([primSrc, secMonoSrc, secDipoleSrc])




Exemple #7
0
and secondary on the left at x=0.
"""

from __future__ import division
import numpy as np
import duct

duct.xMax = 5

freq = 50
waveLength = duct.c0 / freq
k = 2 * np.pi / waveLength

L = 2

ampPrim = 0.01
sp = duct.MonopoleSource(position=L,
                         generator=duct.PulseGenerator(ampPrim, 0),
                         name='Primary source')

# Amplitude and delay to ensure no reflected sound.
# Compared to equation 5.15.4 in Nelson&Elliott we added factor 1/2,
# because in our case the duct is opened on primary source side.
ampSec = -ampPrim / 2
delay = L / duct.c0
ss = duct.MonopoleSource(position=0,
                         generator=duct.PulseGenerator(ampSec, delay),
                         name='Secondary source')

duct.animate([sp, ss], reflect=True)
from __future__ import division
import numpy as np
import duct

duct.xMax = 10

freq = 50
waveLength = duct.c0 / freq
k = 2 * np.pi / waveLength

qp = 0.01
primSrc = duct.MonopoleSource(position=1,
                              generator=duct.SineGenerator(qp, freq),
                              name='Primary source')

L = waveLength * 3 / 4

f = -duct.ro0 * duct.c0 * qp / 2 * np.exp(-1j * k * L)
qs = -qp / 2 * np.exp(-1j * k * L)

secMonoSrc = duct.MonopoleSource(position=1 + L,
                                 generator=duct.SineGenerator(qs, freq),
                                 name='Secondary monopole source')
secDipoleSrc = duct.DipoleSource(position=1 + L,
                                 generator=duct.SineGenerator(
                                     f / (duct.ro0 * duct.c0), freq),
                                 name='Secondary dipole source')

duct.animate([primSrc, secMonoSrc, secDipoleSrc])
Exemple #9
0
import numpy as np
import duct

duct.xMax = 10

freq = 50
waveLength = duct.c0 / freq
k = 2 * np.pi / waveLength

D = 1
L = 2

# at D=0 and kL=pi/2+n*pi we will have truble - check the amplitude of sec source
#D = 0.01
#L = np.pi/(2*k)

qp = 0.01
primSrc = duct.MonopoleSource(position=D,
                              generator=duct.SineGenerator(qp, freq),
                              name='Primary source')

# equation 5.11.4 for R=1
qs = -qp * (np.exp(1j * k * D) + np.exp(-1j * k * D)) / (np.exp(1j * k * L) +
                                                         np.exp(-1j * k * L))

secSrc = duct.MonopoleSource(position=L,
                             generator=duct.SineGenerator(qs, freq),
                             name='Secondary source')

duct.animate([primSrc, secSrc], reflect=True)
duct.xMax = 10

freq = 50
waveLength = duct.c0 / freq
k = 2*np.pi / waveLength


D=1
L=2

# at D=0 and kL=pi/2+n*pi we will have truble - check the amplitude of sec source
#D = 0.01
#L = np.pi/(2*k)

qp = 0.01
primSrc = duct.MonopoleSource(position=D, generator=duct.SineGenerator(qp, freq),
                         name='Primary source')

# equation 5.11.4 for R=1
qs = -qp*(np.exp(1j*k*D) + np.exp(-1j*k*D)) / (np.exp(1j*k*L) + np.exp(-1j*k*L))

secSrc = duct.MonopoleSource(position=L, generator=duct.SineGenerator(qs, freq),
                         name='Secondary source')

duct.animate([primSrc, secSrc], reflect=True)




import duct


duct.xMax = 5

freq = 50
waveLength = duct.c0 / freq
k = 2*np.pi / waveLength



L = 2

ampPrim = 0.01
sp = duct.MonopoleSource(position=L, generator=duct.PulseGenerator(ampPrim, 0),
                         name='Primary source')

# Amplitude and delay to ensure no reflected sound.
# Compared to equation 5.15.4 in Nelson&Elliott we added factor 1/2,
# because in our case the duct is opened on primary source side.
ampSec = -ampPrim/2
delay = L/duct.c0
ss = duct.MonopoleSource(position=0, generator=duct.PulseGenerator(ampSec, delay),
                         name='Secondary source')

duct.animate([sp, ss], reflect=True)




from __future__ import division
import numpy as np
import duct


duct.xMax = 10


L = 3
d = 1
amp = 0.01
primSrc_pulse1 = duct.MonopoleSource(position=1,
                                     generator=duct.PulseGenerator(amp),
                                     name='Primary source, 1st pulse')
primSrc_pulse2 = duct.MonopoleSource(position=1,
                                     generator=duct.PulseGenerator(-amp, 2*d/duct.c0),
                                     name='Primary source, 2st pulse')
secSrc1 = duct.MonopoleSource(position=1+L,
                              generator=duct.PulseGenerator(amp, (L+2*d)/duct.c0),
                              name='Secondary source 1')
secSrc2 = duct.MonopoleSource(position=1+L+d,
                              generator=duct.PulseGenerator(-amp, (L+d)/duct.c0),
                              name='Secondary source 2')
duct.animate([primSrc_pulse1, primSrc_pulse2, secSrc1, secSrc2])
    





# sine waves
if 0:
    freq = 50
    waveLength = duct.c0 / freq
    k = 2*np.pi / waveLength

    q1 = 1
    #L = waveLength/2 # cancelation in both directions
    L = waveLength * 5/8
    #L = waveLength * 3/4
    #L = waveLength

    q2 = -q1 * np.exp(-1j*k*L) # necessary for calculation
    primSrc = duct.MonopoleSource(position=1, generator=duct.SineGenerator(q1, freq))
    secSrc = duct.MonopoleSource(position=1+L, generator=duct.SineGenerator(q2, freq))


# pulse
else:
    primSrc = duct.MonopoleSource(position=3, generator=duct.PulseGenerator(amp=1, delay=0))
    L = 2
    delay = L/duct.c0
    secSrc = duct.MonopoleSource(position=3+L, generator=duct.PulseGenerator(amp=-1, delay=delay))

    
duct.animate([primSrc, secSrc])