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

How to use Lasy #209

Open
laxmisubramanyam opened this issue Nov 8, 2023 · 8 comments
Open

How to use Lasy #209

laxmisubramanyam opened this issue Nov 8, 2023 · 8 comments
Labels

Comments

@laxmisubramanyam
Copy link

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

@RemiLehe
Copy link
Member

RemiLehe commented Nov 8, 2023

Hi @laxmisubramanyam,

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!

@laxmisubramanyam
Copy link
Author

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

@laxmisubramanyam
Copy link
Author

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'

@laxmisubramanyam
Copy link
Author

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'.

@laxmisubramanyam
Copy link
Author

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.

@RemiLehe
Copy link
Member

RemiLehe commented Nov 9, 2023

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.

@ax3l ax3l added the question label Nov 9, 2023
@ax3l
Copy link
Member

ax3l commented Nov 9, 2023

@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

@ax3l ax3l reopened this Nov 9, 2023
@laxmisubramanyam
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants