# Gaussian-shaped external current density

### Gaussian-shaped external current density passed by a Gaussian temporal current pulse

#### No absorbing boundaries

click for complete input

Instead of an incoming external plane wave, Octopus can simulate also external current densities placed inside the simulation box. In this example we place one shape of such a current density in the simulation box


%MaxwellBoundaryConditions
zero | zero | zero
%

%MaxwellAbsorbingBoundaries
not_absorbing | not_absorbing | not_absorbing
%


Since we start with no absorbing boundaries, we reset the box size to 10.0.


# ----- Maxwell box variables ---------------------------------------------------------------------

# free maxwell box limit of 10.0

lsize_mx = 10.0
dx_mx    = 0.5

Maxwell.BoxShape   = parallelepiped

%Maxwell.Lsize
lsize_mx | lsize_mx | lsize_mx
%

%Maxwell.Spacing
dx_mx | dx_mx | dx_mx
%


The external current density is switched on by the corresponding options and two blocks define its spatial distribution and its temporal behavior. The spatial distribution of our example external current is a Gaussian distribution in 3D. The temporal pulse is one Gaussian along the y-axis and one along the opposite direction but time shifted.


# ----- External current ------------------------------------------------------------------------

ExternalCurrent = yes
t1 = 4 * 5.0 / c
t2 = 6 * 5.0 / c
tw = 0.03
j = 1.0000

%UserDefinedMaxwellExternalCurrent
current_td_function | "0" | "0" | "j*exp(-x^2/2)*exp(-y^2/2)*exp(-z^2/2)" | 0 | "env_func_1"
current_td_function | "0" |" 0" | "j*exp(-x^2/2)*exp(-y^2/2)*exp(-z^2/2)" | 0 | "env_func_2"
%

%TDFunctions
"env_func_1" | tdf_gaussian |  1.0 | tw | t1
"env_func_2" | tdf_gaussian | -1.0 | tw | t2
%

gnuplot script

Contour plot of the electric field in z-direction after 120 time steps for t=0.24 and 180 time steps for t=0.36:

click for complete input


%MaxwellBoundaryConditions
zero | zero | zero
%

%MaxwellAbsorbingBoundaries
%

MaxwellABWidth = 5.0


Accordingly to the additional absorbing width, we have to update the simulation box dimensions.


# ----- Maxwell box variables ---------------------------------------------------------------------

# free maxwell box limit of 10.0 plus 5.0 for absorbing boundary conditions

lsize_mx = 15.0
dx_mx    = 0.5

Maxwell.BoxShape   = parallelepiped

%Maxwell.Lsize
lsize_mx | lsize_mx | lsize_mx
%

%Maxwell.Spacing
dx_mx | dx_mx | dx_mx
%


Contour plot of the electric field in z-direction after 120 time steps for t=0.24 and 180 time steps for t=0.36:

#### PML boundaries

click for complete input

We can repeat the simulation using PML absorbing boundaries.


%MaxwellBoundaryConditions
zero | zero | zero
%

%MaxwellAbsorbingBoundaries
cpml | cpml | cpml
%

MaxwellABWidth = 5.0
MaxwellABPMLPower              = 2.0
MaxwellABPMLReflectionError    = 1e-16


Contour plot of the electric field in z-direction after 120 time steps for t=0.24 and 180 time steps for t=0.36:

Maxwell fields at the origin and Maxwell energy inside the free Maxwell propagation region of the simulation box: