odak.learn.wave.transfer_function_fresnel¶
A definition to calculate convolution based Fresnel approximation for beam propagation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field |
torch.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 |
---|---|
torch.complex |
Final complex field (MxN). |
Source code in odak/learn/wave/classical.py
def transfer_function_fresnel(field, k, distance, dx, wavelength, zero_padding = False):
"""
A definition to calculate convolution based Fresnel approximation for beam propagation.
Parameters
----------
field : torch.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 : torch.complex
Final complex field (MxN).
"""
distance = torch.tensor([distance]).to(field.device)
nv, nu = field.shape[-1], field.shape[-2]
fx = torch.linspace(-1./2./dx, 1./2./dx, nu,
dtype=torch.float32).to(field.device)
fy = torch.linspace(-1./2./dx, 1./2./dx, nv,
dtype=torch.float32).to(field.device)
FY, FX = torch.meshgrid(fx, fy, indexing='ij')
H = torch.exp(1j*k*distance*(1-(FX*wavelength)**2-(FY*wavelength)**2)**0.5)
H = H.to(field.device)
U1 = torch.fft.fftshift(torch.fft.fft2(torch.fft.fftshift(field)))
if zero_padding == False:
U2 = H*U1
elif zero_padding == True:
U2 = zero_pad(H*U1)
result = torch.fft.ifftshift(torch.fft.ifft2(torch.fft.ifftshift(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.