Пример #1
0
def make_pinholes(distance, wavelength, phase_diff, sampling_density,
                  separation):
    surface = lambda a, b: (a, b, distance)
    source1 = (-separation, 0, 0)
    source2 = (separation, 0, 0)

    pin1 = hl.PointSource(source=source1,
                          wavelength=wavelength,
                          amplitude=1,
                          init_phase=0)

    pin2 = hl.PointSource(source=source2,
                          wavelength=wavelength,
                          amplitude=1,
                          init_phase=phase_diff)

    points = hl.eval_surface_intensity(sources=(pin1, pin2),
                                       surface=surface,
                                       a_range=(-30, 30),
                                       b_range=(-30, 30),
                                       a_density=sampling_density,
                                       b_density=sampling_density)

    canv = hl.set_to_gradient(points,
                              x_range=(-30, 30),
                              y_range=(-30, 30),
                              black_ref=0,
                              white_ref=4.0,
                              default=hl.GRAY,
                              resolution=50)

    return canv
Пример #2
0
def make_zone_plate(distance, wavelength, phase_diff, a_density, b_density,
                    direction, x_range, y_range):
    surface = lambda a, b: (a, b, distance)
    source = (0, 0, 0)

    planewave = hl.PlaneWave(source=source,
                             wavelength=wavelength,
                             amplitude=1,
                             init_phase=0,
                             direction=direction)

    spherewave = hl.PointSource(source=source,
                                wavelength=wavelength,
                                amplitude=1,
                                init_phase=phase_diff)

    points = hl.eval_surface_intensity(sources=(planewave, spherewave),
                                       surface=surface,
                                       a_range=x_range,
                                       b_range=y_range,
                                       a_density=a_density,
                                       b_density=b_density)

    canv = hl.set_to_gradient(points,
                              x_range=x_range,
                              y_range=y_range,
                              black_ref=0,
                              white_ref=4.0,
                              default=hl.GRAY,
                              resolution=30)

    return canv
Пример #3
0
# use object module in 2d
import sys

sys.path.append('../hallucinator')
import hallucinator as hl
import math
import random

surface = lambda a, b: (a, b)
source1 = hl.PointSource(source=(-0.001, 0))
source2 = hl.PointSource(source=(0.001, 0))
source3 = hl.PointSource(source=(0, 0))
source4 = hl.PointSource(source=(0, -100))

num_sources = 2
slit_width = 0.01
interval = slit_width / num_sources
line_of_sources = []
for i in range(num_sources):
    #phase = random.uniform(0, 2*math.pi)
    phase = 0
    line_of_sources.append(
        hl.PointSource(source=(-slit_width / 2 + i * 2 * interval, 0),
                       phase_offset=phase))

planewave1 = hl.PlaneWave(source=(0, 0), direction=(0, 1))
planewave2 = hl.PlaneWave(source=(0, 0), direction=(1, 0))
'''print(source1.path_length(location=(1, 1)))
print(planewave1.path_length(location=(1, 0)))
print(planewave1.path_length(location=(0, 1)))
print(planewave2.path_length(location=(1, 0)))
Пример #4
0
import hallucinator as hl
import math
import numpy as np

surface = lambda a, b: (a, b, 10)
source = (0, 0, 0)
direction = (0, 0, 1)

planewave = hl.PlaneWave(source=source,
                         wavelength=0.05,
                         amplitude=1,
                         init_phase=0,
                         direction=direction)

spherewave = hl.PointSource(source=source,
                            wavelength=0.05,
                            amplitude=1,
                            init_phase=math.pi / 2)

points = hl.eval_surface_intensity(sources=(planewave, spherewave),
                                   surface=surface,
                                   a_range=(-15, 15),
                                   b_range=(-15, 15),
                                   density=15)

canv = hl.set_to_gradient(points,
                          x_range=(-15, 15),
                          y_range=(-15, 15),
                          black_ref=0,
                          white_ref=4.0,
                          default=hl.GRAY,
                          resolution=50)
Пример #5
0
# use object module in 2d
import sys

sys.path.append('../hallucinator')
import hallucinator as hl
import math
import random

surface = lambda a, b: (a, b)
source1 = hl.PointSource(source=(-0, 0))
planewave1 = hl.PlaneWave(source=(0, 0), direction=(0, 1))

a_range = (-5, 5)
b_range = (-5, 5)

intensities = hl.eval_surface(sources=[source1, planewave1],
                              surface=surface,
                              a_range=a_range,
                              b_range=b_range,
                              a_density=100,
                              b_density=100)

canv = hl.set_to_gradient(intensities,
                          x_range=a_range,
                          y_range=b_range,
                          black_ref=0,
                          white_ref=4.0,
                          default=hl.GRAY,
                          resolution=100)

hl.render_from_array(canv)