Commit d9372cd1 authored by Leon Merten Lohse's avatar Leon Merten Lohse
Browse files

remove mask from multislice propagation kernel

parent 8f31ee2b
Pipeline #181964 passed with stages
in 1 minute and 17 seconds
This diff is collapsed.
This diff is collapsed.
%% Cell type:code id: tags:
``` python
import numpy as np
import xraylib as xrl
import matplotlib.pyplot as plt
import fresnel.propagate as propagate
```
%%%% Output: error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-9a70ce741ace> in <module>
3 import matplotlib.pyplot as plt
4
----> 5 import fresnel.propagate as propagate
~/.local/lib/python3.9/site-packages/fresnel/propagate.py in <module>
4
5 from . import finite_differences as fd
----> 6 from .misc import fftfreqn
7
8 _lambda0 = 1.0 # all lengths are in units of the wavelength
~/.local/lib/python3.9/site-packages/fresnel/misc.py in <module>
1 import numpy as np
----> 2 from pyfftw.interfaces.numpy_fft import fftfreq
3
4
5 def fftfreqn(N, d=1.0):
ModuleNotFoundError: No module named 'pyfftw'
%% Cell type:code id: tags:
``` python
%matplotlib inline
```
%% Cell type:code id: tags:
``` python
energy = 12. # keV
# geometry
wavelength = 1.2398 / (energy * 1e3) * 1e-3 # mm
nx = 1024
nz = 1000
ztot = 0.4 # mm
wg_radius = 25e-6
xtot = 5 * wg_radius # mm
# units
dx = xtot / nx / wavelength
dz = ztot / nz / wavelength
print(f"dx: {dx}, dz: {dz} wavelengths")
```
%%%% Output: stream
dx: 1.18151617196322, dz: 3871.592192289079 wavelengths
%% Cell type:code id: tags:
``` python
density_Ge = xrl.ElementDensity(xrl.SymbolToAtomicNumber('Ge'))
density_Polyimide = 1.42
density_Si = xrl.ElementDensity(xrl.SymbolToAtomicNumber('Si'))
n_Ge = xrl.Refractive_Index('Ge', energy, density_Ge)
n_Si = xrl.Refractive_Index('Si', energy, density_Si)
n_PI = xrl.Refractive_Index('Kapton Polyimide Film', energy, density_Polyimide)
xx = np.arange(0, nx) * dx * wavelength
core = (np.abs(xx) < wg_radius)
cladding = ~core
refractive_index = n_Ge * cladding + 1 * core
```
%%%% Output: error
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-dd74c4c06808> in <module>
----> 1 density_Ge = xrl.ElementDensity(xrl.SymbolToAtomicNumber('Ge'))
2 density_Polyimide = 1.42
3 density_Si = xrl.ElementDensity(xrl.SymbolToAtomicNumber('Si'))
4 n_Ge = xrl.Refractive_Index('Ge', energy, density_Ge)
5 n_Si = xrl.Refractive_Index('Si', energy, density_Si)
NameError: name 'xrl' is not defined
%% Cell type:code id: tags:
``` python
boundary = (0,)
u0 = np.exp(-xx**2 / (2 * (2 * wg_radius)**2)).astype(np.complex128)
```
%% Cell type:code id: tags:
``` python
propagator = propagate.FDPropagatorCS(refractive_index, u0, dz, dx)
```
%% Cell type:code id: tags:
``` python
field = np.zeros((nz, nx), dtype=np.complex128)
field[0,...] = u0
for iz in range(1, nz):
boundary = (0,0)
field[iz, ...] = propagator.step(refractive_index, boundary)
```
%% Cell type:code id: tags:
``` python
result = field.transpose()
fig, ax = plt.subplots()
im = ax.imshow(np.abs(result[:,:])**2, aspect='auto', clim=(0,5), cmap='cubehelix', extent=[0, ztot, 0, xtot * 1e6])
ax.set_ylim(0, 2e6 * wg_radius )
fig.colorbar(im)
ax.set_xlabel(r'$z$ (mm)')
ax.set_ylabel(r'$x$ (nm)')
```
%%%% Output: display_data
%%%% Output: execute_result
Text(0, 0.5, '$x$ (nm)')
%% Cell type:code id: tags:
``` python
```
......
This diff is collapsed.
......@@ -24,11 +24,13 @@ def rayleighSommerfeldTF(shape, dperp, k, dz):
f = fftfreqn(shape, dperp) # spatial frequencies
f2 = squaresum(f)
mask = f2 < 1 / wl
# mask = f2 < 1 / wl
phasechirp = np.sqrt(1 - wl ** 2 * (mask * f2))
# phasechirp = np.sqrt(1 - wl ** 2 * (mask * f2))
phasechirp = np.sqrt(1 - wl ** 2 * f2)
TF = mask * np.exp(1j * k * dz * phasechirp)
# TF = mask * np.exp(1j * k * dz * phasechirp)
TF = np.exp(1j * k * dz * phasechirp)
return TF
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment