odak.learn.wave.impulse_response_fresnel¶
A definition to calculate impulse response based Fresnel approximation for beam propagation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field |
np.complex |
Complex field (MxN). |
required |
k |
odak.wave.wavenumber |
Wave number of a wave, see odak.wave.wavenumber for more. |
required |
distance |
float |
Propagation distance. |
required |
dx |
float |
Size of one single pixel in the field grid (in meters). |
required |
wavelength |
float |
Wavelength of the electric field. |
required |
Returns:
Type | Description |
---|---|
np.complex |
Final complex field (MxN). |
Source code in odak/learn/wave/classical.py
def impulse_response_fresnel(field, k, distance, dx, wavelength):
"""
A definition to calculate impulse response based Fresnel approximation for beam propagation.
Parameters
----------
field : np.complex
Complex field (MxN).
k : odak.wave.wavenumber
Wave number of a wave, see odak.wave.wavenumber for more.
distance : float
Propagation distance.
dx : float
Size of one single pixel in the field grid (in meters).
wavelength : float
Wavelength of the electric field.
Returns
-------
result : np.complex
Final complex field (MxN).
"""
assert True == False, "Refer to Issue 19 for more. This definition is unreliable."
nv, nu = field.shape[-1], field.shape[-2]
x = torch.linspace(-nu/2*dx, nu/2*dx, nu)
y = torch.linspace(-nv/2*dx, nv/2*dx, nv)
X, Y = torch.meshgrid(x, y, indexing='ij')
Z = X**2+Y**2
distance = torch.tensor([distance]).to(field.device)
h = torch.exp(1j*k*distance)/(1j*wavelength*distance) * \
torch.exp(1j*k/2/distance*Z)
h = torch.fft.fft2(torch.fft.fftshift(h))*dx**2
h = h.to(field.device)
U1 = torch.fft.fft2(torch.fft.fftshift(field))
U2 = h*U1
result = torch.fft.ifftshift(torch.fft.ifft2(U2))
return result
Notes¶
Unless you know what you are doing, we do not suggest you to use this function directly.
Rather stick to odak.learn.wave.propagate_beam
for your beam propagation code.