Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable to initialize spatial/temporal/angular chirped laser + CI test #1136

Open
wants to merge 235 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
235 commits
Select commit Hold shift + click to select a range
a2ef19c
copy paste stretch factor from Warpx
huixingjian Jul 16, 2024
70c7489
reduce redundant defination of k0
huixingjian Jul 16, 2024
ef1046a
debug
huixingjian Jul 16, 2024
9059a67
amrex::print stretch factor
huixingjian Jul 16, 2024
9d29777
found no problem. bug in test program?
huixingjian Jul 16, 2024
c5237bc
set laser.tau no to be 0
huixingjian Jul 17, 2024
c0a364a
add the spatial temperal coupling term
huixingjian Jul 22, 2024
13745a7
missing ._rt
huixingjian Jul 22, 2024
1dd365d
fix typoo
huixingjian Jul 22, 2024
6e87829
fix typoo again
huixingjian Jul 22, 2024
c0c4fe6
Fix the dimension
huixingjian Jul 25, 2024
0bd0667
typoo
huixingjian Jul 25, 2024
349435d
debug
huixingjian Jul 25, 2024
27f2255
dimension error
huixingjian Jul 29, 2024
0aab9f9
debug when checking zeta
huixingjian Jul 29, 2024
fc1c939
add CI test to varify chirp inits
huixingjian Aug 12, 2024
8148926
typoo
huixingjian Aug 12, 2024
09fe97f
rename python test file
huixingjian Aug 12, 2024
718621b
fix some typoos
huixingjian Aug 12, 2024
2a0655a
add endline slash
huixingjian Aug 12, 2024
2e41451
missing argument
huixingjian Aug 12, 2024
3538fdc
cancel comma in py script
huixingjian Aug 12, 2024
73cb837
cancel redundant variables in laser_init_check_chirp.sh
huixingjian Aug 12, 2024
4e2697d
Merge branch 'origin_devel' into stretch_factor
huixingjian Sep 2, 2024
d04fb41
add to Cmakelists
huixingjian Sep 2, 2024
01ca26f
fix typo in .py file
huixingjian Sep 2, 2024
9a303bb
delete previous test result
huixingjian Sep 2, 2024
5ea5bde
fix typo on filename
huixingjian Sep 2, 2024
08b79c3
fix the typo
huixingjian Sep 2, 2024
9c6e8a8
add two debug lines in py testfile
huixingjian Sep 2, 2024
32be993
chmod the python file
huixingjian Sep 2, 2024
5908980
syntax error fixed
huixingjian Sep 2, 2024
4df1073
chmod py file
huixingjian Sep 2, 2024
65fc3ce
fix syntax error
huixingjian Sep 2, 2024
f908df7
cancel the space
huixingjian Sep 2, 2024
362fb05
fix bug in python
huixingjian Sep 2, 2024
81d945f
debug on zeta
huixingjian Sep 2, 2024
0dca6bc
change the resolution on the CI input
huixingjian Sep 3, 2024
e89bba1
debug on the py file
huixingjian Sep 3, 2024
5a0f6da
fix typo in py
huixingjian Sep 3, 2024
8176a78
change the resolution try again
huixingjian Sep 3, 2024
18658e4
changer the resolution
huixingjian Sep 3, 2024
b9e50f5
give permisiion
huixingjian Sep 3, 2024
406c78a
change the resolution one more time
huixingjian Sep 3, 2024
0d23f97
ad new input script for chirp test
huixingjian Sep 3, 2024
27cc3e7
change test value of zeta
huixingjian Sep 3, 2024
dabe389
modify inputscripts
huixingjian Sep 3, 2024
992cc79
reduce the resolution of chirp test
huixingjian Sep 3, 2024
51492ee
Further reduce the resoultion
huixingjian Sep 3, 2024
820ca99
change L/c to tau
huixingjian Sep 4, 2024
2c7d30b
FIXED input script
huixingjian Sep 4, 2024
554acf4
change the new boundary condition set
huixingjian Sep 4, 2024
1b2f2d7
add check for beta
huixingjian Sep 5, 2024
97058f9
DEBUG beta check
huixingjian Sep 5, 2024
bd13b8b
simplify the code
huixingjian Sep 5, 2024
8a689e7
add k0
huixingjian Sep 5, 2024
8348420
Standardize the code
huixingjian Sep 6, 2024
7fdb761
delete PFT_yz, add chirp_direction
huixingjian Sep 10, 2024
8d519b5
Update tests/laser_init_check_chirp.1Rank.sh
huixingjian Sep 30, 2024
397496b
Update examples/laser/inputs_chirp
huixingjian Sep 30, 2024
27c90ad
Update docs/source/run/parameters.rst
huixingjian Sep 30, 2024
aecd9fe
Update examples/laser/analysis_laser_init_chirp.py
huixingjian Sep 30, 2024
8a0fbac
fix format
huixingjian Sep 30, 2024
0016cb4
fix format
huixingjian Sep 30, 2024
d1afd49
change everything back
huixingjian Sep 30, 2024
f167457
formating chirp.py
huixingjian Sep 30, 2024
0988ea2
fix phi2
huixingjian Sep 30, 2024
d312ed9
cancel spaces
huixingjian Sep 30, 2024
b218ca3
typo
huixingjian Sep 30, 2024
2fadc4b
change the definition of clight in gaussian init
huixingjian Oct 2, 2024
fa87537
Update src/laser/Laser.cpp
huixingjian Oct 10, 2024
d26915c
Update examples/laser/analysis_laser_init_chirp.py
huixingjian Oct 10, 2024
6d3c8d9
Update examples/laser/analysis_laser_init_chirp.py
huixingjian Oct 10, 2024
4fb5d86
Update docs/source/run/parameters.rst
huixingjian Oct 10, 2024
3cbf88c
change the CI test file
huixingjian Oct 10, 2024
a192ad0
change the CI name
huixingjian Oct 10, 2024
7480ee1
Merge branch 'origin_devel' into stretch_factor
huixingjian Oct 11, 2024
520cb9b
Merge branch 'development' into stretch_factor
huixingjian Oct 11, 2024
7d9d65a
change the explanation of the sh file
huixingjian Oct 12, 2024
936f455
change the name of the parameter from chirp_theta to STC_theta
huixingjian Oct 12, 2024
aa94037
Update parameters.rst
huixingjian Oct 15, 2024
4577367
Update parameters.rst
huixingjian Oct 15, 2024
38c3eac
Update inputs_chirp
huixingjian Oct 15, 2024
b671512
Update parameters.rst
huixingjian Oct 15, 2024
c037958
Update analysis_laser_init_chirp.py
huixingjian Oct 15, 2024
599fae1
Update Laser.H
huixingjian Oct 15, 2024
0fc4205
Update laser_STC.SI.1Rank.sh
huixingjian Oct 15, 2024
f4ee936
Update parameters.rst
huixingjian Oct 15, 2024
233fd36
Update parameters.rst
huixingjian Oct 16, 2024
2203095
Update parameters.rst
huixingjian Oct 17, 2024
ccb07ce
Update tests/laser_STC.SI.1Rank.sh
huixingjian Oct 29, 2024
79c7f3a
Update docs/source/run/parameters.rst
huixingjian Oct 29, 2024
3eedf09
Update docs/source/run/parameters.rst
huixingjian Oct 29, 2024
720a077
Update docs/source/run/parameters.rst
huixingjian Oct 29, 2024
fb540f3
Update docs/source/run/parameters.rst
huixingjian Oct 29, 2024
97795e0
Update src/laser/Laser.H
huixingjian Oct 29, 2024
961f4e1
Update examples/laser/analysis_laser_init_chirp.py
huixingjian Oct 29, 2024
324f9a0
Update docs/source/run/parameters.rst
huixingjian Oct 29, 2024
8eac5fd
Update parameters.rst
huixingjian Oct 29, 2024
78f27bc
Update src/laser/Laser.H
huixingjian Oct 29, 2024
6bf42db
Update parameters.rst
huixingjian Oct 30, 2024
8470e92
Update parameters.rst
huixingjian Oct 30, 2024
5881045
Update docs/source/run/parameters.rst
MaxThevenet Nov 18, 2024
db37901
Update examples/laser/analysis_laser_init_chirp.py
huixingjian Nov 27, 2024
248e903
Update examples/laser/analysis_laser_init_chirp.py
huixingjian Nov 27, 2024
25630be
Update examples/laser/analysis_laser_init_chirp.py
huixingjian Nov 27, 2024
16a9e31
Update analysis_laser_init_chirp.py
huixingjian Nov 27, 2024
d78d093
Update analysis_laser_init_chirp.py
huixingjian Dec 4, 2024
3bb3ba7
Update analysis_laser_init_chirp.py
huixingjian Dec 4, 2024
3b9b19e
Update MultiLaser.cpp
huixingjian Dec 4, 2024
62d0ee3
Update analysis_laser_init_chirp.py
huixingjian Dec 4, 2024
ab9a5e1
Update analysis_laser_init_chirp.py
huixingjian Dec 4, 2024
7b37e55
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
f11c2bb
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
c01f483
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
d7fd8ff
Update inputs_chirp
huixingjian Dec 9, 2024
7483140
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
8e86f77
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
7c0b78a
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
53ebf23
Update laser_STC.SI.1Rank.sh
huixingjian Dec 9, 2024
34eabc7
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
9a1aac3
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
538b79a
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
d5f1b9a
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
64cae75
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
e439902
Update laser_STC.SI.1Rank.sh
huixingjian Dec 9, 2024
c861612
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
7e77299
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
f94d0f3
Update laser_STC.SI.1Rank.sh
huixingjian Dec 9, 2024
49ffe35
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
e7fdc30
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
1cf5942
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
4b137a8
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
3f5e205
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
a6598f5
Update inputs_SI
huixingjian Dec 9, 2024
294c638
Update laser_STC.SI.1Rank.sh
huixingjian Dec 9, 2024
06b3ea5
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
30e59c0
Update laser_STC.SI.1Rank.sh
huixingjian Dec 9, 2024
7a4c105
Update MultiLaser.cpp
huixingjian Dec 9, 2024
0c17d24
Update laser_STC.SI.1Rank.sh
huixingjian Dec 9, 2024
03420a5
Update inputs_chirp
huixingjian Dec 9, 2024
0afc89d
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
7cd81f4
Update MultiLaser.cpp
huixingjian Dec 9, 2024
5fa7db3
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
9b421f0
Update inputs_chirp
huixingjian Dec 9, 2024
eab515e
Update analysis_laser_init_chirp.py
huixingjian Dec 9, 2024
6e45dc5
use lasy to diag
huixingjian Dec 10, 2024
0df4f48
Update analysis_laser_init_chirp.py
huixingjian Dec 10, 2024
76d402b
Update ubuntu_ompi.sh
huixingjian Dec 10, 2024
29890bd
Update analysis_laser_init_chirp.py
huixingjian Dec 10, 2024
ac58466
Update inputs_chirp
huixingjian Dec 10, 2024
38dbc5b
Update analysis_laser_init_chirp.py
huixingjian Dec 10, 2024
a880f70
Update inputs_chirp
huixingjian Dec 10, 2024
b5015e1
Update ubuntu_ompi.sh
huixingjian Dec 10, 2024
ac709e0
Update analysis_laser_init_chirp.py
huixingjian Dec 10, 2024
815e663
Update analysis_laser_init_chirp.py
huixingjian Dec 10, 2024
b70fe7b
Update analysis_laser_init_chirp.py
huixingjian Dec 10, 2024
aa68948
Update laser_STC.SI.1Rank.sh
huixingjian Dec 10, 2024
bf1dae6
Update analysis_laser_init_chirp.py
huixingjian Dec 10, 2024
90f5506
Update laser_STC.SI.1Rank.sh
huixingjian Dec 10, 2024
bd28df6
Update analysis_laser_init_chirp.py
huixingjian Dec 10, 2024
eee6fba
Update analysis_laser_init_chirp.py
huixingjian Dec 11, 2024
7032c24
Update analysis_laser_init_chirp.py
huixingjian Dec 11, 2024
dfca07c
Update analysis_laser_init_chirp.py
huixingjian Dec 11, 2024
b125be0
Update analysis_laser_init_chirp.py
huixingjian Dec 11, 2024
b9ac2c8
Update analysis_laser_init_chirp.py
huixingjian Dec 11, 2024
925fdaf
Update analysis_laser_init_chirp.py
huixingjian Dec 11, 2024
8395f5b
Update analysis_laser_init_chirp.py
huixingjian Dec 11, 2024
e9df903
Update inputs_chirp
huixingjian Dec 11, 2024
10649f7
Update analysis_laser_init_chirp.py
huixingjian Dec 11, 2024
d1cb2dc
Update inputs_chirp
huixingjian Dec 11, 2024
25da5b6
Update analysis_laser_init_chirp.py
huixingjian Dec 11, 2024
a300083
Update inputs_chirp
huixingjian Dec 11, 2024
332126b
Update inputs_chirp
huixingjian Dec 11, 2024
c8c1ded
Update analysis_laser_init_chirp.py
huixingjian Dec 11, 2024
06a3149
Update inputs_chirp
huixingjian Dec 11, 2024
5868db7
Update inputs_chirp
huixingjian Dec 11, 2024
d509499
Update inputs_chirp
huixingjian Dec 12, 2024
cbc143c
Update inputs_chirp
huixingjian Dec 12, 2024
cb02a6f
Update inputs_chirp
huixingjian Dec 12, 2024
33e1be5
Update inputs_chirp
huixingjian Dec 12, 2024
440e2eb
Update analysis_laser_init_chirp.py
huixingjian Dec 16, 2024
898ff88
Update inputs_chirp
huixingjian Dec 16, 2024
9499527
Update analysis_laser_init_chirp.py
huixingjian Dec 16, 2024
3b5e418
Update analysis_laser_init_chirp.py
huixingjian Dec 16, 2024
bce8836
Update analysis_laser_init_chirp.py
huixingjian Dec 16, 2024
cc30256
Update inputs_chirp
huixingjian Dec 16, 2024
06eadd6
Update inputs_chirp
huixingjian Dec 16, 2024
ca25ee1
Update MultiLaser.cpp
huixingjian Dec 16, 2024
8b62764
Update MultiLaser.cpp
huixingjian Dec 16, 2024
473e3ba
Update analysis_laser_init_chirp.py
huixingjian Dec 16, 2024
f842f5c
Update inputs_chirp
huixingjian Dec 16, 2024
e9a863c
Update inputs_chirp
huixingjian Dec 16, 2024
eda52e9
Update inputs_chirp
huixingjian Dec 16, 2024
9594260
Update MultiLaser.cpp
huixingjian Dec 16, 2024
2938830
Update MultiLaser.cpp
huixingjian Dec 16, 2024
47c31ec
Update inputs_chirp
huixingjian Dec 16, 2024
264431d
Update inputs_chirp
huixingjian Dec 16, 2024
c54bad4
Update analysis_laser_init_chirp.py
huixingjian Dec 16, 2024
4651541
Update inputs_chirp
huixingjian Dec 17, 2024
e5eb5f1
Update analysis_laser_init_chirp.py
huixingjian Dec 17, 2024
44526ae
Update inputs_chirp
huixingjian Dec 17, 2024
1b98624
Update inputs_chirp
huixingjian Dec 17, 2024
a7ba153
Update inputs_chirp
huixingjian Dec 17, 2024
629001d
Update analysis_laser_init_chirp.py
huixingjian Dec 17, 2024
1f5241e
Update analysis_laser_init_chirp.py
huixingjian Dec 17, 2024
b43e6e1
Update inputs_chirp
huixingjian Dec 17, 2024
2851f9a
Update inputs_chirp
huixingjian Dec 17, 2024
9a65bb1
Update analysis_laser_init_chirp.py
huixingjian Dec 17, 2024
c6f584d
Update inputs_chirp
huixingjian Dec 17, 2024
503b8f7
Update inputs_chirp
huixingjian Dec 17, 2024
05c82e7
Update inputs_chirp
huixingjian Dec 17, 2024
3b6695d
Update inputs_chirp
huixingjian Dec 17, 2024
56327e9
Update analysis_laser_init_chirp.py
huixingjian Dec 17, 2024
cb070e9
Update inputs_chirp
huixingjian Dec 17, 2024
4f53a72
Update ubuntu_ompi.sh
huixingjian Jan 9, 2025
e06306c
Update ubuntu_ompi.sh
huixingjian Jan 9, 2025
0e22e18
Merge branch 'development' into stretch_factor
huixingjian Jan 9, 2025
a1214ce
Update ubuntu_ompi.sh
huixingjian Jan 9, 2025
e345bcf
pip install lasy
huixingjian Jan 9, 2025
09b73ac
Update analysis_laser_init_chirp.py
huixingjian Jan 9, 2025
76b9339
Update analysis_laser_init_chirp.py
huixingjian Jan 9, 2025
535bb4d
Update analysis_laser_init_chirp.py
huixingjian Jan 9, 2025
b27d3c1
Update analysis_laser_init_chirp.py
huixingjian Jan 9, 2025
f6c2299
Update analysis_laser_init_chirp.py
huixingjian Jan 9, 2025
d8734be
Update ubuntu.sh
huixingjian Jan 9, 2025
4f92ec5
Update inputs_chirp
huixingjian Jan 9, 2025
c61bb36
Update analysis_laser_init_chirp.py
huixingjian Jan 9, 2025
834aa59
Update ubuntu_ompi.sh
huixingjian Jan 10, 2025
3edda94
Update analysis_laser_init_chirp.py
huixingjian Jan 10, 2025
138600a
Update inputs_chirp
huixingjian Jan 10, 2025
461df6a
Update analysis_laser_init_chirp.py
huixingjian Jan 10, 2025
92426f7
Update inputs_chirp
huixingjian Jan 10, 2025
40a461b
Update inputs_chirp
huixingjian Jan 10, 2025
55ccc11
Update analysis_laser_init_chirp.py
huixingjian Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ if(BUILD_TESTING)
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)

add_test(NAME laser_STC.SI.1Rank
COMMAND bash ${HiPACE_SOURCE_DIR}/tests/laser_STC.SI.1Rank.sh
$<TARGET_FILE:HiPACE> ${HiPACE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)

if (NOT HiPACE_COMPUTE STREQUAL CUDA)

# These tests only run on CPU
Expand Down
31 changes: 29 additions & 2 deletions docs/source/run/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,36 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start
Distance at which the laser pulse is focused (in the z direction, counted from laser initial position).

* ``<laser name>.propagation_angle_yz`` (`float`) optional (default `0`)
Propagation angle of the pulse in the yz plane (0 is along the z axis)
Propagation angle of the pulse in the yz plane (0 is along z axis)
huixingjian marked this conversation as resolved.
Show resolved Hide resolved

Option: ``from_file`` the laser is loaded from an openPMD file.
* ``<laser name>.STC_theta_xy`` (`float`) optional (default `pi/2`)
Direction of the linear spatial and angular chirp on xoy plane (0 is along x axis).
huixingjian marked this conversation as resolved.
Show resolved Hide resolved

* ``<laser name>.beta`` (`float`) optional (default `0.`)
Angular dispersion (or angular chirp) at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) <https://doi.org/10.1364/OPEX.12.004399>`__.

* ``<laser name>.zeta`` (`float`) optional (default `0.`)
Spatial chirp at focus defined by `S. Akturk et al., Optics Express 12, 4399 (2004) <https://doi.org/10.1364/OPEX.12.004399>`__.
huixingjian marked this conversation as resolved.
Show resolved Hide resolved

* ``<laser name>.phi2`` (`float`) optional (default `pi/2`)
The amount of temporal chirp :math:`\phi^{(2)}` at focus (in the lab frame).
huixingjian marked this conversation as resolved.
Show resolved Hide resolved
Namely, a wave packet centered on the frequency :math:`(\omega_0 + \delta \omega)` will reach its peak intensity at :math:`z(\delta \omega) = z_0 - c \phi^{(2)} \, \delta \omega`.
Thus, a positive :math:`\phi^{(2)}` corresponds to positive chirp, i.e., red part of the spectrum in the front of the pulse and blue part of the spectrum in the back.
More specifically, the electric field in the focal plane is of the form:
MaxThevenet marked this conversation as resolved.
Show resolved Hide resolved

.. math::

E(\boldsymbol{x},t) \propto Re\left[ \exp\left( -\frac{(t-t_{peak})^2}{\tau^2 + 2i\phi^{(2)}} + i\omega_0 (t-t_{peak}) + i\phi_0 \right) \right]

where :math:`\tau` is given by ``<laser_name>.tau`` and represents the Fourier-limited duration of the laser pulse. Thus, the actual duration of the chirped laser pulse is:

.. math::

\tau' = \sqrt{ \tau^2 + 4 (\phi^{(2)})^2/\tau^2 }

See also the definition in `S. Akturk et al., Optics Express 12, 4399 (2004) <https://doi.org/10.1364/OPEX.12.004399>`__.

huixingjian marked this conversation as resolved.
Show resolved Hide resolved
Option: ``from_file`` the laser is loaded from an openPMD file

* ``<laser name>.input_file`` (`string`) optional (default `""`)
Path to an openPMD file containing a laser envelope.
Expand Down
97 changes: 97 additions & 0 deletions examples/laser/analysis_laser_init_chirp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#! /usr/bin/env python3

# Copyright 2024
#
# This file is part of HiPACE++.
#
# Authors: Xingjian Hui
# License: BSD-3-Clause-LBNL

import argparse
import numpy as np
import scipy.constants as scc
from openpmd_viewer.addons import LpaDiagnostics

def get_zeta(Ar, m, w0, L):
nu = 0
summ = 0
huixingjian marked this conversation as resolved.
Show resolved Hide resolved
laser_module = np.abs(Ar)
phi_envelop = np.array(np.arctan2(Ar.imag, Ar.real))
# unwrap phi_envelop
phi_envelop = np.unwrap(np.unwrap(phi_envelop, axis=0), axis=1)
# calculate pphi_pz
z_diff = np.diff(m.z)
x_diff = np.diff(m.x)
pphi_pz = (np.diff(phi_envelop, axis=0)).T / (z_diff / scc.c)
pphi_pzpy = (np.diff(pphi_pz, axis=0)).T / x_diff
huixingjian marked this conversation as resolved.
Show resolved Hide resolved
for i in range(len(m.z) - 2):
for j in range(len(m.x) - 2):
nu = nu + pphi_pzpy[i, j] * laser_module[i, j]
summ = summ + laser_module[i, j]
nu = nu / scc.c / summ
huixingjian marked this conversation as resolved.
Show resolved Hide resolved
a = 4 * nu * w0**2 * L**4
b = -4 * scc.c
c = nu * w0**2 * L**2
zeta_roots = np.roots([a, b, c])
return np.min(zeta_roots)

def get_phi2 (Ar, m, tau):
# get temporal chirp phi2
temp_chirp = 0
summ = 0
laser_module1 = np.abs(Ar)
phi_envelop = np.unwrap(np.array(np.arctan2(Ar.imag, Ar.real)), axis=0)
# calculate pphi_pz
z_diff = np.diff(m.z)
pphi_pz = (np.diff(phi_envelop, axis=0)).T/ (z_diff/scc.c)
pphi_pz2 = ((np.diff(pphi_pz, axis=1)) / (z_diff[:len(z_diff)-1]) / scc.c).T
for i in range(len(m.z)-2):
for j in range(len(m.x)-2):
temp_chirp = temp_chirp + pphi_pz2[i,j] * laser_module1[i,j]
summ = summ + laser_module1[i,j]
x = temp_chirp * scc.c**2 / summ
a = 4 * x
b = -4
c = tau**4 * x
zeta_roots = np.roots([a, b, c])
return np.max(zeta_roots)

def get_centroids(F, x, z):
index_array = np.mgrid[0:F.shape[0], 0:F.shape[1]][1]
centroids = np.sum(index_array * np.abs(F**2), axis=1) / np.sum(np.abs(F**2), axis=1)
return z[centroids.astype(int)]

def get_beta(F, m, k0):
z_centroids = get_centroids(F.T, m.x, m.z)
weight = np.mean(np.abs(F.T)**2, axis = np.ndim(F) - 1)
derivative = np.gradient(z_centroids) / (m.x[1] - m.x[0])
return (np.sum(derivative * weight) / np.sum(weight)) / k0 / scc.c

parser = argparse.ArgumentParser(description = 'Verify the chirp initialization')
parser.add_argument('--output-dir',
dest='output_dir',
default='diags/hdf5',
help='Path to the directory containing output files')
parser.add_argument('--chirp_type',
dest='chirp_type',
default='phi2',
help='the type of the initialized chirp')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the help entries consistent in style

Suggested change
help='Path to the directory containing output files')
parser.add_argument('--chirp_type',
dest='chirp_type',
default='phi2',
help='the type of the initialized chirp')
help='Path to the directory containing output files')
parser.add_argument('--chirp_type',
dest='chirp_type',
default='phi2',
help='Type of the initialized chirp')

args = parser.parse_args()

ts = LpaDiagnostics(args.output_dir)

Ar, m = ts.get_field(field='laserEnvelope', iteration=0)
lambda0 = .8e-6 # Laser wavelength
w0 = 30.e-6 # Laser waist
L0 = 5e-6
tau = L0 / scc.c # Laser duration
k0 = 2 * scc.pi / lambda0
if args.chirp_type == 'phi2':
phi2 = get_phi2(Ar, m, tau)
assert(np.abs(phi2 - 2.4e-26) / 2.4e-26 < 1e-2)
elif args.chirp_type == 'zeta':
zeta = get_zeta(Ar, m, w0, L0)
assert(np.abs(zeta - 2.4e-19) / 2.4e-19 < 1e-2)
elif args.chirp_type == 'beta':
beta = get_beta(Ar, m, k0)
assert(np.abs(beta - 2e-17) / 2e-17 < 1e-2)
2 changes: 1 addition & 1 deletion examples/laser/inputs_SI
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ max_step = 30
hipace.dt = 70.e-6/clight
hipace.verbose=3

amr.n_cell = 128 128 50 # 128 128 100
amr.n_cell = 128 128 50

my_constants.kp_inv = 10.e-6

Expand Down
32 changes: 32 additions & 0 deletions examples/laser/inputs_chirp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
max_step = 1
hipace.dt = 70.e-6/clight
hipace.verbose = 3

amr.n_cell = 255 127 200

my_constants.kp_inv = 10.e-6

hipace.file_prefix = new
hipace.do_tiling = 0

geometry.prob_lo = -15.*kp_inv -15.*kp_inv -2.*kp_inv
geometry.prob_hi = 15.*kp_inv 15.*kp_inv 2.*kp_inv

lasers.names = laser
lasers.lambda0 = .8e-6

laser.a0 = 1
laser.position_mean = 0. 0. 0
laser.focal_distance = 0.0
laser.w0 = 30e-6
laser.L0 = 5e-6
amr.max_level = 0

diagnostic.output_period = 1

hipace.depos_order_xy = 0

boundary.field = Dirichlet
boundary.particle = Absorbing

diagnostic.diag_type = xz
14 changes: 9 additions & 5 deletions src/laser/Laser.H
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
*
* This file is part of HiPACE++.
*
* Authors: MaxThevenet, AlexanderSinn
* Severin Diederichs, atmyers, Angel Ferran Pousa
* Authors: MaxThevenet, AlexanderSinn, Severin Diederichs,
* atmyers, Angel Ferran Pousa, Xingjian Hui
* License: BSD-3-Clause-LBNL
*/

Expand All @@ -23,6 +23,7 @@ public:
*\param[in] laser_geom_3D 3D laser geometry for level 0
*/
void GetEnvelopeFromFileHelper (amrex::Geometry laser_geom_3D);

template<typename input_type>
void GetEnvelopeFromFile (amrex::Geometry laser_geom_3D);
Laser (std::string name, amrex::Geometry laser_geom_3D);
Expand All @@ -33,12 +34,15 @@ public:
amrex::Real m_a0 {0.}; /**< Laser peak normalized amplitude */
amrex::Real m_w0 {0.}; /**< Laser waist */
amrex::Real m_CEP {0.}; /**< Laser carrier-envelope phase (CEP) */
/** Propagation angle of the pulse in the yz plane (0 is the along the z axis) */
/** Propagation angle of the pulse in the yz plane (0 is along z axis) */
huixingjian marked this conversation as resolved.
Show resolved Hide resolved
amrex::Real m_propagation_angle_yz {0.};
/**Pulse front tilt angle of the pulse in yz plane (pi/2 is no PFT)*/
amrex::Real m_PFT_yz {MathConst::pi/2.0};
amrex::Real m_L0 {0.}; /**< Laser length (HW 1/e in amplitude) */
amrex::Real m_tau {0.}; /**< Laser duration (HW 1/e in amplitude) */
/** Time stretching factors */
amrex::Real m_STC_theta_xy {MathConst::pi/2.0};
huixingjian marked this conversation as resolved.
Show resolved Hide resolved
amrex::Real m_zeta {0.};
amrex::Real m_beta {0.};
amrex::Real m_phi2 {0.};
/** Focal distance of the laser pulse */
amrex::Real m_focal_distance {0.};
/** Average position of the Gaussian laser pulse */
Expand Down
10 changes: 7 additions & 3 deletions src/laser/Laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ Laser::Laser (std::string name, amrex::Geometry laser_geom_3D)
queryWithParser(pp, "w0", m_w0);
queryWithParser(pp, "CEP", m_CEP);
queryWithParser(pp, "propagation_angle_yz", m_propagation_angle_yz);
queryWithParser(pp, "PFT_yz", m_PFT_yz);
queryWithParser(pp, "STC_theta_xy", m_STC_theta_xy);
bool length_is_specified = queryWithParser(pp, "L0", m_L0);
bool duration_is_specified = queryWithParser(pp, "tau", m_tau);
AMREX_ALWAYS_ASSERT_WITH_MESSAGE( length_is_specified + duration_is_specified == 1,
"Please specify exlusively either the pulse length L0 or the duration tau of gaussian lasers");
if (duration_is_specified) m_L0 = m_tau*get_phys_const().c;
"Please specify exlusively either the pulse length L0 or the duration tau of the laser");
if (duration_is_specified) m_L0 = m_tau * get_phys_const().c;
if (length_is_specified) m_tau = m_L0 / get_phys_const().c;
queryWithParser(pp, "focal_distance", m_focal_distance);
queryWithParser(pp, "position_mean", m_position_mean);
queryWithParser(pp, "zeta", m_zeta);
queryWithParser(pp, "beta", m_beta);
queryWithParser(pp, "phi2", m_phi2);
return;
}
else if (m_laser_init_type == "parser") {
Expand Down
32 changes: 22 additions & 10 deletions src/laser/MultiLaser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,15 +874,20 @@ MultiLaser::InitLaserSlice (const int islice, const int comp)
}
else if (laser.m_laser_init_type == "gaussian") {
const amrex::Real a0 = laser.m_a0;
const amrex::Real w0 = laser.m_w0;
const amrex::Real w0_2 = laser.m_w0 * laser.m_w0;
const amrex::Real cep = laser.m_CEP;
const amrex::Real propagation_angle_yz = laser.m_propagation_angle_yz;
const amrex::Real PFT_yz = laser.m_PFT_yz - MathConst::pi/2.0;
const amrex::Real x0 = laser.m_position_mean[0];
const amrex::Real y0 = laser.m_position_mean[1];
const amrex::Real z0 = laser.m_position_mean[2];
const amrex::Real L0 = laser.m_L0;
const amrex::Real inv_tau2 = 1/(laser.m_tau*laser.m_tau);
const amrex::Real zfoc = laser.m_focal_distance;
const amrex::Real zeta = laser.m_zeta;
const amrex::Real beta = laser.m_beta;
const amrex::Real phi2 = laser.m_phi2;
const amrex::Real clight = get_phys_const().c;
const amrex::Real theta_xy = laser.m_STC_theta_xy;
amrex::ParallelFor(
bx,
[=] AMREX_GPU_DEVICE(int i, int j, int k)
Expand All @@ -891,21 +896,28 @@ MultiLaser::InitLaserSlice (const int islice, const int comp)
const amrex::Real y = j * dx_arr[1] + poff_y - y0;
const amrex::Real z = islice * dx_arr[2] + poff_z - z0;
// Coordinate rotation in yz plane for a laser propagating at an angle.
const amrex::Real yp = std::cos( propagation_angle_yz + PFT_yz ) * y \
- std::sin( propagation_angle_yz + PFT_yz ) * z;
const amrex::Real zp = std::sin( propagation_angle_yz + PFT_yz ) * y \
+ std::cos( propagation_angle_yz + PFT_yz ) * z;
const amrex::Real yp = std::cos(propagation_angle_yz) * y \
- std::sin(propagation_angle_yz) * z;
const amrex::Real zp = std::sin(propagation_angle_yz) * y \
+ std::cos(propagation_angle_yz) * z;
// For first laser, setval to 0.
if (ilaser == 0) {
arr(i, j, k, comp ) = 0._rt;
arr(i, j, k, comp + 1 ) = 0._rt;
}
// Compute envelope for time step 0
Complex diffract_factor = 1._rt + I * ( zp - zfoc + z0 * std::cos( propagation_angle_yz ) ) \
* 2._rt/( k0 * w0 * w0 );
Complex inv_complex_waist_2 = 1._rt /( w0 * w0 * diffract_factor );
Complex diffract_factor = 1._rt + I * (zp - zfoc + z0 * std::cos(propagation_angle_yz)) \
* 2._rt/(k0 * w0_2);
Complex inv_complex_waist_2 = 1._rt /(w0_2 * diffract_factor);
// Time stretching due to STCs and phi2 complex envelope
// (1 if zeta=0, beta=0, phi2=0)
Complex stretch_factor = 1._rt \
+ 4._rt * (zeta + beta * zfoc * inv_tau2) * (zeta + beta * zfoc * inv_complex_waist_2) \
+ 2._rt * I * (phi2 - beta * beta * k0 * zfoc) * inv_tau2;
Complex prefactor = a0 / diffract_factor;
Complex time_exponent = zp * zp / ( L0 * L0 );
Complex time_exponent = 1._rt / ( stretch_factor * L0 * L0 ) *
amrex::pow(zp - beta * k0 * (x * std::cos(theta_xy) + yp * std::sin(theta_xy)) * clight - 2._rt * I * (x * std::cos(theta_xy) + yp * std::sin(theta_xy))
* (zeta - beta * zfoc) * clight * inv_complex_waist_2, 2);
Complex stcfactor = prefactor * amrex::exp( - time_exponent );
Complex exp_argument = - ( x * x + yp * yp ) * inv_complex_waist_2;
Complex envelope = stcfactor * amrex::exp( exp_argument ) * \
Expand Down
60 changes: 60 additions & 0 deletions tests/laser_STC.SI.1Rank.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#! /usr/bin/env bash

# Copyright 2024
#
# This file is part of HiPACE++.
#
# Authors: Xingjian Hui
# License: BSD-3-Clause-LBNL


# This file is part of the HiPACE++ test suite.
# It initializes a Hipace simulation of a gaussian laser with initial STC parameters
# and test the correctness of the STC factors
huixingjian marked this conversation as resolved.
Show resolved Hide resolved

# Abort on first encountered error
set -eu -o pipefail

# Read input parameters
HIPACE_EXECUTABLE=$1
HIPACE_SOURCE_DIR=$2

HIPACE_EXAMPLE_DIR=${HIPACE_SOURCE_DIR}/examples/laser
HIPACE_TEST_DIR=${HIPACE_SOURCE_DIR}/tests

FILE_NAME=`basename "$0"`
TEST_NAME="${FILE_NAME%.*}"

# Run the simulation with initial phi2
mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \
laser.phi2 = 2.4e-26 \
laser.STC_theta_xy = 0 \
hipace.file_prefix = $TEST_NAME
# Compare the result with theory
$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \
--chirp_type="phi2"

rm -rf $TEST_NAME

# Run the simulation with initial zeta
mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \
laser.zeta = 2.4e-19 \
laser.STC_theta_xy = 0 \
hipace.file_prefix = $TEST_NAME

# Compare the result with theory
$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \
--chirp_type="zeta"

rm -rf $TEST_NAME

mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \
laser.beta = 2e-17 \
laser.STC_theta_xy = 0 \
hipace.file_prefix = $TEST_NAME
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make laser.STC_theta_xy = 0 default and not specify it every time.
Furthermore, could you run 1 single simulation with all chirps?

        laser.phi2 = 2.4e-26 \
        laser.zeta = 2.4e-19 \
        laser.beta = 2e-17 \

Would your post-processing disentangle these separately? That would be neat and quite convincing on the robustness of post-processing.

Suggested change
mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \
laser.phi2 = 2.4e-26 \
laser.STC_theta_xy = 0 \
hipace.file_prefix = $TEST_NAME
# Compare the result with theory
$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \
--chirp_type="phi2"
rm -rf $TEST_NAME
# Run the simulation with initial zeta
mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \
laser.zeta = 2.4e-19 \
laser.STC_theta_xy = 0 \
hipace.file_prefix = $TEST_NAME
# Compare the result with theory
$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \
--chirp_type="zeta"
rm -rf $TEST_NAME
mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \
laser.beta = 2e-17 \
laser.STC_theta_xy = 0 \
hipace.file_prefix = $TEST_NAME
mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \
laser.phi2 = 2.4e-26 \
hipace.file_prefix = $TEST_NAME
# Compare the result with theory
$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \
--chirp_type="phi2"
rm -rf $TEST_NAME
# Run the simulation with initial zeta
mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \
laser.zeta = 2.4e-19 \
hipace.file_prefix = $TEST_NAME
# Compare the result with theory
$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \
--chirp_type="zeta"
rm -rf $TEST_NAME
mpiexec -n 1 $HIPACE_EXECUTABLE $HIPACE_EXAMPLE_DIR/inputs_chirp \
laser.beta = 2e-17 \
hipace.file_prefix = $TEST_NAME

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huixingjian. I think you mention that the post-processing currently would not support this, correct? If so, it is alright to keep as is and reconsider once we have a better understanding on this.


# Compare the result with theory
$HIPACE_EXAMPLE_DIR/analysis_laser_init_chirp.py --output-dir=$TEST_NAME \
--chirp_type="beta"

rm -rf $TEST_NAME
2 changes: 2 additions & 0 deletions tests/laser_evolution.SI.2Rank.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ $HIPACE_TEST_DIR/checksum/checksumAPI.py \
--rtol $RTOL \
--file_name $TEST_NAME \
--test-name $TEST_NAME

rm -rf $TEST_NAME
Loading