quvac 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. quvac-0.1.2/LICENSE +21 -0
  2. quvac-0.1.2/PKG-INFO +143 -0
  3. quvac-0.1.2/README.md +100 -0
  4. quvac-0.1.2/pyproject.toml +126 -0
  5. quvac-0.1.2/setup.cfg +4 -0
  6. quvac-0.1.2/src/quvac/__init__.py +1 -0
  7. quvac-0.1.2/src/quvac/analytic_scalings.py +168 -0
  8. quvac-0.1.2/src/quvac/cluster/config.py +6 -0
  9. quvac-0.1.2/src/quvac/cluster/fields.py +65 -0
  10. quvac-0.1.2/src/quvac/cluster/gridscan.py +234 -0
  11. quvac-0.1.2/src/quvac/cluster/optimization.py +627 -0
  12. quvac-0.1.2/src/quvac/config.py +19 -0
  13. quvac-0.1.2/src/quvac/field/__init__.py +35 -0
  14. quvac-0.1.2/src/quvac/field/abc.py +435 -0
  15. quvac-0.1.2/src/quvac/field/dipole.py +254 -0
  16. quvac-0.1.2/src/quvac/field/external_field.py +182 -0
  17. quvac-0.1.2/src/quvac/field/gaussian.py +471 -0
  18. quvac-0.1.2/src/quvac/field/laguerre_gaussian.py +140 -0
  19. quvac-0.1.2/src/quvac/field/maxwell.py +210 -0
  20. quvac-0.1.2/src/quvac/field/model.py +123 -0
  21. quvac-0.1.2/src/quvac/field/planewave.py +98 -0
  22. quvac-0.1.2/src/quvac/field/utils.py +183 -0
  23. quvac-0.1.2/src/quvac/grid.py +669 -0
  24. quvac-0.1.2/src/quvac/integrator/__init__.py +0 -0
  25. quvac-0.1.2/src/quvac/integrator/abc.py +18 -0
  26. quvac-0.1.2/src/quvac/integrator/vacuum_emission.py +283 -0
  27. quvac-0.1.2/src/quvac/log.py +298 -0
  28. quvac-0.1.2/src/quvac/plotting.py +267 -0
  29. quvac-0.1.2/src/quvac/postprocess.py +940 -0
  30. quvac-0.1.2/src/quvac/simulation.py +407 -0
  31. quvac-0.1.2/src/quvac/simulation_parallel.py +247 -0
  32. quvac-0.1.2/src/quvac/utils.py +218 -0
  33. quvac-0.1.2/src/quvac.egg-info/PKG-INFO +143 -0
  34. quvac-0.1.2/src/quvac.egg-info/SOURCES.txt +40 -0
  35. quvac-0.1.2/src/quvac.egg-info/dependency_links.txt +1 -0
  36. quvac-0.1.2/src/quvac.egg-info/entry_points.txt +5 -0
  37. quvac-0.1.2/src/quvac.egg-info/requires.txt +33 -0
  38. quvac-0.1.2/src/quvac.egg-info/top_level.txt +1 -0
  39. quvac-0.1.2/tests/test_field.py +268 -0
  40. quvac-0.1.2/tests/test_grid.py +244 -0
  41. quvac-0.1.2/tests/test_simulation.py +161 -0
  42. quvac-0.1.2/tests/test_utils.py +83 -0
quvac-0.1.2/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Maksim Valialshchikov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
quvac-0.1.2/PKG-INFO ADDED
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: quvac
3
+ Version: 0.1.2
4
+ Summary: Calculate quantum vacuum signal from the interaction of electromagnetic fields.
5
+ Author-email: Maksim Valialshchikov <maksim.valialshchikov@uni-jena.de>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/maxbalrog/quvac
8
+ Project-URL: Repository, https://github.com/maxbalrog/quvac
9
+ Keywords: quantum,vacuum,qed,maxwell,electrodynamics
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Programming Language :: Python
12
+ Requires-Python: >=3.12
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: pip>=25.0
16
+ Requires-Dist: numpy
17
+ Requires-Dist: scipy
18
+ Requires-Dist: numexpr
19
+ Requires-Dist: pyfftw
20
+ Requires-Dist: tqdm
21
+ Requires-Dist: submitit
22
+ Requires-Dist: pyyaml
23
+ Provides-Extra: optimization
24
+ Requires-Dist: ax-platform; extra == "optimization"
25
+ Provides-Extra: plot
26
+ Requires-Dist: matplotlib>=3.10.1; extra == "plot"
27
+ Requires-Dist: jupyterlab>=4.5.3; extra == "plot"
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest>=8.3.5; extra == "test"
30
+ Requires-Dist: pytest-cov>=6.1.0; extra == "test"
31
+ Provides-Extra: docs
32
+ Requires-Dist: astroid==3.3.8; extra == "docs"
33
+ Requires-Dist: sphinx>=8.2.1; extra == "docs"
34
+ Requires-Dist: jinja2>=3.1.0; extra == "docs"
35
+ Requires-Dist: furo==2024.8.6; extra == "docs"
36
+ Requires-Dist: sphinx-autoapi==3.6.0; extra == "docs"
37
+ Requires-Dist: sphinx-copybutton==0.5.2; extra == "docs"
38
+ Provides-Extra: light
39
+ Requires-Dist: quvac[docs,plot,test]; extra == "light"
40
+ Provides-Extra: all
41
+ Requires-Dist: quvac[docs,optimization,plot,test]; extra == "all"
42
+ Dynamic: license-file
43
+
44
+ # quvac
45
+
46
+ ![Tests](https://github.com/maxbalrog/quantum-vacuum/actions/workflows/tests.yml/badge.svg)
47
+ ![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/maxbalrog/d6b0645fa035119a53bb6356d169c98b/raw/quvac_coverage_badge.json)
48
+
49
+ <img src="images/logo.jpg" alt="Alt Text" width="250" height="230">
50
+
51
+ Quvac (from quantum vacuum, pronounced as qu-ack 🐸) allows to calculate quantum vacuum signals produced during light-by-light scattering.
52
+
53
+ Documentation is available [here](https://maxbalrog.github.io/quvac/).
54
+
55
+ > [!IMPORTANT]
56
+ > This project is still in development!
57
+
58
+ ## Installation
59
+
60
+ It is recommended to create a separate Python environment for this package, e.g.
61
+
62
+ ```bash
63
+ micromamba create -n quvac python=3.12
64
+ ```
65
+
66
+ After cloning the git repository and entering it, choose relevant optional dependencies
67
+
68
+ - `[test]` allows to run tests
69
+ - `[plot]` installs `matplotlib` and `jupyterlab`
70
+ - `[docs]` installs `sphinx` and everything necessary for documentation generation
71
+ - `[optimization]` installs Bayesian optimization package
72
+ - `[light]` is a shorthand for `[test,plot,docs]`
73
+
74
+ To install all dependencies, run
75
+
76
+ ```bash
77
+ pip install .[all]
78
+ ```
79
+
80
+ > [!NOTE]
81
+ > For example, if you do not require optimization capabilities, run
82
+ >
83
+ > ```bash
84
+ > pip install .[test,plot]
85
+ > ```
86
+
87
+ After successfull installation with `[all]` or `[test]` option, run ``pytest`` to make sure the installation was
88
+ successfull (it takes some time).
89
+
90
+ ```bash
91
+ pytest
92
+ ```
93
+
94
+ ### Using `uv`
95
+
96
+ If you prefer using `uv` package manager then the installation follows similar steps. After cloning the git repository and entering
97
+ it, create the environment and install `quvac`
98
+
99
+ ```bash
100
+ uv venv
101
+ uv pip install .[light]
102
+ ```
103
+
104
+ You can test the installation with
105
+
106
+ ```bash
107
+ uv run pytest
108
+ ```
109
+
110
+ Launch the jupyterlab (e.g. tutorial notebooks) with
111
+
112
+ ```bash
113
+ uv run jupyter lab
114
+ ```
115
+
116
+ Generate the documentation with
117
+
118
+ ```bash
119
+ uv run python -m sphinx -b html docs/source docs/build/html
120
+ ```
121
+
122
+ ## Contribution
123
+
124
+ If you noticed a bug or have a feature request, open a new [issue](https://github.com/maxbalrog/quvac/issues).
125
+
126
+ ## Acknowledgements
127
+
128
+ If you use this code and/or consider it useful, please cite our article.
129
+
130
+ ```bibtex
131
+ @article{valialshchikov2025back,
132
+ title={Back-reflection in dipole fields and beyond},
133
+ author={Valialshchikov, Maksim and Karbstein, Felix and Seipt, Daniel and Zepf, Matt},
134
+ journal={arXiv preprint arXiv:2510.11764},
135
+ year={2025}
136
+ }
137
+ ```
138
+
139
+ ## References
140
+
141
+ [1] - F. Karbstein, and R. Shaisultanov. "Stimulated photon emission from the vacuum." PRD 91.11 (2015): 113002 [[article]](https://arxiv.org/abs/1412.6050).
142
+
143
+ [2] - A. Blinne, et al. "All-optical signatures of quantum vacuum nonlinearities in generic laser fields." PRD 99.1 (2019): 016006 [[article]](https://arxiv.org/abs/1811.08895).
quvac-0.1.2/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # quvac
2
+
3
+ ![Tests](https://github.com/maxbalrog/quantum-vacuum/actions/workflows/tests.yml/badge.svg)
4
+ ![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/maxbalrog/d6b0645fa035119a53bb6356d169c98b/raw/quvac_coverage_badge.json)
5
+
6
+ <img src="images/logo.jpg" alt="Alt Text" width="250" height="230">
7
+
8
+ Quvac (from quantum vacuum, pronounced as qu-ack 🐸) allows to calculate quantum vacuum signals produced during light-by-light scattering.
9
+
10
+ Documentation is available [here](https://maxbalrog.github.io/quvac/).
11
+
12
+ > [!IMPORTANT]
13
+ > This project is still in development!
14
+
15
+ ## Installation
16
+
17
+ It is recommended to create a separate Python environment for this package, e.g.
18
+
19
+ ```bash
20
+ micromamba create -n quvac python=3.12
21
+ ```
22
+
23
+ After cloning the git repository and entering it, choose relevant optional dependencies
24
+
25
+ - `[test]` allows to run tests
26
+ - `[plot]` installs `matplotlib` and `jupyterlab`
27
+ - `[docs]` installs `sphinx` and everything necessary for documentation generation
28
+ - `[optimization]` installs Bayesian optimization package
29
+ - `[light]` is a shorthand for `[test,plot,docs]`
30
+
31
+ To install all dependencies, run
32
+
33
+ ```bash
34
+ pip install .[all]
35
+ ```
36
+
37
+ > [!NOTE]
38
+ > For example, if you do not require optimization capabilities, run
39
+ >
40
+ > ```bash
41
+ > pip install .[test,plot]
42
+ > ```
43
+
44
+ After successfull installation with `[all]` or `[test]` option, run ``pytest`` to make sure the installation was
45
+ successfull (it takes some time).
46
+
47
+ ```bash
48
+ pytest
49
+ ```
50
+
51
+ ### Using `uv`
52
+
53
+ If you prefer using `uv` package manager then the installation follows similar steps. After cloning the git repository and entering
54
+ it, create the environment and install `quvac`
55
+
56
+ ```bash
57
+ uv venv
58
+ uv pip install .[light]
59
+ ```
60
+
61
+ You can test the installation with
62
+
63
+ ```bash
64
+ uv run pytest
65
+ ```
66
+
67
+ Launch the jupyterlab (e.g. tutorial notebooks) with
68
+
69
+ ```bash
70
+ uv run jupyter lab
71
+ ```
72
+
73
+ Generate the documentation with
74
+
75
+ ```bash
76
+ uv run python -m sphinx -b html docs/source docs/build/html
77
+ ```
78
+
79
+ ## Contribution
80
+
81
+ If you noticed a bug or have a feature request, open a new [issue](https://github.com/maxbalrog/quvac/issues).
82
+
83
+ ## Acknowledgements
84
+
85
+ If you use this code and/or consider it useful, please cite our article.
86
+
87
+ ```bibtex
88
+ @article{valialshchikov2025back,
89
+ title={Back-reflection in dipole fields and beyond},
90
+ author={Valialshchikov, Maksim and Karbstein, Felix and Seipt, Daniel and Zepf, Matt},
91
+ journal={arXiv preprint arXiv:2510.11764},
92
+ year={2025}
93
+ }
94
+ ```
95
+
96
+ ## References
97
+
98
+ [1] - F. Karbstein, and R. Shaisultanov. "Stimulated photon emission from the vacuum." PRD 91.11 (2015): 113002 [[article]](https://arxiv.org/abs/1412.6050).
99
+
100
+ [2] - A. Blinne, et al. "All-optical signatures of quantum vacuum nonlinearities in generic laser fields." PRD 99.1 (2019): 016006 [[article]](https://arxiv.org/abs/1811.08895).
@@ -0,0 +1,126 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "quvac"
7
+ dynamic = ["version"]
8
+ dependencies = [
9
+ "pip>=25.0",
10
+ "numpy",
11
+ "scipy",
12
+ "numexpr",
13
+ "pyfftw",
14
+ "tqdm",
15
+ "submitit",
16
+ "pyyaml",
17
+ ]
18
+ requires-python = ">=3.12"
19
+ authors = [
20
+ {name = "Maksim Valialshchikov", email = "maksim.valialshchikov@uni-jena.de"},
21
+ ]
22
+ maintainers = [
23
+ ]
24
+ description = "Calculate quantum vacuum signal from the interaction of electromagnetic fields."
25
+ readme = "README.md"
26
+ license = "MIT"
27
+ license-files = ["LICENSE"]
28
+ keywords = ["quantum", "vacuum", "qed", "maxwell", "electrodynamics"]
29
+ classifiers = [
30
+ "Development Status :: 3 - Alpha",
31
+ "Programming Language :: Python",
32
+ ]
33
+
34
+ [project.scripts]
35
+ quvac-simulation = "quvac.simulation:main_simulation"
36
+ quvac-simulation-parallel = "quvac.simulation_parallel:main_simulation_parallel"
37
+ quvac-gridscan = "quvac.cluster.gridscan:main_gridscan"
38
+ quvac-optimization = "quvac.cluster.optimization:main_optimization"
39
+
40
+ [project.optional-dependencies]
41
+ optimization = [
42
+ "ax-platform",
43
+ ]
44
+ plot = [
45
+ "matplotlib>=3.10.1",
46
+ "jupyterlab>=4.5.3",
47
+ ]
48
+ test = [
49
+ "pytest>=8.3.5",
50
+ "pytest-cov>=6.1.0",
51
+ ]
52
+ docs = [
53
+ "astroid==3.3.8",
54
+ "sphinx>=8.2.1",
55
+ "jinja2>=3.1.0",
56
+ "furo==2024.8.6",
57
+ "sphinx-autoapi==3.6.0",
58
+ "sphinx-copybutton==0.5.2",
59
+ ]
60
+ light = [
61
+ "quvac[test,plot,docs]",
62
+ ]
63
+ all = [
64
+ "quvac[test,plot,optimization,docs]",
65
+ ]
66
+
67
+ [project.urls]
68
+ Homepage = "https://github.com/maxbalrog/quvac"
69
+ Repository = "https://github.com/maxbalrog/quvac"
70
+
71
+ [tool.setuptools.packages.find]
72
+ where = ["src"]
73
+
74
+ [tool.setuptools.dynamic]
75
+ version = {attr = "quvac.__version__"}
76
+
77
+ [tool.uv]
78
+ default-groups = "all"
79
+
80
+ [tool.pytest.ini_options]
81
+ markers = [
82
+ "slow: marks tests as slow (deselect with `-m 'not slow'`)",
83
+ "benchmark: marks tests as becnhmarks",
84
+ ]
85
+ addopts = "-m 'not slow' -m 'not benchmark' --ignore=tests/bench_optimization.py"
86
+ python_files = [
87
+ "bench_*.py",
88
+ "test_*.py",
89
+ ]
90
+
91
+ # exclude certain scripts from coverage report
92
+ [tool.coverage.run]
93
+ omit = [
94
+ "*/cluster/*",
95
+ "src/quvac/analytic_scalings.py",
96
+ "src/quvac/plotting.py",
97
+ ]
98
+
99
+ [tool.ruff]
100
+ extend-exclude = ["*.ipynb"]
101
+
102
+ [tool.ruff.lint]
103
+ select = [
104
+ "F", # pyflakes
105
+ "E", # pycodestyle
106
+ "I", # isort
107
+ "UP", # pyupgrade
108
+ "B", # flake8-bugbear
109
+ "C4", # flake8-comprehensions
110
+ ]
111
+ unfixable = [
112
+ "F401",
113
+ ]
114
+
115
+ [tool.ruff.lint.isort]
116
+ force-sort-within-sections = true
117
+ split-on-trailing-comma = false
118
+
119
+ [dependency-groups]
120
+ dev = [
121
+ "ruff>=0.11.2",
122
+ ]
123
+ test = [
124
+ "pytest>=8.3.5",
125
+ "pytest-cov>=6.1.0",
126
+ ]
quvac-0.1.2/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ __version__ = "0.1.2"
@@ -0,0 +1,168 @@
1
+ """
2
+ Calculation of analytic scalings from articles.
3
+
4
+ Currently supports:
5
+
6
+ 1. Total signal and perpendicular signal for two colliding
7
+ paraxial gaussian beams (off-axis).
8
+
9
+ 2. More exact scaling for on-axis collision of two beams.
10
+
11
+ ----
12
+
13
+ .. [1] F. Karbstein, et al. "Vacuum birefringence at x-ray free-electron
14
+ lasers." NJP 23.9 (2021): 095001.
15
+
16
+ .. [2] E. Mosman, F.Karbstein "Vacuum birefringence and diffraction at
17
+ XFEL: from analytical estimates to optimal parameters." PRD 104.1
18
+ (2021): 013006.
19
+ """
20
+
21
+ import numpy as np
22
+ from scipy.constants import alpha, c, hbar, m_e, pi
23
+ from scipy.integrate import quad
24
+ from scipy.special import erfc
25
+
26
+ W_e = m_e * c**2 # electron's rest energy
27
+ lam_C = hbar / (m_e * c) # reduced Compton wavelength
28
+
29
+
30
+ def get_two_paraxial_scaling(fields, channels="both"):
31
+ """
32
+ Calculate the total signal and perpendicular signal for two colliding
33
+ paraxial Gaussian beams (off-axis).
34
+
35
+ Parameters
36
+ ----------
37
+ fields : list of dict
38
+ List of dictionaries containing the field parameters.
39
+ channels : str, optional
40
+ Channels to iterate through, by default "both".
41
+
42
+ Returns
43
+ -------
44
+ N_signal : float
45
+ Total signal.
46
+ N_perp : float
47
+ Perpendicular signal.
48
+
49
+ Notes
50
+ -----
51
+ We introduced additional polarization-dependent factors (beta). The
52
+ formula should work for theta not close to 180, loose focusing and
53
+ short pulse duration. Result for N_perp should be used only for beta=45.
54
+
55
+ This is a variation of Eq.(25) from [1]_.
56
+ """
57
+ theta_c = (fields[1]["theta"] - fields[0]["theta"]) * pi / 180
58
+ beta = (fields[1]["beta"] - fields[0]["beta"]) * pi / 180
59
+
60
+ omega = 2 * pi * c / fields[0]["lam"]
61
+ N_signal, N_perp = 0, 0
62
+ # Iterate through pump/probe channels
63
+ match channels:
64
+ case "first":
65
+ fields_to_iterate = [fields]
66
+ case "second":
67
+ fields_to_iterate = [fields[::-1]]
68
+ case _:
69
+ fields_to_iterate = [fields, fields[::-1]]
70
+
71
+ for field1, field2 in fields_to_iterate:
72
+ tau1, tau2 = field1["tau"], field2["tau"]
73
+ w01, w02 = field1["w0"], field2["w0"]
74
+ W1, W2 = field1["W"], field2["W"]
75
+
76
+ # Define additional parameters
77
+ T1 = tau1 * np.sqrt(1 + 2 * (tau1 / tau2) ** 2)
78
+ T2 = tau2 * np.sqrt(1 + 0.5 * (tau2 / tau1) ** 2)
79
+ w1 = w01 * np.sqrt(1 + 2 * (w01 / w02) ** 2)
80
+ w2 = w02 * np.sqrt(1 + 0.5 * (w02 / w01) ** 2)
81
+ sin_term = T1 * T2 * c**2 / (w1 * w2) * np.sin(theta_c) ** 2
82
+ cos_term = 4 * (1 - np.cos(theta_c)) ** 2
83
+
84
+ # Calculate N_signal and N_perp
85
+ theta_term = (1 - np.cos(theta_c)) ** 4 / np.sqrt(cos_term + sin_term)
86
+ theta_term *= 1 / np.sqrt((T1 / tau1 * w01 / w1) ** 2 * cos_term + sin_term)
87
+ dims = hbar * omega / W_e
88
+ prefactor = 8 * pi**2 / 225 * (alpha / pi) ** 4 * W1 * W2**2 / W_e**3 * dims
89
+ prefactor *= T1 / tau1 * w1 / w01 * lam_C**4 / (w1 * w2) ** 2 / 9
90
+ N_perp += prefactor * theta_term * 9 * np.sin(2 * beta) ** 2
91
+ N_signal += prefactor * theta_term * (130 - 66 * np.cos(2 * beta))
92
+ return N_signal, N_perp
93
+
94
+
95
+ def _onaxis_function(x, r, k0=20):
96
+ """
97
+ Calculate the integral for the function defined in [2]_.
98
+
99
+ Parameters
100
+ ----------
101
+ x : float
102
+ Parameter x.
103
+ r : float
104
+ Parameter r.
105
+ k0 : float, optional
106
+ Integration limit for the integral, by default 20.
107
+
108
+ Returns
109
+ -------
110
+ result : float
111
+ Result of the integral.
112
+ """
113
+ def integrand(k):
114
+ s = 0
115
+ for n in [-1, 1]:
116
+ s += np.exp(2*n*r*x*k) * erfc(n*r*k + x)
117
+ s = np.abs(s)**2
118
+ return np.exp(-k**2) * s
119
+
120
+ prefactor = np.sqrt((1 + 2*r**2)/3) * x**2 * np.exp(2*x**2)
121
+ result = quad(integrand, -k0, k0)
122
+ return prefactor * result[0]
123
+
124
+
125
+ def get_onaxis_scaling(fields, k0=20):
126
+ """
127
+ Calculate the more exact scaling for on-axis collision of two beams.
128
+
129
+ Parameters
130
+ ----------
131
+ fields : list of dict
132
+ List of dictionaries containing the field parameters.
133
+ k0 : float, optional
134
+ Integration limit for the integral in F function, by default 20.
135
+
136
+ Returns
137
+ -------
138
+ N_signal : float
139
+ Total signal.
140
+ N_perp : float
141
+ Perpendicular signal.
142
+
143
+ Notes
144
+ -----
145
+ We assume that the 1st field in the list is x-ray.
146
+
147
+ This is an integrated version of Eq.(11) [Eq. (13)] from [2]_.
148
+ """
149
+ wx, w0 = fields[0]["w0"], fields[1]["w0"]
150
+ beta = wx / w0
151
+ Wx, W = fields[0]["W"], fields[1]["W"]
152
+ lam_x, lam = fields[0]["lam"], fields[1]["lam"]
153
+ omega_x = 2 * pi * c / lam_x
154
+ Nx = Wx / (hbar * omega_x)
155
+ T, tau = fields[0]["tau"], fields[1]["tau"]
156
+ zR = pi * w0**2 / lam
157
+
158
+ x0 = 4 * zR / (c * np.sqrt(T**2 + 1/2*tau**2))
159
+ r0 = T / tau
160
+ Fbeta = _onaxis_function(x0 * np.sqrt(1+2*beta**2), r0, k0=k0)
161
+ F0 = _onaxis_function(x0, r0, k0=k0)
162
+
163
+ prefactor = 4 * alpha**4 / (3*pi)**1.5 * W**2 * (hbar * omega_x)**2 / W_e**4
164
+ result = prefactor * (lam_C / w0)**4 / (1 + 2*beta**2) * np.sqrt(Fbeta*F0) * Nx
165
+
166
+ N_signal = 26/45 * result
167
+ N_perp = 1/25 * result
168
+ return N_signal, N_perp
@@ -0,0 +1,6 @@
1
+ DEFAULT_SUBMITIT_PARAMS = {
2
+ "slurm_partition": "hij-gpu",
3
+ "cpus_per_task": 16,
4
+ "slurm_mem": "20GB",
5
+ "timeout_min": 240,
6
+ }
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Script to create images of participating fields
4
+ """
5
+ import argparse
6
+ from copy import deepcopy
7
+ import gc
8
+ import os
9
+ from pathlib import Path
10
+
11
+ from quvac.field.external_field import ExternalField
12
+ from quvac.grid import setup_grids
13
+ from quvac.plotting import plot_fields
14
+ from quvac.simulation import set_precision
15
+ from quvac.utils import read_yaml
16
+
17
+
18
+ def parse_args():
19
+ description = "Plot fields present in the simulation"
20
+ argparser = argparse.ArgumentParser(description=description)
21
+ argparser.add_argument(
22
+ "--input", "-i", default=None, help="Input yaml file with field and grid params"
23
+ )
24
+ argparser.add_argument(
25
+ "--output", "-o", default=None, help="Path to save simulation data to"
26
+ )
27
+ return argparser.parse_args()
28
+
29
+
30
+ def image_fields(ini_file, save_path=None):
31
+ if save_path is None:
32
+ save_path = os.path.join(os.path.dirname(ini_file), 'imgs')
33
+ Path(save_path).mkdir(parents=True, exist_ok=True)
34
+
35
+ ini_config = read_yaml(ini_file)
36
+ fields_params = ini_config['fields']
37
+ grid_params = ini_config["grid"]
38
+
39
+ perf_params = ini_config.get("performance", {})
40
+ precision = perf_params.get("precision", "float32")
41
+ set_precision(precision)
42
+
43
+ # Setup grids
44
+ grid_xyz, grid_t = setup_grids(deepcopy(fields_params), deepcopy(grid_params))
45
+ grid_xyz.get_k_grid()
46
+ grid_shape = grid_xyz.grid_shape
47
+ print(f"Grid shape: {grid_shape}")
48
+ print(f"Time steps: {len(grid_t)}")
49
+
50
+ plot_keys = ["Intensity"]
51
+ # Setup fields and plot
52
+ for idx,field_param in enumerate(fields_params.values()):
53
+ field = ExternalField([field_param], grid_xyz)
54
+ for t0 in [0, grid_t[-1]]:
55
+ save_loc = os.path.join(save_path, f"field_{idx+1}_t0_{t0*1e15:.1f}fs")
56
+ plot_fields(field, t=t0, plot_keys=plot_keys, norm_lim=1e-10,
57
+ save_path=save_loc)
58
+ del field
59
+ gc.collect()
60
+ print("Plotting finished successfully")
61
+
62
+
63
+ if __name__ == "__main__":
64
+ args = parse_args()
65
+ image_fields(args.input, args.output)