maxwelllink.tools package¶
- maxwelllink.tools.calc_transverse_components_3d(size=(20, 20, 20), dx=1.0, sigma=1.0, mu12=0.10, local_size=100, component='z')[source]¶
Calculate the transverse components of a 3D Gaussian polarization distribution.
- Parameters:
size (tuple of float of length 3) – The size of the simulation box in each dimension.
dx (float) – The spatial resolution (grid spacing) = 1 / resolution.
sigma (float) – The width of the Gaussian distribution.
mu12 (float) – The transition dipole moment scaling factor.
local_size (float) – The size of the local box for FFT calculations, which should be larger than size for convergence.
component (str) – The component of the polarization to calculate (‘x’, ‘y’, or ‘z’). Default is ‘z’.
- maxwelllink.tools.cosine_drive(amplitude_au=1.0, omega_au=0.1, phase_rad=0.0, t_start_au=0.0, t_end_au=1e10)[source]¶
Return a continuous cosine drive.
\[E(t) = A \cos(\omega t + \phi)\]- Parameters:
amplitude_au (float, default: 1.0) – Oscillation amplitude in atomic units.
omega_au (float, default: 0.1) – Angular frequency in atomic units.
phase_rad (float, default: 0.0) – Phase offset in radians.
t_start_au (float, default: 0.0) – Time before which the drive is zero (atomic units).
t_end_au (float, default: 1e10) – Time after which the drive is zero (atomic units).
- Returns:
A cosine drive suitable for steady-state excitation.
- Return type:
callable
- maxwelllink.tools.gaussian_enveloped_cosine(amplitude_au=1.0, t0_au=0.0, sigma_au=10.0, omega_au=0.1, phase_rad=0.0, t_start_au=0.0, t_end_au=1e10)[source]¶
Return a Gaussian-enveloped cosine drive.
\[E(t) = A \exp\left(-\frac{(t - t_0)^2}{2 \sigma^2}\right) \cos\bigl(\omega (t - t_0) + \phi\bigr)\]- Parameters:
amplitude_au (float, default: 1.0) – Peak field amplitude in atomic units.
t0_au (float, default: 0.0) – Temporal center of the pulse in atomic units.
sigma_au (float, default: 10.0) – Temporal sigma in atomic units.
omega_au (float, default: 0.1) – Angular frequency of the cosine wave in atomic units.
phase_rad (float, default: 0.0) – Phase of the cosine wave (radians).
t_start_au (float, default: 0.0) – Time before which the pulse is zero (atomic units).
t_end_au (float, default: 1e10) – Time after which the pulse is zero (atomic units).
- Returns:
A function
f(t_au)for use as a time-dependent electric field.- Return type:
callable
- maxwelllink.tools.gaussian_pulse(amplitude_au=1.0, t0_au=0.0, sigma_au=10.0, t_start_au=0.0, t_end_au=1e10)[source]¶
Return a Gaussian pulse drive.
\[E(t) = A \exp\left(-\frac{(t - t_0)^2}{2 \sigma^2}\right)\]- Parameters:
amplitude_au (float, default: 1.0) – Peak field amplitude in atomic units.
t0_au (float, default: 0.0) – Temporal center of the pulse in atomic units.
sigma_au (float, default: 10.0) – Temporal sigma in atomic units.
t_start_au (float, default: 0.0) – Time before which the pulse is zero (atomic units).
t_end_au (float, default: 1e10) – Time after which the pulse is zero (atomic units).
- Returns:
A function
f(t_au)that evaluates the Gaussian pulse att_au.- Return type:
callable
- maxwelllink.tools.ir_spectrum(x, dtfs, N=None, field_description='square', smooth_window_len=11)[source]¶
Compute an infrared spectrum from a dipole trajectory.
- Parameters:
x (numpy.ndarray) – Dipole moment trajectory.
dtfs (float) – Time step in femtoseconds.
N (int or None, optional) – Number of DCT points.
None(default) usesx.size. Values greater thanx.sizeresult in zero-padding.field_description ({'square', 'none'}, default: 'square') – Field prefactor passed to
fft(). Use'square'for dipole autocorrelation functions and'none'for velocity autocorrelations.smooth_window_len (int or None, optional) – Window length applied to smooth the spectrum.
Nonedisables smoothing. Default is 11.
- Returns:
numpy.ndarray – Frequencies in \(\text{cm}^{-1}\).
numpy.ndarray – Smoothed IR spectral intensities.
- Raises:
ValueError – If
field_descriptionis not'square'or'none'.
- maxwelllink.tools.k_parallel_pulse(cavity, envelope, omega_au, k_parallel_au, direction='y', center=(0.5, 0.5), size=(0.1, 0.1), amplitude_au=1.0, phase_rad=0.0, target='molecule', projection_axis=None)[source]¶
Build a multimode pulse with a selected in-plane wave vector.
The returned object is a callable
source(t_au)with shape(len(source.excited_grid_list),)fortarget="molecule"or(len(source.excited_mode_list),)fortarget="photon". It can be passed directly tomaxwelllink.MultiModeSimulationas eithermolecule_pulse_driveorphoton_pulse_drive.The physical in-plane wave-vector scale is the one used by
maxwelllink.FabryPerotCavity’s planar dispersion:\[\omega_k = \sqrt{\omega_c^2 + k_{\parallel,x}^2 + k_{\parallel,y}^2}.\]For
direction="y",k_parallel_auis mapped to the normalized fractional-coordinate phase byky_norm = pi * k_parallel_au / cavity.delta_omega_y_au.- Parameters:
cavity – A
FabryPerotCavityinstance. It must exposegrid_xyand the relevantdelta_omega_*_auvalue.envelope (Callable[[float], float] | float) – Time-domain envelope callable
envelope(t_au)or constant scalar multiplier. Use helpers such asgaussian_pulse(); the carriercos(omega_au * t - k*r)is supplied by this function. Passing1.0gives a continuous cosine source with grid-dependent phases.omega_au (float) – Carrier angular frequency in atomic units.
k_parallel_au (float) – Physical in-plane wave-vector contribution in atomic units, in the same units as
delta_omega_x_au/delta_omega_y_au.direction (str) – In-plane propagation direction:
"x","y","+x","-x","+y", or"-y".center (Sequence[float]) – Source center
(x, y)in fractional cavity coordinates.size (Sequence[float]) – Full source window size
(size_x, size_y)in fractional cavity coordinates. A smooth Hann window is applied inside this rectangle.amplitude_au (float) – Additional peak amplitude multiplier.
phase_rad (float) – Global carrier phase in radians.
target (str) – Source target, either
"molecule"or"photon". Molecule-targeted sources return one value per selected molecular grid point. Photon- targeted sources project the same spatial source onto cavity modes and return one value per selected mode.projection_axis (str | None) – Mode-function component used for photon-target projection. Defaults to
"y"fortarget="photon"and is ignored fortarget="molecule".
- Returns:
Callable source object with attributes including
target,excited_grid_list,excited_mode_list,spatial_window,spatial_phase, andk_order.- Return type:
callable
- maxwelllink.tools.lr_tddft_spectrum(energy_au, e_osc, e_cutoff_ev=30.0, linewidth=1e-2, w_step=1e-5)[source]¶
Construct an LR-TDDFT spectrum using Lorentzian broadening.
- Parameters:
energy_au (numpy.ndarray) – Excitation energies in atomic units.
e_osc (numpy.ndarray) – Oscillator strengths corresponding to
energy_au.e_cutoff_ev (float, default: 30.0) – Upper bound of the returned frequency grid in electron volts.
linewidth (float, default: 1e-2) – Lorentzian full width at half maximum in electron volts.
w_step (float, default: 1e-5) – Energy grid spacing in electron volts.
- Returns:
numpy.ndarray – Frequency grid in electron volts.
numpy.ndarray – Lorentzian-broadened spectrum.
- maxwelllink.tools.rt_tddft_spectrum(mu, dt_au, sp_form='absorption', e_start_ev=0.5, e_cutoff_ev=30.0, sigma=1e5, w_step=1e-5)[source]¶
Compute an RT-TDDFT spectrum via Pade-approximant Fourier transform.
- Parameters:
mu (numpy.ndarray) – Time-dependent dipole moment in atomic units.
dt_au (float) – Time step in atomic units.
sp_form ({'absorption', 'absolute'}, default: 'absorption') – Spectrum representation.
'absorption'returns-omega * Im(mu_tilde(omega));'absolute'returnsabs(mu_tilde(omega)).e_start_ev (float, default: 0.5) – Lower energy cutoff in electron volts.
e_cutoff_ev (float, default: 30.0) – Upper energy cutoff in electron volts.
sigma (float, default: 1e5) – Damping factor passed to
_pade().w_step (float, default: 1e-5) – Frequency grid spacing in atomic units used by
_pade().
- Returns:
numpy.ndarray – Frequency grid in electron volts.
numpy.ndarray – Spectrum on the selected grid with units determined by
sp_form.numpy.ndarray – Time grid in femtoseconds.
numpy.ndarray – Dipole moment trajectory (identical to the input
mu).