From cf57205f5f7dca2cea86cbc02fa63a6cc26aaa81 Mon Sep 17 00:00:00 2001 From: Maxence Thevenet Date: Thu, 3 Aug 2023 17:33:10 +0200 Subject: [PATCH] small change in E-a0 conversion --- lasy/utils/laser_utils.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lasy/utils/laser_utils.py b/lasy/utils/laser_utils.py index ece7c6e3..512e8186 100644 --- a/lasy/utils/laser_utils.py +++ b/lasy/utils/laser_utils.py @@ -326,11 +326,13 @@ def field_to_a0(field, axes, omega0): ------- Normalized vector potential """ + # Here, we neglect the time derivative of the envelope of E, the first RHS + # term in: E = -dA/dt + 1j * omega0 * A where E and A are the field and + # vector potential envelopes, respectively omega, _ = get_frequency(field, axes, is_envelope=True, omega0=omega0) - return e * field / (m_e * omega * c) + return -1j * e * field / (m_e * omega * c) - -def a0_to_field(a0, axes, omega0): +def a0_to_field(a0, axes, omega0, direct=True): """ Convert envelope from electric field (V/m) to normalized vector potential. @@ -346,9 +348,16 @@ def a0_to_field(a0, axes, omega0): omega0 : scalar Angular frequency at which the envelope is defined. + direct : boolean (optional) + If true, the conversion is done directly with derivative of vector + potential. Otherwise, this is done using the local frequency. Returns ------- Envelope of the electric field (V/m). """ - omega, _ = get_frequency(a0, axes, is_envelope=True, omega0=omega0) - return m_e * omega * c * a0 / e + if direct: + A = -np.gradient(a0, axes[-1], axis=-1, edge_order=2) + 1j * omega0 * a0 + return m_e * c / e * A + else: + omega, _ = get_frequency(a0, axes, is_envelope=True, omega0=omega0) + return 1j * m_e * omega * c * a0 / e