jaxion 0.0.3__py3-none-any.whl → 0.0.4__py3-none-any.whl
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.
- jaxion/analysis.py +19 -4
- jaxion/constants.py +8 -8
- jaxion/simulation.py +41 -2
- jaxion/visualization.py +2 -2
- {jaxion-0.0.3.dist-info → jaxion-0.0.4.dist-info}/METADATA +41 -4
- {jaxion-0.0.3.dist-info → jaxion-0.0.4.dist-info}/RECORD +9 -9
- {jaxion-0.0.3.dist-info → jaxion-0.0.4.dist-info}/WHEEL +0 -0
- {jaxion-0.0.3.dist-info → jaxion-0.0.4.dist-info}/licenses/LICENSE +0 -0
- {jaxion-0.0.3.dist-info → jaxion-0.0.4.dist-info}/top_level.txt +0 -0
jaxion/analysis.py
CHANGED
|
@@ -4,10 +4,25 @@ import jaxdecomp as jd
|
|
|
4
4
|
|
|
5
5
|
def radial_power_spectrum(data_cube, kx, ky, kz, box_size):
|
|
6
6
|
"""
|
|
7
|
-
Computes radially averaged power spectral density of
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
Computes the radially averaged power spectral density of a 3D datacube.
|
|
8
|
+
|
|
9
|
+
Parameters
|
|
10
|
+
----------
|
|
11
|
+
data_cube : jnp.ndarray
|
|
12
|
+
3D data cube, must be cubic
|
|
13
|
+
kx, ky, kz: jnp.ndarray
|
|
14
|
+
wavenumber grids in each dimension
|
|
15
|
+
box_size: float
|
|
16
|
+
physical size of box
|
|
17
|
+
|
|
18
|
+
Returns
|
|
19
|
+
-------
|
|
20
|
+
Pf: jnp.ndarray
|
|
21
|
+
radial power spectrum
|
|
22
|
+
k: jnp.ndarray
|
|
23
|
+
wavenumbers
|
|
24
|
+
total_power: float
|
|
25
|
+
total power
|
|
11
26
|
"""
|
|
12
27
|
dim = data_cube.ndim
|
|
13
28
|
nx = data_cube.shape[0]
|
jaxion/constants.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Copyright (c) 2025 The Jaxion Team.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
"""
|
|
4
|
+
Physical constants in units of:
|
|
5
|
+
[L] = kpc,
|
|
6
|
+
[V] = km/s,
|
|
7
|
+
[M] = Msun
|
|
8
|
+
|
|
9
|
+
note: other units are derived from these base units, e.g., [T] = [L]/[V] = kpc / (km/s) ~= 0.978 Gyr
|
|
10
|
+
"""
|
|
11
11
|
|
|
12
12
|
constants = {
|
|
13
13
|
"gravitational_constant": 4.30241002e-6, # G / (kpc * (km/s)^2 / Msun)
|
jaxion/simulation.py
CHANGED
|
@@ -28,8 +28,11 @@ class Simulation:
|
|
|
28
28
|
|
|
29
29
|
Parameters
|
|
30
30
|
----------
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
params : dict
|
|
32
|
+
The Python dictionary that contains the simulation parameters.
|
|
33
|
+
Params can also be a string path to a checkpoint directory to load a saved simulation.
|
|
34
|
+
sharding : jax.sharding.NamedSharding, optional
|
|
35
|
+
jax sharding used for distributed (multi-GPU) simulations
|
|
33
36
|
|
|
34
37
|
"""
|
|
35
38
|
|
|
@@ -126,6 +129,9 @@ class Simulation:
|
|
|
126
129
|
|
|
127
130
|
@property
|
|
128
131
|
def resolution(self):
|
|
132
|
+
"""
|
|
133
|
+
Return the (linear) resolution of the simulation
|
|
134
|
+
"""
|
|
129
135
|
return (
|
|
130
136
|
self.params["domain"]["resolution_base"]
|
|
131
137
|
* self.params["domain"]["resolution_multiplier"]
|
|
@@ -133,18 +139,30 @@ class Simulation:
|
|
|
133
139
|
|
|
134
140
|
@property
|
|
135
141
|
def num_particles(self):
|
|
142
|
+
"""
|
|
143
|
+
Return the number of particles in the simulation
|
|
144
|
+
"""
|
|
136
145
|
return self.params["particles"]["num_particles"]
|
|
137
146
|
|
|
138
147
|
@property
|
|
139
148
|
def box_size(self):
|
|
149
|
+
"""
|
|
150
|
+
Return the box size of the simulation (kpc)
|
|
151
|
+
"""
|
|
140
152
|
return self.params["domain"]["box_size"]
|
|
141
153
|
|
|
142
154
|
@property
|
|
143
155
|
def dx(self):
|
|
156
|
+
"""
|
|
157
|
+
Return the cell size size of the simulation (kpc)
|
|
158
|
+
"""
|
|
144
159
|
return self.box_size / self.resolution
|
|
145
160
|
|
|
146
161
|
@property
|
|
147
162
|
def axion_mass(self):
|
|
163
|
+
"""
|
|
164
|
+
Return the axion particle mass in the simulation (M_sun)
|
|
165
|
+
"""
|
|
148
166
|
return (
|
|
149
167
|
self.params["quantum"]["m_22"]
|
|
150
168
|
* 1.0e-22
|
|
@@ -154,14 +172,23 @@ class Simulation:
|
|
|
154
172
|
|
|
155
173
|
@property
|
|
156
174
|
def sound_speed(self):
|
|
175
|
+
"""
|
|
176
|
+
Return the isothermal gas sound speed in the simulation (km/s)
|
|
177
|
+
"""
|
|
157
178
|
return self.params["hydro"]["sound_speed"]
|
|
158
179
|
|
|
159
180
|
@property
|
|
160
181
|
def params(self):
|
|
182
|
+
"""
|
|
183
|
+
Return the parameters of the simulation
|
|
184
|
+
"""
|
|
161
185
|
return self._params
|
|
162
186
|
|
|
163
187
|
@property
|
|
164
188
|
def grid(self):
|
|
189
|
+
"""
|
|
190
|
+
Return the simulation grid
|
|
191
|
+
"""
|
|
165
192
|
hx = 0.5 * self.dx
|
|
166
193
|
x_lin = jnp.linspace(hx, self.box_size - hx, self.resolution)
|
|
167
194
|
xx, yy, zz = self.xmeshgrid_jit(x_lin)
|
|
@@ -169,6 +196,9 @@ class Simulation:
|
|
|
169
196
|
|
|
170
197
|
@property
|
|
171
198
|
def kgrid(self):
|
|
199
|
+
"""
|
|
200
|
+
Return the simulation spectral grid
|
|
201
|
+
"""
|
|
172
202
|
nx = self.resolution
|
|
173
203
|
k_lin = (2.0 * jnp.pi / self.box_size) * jnp.arange(-nx / 2, nx / 2)
|
|
174
204
|
kx, ky, kz = self.xmeshgrid_transpose_jit(k_lin)
|
|
@@ -179,6 +209,9 @@ class Simulation:
|
|
|
179
209
|
|
|
180
210
|
@property
|
|
181
211
|
def quantum_velocity(self):
|
|
212
|
+
"""
|
|
213
|
+
Return the dark matter velocity field from the wavefunction
|
|
214
|
+
"""
|
|
182
215
|
m_per_hbar = self.axion_mass / constants["reduced_planck_constant"]
|
|
183
216
|
return quantum_velocity(self.state["psi"], self.box_size, m_per_hbar)
|
|
184
217
|
|
|
@@ -214,6 +247,9 @@ class Simulation:
|
|
|
214
247
|
|
|
215
248
|
@property
|
|
216
249
|
def potential(self):
|
|
250
|
+
"""
|
|
251
|
+
Return the gravitational potential
|
|
252
|
+
"""
|
|
217
253
|
kx, ky, kz = self.kgrid
|
|
218
254
|
k_sq = kx**2 + ky**2 + kz**2
|
|
219
255
|
return self._calc_grav_potential(self.state, k_sq)
|
|
@@ -387,5 +423,8 @@ class Simulation:
|
|
|
387
423
|
return state
|
|
388
424
|
|
|
389
425
|
def run(self):
|
|
426
|
+
"""
|
|
427
|
+
Run the simulation
|
|
428
|
+
"""
|
|
390
429
|
self.state = self._evolve(self.state)
|
|
391
430
|
jax.block_until_ready(self.state)
|
jaxion/visualization.py
CHANGED
|
@@ -20,7 +20,7 @@ def plot_sim(state, checkpoint_dir, i, params):
|
|
|
20
20
|
nx = state["rho"].shape[0]
|
|
21
21
|
rho_bar_gas = jnp.mean(state["rho"])
|
|
22
22
|
rho_proj_gas = jax.experimental.multihost_utils.process_allgather(
|
|
23
|
-
jnp.log10(jnp.mean(
|
|
23
|
+
jnp.log10(jnp.mean(state["rho"], axis=2).T)
|
|
24
24
|
).reshape(nx, nx)
|
|
25
25
|
|
|
26
26
|
# create plot on process 0
|
|
@@ -48,7 +48,7 @@ def plot_sim(state, checkpoint_dir, i, params):
|
|
|
48
48
|
sx = (state["pos"][:, 0] / box_size) * nx
|
|
49
49
|
sy = (state["pos"][:, 1] / box_size) * nx
|
|
50
50
|
plt.plot(
|
|
51
|
-
sx, sy, color="cyan", marker=".", linestyle="None", markersize=
|
|
51
|
+
sx, sy, color="cyan", marker=".", linestyle="None", markersize=5
|
|
52
52
|
)
|
|
53
53
|
ax.set_aspect("equal")
|
|
54
54
|
ax.get_xaxis().set_visible(False)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jaxion
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
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
|
|
@@ -32,6 +32,7 @@ Dynamic: license-file
|
|
|
32
32
|
[![Repo Status][status-badge]][status-link]
|
|
33
33
|
[![PyPI Version Status][pypi-badge]][pypi-link]
|
|
34
34
|
[![Test Status][workflow-test-badge]][workflow-test-link]
|
|
35
|
+
[![Coverage][coverage-badge]][coverage-link]
|
|
35
36
|
[![Readthedocs Status][docs-badge]][docs-link]
|
|
36
37
|
[![License][license-badge]][license-link]
|
|
37
38
|
|
|
@@ -41,6 +42,8 @@ Dynamic: license-file
|
|
|
41
42
|
[pypi-badge]: https://img.shields.io/pypi/v/jaxion?label=PyPI&logo=pypi
|
|
42
43
|
[workflow-test-link]: https://github.com/JaxionProject/jaxion/actions/workflows/test-package.yml
|
|
43
44
|
[workflow-test-badge]: https://github.com/JaxionProject/jaxion/actions/workflows/test-package.yml/badge.svg?event=push
|
|
45
|
+
[coverage-link]: https://app.codecov.io/gh/JaxionProject/jaxion
|
|
46
|
+
[coverage-badge]: https://codecov.io/github/jaxionproject/jaxion/graph/jaxion-server/badge.svg
|
|
44
47
|
[docs-link]: https://jaxion.readthedocs.io
|
|
45
48
|
[docs-badge]: https://readthedocs.org/projects/jaxion/badge
|
|
46
49
|
[license-link]: https://opensource.org/licenses/Apache-2.0
|
|
@@ -63,34 +66,68 @@ Install with:
|
|
|
63
66
|
pip install jaxion
|
|
64
67
|
```
|
|
65
68
|
|
|
66
|
-
or, for GPU support use:
|
|
69
|
+
or, for GPU support, use:
|
|
67
70
|
|
|
68
71
|
```console
|
|
69
72
|
pip install jaxion[cuda12]
|
|
70
73
|
```
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
See the docs for more info on how to [build from source](https://jaxion.readthedocs.io/en/latest/pages/installation.html).
|
|
73
76
|
|
|
74
77
|
|
|
75
78
|
## Examples
|
|
76
79
|
|
|
80
|
+
Check out the `examples/` directory for demonstrations of using Jaxion.
|
|
81
|
+
|
|
77
82
|
<p align="center">
|
|
83
|
+
<a href="https://github.com/JaxionProject/jaxion/tree/main/examples/cosmological_box">
|
|
84
|
+
<img src="examples/cosmological_box/movie.gif" alt="cosmological_box" width="128"/>
|
|
85
|
+
</a>
|
|
78
86
|
<a href="https://github.com/JaxionProject/jaxion/tree/main/examples/dynamical_friction">
|
|
79
87
|
<img src="examples/dynamical_friction/movie.gif" alt="dynamical_friction" width="128"/>
|
|
80
88
|
</a>
|
|
81
89
|
<a href="https://github.com/JaxionProject/jaxion/tree/main/examples/heating_gas">
|
|
82
90
|
<img src="examples/heating_gas/movie.gif" alt="heating_gas" width="128"/>
|
|
83
91
|
</a>
|
|
92
|
+
<br>
|
|
93
|
+
<a href="https://github.com/JaxionProject/jaxion/tree/main/examples/heating_stars">
|
|
94
|
+
<img src="examples/heating_stars/movie.gif" alt="heating_stars" width="128"/>
|
|
95
|
+
</a>
|
|
96
|
+
<a href="https://github.com/JaxionProject/jaxion/tree/main/examples/kinetic_condensation">
|
|
97
|
+
<img src="examples/kinetic_condensation/movie.gif" alt="kinetic_condensation" width="128"/>
|
|
98
|
+
</a>
|
|
99
|
+
<a href="https://github.com/JaxionProject/jaxion/tree/main/examples/logo">
|
|
100
|
+
<img src="examples/logo/movie.gif" alt="logo" width="128"/>
|
|
101
|
+
</a>
|
|
102
|
+
<br>
|
|
103
|
+
<a href="https://github.com/JaxionProject/jaxion/tree/main/examples/soliton_binary_merger">
|
|
104
|
+
<img src="examples/soliton_binary_merger/movie.gif" alt="soliton_binary_merger" width="128"/>
|
|
105
|
+
</a>
|
|
106
|
+
<a href="https://github.com/JaxionProject/jaxion/tree/main/examples/soliton_merger">
|
|
107
|
+
<img src="examples/soliton_merger/movie.gif" alt="soliton_merger" width="128"/>
|
|
108
|
+
</a>
|
|
84
109
|
<a href="https://github.com/JaxionProject/jaxion/tree/main/examples/tidal_stripping">
|
|
85
110
|
<img src="examples/tidal_stripping/movie.gif" alt="tidal_stripping" width="128"/>
|
|
86
111
|
</a>
|
|
87
112
|
</p>
|
|
88
113
|
|
|
114
|
+
|
|
89
115
|
## Links
|
|
90
116
|
|
|
91
117
|
* [Code repository](https://github.com/JaxionProject/jaxion) on GitHub (this page).
|
|
92
|
-
* [Documentation](https://jaxion.readthedocs.io) for up-to-date information about installing and
|
|
118
|
+
* [Documentation](https://jaxion.readthedocs.io) for up-to-date information about installing and using jaxion.
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
## Testing
|
|
122
|
+
|
|
123
|
+
Jaxion is tested with `pytest`. Tests are included in the `tests/` folder.
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## Contributing
|
|
127
|
+
|
|
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)
|
|
93
129
|
|
|
94
130
|
|
|
95
131
|
## Cite this repository
|
|
96
132
|
|
|
133
|
+
TODO XXX
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
jaxion/__init__.py,sha256=Hdji1UQ47lG24Pqcy6UUq9L0-qy6m9Ax41L0vIYzBto,164
|
|
2
|
-
jaxion/analysis.py,sha256=
|
|
3
|
-
jaxion/constants.py,sha256=
|
|
2
|
+
jaxion/analysis.py,sha256=4YT9Z2dkFoXwft3fQM1HyynVPlIdtRd80VtI2vWTyq4,1568
|
|
3
|
+
jaxion/constants.py,sha256=HyY2ktKQakv78jD1yQvFdM3sklUJcPgDMYlTsSPQTxI,512
|
|
4
4
|
jaxion/cosmology.py,sha256=UC1McXNTXGoPRYXn0nI2-csVkJWL-ZBNoCa44oU1b4w,2681
|
|
5
5
|
jaxion/gravity.py,sha256=3brRZelKm-soXqk_Lt3SqhbZ00woJCraqwdMuR-KooA,291
|
|
6
6
|
jaxion/hydro.py,sha256=KoJ02tRpAc4V3Ofzw4zbHLRaE2GdIatbOBE04_LsSRw,6980
|
|
7
7
|
jaxion/params_default.json,sha256=9CJrhEPsv5zGEs7_WqFyuccCDipPCDhXgKzVdqOsOWE,2775
|
|
8
8
|
jaxion/particles.py,sha256=pMopGvoZ0J_3EviD0WnTMmiebU9h2_8IO-p6I-E5DEU,3980
|
|
9
9
|
jaxion/quantum.py,sha256=GWOpN6ipfEw-6Ah2zQpxS3oqeSt_iHMDSgnVYSjXY5E,3321
|
|
10
|
-
jaxion/simulation.py,sha256=
|
|
10
|
+
jaxion/simulation.py,sha256=s6gCAt-gAoN5d46vcdxoqtn4TwsrfNGb4Cq-2p_JxsI,15927
|
|
11
11
|
jaxion/utils.py,sha256=rT7NM0FNEgFwN7oTgTb-jkR66Iw0xYTHHxcoikYd1ag,3572
|
|
12
|
-
jaxion/visualization.py,sha256=
|
|
13
|
-
jaxion-0.0.
|
|
14
|
-
jaxion-0.0.
|
|
15
|
-
jaxion-0.0.
|
|
16
|
-
jaxion-0.0.
|
|
17
|
-
jaxion-0.0.
|
|
12
|
+
jaxion/visualization.py,sha256=K5EQOHPfj7LF29fW_naWH8a7TEyEa3wIaQw7rpebx0w,2914
|
|
13
|
+
jaxion-0.0.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
14
|
+
jaxion-0.0.4.dist-info/METADATA,sha256=66lU0x1ZofP-uCwD4hF0C45Ao-pNhPvMzr6Krs__Hws,5305
|
|
15
|
+
jaxion-0.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
+
jaxion-0.0.4.dist-info/top_level.txt,sha256=S1OV2VdlDG_9UwpKOIji4itQGOS-VWUOWUi3GeXWzt0,7
|
|
17
|
+
jaxion-0.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|