jaxion 0.0.4__tar.gz → 0.0.5__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 (26) hide show
  1. {jaxion-0.0.4 → jaxion-0.0.5}/PKG-INFO +39 -11
  2. {jaxion-0.0.4 → jaxion-0.0.5}/README.md +38 -10
  3. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/simulation.py +21 -9
  4. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/utils.py +17 -0
  5. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/visualization.py +10 -6
  6. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion.egg-info/PKG-INFO +39 -11
  7. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion.egg-info/SOURCES.txt +2 -0
  8. jaxion-0.0.5/tests/test_analysis.py +24 -0
  9. jaxion-0.0.5/tests/test_cosmology.py +29 -0
  10. {jaxion-0.0.4 → jaxion-0.0.5}/tests/test_examples.py +12 -1
  11. {jaxion-0.0.4 → jaxion-0.0.5}/LICENSE +0 -0
  12. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/__init__.py +0 -0
  13. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/analysis.py +0 -0
  14. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/constants.py +0 -0
  15. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/cosmology.py +0 -0
  16. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/gravity.py +0 -0
  17. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/hydro.py +0 -0
  18. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/params_default.json +0 -0
  19. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/particles.py +0 -0
  20. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion/quantum.py +0 -0
  21. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion.egg-info/dependency_links.txt +0 -0
  22. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion.egg-info/requires.txt +0 -0
  23. {jaxion-0.0.4 → jaxion-0.0.5}/jaxion.egg-info/top_level.txt +0 -0
  24. {jaxion-0.0.4 → jaxion-0.0.5}/pyproject.toml +0 -0
  25. {jaxion-0.0.4 → jaxion-0.0.5}/requirements.txt +0 -0
  26. {jaxion-0.0.4 → jaxion-0.0.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jaxion
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: A differentiable simulation library for fuzzy dark matter in JAX
5
5
  Author-email: Philip Mocz <philip.mocz@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -33,8 +33,11 @@ Dynamic: license-file
33
33
  [![PyPI Version Status][pypi-badge]][pypi-link]
34
34
  [![Test Status][workflow-test-badge]][workflow-test-link]
35
35
  [![Coverage][coverage-badge]][coverage-link]
36
+ [![Ruff][ruff-badge]][ruff-link]
37
+ [![asv][asv-badge]][asv-link]
36
38
  [![Readthedocs Status][docs-badge]][docs-link]
37
39
  [![License][license-badge]][license-link]
40
+ [![Software DOI][software-doi-badge]][software-doi-link]
38
41
 
39
42
  [status-link]: https://www.repostatus.org/#active
40
43
  [status-badge]: https://www.repostatus.org/badges/latest/active.svg
@@ -44,10 +47,17 @@ Dynamic: license-file
44
47
  [workflow-test-badge]: https://github.com/JaxionProject/jaxion/actions/workflows/test-package.yml/badge.svg?event=push
45
48
  [coverage-link]: https://app.codecov.io/gh/JaxionProject/jaxion
46
49
  [coverage-badge]: https://codecov.io/github/jaxionproject/jaxion/graph/jaxion-server/badge.svg
50
+ [ruff-link]: https://github.com/astral-sh/ruff
51
+ [ruff-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
52
+ [asv-link]: https://jaxionproject.github.io/jaxion-benchmarks/
53
+ [asv-badge]: https://img.shields.io/badge/benchmarked%20by-asv-blue.svg?style=flat
47
54
  [docs-link]: https://jaxion.readthedocs.io
48
55
  [docs-badge]: https://readthedocs.org/projects/jaxion/badge
49
56
  [license-link]: https://opensource.org/licenses/Apache-2.0
50
57
  [license-badge]: https://img.shields.io/badge/License-Apache_2.0-blue.svg
58
+ [software-doi-link]: https://doi.org/10.5281/zenodo.17438467
59
+ [software-doi-badge]: https://zenodo.org/badge/1072645376.svg
60
+
51
61
 
52
62
  A simple JAX-powered simulation library for numerical experiments of fuzzy dark matter, stars, gas + more!
53
63
 
@@ -96,8 +106,8 @@ Check out the `examples/` directory for demonstrations of using Jaxion.
96
106
  <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/kinetic_condensation">
97
107
  <img src="examples/kinetic_condensation/movie.gif" alt="kinetic_condensation" width="128"/>
98
108
  </a>
99
- <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/logo">
100
- <img src="examples/logo/movie.gif" alt="logo" width="128"/>
109
+ <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/logo_inverse_problem">
110
+ <img src="examples/logo_inverse_problem/movie.gif" alt="logo_inverse_problem" width="128"/>
101
111
  </a>
102
112
  <br>
103
113
  <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/soliton_binary_merger">
@@ -112,22 +122,40 @@ Check out the `examples/` directory for demonstrations of using Jaxion.
112
122
  </p>
113
123
 
114
124
 
115
- ## Links
125
+ ## High-Performance
116
126
 
117
- * [Code repository](https://github.com/JaxionProject/jaxion) on GitHub (this page).
118
- * [Documentation](https://jaxion.readthedocs.io) for up-to-date information about installing and using jaxion.
127
+ Jaxion is scalable on multiple GPUs!
119
128
 
129
+ <p align="center">
130
+ <a href="https://jaxion.readthedocs.io">
131
+ <img src="examples/soliton_binary_merger/timing.png" alt="timing" width="400"/>
132
+ </a>
133
+ </p>
120
134
 
121
- ## Testing
122
135
 
123
- Jaxion is tested with `pytest`. Tests are included in the `tests/` folder.
136
+ ## Contributing
124
137
 
138
+ Jaxion welcomes community contributions of all kinds. Open an issue or fork the code and submit a pull request. Please check out the [Contributing Guidelines](CONTRIBUTING.md)
125
139
 
126
- ## Contributing
127
140
 
128
- Jaxion welcomes community contributions of all kinds. Open an issue or fork the code and submit a Pull request. Please check out the [Contributing Guidelines](CONTRIBUTING.md)
141
+ ## Links
142
+
143
+ * [Code repository](https://github.com/JaxionProject/jaxion) on GitHub (this page).
144
+ * [Documentation](https://jaxion.readthedocs.io) for up-to-date information about installing and using Jaxion.
129
145
 
130
146
 
131
147
  ## Cite this repository
132
148
 
133
- TODO XXX
149
+ If you use this software, please cite it as below.
150
+
151
+ ```bibtex
152
+ @software{Mocz_Jaxion_2025,
153
+ author = {Mocz, Philip},
154
+ doi = {10.5281/zenodo.17438467},
155
+ month = oct,
156
+ title = {{Jaxion}},
157
+ url = {https://github.com/JaxionProject/jaxion},
158
+ version = {0.0.4},
159
+ year = {2025}
160
+ }
161
+ ```
@@ -10,8 +10,11 @@
10
10
  [![PyPI Version Status][pypi-badge]][pypi-link]
11
11
  [![Test Status][workflow-test-badge]][workflow-test-link]
12
12
  [![Coverage][coverage-badge]][coverage-link]
13
+ [![Ruff][ruff-badge]][ruff-link]
14
+ [![asv][asv-badge]][asv-link]
13
15
  [![Readthedocs Status][docs-badge]][docs-link]
14
16
  [![License][license-badge]][license-link]
17
+ [![Software DOI][software-doi-badge]][software-doi-link]
15
18
 
16
19
  [status-link]: https://www.repostatus.org/#active
17
20
  [status-badge]: https://www.repostatus.org/badges/latest/active.svg
@@ -21,10 +24,17 @@
21
24
  [workflow-test-badge]: https://github.com/JaxionProject/jaxion/actions/workflows/test-package.yml/badge.svg?event=push
22
25
  [coverage-link]: https://app.codecov.io/gh/JaxionProject/jaxion
23
26
  [coverage-badge]: https://codecov.io/github/jaxionproject/jaxion/graph/jaxion-server/badge.svg
27
+ [ruff-link]: https://github.com/astral-sh/ruff
28
+ [ruff-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
29
+ [asv-link]: https://jaxionproject.github.io/jaxion-benchmarks/
30
+ [asv-badge]: https://img.shields.io/badge/benchmarked%20by-asv-blue.svg?style=flat
24
31
  [docs-link]: https://jaxion.readthedocs.io
25
32
  [docs-badge]: https://readthedocs.org/projects/jaxion/badge
26
33
  [license-link]: https://opensource.org/licenses/Apache-2.0
27
34
  [license-badge]: https://img.shields.io/badge/License-Apache_2.0-blue.svg
35
+ [software-doi-link]: https://doi.org/10.5281/zenodo.17438467
36
+ [software-doi-badge]: https://zenodo.org/badge/1072645376.svg
37
+
28
38
 
29
39
  A simple JAX-powered simulation library for numerical experiments of fuzzy dark matter, stars, gas + more!
30
40
 
@@ -73,8 +83,8 @@ Check out the `examples/` directory for demonstrations of using Jaxion.
73
83
  <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/kinetic_condensation">
74
84
  <img src="examples/kinetic_condensation/movie.gif" alt="kinetic_condensation" width="128"/>
75
85
  </a>
76
- <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/logo">
77
- <img src="examples/logo/movie.gif" alt="logo" width="128"/>
86
+ <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/logo_inverse_problem">
87
+ <img src="examples/logo_inverse_problem/movie.gif" alt="logo_inverse_problem" width="128"/>
78
88
  </a>
79
89
  <br>
80
90
  <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/soliton_binary_merger">
@@ -89,22 +99,40 @@ Check out the `examples/` directory for demonstrations of using Jaxion.
89
99
  </p>
90
100
 
91
101
 
92
- ## Links
102
+ ## High-Performance
93
103
 
94
- * [Code repository](https://github.com/JaxionProject/jaxion) on GitHub (this page).
95
- * [Documentation](https://jaxion.readthedocs.io) for up-to-date information about installing and using jaxion.
104
+ Jaxion is scalable on multiple GPUs!
96
105
 
106
+ <p align="center">
107
+ <a href="https://jaxion.readthedocs.io">
108
+ <img src="examples/soliton_binary_merger/timing.png" alt="timing" width="400"/>
109
+ </a>
110
+ </p>
97
111
 
98
- ## Testing
99
112
 
100
- Jaxion is tested with `pytest`. Tests are included in the `tests/` folder.
113
+ ## Contributing
101
114
 
115
+ Jaxion welcomes community contributions of all kinds. Open an issue or fork the code and submit a pull request. Please check out the [Contributing Guidelines](CONTRIBUTING.md)
102
116
 
103
- ## Contributing
104
117
 
105
- Jaxion welcomes community contributions of all kinds. Open an issue or fork the code and submit a Pull request. Please check out the [Contributing Guidelines](CONTRIBUTING.md)
118
+ ## Links
119
+
120
+ * [Code repository](https://github.com/JaxionProject/jaxion) on GitHub (this page).
121
+ * [Documentation](https://jaxion.readthedocs.io) for up-to-date information about installing and using Jaxion.
106
122
 
107
123
 
108
124
  ## Cite this repository
109
125
 
110
- TODO XXX
126
+ If you use this software, please cite it as below.
127
+
128
+ ```bibtex
129
+ @software{Mocz_Jaxion_2025,
130
+ author = {Mocz, Philip},
131
+ doi = {10.5281/zenodo.17438467},
132
+ month = oct,
133
+ title = {{Jaxion}},
134
+ url = {https://github.com/JaxionProject/jaxion},
135
+ version = {0.0.4},
136
+ year = {2025}
137
+ }
138
+ ```
@@ -14,6 +14,7 @@ from .cosmology import get_supercomoving_time_interval, get_next_scale_factor
14
14
  from .utils import (
15
15
  set_up_parameters,
16
16
  print_parameters,
17
+ print_distributed_info,
17
18
  xmeshgrid,
18
19
  xmeshgrid_transpose,
19
20
  xzeros,
@@ -72,10 +73,12 @@ class Simulation:
72
73
  "hydro/particles sharding is not yet implemented."
73
74
  )
74
75
 
75
- if self.params["output"]["save"]:
76
- if jax.process_index() == 0:
77
- print("Simulation parameters:")
78
- print_parameters(self.params)
76
+ # print info
77
+ if jax.process_index() == 0:
78
+ print("Simulation parameters:")
79
+ print_parameters(self.params)
80
+ if sharding is not None:
81
+ print_distributed_info()
79
82
 
80
83
  # jitted functions
81
84
  self.xmeshgrid_jit = jax.jit(
@@ -170,6 +173,13 @@ class Simulation:
170
173
  / constants["speed_of_light"] ** 2
171
174
  )
172
175
 
176
+ @property
177
+ def m_per_hbar(self):
178
+ """
179
+ Return the mass per hbar in the simulation (M_sun / hbar)
180
+ """
181
+ return self.axion_mass / constants["reduced_planck_constant"]
182
+
173
183
  @property
174
184
  def sound_speed(self):
175
185
  """
@@ -212,8 +222,7 @@ class Simulation:
212
222
  """
213
223
  Return the dark matter velocity field from the wavefunction
214
224
  """
215
- m_per_hbar = self.axion_mass / constants["reduced_planck_constant"]
216
- return quantum_velocity(self.state["psi"], self.box_size, m_per_hbar)
225
+ return quantum_velocity(self.state["psi"], self.box_size, self.m_per_hbar)
217
226
 
218
227
  def _calc_rho_bar(self, state):
219
228
  rho_bar = 0.0
@@ -271,7 +280,7 @@ class Simulation:
271
280
 
272
281
  # Simulation parameters
273
282
  dx = self.dx
274
- m_per_hbar = self.axion_mass / constants["reduced_planck_constant"]
283
+ m_per_hbar = self.m_per_hbar
275
284
  box_size = self.box_size
276
285
 
277
286
  dt_fac = 1.0
@@ -408,14 +417,17 @@ class Simulation:
408
417
  elapsed = time.time() - t_start_timer
409
418
  est_total = elapsed / i * num_checkpoints
410
419
  est_remaining = est_total - elapsed
420
+ num_cells = self.resolution**3
421
+ mcups = (num_cells * (i * nt_sub)) / (elapsed * 1.0e6)
411
422
  if jax.process_index() == 0:
412
423
  print(
413
- f"{percent:.1f}%: estimated time remaining (s): {est_remaining:.1f}"
424
+ f"{percent:.1f}%: mcups={mcups:.1f}, estimated time left (s): {est_remaining:.1f}"
414
425
  )
415
426
  plot_sim(state, checkpoint_dir, i, self.params)
416
427
  async_checkpoint_manager.wait_until_finished()
417
428
  else:
418
- state = jax.lax.fori_loop(0, nt, _update, init_val=state)
429
+ carry = jax.lax.fori_loop(0, nt, _update, init_val=carry)
430
+ state, kx, ky, kz, k_sq = carry
419
431
  jax.block_until_ready(state)
420
432
  if jax.process_index() == 0:
421
433
  print("Simulation Run Time (s): ", time.time() - t_start_timer)
@@ -5,6 +5,7 @@ from pathlib import Path
5
5
  import importlib.resources
6
6
  import json
7
7
  from importlib.metadata import version
8
+ import jax
8
9
  import jax.numpy as jnp
9
10
 
10
11
 
@@ -12,6 +13,22 @@ def print_parameters(params):
12
13
  print(json.dumps(params, indent=2))
13
14
 
14
15
 
16
+ def print_distributed_info():
17
+ for env_var in [
18
+ "SLURM_JOB_ID",
19
+ "SLURM_NTASKS",
20
+ "SLURM_NODELIST",
21
+ "SLURM_STEP_NODELIST",
22
+ "SLURM_STEP_GPUS",
23
+ "SLURM_GPUS",
24
+ ]:
25
+ print(f"{env_var}: {os.getenv(env_var, '')}")
26
+ print("Total number of processes: ", jax.process_count())
27
+ print("Total number of devices: ", jax.device_count())
28
+ print("List of devices: ", jax.devices())
29
+ print("Number of devices on this process: ", jax.local_device_count())
30
+
31
+
15
32
  def set_up_parameters(user_overwrites):
16
33
  # first load the default params
17
34
  params_path = importlib.resources.files("jaxion") / "params_default.json"
@@ -13,15 +13,19 @@ def plot_sim(state, checkpoint_dir, i, params):
13
13
  if params["physics"]["quantum"]:
14
14
  nx = state["psi"].shape[0]
15
15
  rho_bar_dm = jnp.mean(jnp.abs(state["psi"]) ** 2)
16
- rho_proj_dm = jax.experimental.multihost_utils.process_allgather(
17
- jnp.log10(jnp.mean(jnp.abs(state["psi"]) ** 2, axis=2).T)
18
- ).reshape(nx, nx)
16
+ rho_proj_dm = jnp.log10(
17
+ jax.experimental.multihost_utils.process_allgather(
18
+ jnp.mean(jnp.abs(state["psi"]) ** 2, axis=2), tiled=True
19
+ )
20
+ ).T
19
21
  if params["physics"]["hydro"]:
20
22
  nx = state["rho"].shape[0]
21
23
  rho_bar_gas = jnp.mean(state["rho"])
22
- rho_proj_gas = jax.experimental.multihost_utils.process_allgather(
23
- jnp.log10(jnp.mean(state["rho"], axis=2).T)
24
- ).reshape(nx, nx)
24
+ rho_proj_gas = jnp.log10(
25
+ jax.experimental.multihost_utils.process_allgather(
26
+ jnp.mean(state["rho"], axis=2), tiled=True
27
+ )
28
+ ).T
25
29
 
26
30
  # create plot on process 0
27
31
  if jax.process_index() == 0:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jaxion
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: A differentiable simulation library for fuzzy dark matter in JAX
5
5
  Author-email: Philip Mocz <philip.mocz@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -33,8 +33,11 @@ Dynamic: license-file
33
33
  [![PyPI Version Status][pypi-badge]][pypi-link]
34
34
  [![Test Status][workflow-test-badge]][workflow-test-link]
35
35
  [![Coverage][coverage-badge]][coverage-link]
36
+ [![Ruff][ruff-badge]][ruff-link]
37
+ [![asv][asv-badge]][asv-link]
36
38
  [![Readthedocs Status][docs-badge]][docs-link]
37
39
  [![License][license-badge]][license-link]
40
+ [![Software DOI][software-doi-badge]][software-doi-link]
38
41
 
39
42
  [status-link]: https://www.repostatus.org/#active
40
43
  [status-badge]: https://www.repostatus.org/badges/latest/active.svg
@@ -44,10 +47,17 @@ Dynamic: license-file
44
47
  [workflow-test-badge]: https://github.com/JaxionProject/jaxion/actions/workflows/test-package.yml/badge.svg?event=push
45
48
  [coverage-link]: https://app.codecov.io/gh/JaxionProject/jaxion
46
49
  [coverage-badge]: https://codecov.io/github/jaxionproject/jaxion/graph/jaxion-server/badge.svg
50
+ [ruff-link]: https://github.com/astral-sh/ruff
51
+ [ruff-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
52
+ [asv-link]: https://jaxionproject.github.io/jaxion-benchmarks/
53
+ [asv-badge]: https://img.shields.io/badge/benchmarked%20by-asv-blue.svg?style=flat
47
54
  [docs-link]: https://jaxion.readthedocs.io
48
55
  [docs-badge]: https://readthedocs.org/projects/jaxion/badge
49
56
  [license-link]: https://opensource.org/licenses/Apache-2.0
50
57
  [license-badge]: https://img.shields.io/badge/License-Apache_2.0-blue.svg
58
+ [software-doi-link]: https://doi.org/10.5281/zenodo.17438467
59
+ [software-doi-badge]: https://zenodo.org/badge/1072645376.svg
60
+
51
61
 
52
62
  A simple JAX-powered simulation library for numerical experiments of fuzzy dark matter, stars, gas + more!
53
63
 
@@ -96,8 +106,8 @@ Check out the `examples/` directory for demonstrations of using Jaxion.
96
106
  <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/kinetic_condensation">
97
107
  <img src="examples/kinetic_condensation/movie.gif" alt="kinetic_condensation" width="128"/>
98
108
  </a>
99
- <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/logo">
100
- <img src="examples/logo/movie.gif" alt="logo" width="128"/>
109
+ <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/logo_inverse_problem">
110
+ <img src="examples/logo_inverse_problem/movie.gif" alt="logo_inverse_problem" width="128"/>
101
111
  </a>
102
112
  <br>
103
113
  <a href="https://github.com/JaxionProject/jaxion/tree/main/examples/soliton_binary_merger">
@@ -112,22 +122,40 @@ Check out the `examples/` directory for demonstrations of using Jaxion.
112
122
  </p>
113
123
 
114
124
 
115
- ## Links
125
+ ## High-Performance
116
126
 
117
- * [Code repository](https://github.com/JaxionProject/jaxion) on GitHub (this page).
118
- * [Documentation](https://jaxion.readthedocs.io) for up-to-date information about installing and using jaxion.
127
+ Jaxion is scalable on multiple GPUs!
119
128
 
129
+ <p align="center">
130
+ <a href="https://jaxion.readthedocs.io">
131
+ <img src="examples/soliton_binary_merger/timing.png" alt="timing" width="400"/>
132
+ </a>
133
+ </p>
120
134
 
121
- ## Testing
122
135
 
123
- Jaxion is tested with `pytest`. Tests are included in the `tests/` folder.
136
+ ## Contributing
124
137
 
138
+ Jaxion welcomes community contributions of all kinds. Open an issue or fork the code and submit a pull request. Please check out the [Contributing Guidelines](CONTRIBUTING.md)
125
139
 
126
- ## Contributing
127
140
 
128
- Jaxion welcomes community contributions of all kinds. Open an issue or fork the code and submit a Pull request. Please check out the [Contributing Guidelines](CONTRIBUTING.md)
141
+ ## Links
142
+
143
+ * [Code repository](https://github.com/JaxionProject/jaxion) on GitHub (this page).
144
+ * [Documentation](https://jaxion.readthedocs.io) for up-to-date information about installing and using Jaxion.
129
145
 
130
146
 
131
147
  ## Cite this repository
132
148
 
133
- TODO XXX
149
+ If you use this software, please cite it as below.
150
+
151
+ ```bibtex
152
+ @software{Mocz_Jaxion_2025,
153
+ author = {Mocz, Philip},
154
+ doi = {10.5281/zenodo.17438467},
155
+ month = oct,
156
+ title = {{Jaxion}},
157
+ url = {https://github.com/JaxionProject/jaxion},
158
+ version = {0.0.4},
159
+ year = {2025}
160
+ }
161
+ ```
@@ -19,4 +19,6 @@ jaxion.egg-info/SOURCES.txt
19
19
  jaxion.egg-info/dependency_links.txt
20
20
  jaxion.egg-info/requires.txt
21
21
  jaxion.egg-info/top_level.txt
22
+ tests/test_analysis.py
23
+ tests/test_cosmology.py
22
24
  tests/test_examples.py
@@ -0,0 +1,24 @@
1
+ import jax.numpy as jnp
2
+ import jaxion
3
+ from jaxion.quantum import quantum_velocity
4
+ from jaxion.analysis import radial_power_spectrum
5
+ import pytest
6
+
7
+
8
+ def test_quantum_velocity_and_radial_power_spectrum():
9
+ sim = jaxion.Simulation({})
10
+ box_size = sim.box_size
11
+ m_per_hbar = sim.m_per_hbar
12
+ xx, yy, _ = sim.grid
13
+ kx, ky, kz = sim.kgrid
14
+
15
+ psi = (
16
+ jnp.cos(2.0 * jnp.pi * xx / box_size) ** 2
17
+ + jnp.cos(2.0 * jnp.pi * yy / box_size) * 1j
18
+ )
19
+
20
+ vx, _, _ = quantum_velocity(psi, box_size, m_per_hbar)
21
+
22
+ Pf, _, _ = radial_power_spectrum(vx, kx, ky, kz, box_size)
23
+
24
+ assert jnp.max(Pf) == pytest.approx(8244.606, rel=1e-4)
@@ -0,0 +1,29 @@
1
+ from jaxion.cosmology import (
2
+ get_physical_time_interval,
3
+ get_supercomoving_time_interval,
4
+ get_scale_factor,
5
+ get_next_scale_factor,
6
+ )
7
+ import pytest
8
+
9
+
10
+ def test_cosmology_functions():
11
+ z_start = 127.0
12
+ z_end = 0.0
13
+ omega_matter = 0.3
14
+ omega_lambda = 0.7
15
+ little_h = 0.7
16
+ dt_hat = 10.0
17
+
18
+ assert get_physical_time_interval(
19
+ z_start, z_end, omega_matter, omega_lambda, little_h
20
+ ) == pytest.approx(13.76084)
21
+ assert get_supercomoving_time_interval(
22
+ z_start, z_end, omega_matter, omega_lambda, little_h
23
+ ) == pytest.approx(530.44415)
24
+ assert get_scale_factor(
25
+ z_start, dt_hat, omega_matter, omega_lambda, little_h
26
+ ) == pytest.approx(0.008084139320999384)
27
+ assert get_next_scale_factor(
28
+ z_start, dt_hat, omega_matter, omega_lambda, little_h
29
+ ) == pytest.approx(0.00808401)
@@ -7,7 +7,18 @@ rel_tol = 1e-4
7
7
 
8
8
  def test_tidal_stripping():
9
9
  sim = run_example_main(
10
- "examples/tidal_stripping/tidal_stripping.py", argv=["--res", "1"]
10
+ "examples/tidal_stripping/tidal_stripping.py",
11
+ argv=["--res", "1", "--save", "False"],
12
+ )
13
+ assert sim.resolution == 32
14
+ assert sim.state["t"] > 0.0
15
+ assert jnp.mean(jnp.abs(sim.state["psi"])) == pytest.approx(639.0479, rel=rel_tol)
16
+
17
+
18
+ def test_tidal_stripping_distributed_emulate():
19
+ sim = run_example_main(
20
+ "examples/tidal_stripping/tidal_stripping.py",
21
+ argv=["--res", "1", "--distributed", "--emulate"],
11
22
  )
12
23
  assert sim.resolution == 32
13
24
  assert sim.state["t"] > 0.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes