def plane_interference(distance, wavelength, phase_diff, sampling_density, a_direction, b_direction): surface = lambda a, b: (a, b, distance) source1 = (0, 0, 0) source2 = (0, 0, 0) pin1 = hl.PlaneWave(source=source1, wavelength=wavelength, amplitude=1, init_phase=0, direction=a_direction) pin2 = hl.PlaneWave(source=source2, wavelength=wavelength, amplitude=1, init_phase=phase_diff, direction=b_direction) points = hl.eval_surface_intensity(sources=(pin1, pin2), surface=surface, a_range=(-15, 15), b_range=(-15, 15), a_density=sampling_density, b_density=sampling_density) 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) return canv
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
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))) print(planewave2.path_length(location=(0, 1))) print(source1.phase_at(location=(0, 0))) print(source1.phase_at(location=(1, 0))) print(source1.phase_at(location=(0.000000045, 0))) print(source1.detect(location=(0, 0))) print(source1.detect(location=(1, 0))) print(hl.cart_to_polar(hl.field_at(sources=[source1], location=(0, 0)))) print(hl.cart_to_polar(hl.field_at(sources=[source1], location=(1, 0)))) print(hl.cart_to_polar(hl.field_at(sources=[source2], location=(1, 0)))) print(hl.intensity_at(sources=[source1], location=(1, 0)))
import sys sys.path.append('../hallucinator') 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),