Hi Jassim,
I suggest the following implementation:
- use the 'inloopFun' method of chi3D which is explained here:
hereBasically, it executes a function which is defined in the ‘inloopFun’ parameter under obj.simProp, for every step during the propagation.
Here an example for your TPA case:
Before you run your simulation you define the inloopFun parameter:
obj = chi3D(); %greate a chi3D object
obj('inloopFun','[Eftfxfy_o Eftfxfy_e]=TPA(obj,Eftfxfy_o,Eftfxfy_e);'); %this points to a function named TPA which needs to be in the same working folder
% now you can simply run the simulation
obj.run({'pulse1','Ny',1,'propagationLength',1e-3});
The TPA function (TPA.m) can look like this:
function [Eftfxfy_o Eftfxfy_e]=TPA(obj,Eftfxfy_o,Eftfxfy_e)
ce0=299792458/2*8.854e-12; %needed later for getting the intensity distribution; n is different for ordinary and extra-ordinary field
beta_o = 0; %TPA coefficient for the ordinary field
beta_e = .34e-11; %TPA coefficient for the extra-ordinary field
dz=obj.constVars.dz; %step size in z direction
n = meshgrid(obj.constVect.no,[1:obj.simProp.Nx])'; %ordinary refractiv index field in frequency domain; for 3D simulation this needs to be 3D as well
Etxy = ifftn(Eftfxfy_o.*sqrt(n)); %electrical field in vacuum -> intensity is independent on the refractive index
I_txy = abs(Etxy).^2 *ce0; %convert to intensity
dItx = -beta_o*I_txy.^2*obj.constVars.dz; %TPA -> dI = - beta * I^2 *dz
Ftx = 1+dItx./I_txy; %is is the time and spatial dependen two photon absorption factor for the propagation step dz
Eftfxfy_o = fftn(Etxy.*sqrt(Ftx))./sqrt(n); %applying the factor and transformation back to the spectral domain -> this field now is send back to the main loop in chi3D
%doing the same for the extra-ordinary field
n = obj.constVect.ne';
Etxy = ifftn(Eftfxfy_e.*sqrt(n));
I_txy = abs(Etxy).^2 *ce0;
dItx = -beta_e*I_txy.^2*obj.constVars.dz; % dI = - beta * I^2 *dz
Ftx = 1+dItx./I_txy;
Eftfxfy_e = fftn(Etxy.*sqrt(Ftx))./sqrt(n);
For the high green intensity in the SHG standard example this is a suprisingly strong effect.
Thanks for this question!
Best,
Tino
Tino Lang