return ampl * sin(k * r) / sqrt(r)


ndiv = 100
ampl = 1.
lmbd = 1.
k = 2. * pi / lmbd
d = 50.
a = 2.
yl = -50.
yr = 50.
ny = 100

hy = (yr - yl) / ny

yarr = []
iarr = []

for iy in range(0, ny - 1):
    y = yl + iy * hy
    i = simpson(-a / 2., a / 2., ndiv, real_amp) ** 2 + simpson(-a / 2, a / 2, ndiv, imag_amp) ** 2
    yarr.append(180 / pi * asin(y / sqrt(y ** 2 + d ** 2)))
    iarr.append(i)

pyplot.figure('Exercise 1 - intensity chart', figsize=(9.5, 7))
pyplot.title('Intensity chart\nParameters: λ = %.2f, a = %.2f, d = %.2f' % (lmbd, a, d))
pyplot.xlabel("Angle from the system's axis of symmetry")
pyplot.ylabel('Intensity')
pyplot.plot(yarr, iarr)
pyplot.show()
Exemplo n.º 2
0
numberOfSlits = 2
slitWidth = 10.
distanceBetweenSlits = 8
yarr = []
iarr = []
xrMAX = 0.5 * (numberOfSlits * slitWidth +
               (numberOfSlits - 1) * distanceBetweenSlits)

for iy in range(0, ny - 1):
    y = yl + iy * hy
    intensity = 0
    xl = -0.5 * (numberOfSlits * slitWidth +
                 (numberOfSlits - 1) * distanceBetweenSlits)
    xr = xl + slitWidth
    while xr <= xrMAX:
        intensity += simpson(xl, xr, ndiv, real_amp)**2 + simpson(
            xl, xr, ndiv, imag_amp)**2
        xl += slitWidth + distanceBetweenSlits
        xr = xl + slitWidth
    yarr.append(180 / pi * asin(y / sqrt(y**2 + d**2)))
    iarr.append(intensity)

pyplot.figure('Multi-slit chart', figsize=(9.5, 7))
pyplot.title(
    'Intensity of wave\nParameters: λ = %.2f, a = %.2f, number of slits= %.2f, distance between slits = %.2f'
    % (lmbd, slitWidth, numberOfSlits, distanceBetweenSlits))
pyplot.xlabel("Angle from the system's axis of symmetry")
pyplot.ylabel('Intensity')
pyplot.plot(yarr, iarr)
pyplot.show()
Exemplo n.º 3
0
import matplotlib.pyplot as plt
import time

xl = 0
xr = 1
logValues = []
simpsonValues = []
calcTimes = []
nMax = floor(log10(1000000000))

for i in range(1, nMax):
    N = 10**i
    h = (xr - xl) / N / 2
    logValues.append(-log10(h))
    start = time.time()
    simpsonValues.append(simpson(xl, xr, N, fun))
    end = time.time()
    calcTimes.append(end - start)

plt.plot(logValues, simpsonValues)
plt.grid(1)
plt.title("Nf = " + str(N))
plt.xlabel("-log(h)")
plt.ylim([0, 2])
plt.ylabel("F")
plt.show()
plt.plot(logValues, calcTimes)
plt.grid(1)
plt.title("Nf = " + str(N))
plt.xlabel("-log(h)")
plt.ylabel("t [s]")
slitWidth = 10.
distanceBetweenSlits = 8.
yarr = []
iarr = []
xrMAX = 0.5 * (numberOfSlits * slitWidth +
               (numberOfSlits - 1) * distanceBetweenSlits)

for iy in range(0, ny - 1):
    y = yl + iy * hy
    intensityRe = 0
    intensityIm = 0
    xl = -0.5 * (numberOfSlits * slitWidth +
                 (numberOfSlits - 1) * distanceBetweenSlits)
    xr = xl + slitWidth
    while xr <= xrMAX:
        intensityRe += simpson(xl, xr, ndiv, real_amp)
        intensityIm += simpson(xl, xr, ndiv, imag_amp)
        xl += slitWidth + distanceBetweenSlits
        xr = xl + slitWidth
    yarr.append(180 / pi * asin(y / sqrt(y**2 + d**2)))
    intensity = intensityRe**2 + intensityIm**2
    iarr.append(intensity)

pyplot.figure('Multi-slit chart', figsize=(9.5, 7))
pyplot.title(
    'Intensity of wave\nParameters: λ = %.2f, a = %.2f, number of slits= %.2f, distance between slits = %.2f'
    % (lmbd, slitWidth, numberOfSlits, distanceBetweenSlits))
pyplot.xlabel("Angle from the system's axis of symmetry")
pyplot.ylabel('Intensity')
pyplot.plot(yarr, iarr)
pyplot.show()
Exemplo n.º 5
0
from quadrat import simpson
from math import sqrt, log
import matplotlib.pyplot as plt


def fun(x):
    return 4 * sqrt(1 - x * x)


print(simpson(0, 1, 1000000, fun))