How to use Lasy
Opened this issue · 8 comments
Hi friends, I heard about Lasy from some researchers in a meeting. I am interested in understanding how Lasy can be used to incorporate real laser profile (measured experimentally) into the simulation. For example, in FBPIC code, which we use for simulating LWFA.
We check the two example files given in (https://github.com/LASY-org/lasy/tree/development/examples) but these are not self explanatory. Is there any documentation where the example files are explained ?
More precisely the question is, from experiment one can have spectral and temporal profile of the laser pulse and best focus spot. How these informations can be used in Lasy to make a numerical laser profile, and how this laser profile can be migrated to FBPIC.
Best regards,
Laxmi
Thanks for your question. In addition to the examples that you mentioned, we also have a tutorial on how to create a simple lasy
file:
https://lasydoc.readthedocs.io/en/latest/tutorials/gaussian_laser.html
Maybe you can start with this.
In order to initialize a laser from spectral/temporal profile as well as best focal spot, you would replace the GaussianProfile in the above tutorial by a CombinedLongitudinalTransverseProfile, with a LongitudinalProfileFromData and TransverseProfileFromData.
See the links above for a more detailed description of these objects ; we will probably add another tutorial showing this capability in the future.
Finally, here is a test that shows the syntax for using a lasy
file in FBPIC:
https://github.com/fbpic/fbpic/blob/dev/tests/test_lasy_laser.py
This also documented here:
https://fbpic.github.io/api_reference/lpa_utilities/laser_profiles/from_lasy_file.html
Feel free to let us know if you have questions on the above!
Hi @RemiLehe, thanks for the clear and precise explanation. It's quite helpful. I will go through as per your suggestions. I hope it will work. If there are any questions, I will ask again to get more help.
Best regards,
Laxmi
Hi @RemiLehe, we encountered an error message when trying the simple Lasy file (Gaussian laser pulse): https://lasydoc.readthedocs.io/en/latest/tutorials/gaussian_laser.html
Error: 'Laser' object has no attribute 'show'
Hi @RemiLehe, another issue is with writing to openpmd format. The error message is the following:
Traceback (most recent call last):
File "/Users/laxmi/Desktop/Lasy_test/Gaussian_laser_pulse.py", line 51, in
laser.write_to_file(file_prefix, file_format)
File "/Users/laxmi/opt/anaconda3/lib/python3.9/site-packages/lasy/laser.py", line 270, in write_to_file
write_to_openpmd_file(
File "/Users/laxmi/opt/anaconda3/lib/python3.9/site-packages/lasy/utils/openpmd_output.py", line 47, in write_to_openpmd_file
series = io.Series("{}_%05T.{}".format(file_prefix, file_format), io.Access.create)
openpmd_api.openpmd_api_cxx.ErrorWrongAPIUsage: Wrong API usage: openPMD-api built without support for backend 'HDF5'.
Hi @RemiLehe, writing to openpmd format error disappear when I work on another PC. Now, I can save the file with the command laser.write_to_file(file_prefix, file_format).
But "laser.show()" still not working. ( Error: 'Laser' object has no attribute 'show' ).
I am closing this issue assuming that you will look later on why laser.show() is throwing an error.
I have some minor questions on organizing file for laser laser longitudinal profile, but may be I will ask it in an another thread.
Thanks again for raising this issue @laxmisubramanyam
Regarding the show
function: could you do:
pip install --upgrade lasy
This should download version 0.4.0 of lasy
, which should have the new show
function.
@laxmisubramanyam thank you for the note!
writing to openpmd format error disappear when I work on another PC. Now, I can save the file with the command laser.write_to_file(file_prefix, file_format).
That might be a bug on our side. Can you help me diagnose it further?
Can you please tell me on the PC that had an issue:
- What is the operating system?
- How was openPMD-api installed (pip? conda?)
- What does
python3 --version
return? - What does
python3 -c "import openpmd_api as io; print(io.__version__, io.__path__, io.variants)"
return for you on that system?
My current guess is that on the system that had the issue, the openPMD-api version might be slightly old and needs an update: openPMD/openPMD-api#1305
python3 -m pip install --upgrade openpmd-api
Hi @RemiLehe and @ax3l thanks for looking into the issue. Now, laser.show() is working.
Below are answers to the questions raised by @ax3l
What is the operating system?
MacOS Sonoma 14.0
How was openPMD-api installed (pip? Conda?)
This I don’t exactly remember, but I guess I use conda (because I use spyder from conda navigator).
Python3 --version
Python 3.9.13
python3 -c "import openpmd_api as io; print(io.__version__, io.__path__, io.variants)"
0.15.2 ['/Users/laxmi/opt/anaconda3/lib/python3.9/site-packages/openpmd_api'] {'adios1': False, 'adios2': True, 'hdf5': False, 'json': True, 'mpi': False}
python3 -m pip install –upgrade openmpd-api
doing above does not remove the error.