-
Notifications
You must be signed in to change notification settings - Fork 4
/
WaveSimVector.m
53 lines (49 loc) · 1.97 KB
/
WaveSimVector.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
classdef WaveSimVector < WaveSimBase
% Implementation of the modified Born series approach for
% vector waves
%
% The only difference that this function implements is in the
% propagation step
%
% Ivo Vellekoop & Gerwin Osnabrugge 2016-2020
properties
end
methods
function obj=WaveSimVector(refractive_index, options)
obj@WaveSimBase(refractive_index, options);
if ~isfield(options,'roi')
obj.roi(2,4) = 3; %by default return all 3 polarization planes
end
obj.N(4) = 3;
end
function E = propagate(obj, E, wiggle)
% calculate (I - p p^T / (k_0^2+i epsilon)
% TODO: replace ifft by fft somehow, because ifftn is slow!?
% apply wiggle phase ramps
if obj.gpu_enabled
E = arrayfun(@f_wiggle, E, wiggle.gx, wiggle.gy, wiggle.gz);
else
E = f_wiggle(E, wiggle.gx, wiggle.gy, wiggle.gz);
end
% Fourier transform all vector components separately
fEx = fftn(E(:,:,:,1));
fEy = fftn(E(:,:,:,2));
fEz = fftn(E(:,:,:,3));
clear E;
% apply propagation kernel
if obj.gpu_enabled
[fEx, fEy, fEz] = arrayfun(@f_g0_vector, fEx, fEy, fEz, wiggle.pxe, wiggle.pye, wiggle.pze, obj.k02e);
else
[fEx, fEy, fEz] = f_g0_vector(fEx, fEy, fEz, wiggle.pxe, wiggle.pye, wiggle.pze, obj.k02e);
end
% inverse Fourier transform all vector components
E = cat(4, ifftn(fEx), ifftn(fEy), ifftn(fEz));
% reverse wiggle phase ramp
if obj.gpu_enabled
E = arrayfun(@f_wiggle, E, conj(wiggle.gx), conj(wiggle.gy), conj(wiggle.gz));
else
E = f_wiggle(E, conj(wiggle.gx), conj(wiggle.gy), conj(wiggle.gz));
end
end
end
end