-
Notifications
You must be signed in to change notification settings - Fork 22
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
ML surrogate example #482
ML surrogate example #482
Conversation
b599504
to
c1f1fdb
Compare
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, excellent!
I added a first round of review! 🙏
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Sigmoid = 4 | ||
|
||
|
||
def get_enum_type(type_to_test, EnumClass): |
Check notice
Code scanning / CodeQL
Explicit returns mixed with implicit (fall through) returns Note
def download_and_unzip(url, data_dir): | ||
request.urlretrieve(url, data_dir) | ||
with tarfile.open(data_dir) as tar_dataset: | ||
tar_dataset.extractall() |
Check failure
Code scanning / CodeQL
Arbitrary file write during tarfile extraction High
An example using PyTorch neural network surrogates in ImpactX. The neural networks are trained on data from WarpX simulations.
This is an example of 9 stages of Laser-plasma accelerator elements coupled with simple 3 cm beam transport between stages using idealized plasma lenses as illustrated in the below schematic.
![schema_9_stages](https://private-user-images.githubusercontent.com/10621396/289956389-c7463b99-fb56-490a-8511-22c43f45cdf8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzAzMDAsIm5iZiI6MTczOTA3MDAwMCwicGF0aCI6Ii8xMDYyMTM5Ni8yODk5NTYzODktYzc0NjNiOTktZmI1Ni00OTBhLTg1MTEtMjJjNDNmNDVjZGY4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDAzMDAwMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc2ODdiNDMxNWUxNDQzMzZiYjdhNDNjNWJlMmNjOTA1MjBjMTY1NjQ2M2I4YjFmNzRiYmNmODZjMmYxZTg1YTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.5yzXKmkfkG4mepugZ3vvui6R5SwNo_J3M5pmdVWLfFU)
Some initial phase space projections are as shown:
![initial_phase_spaces](https://private-user-images.githubusercontent.com/10621396/289956805-49e0a94a-454f-4b48-b448-7ac772edf95a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzAzMDAsIm5iZiI6MTczOTA3MDAwMCwicGF0aCI6Ii8xMDYyMTM5Ni8yODk5NTY4MDUtNDllMGE5NGEtNDU0Zi00YjQ4LWI0NDgtN2FjNzcyZWRmOTVhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDAzMDAwMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgyODUzYTRmZjMyMDFjZTczZGRkNzAxMTVkODIyMjJkYzE4NjNiMjkzYjkxYzhkZjJhYmM4ZjNjMmI1YzMwN2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.WeibiuvbqJ07lZJbVdv_pkWgFSKejyZrQF9w8EIohHg)
At the end of the 9 stages, the beam evolves to this:
![stage_8_phase_spaces](https://private-user-images.githubusercontent.com/10621396/289975961-7d389864-9106-4446-8556-b0ea4bb28145.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzAzMDAsIm5iZiI6MTczOTA3MDAwMCwicGF0aCI6Ii8xMDYyMTM5Ni8yODk5NzU5NjEtN2QzODk4NjQtOTEwNi00NDQ2LTg1NTYtYjBlYTRiYjI4MTQ1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDAzMDAwMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNhNTM1MDQwYmYxY2EwZTUxOThkZjZhMjNiNGY1ZjEyM2QwMWU0NjQzMmU1ZmE1Y2M5NjUxNTliYmJjNjEwNDkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Yh3N-DY3REFFQIvELQ3CgaGPswdt3_YMBzwEK9WWZZ4)
The beam moments evolve as shown:
![lpa_ml_surrogate_moments](https://private-user-images.githubusercontent.com/10621396/289976300-6f861d19-5a5c-42eb-9435-9f57bd2010bf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzAzMDAsIm5iZiI6MTczOTA3MDAwMCwicGF0aCI6Ii8xMDYyMTM5Ni8yODk5NzYzMDAtNmY4NjFkMTktNWE1Yy00MmViLTk0MzUtOWY1N2JkMjAxMGJmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDAzMDAwMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFlMmI5OTZlM2E3OTE2MWZiMzZkZTA5YzYwY2ViZThmZDViYWQzNjRhOGExMTA2N2VjZWEwZWVkZmQzMmMxMzEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.AQC4eMGkFpI0BGPvVy8xWLi2sEFPuLXQH04SkSBhHTM)
Actions