jaxion 0.0.1__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/__init__.py +2 -0
- jaxion/constants.py +17 -0
- jaxion/gravity.py +9 -0
- jaxion/hydro.py +231 -0
- jaxion/params_default.json +77 -0
- jaxion/particles.py +113 -0
- jaxion/quantum.py +15 -0
- jaxion/simulation.py +284 -0
- jaxion/utils.py +92 -0
- jaxion/visualization.py +74 -0
- jaxion-0.0.1.dist-info/METADATA +76 -0
- jaxion-0.0.1.dist-info/RECORD +15 -0
- jaxion-0.0.1.dist-info/WHEEL +5 -0
- jaxion-0.0.1.dist-info/licenses/LICENSE +201 -0
- jaxion-0.0.1.dist-info/top_level.txt +1 -0
jaxion/__init__.py
ADDED
jaxion/constants.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright (c) 2025 The Jaxion Team.
|
|
2
|
+
|
|
3
|
+
# Physical Constants
|
|
4
|
+
#
|
|
5
|
+
# Jaxion uses a unit system of:
|
|
6
|
+
# [L] = kpc
|
|
7
|
+
# [V] = km/s
|
|
8
|
+
# [M] = Msun
|
|
9
|
+
#
|
|
10
|
+
# other units are derived from these base units, e.g., [T] = [L]/[V] = kpc / (km/s) ~= 0.978 Gyr
|
|
11
|
+
|
|
12
|
+
constants = {
|
|
13
|
+
"gravitational_constant": 4.30241002e-6, # G / (kpc * (km/s)^2 / Msun)
|
|
14
|
+
"reduced_planck_constant": 1.71818134e-87, # hbar / ((km/s) * kpc * mass of sun)
|
|
15
|
+
"electron_volt": 8.05478173e-56, # eV / (mass of sun * (km/s)^2)
|
|
16
|
+
"speed_of_light": 299792.458, # c / (km/s)
|
|
17
|
+
}
|
jaxion/gravity.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import jax.numpy as jnp
|
|
2
|
+
|
|
3
|
+
# Pure functions for gravity calculations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def calculate_gravitational_potential(rho, k_sq, G, rho_bar):
|
|
7
|
+
Vhat = -jnp.fft.fftn(4.0 * jnp.pi * G * (rho - rho_bar)) / (k_sq + (k_sq == 0))
|
|
8
|
+
V = jnp.real(jnp.fft.ifftn(Vhat))
|
|
9
|
+
return V
|
jaxion/hydro.py
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import jax.numpy as jnp
|
|
2
|
+
|
|
3
|
+
# Pure functions for hydro simulation
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_conserved(rho, vx, vy, vz, vol):
|
|
7
|
+
Mass = rho * vol
|
|
8
|
+
Momx = rho * vx * vol
|
|
9
|
+
Momy = rho * vy * vol
|
|
10
|
+
Momz = rho * vz * vol
|
|
11
|
+
|
|
12
|
+
return Mass, Momx, Momy, Momz
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_primitive(Mass, Momx, Momy, Momz, vol):
|
|
16
|
+
rho = Mass / vol
|
|
17
|
+
vx = Momx / Mass
|
|
18
|
+
vy = Momy / Mass
|
|
19
|
+
vz = Momz / Mass
|
|
20
|
+
|
|
21
|
+
return rho, vx, vy, vz
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_gradient(f, dx):
|
|
25
|
+
f_dx = (jnp.roll(f, -1, axis=0) - jnp.roll(f, 1, axis=0)) / (2.0 * dx)
|
|
26
|
+
f_dy = (jnp.roll(f, -1, axis=1) - jnp.roll(f, 1, axis=1)) / (2.0 * dx)
|
|
27
|
+
f_dz = (jnp.roll(f, -1, axis=2) - jnp.roll(f, 1, axis=2)) / (2.0 * dx)
|
|
28
|
+
|
|
29
|
+
return f_dx, f_dy, f_dz
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def extrap_to_face(f, f_dx, f_dy, f_dz, dx):
|
|
33
|
+
f_XL = f + 0.5 * f_dx * dx
|
|
34
|
+
f_XR = f - 0.5 * f_dx * dx
|
|
35
|
+
f_XR = jnp.roll(f_XR, -1, axis=0)
|
|
36
|
+
|
|
37
|
+
f_YL = f + 0.5 * f_dy * dx
|
|
38
|
+
f_YR = f - 0.5 * f_dy * dx
|
|
39
|
+
f_YR = jnp.roll(f_YR, -1, axis=1)
|
|
40
|
+
|
|
41
|
+
f_ZL = f + 0.5 * f_dz * dx
|
|
42
|
+
f_ZR = f - 0.5 * f_dz * dx
|
|
43
|
+
f_ZR = jnp.roll(f_ZR, -1, axis=2)
|
|
44
|
+
|
|
45
|
+
return f_XL, f_XR, f_YL, f_YR, f_ZL, f_ZR
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def apply_fluxes(F, flux_F_X, flux_F_Y, flux_F_Z, dx, dt):
|
|
49
|
+
fac = dt * dx * dx
|
|
50
|
+
F += -fac * flux_F_X
|
|
51
|
+
F += fac * jnp.roll(flux_F_X, 1, axis=0)
|
|
52
|
+
|
|
53
|
+
F += -fac * flux_F_Y
|
|
54
|
+
F += fac * jnp.roll(flux_F_Y, 1, axis=1)
|
|
55
|
+
|
|
56
|
+
F += -fac * flux_F_Z
|
|
57
|
+
F += fac * jnp.roll(flux_F_Z, 1, axis=2)
|
|
58
|
+
|
|
59
|
+
return F
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def get_flux(rho_L, vx_L, vy_L, vz_L, rho_R, vx_R, vy_R, vz_R, cs):
|
|
63
|
+
# compute star (averaged) states
|
|
64
|
+
rho_star = 0.5 * (rho_L + rho_R)
|
|
65
|
+
momx_star = 0.5 * (rho_L * vx_L + rho_R * vx_R)
|
|
66
|
+
momy_star = 0.5 * (rho_L * vy_L + rho_R * vy_R)
|
|
67
|
+
momz_star = 0.5 * (rho_L * vz_L + rho_R * vz_R)
|
|
68
|
+
|
|
69
|
+
P_star = rho_star * cs * cs
|
|
70
|
+
|
|
71
|
+
# compute fluxes (local Lax-Friedrichs/Rusanov)
|
|
72
|
+
flux_Mass = momx_star
|
|
73
|
+
flux_Momx = momx_star**2 / rho_star + P_star
|
|
74
|
+
flux_Momy = momx_star * momy_star / rho_star
|
|
75
|
+
flux_Momz = momx_star * momz_star / rho_star
|
|
76
|
+
|
|
77
|
+
# find wavespeeds
|
|
78
|
+
C_L = cs + jnp.abs(vx_L)
|
|
79
|
+
C_R = cs + jnp.abs(vx_R)
|
|
80
|
+
C = jnp.maximum(C_L, C_R)
|
|
81
|
+
|
|
82
|
+
# add stabilizing diffusive term
|
|
83
|
+
flux_Mass -= C * 0.5 * (rho_R - rho_L)
|
|
84
|
+
flux_Momx -= C * 0.5 * (rho_R * vx_R - rho_L * vx_L)
|
|
85
|
+
flux_Momy -= C * 0.5 * (rho_R * vy_R - rho_L * vy_L)
|
|
86
|
+
flux_Momz -= C * 0.5 * (rho_R * vz_R - rho_L * vz_L)
|
|
87
|
+
|
|
88
|
+
return flux_Mass, flux_Momx, flux_Momy, flux_Momz
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def hydro_accelerate(vx, vy, vz, V, kx, ky, kz, dt):
|
|
92
|
+
V_hat = jnp.fft.fftn(V)
|
|
93
|
+
|
|
94
|
+
ax = -jnp.real(jnp.fft.ifftn(1.0j * kx * V_hat))
|
|
95
|
+
ay = -jnp.real(jnp.fft.ifftn(1.0j * ky * V_hat))
|
|
96
|
+
az = -jnp.real(jnp.fft.ifftn(1.0j * kz * V_hat))
|
|
97
|
+
|
|
98
|
+
vx += ax * dt
|
|
99
|
+
vy += ay * dt
|
|
100
|
+
vz += az * dt
|
|
101
|
+
|
|
102
|
+
return vx, vy, vz
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def hydro_fluxes(rho, vx, vy, vz, dt, dx, cs):
|
|
106
|
+
# calculate gradients
|
|
107
|
+
rho_dx, rho_dy, rho_dz = get_gradient(rho, dx)
|
|
108
|
+
vx_dx, vx_dy, vx_dz = get_gradient(vx, dx)
|
|
109
|
+
vy_dx, vy_dy, vy_dz = get_gradient(vy, dx)
|
|
110
|
+
vz_dx, vz_dy, vz_dz = get_gradient(vz, dx)
|
|
111
|
+
|
|
112
|
+
# slope limit gradients
|
|
113
|
+
rho_dx, rho_dy, rho_dz = slope_limiter(rho, dx, rho_dx, rho_dy, rho_dz)
|
|
114
|
+
vx_dx, vx_dy, vx_dz = slope_limiter(vx, dx, vx_dx, vx_dy, vx_dz)
|
|
115
|
+
vy_dx, vy_dy, vy_dz = slope_limiter(vy, dx, vy_dx, vy_dy, vy_dz)
|
|
116
|
+
vz_dx, vz_dy, vz_dz = slope_limiter(vz, dx, vz_dx, vz_dy, vz_dz)
|
|
117
|
+
|
|
118
|
+
# extrapolate half-step in time
|
|
119
|
+
rho_prime = rho - 0.5 * dt * (
|
|
120
|
+
vx * rho_dx
|
|
121
|
+
+ rho * vx_dx
|
|
122
|
+
+ vy * rho_dy
|
|
123
|
+
+ rho * vy_dy
|
|
124
|
+
+ vz * rho_dz
|
|
125
|
+
+ rho * vz_dz
|
|
126
|
+
)
|
|
127
|
+
vx_prime = vx - 0.5 * dt * (
|
|
128
|
+
vx * vx_dx + vy * vx_dy + vz * vx_dz + (1.0 / rho) * rho_dx * cs * cs
|
|
129
|
+
)
|
|
130
|
+
vy_prime = vy - 0.5 * dt * (
|
|
131
|
+
vx * vy_dx + vy * vy_dy + vz * vy_dz + (1.0 / rho) * rho_dy * cs * cs
|
|
132
|
+
)
|
|
133
|
+
vz_prime = vz - 0.5 * dt * (
|
|
134
|
+
vx * vz_dx + vy * vz_dy + vz * vz_dz + (1.0 / rho) * rho_dz * cs * cs
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
# extrapolate in space to face centers
|
|
138
|
+
rho_XL, rho_XR, rho_YL, rho_YR, rho_ZL, rho_ZR = extrap_to_face(
|
|
139
|
+
rho_prime, rho_dx, rho_dy, rho_dz, dx
|
|
140
|
+
)
|
|
141
|
+
vx_XL, vx_XR, vx_YL, vx_YR, vx_ZL, vx_ZR = extrap_to_face(
|
|
142
|
+
vx_prime, vx_dx, vx_dy, vx_dz, dx
|
|
143
|
+
)
|
|
144
|
+
vy_XL, vy_XR, vy_YL, vy_YR, vy_ZL, vy_ZR = extrap_to_face(
|
|
145
|
+
vy_prime, vy_dx, vy_dy, vy_dz, dx
|
|
146
|
+
)
|
|
147
|
+
vz_XL, vz_XR, vz_YL, vz_YR, vz_ZL, vz_ZR = extrap_to_face(
|
|
148
|
+
vz_prime, vz_dx, vz_dy, vz_dz, dx
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# compute fluxes (local Lax-Friedrichs/Rusanov)
|
|
152
|
+
flux_Mass_X, flux_Momx_X, flux_Momy_X, flux_Momz_X = get_flux(
|
|
153
|
+
rho_XL, vx_XL, vy_XL, vz_XL, rho_XR, vx_XR, vy_XR, vz_XR, cs
|
|
154
|
+
)
|
|
155
|
+
flux_Mass_Y, flux_Momy_Y, flux_Momz_Y, flux_Momx_Y = get_flux(
|
|
156
|
+
rho_YL, vy_YL, vz_YL, vx_YL, rho_YR, vy_YR, vz_YR, vx_YR, cs
|
|
157
|
+
)
|
|
158
|
+
flux_Mass_Z, flux_Momz_Z, flux_Momx_Z, flux_Momy_Z = get_flux(
|
|
159
|
+
rho_ZL, vz_ZL, vx_ZL, vy_ZL, rho_ZR, vz_ZR, vx_ZR, vy_ZR, cs
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
Mass, Momx, Momy, Momz = get_conserved(rho, vx, vy, vz, dx**3)
|
|
163
|
+
|
|
164
|
+
# update solution
|
|
165
|
+
Mass = apply_fluxes(Mass, flux_Mass_X, flux_Mass_Y, flux_Mass_Z, dx, dt)
|
|
166
|
+
Momx = apply_fluxes(Momx, flux_Momx_X, flux_Momx_Y, flux_Momx_Z, dx, dt)
|
|
167
|
+
Momy = apply_fluxes(Momy, flux_Momy_X, flux_Momy_Y, flux_Momy_Z, dx, dt)
|
|
168
|
+
Momz = apply_fluxes(Momz, flux_Momz_X, flux_Momz_Y, flux_Momz_Z, dx, dt)
|
|
169
|
+
|
|
170
|
+
# get Primitive variables
|
|
171
|
+
rho, vx, vy, vz = get_primitive(Mass, Momx, Momy, Momz, dx**3)
|
|
172
|
+
|
|
173
|
+
return rho, vx, vy, vz
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def slope_limiter(f, dx, f_dx, f_dy, f_dz):
|
|
177
|
+
"""
|
|
178
|
+
Apply slope limiter to slopes (minmod)
|
|
179
|
+
"""
|
|
180
|
+
|
|
181
|
+
eps = 1.0e-12
|
|
182
|
+
|
|
183
|
+
# Keep a copy of the original slopes
|
|
184
|
+
orig_f_dx = f_dx
|
|
185
|
+
orig_f_dy = f_dy
|
|
186
|
+
orig_f_dz = f_dz
|
|
187
|
+
|
|
188
|
+
# Function to adjust the denominator safely
|
|
189
|
+
def adjust_denominator(denom):
|
|
190
|
+
denom_safe = jnp.where(
|
|
191
|
+
denom > 0, denom + eps, jnp.where(denom < 0, denom - eps, eps)
|
|
192
|
+
)
|
|
193
|
+
return denom_safe
|
|
194
|
+
|
|
195
|
+
# For x-direction
|
|
196
|
+
denom = adjust_denominator(orig_f_dx)
|
|
197
|
+
num = (f - jnp.roll(f, 1, axis=0)) / dx
|
|
198
|
+
ratio = num / denom
|
|
199
|
+
limiter = jnp.maximum(0.0, jnp.minimum(1.0, ratio))
|
|
200
|
+
f_dx = limiter * f_dx
|
|
201
|
+
|
|
202
|
+
num = -(f - jnp.roll(f, -1, axis=0)) / dx
|
|
203
|
+
ratio = num / denom # Use the same adjusted denominator
|
|
204
|
+
limiter = jnp.maximum(0.0, jnp.minimum(1.0, ratio))
|
|
205
|
+
f_dx = limiter * f_dx
|
|
206
|
+
|
|
207
|
+
# For y-direction
|
|
208
|
+
denom = adjust_denominator(orig_f_dy)
|
|
209
|
+
num = (f - jnp.roll(f, 1, axis=1)) / dx
|
|
210
|
+
ratio = num / denom
|
|
211
|
+
limiter = jnp.maximum(0.0, jnp.minimum(1.0, ratio))
|
|
212
|
+
f_dy = limiter * f_dy
|
|
213
|
+
|
|
214
|
+
num = -(f - jnp.roll(f, -1, axis=1)) / dx
|
|
215
|
+
ratio = num / denom
|
|
216
|
+
limiter = jnp.maximum(0.0, jnp.minimum(1.0, ratio))
|
|
217
|
+
f_dy = limiter * f_dy
|
|
218
|
+
|
|
219
|
+
# For z-direction
|
|
220
|
+
denom = adjust_denominator(orig_f_dz)
|
|
221
|
+
num = (f - jnp.roll(f, 1, axis=2)) / dx
|
|
222
|
+
ratio = num / denom
|
|
223
|
+
limiter = jnp.maximum(0.0, jnp.minimum(1.0, ratio))
|
|
224
|
+
f_dz = limiter * f_dz
|
|
225
|
+
|
|
226
|
+
num = -(f - jnp.roll(f, -1, axis=2)) / dx
|
|
227
|
+
ratio = num / denom
|
|
228
|
+
limiter = jnp.maximum(0.0, jnp.minimum(1.0, ratio))
|
|
229
|
+
f_dz = limiter * f_dz
|
|
230
|
+
|
|
231
|
+
return f_dx, f_dy, f_dz
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"physics": {
|
|
3
|
+
"quantum": {
|
|
4
|
+
"default": true,
|
|
5
|
+
"description": "switch on for fuzzy dark matter."
|
|
6
|
+
},
|
|
7
|
+
"gravity": {
|
|
8
|
+
"default": true,
|
|
9
|
+
"description": "switch on for self-gravity."
|
|
10
|
+
},
|
|
11
|
+
"hydro": {
|
|
12
|
+
"default": false,
|
|
13
|
+
"description": "switch on for hydrodynamics (isothermal)."
|
|
14
|
+
},
|
|
15
|
+
"particles": {
|
|
16
|
+
"default": false,
|
|
17
|
+
"description": "switch on for particle-mesh particles."
|
|
18
|
+
},
|
|
19
|
+
"cosmology": {
|
|
20
|
+
"default": false,
|
|
21
|
+
"description": "switch on for cosmological factors/comoving units."
|
|
22
|
+
},
|
|
23
|
+
"external_potential": {
|
|
24
|
+
"default": false,
|
|
25
|
+
"description": "switch on for external gravitational potential."
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"domain": {
|
|
29
|
+
"box_size": {
|
|
30
|
+
"default": 10.0,
|
|
31
|
+
"description": "periodic domain box size (kpc)."
|
|
32
|
+
},
|
|
33
|
+
"resolution_base": {
|
|
34
|
+
"default": 32,
|
|
35
|
+
"description": "base resolution per linear dimension."
|
|
36
|
+
},
|
|
37
|
+
"resolution_multiplier": {
|
|
38
|
+
"default": 1,
|
|
39
|
+
"description": "resolution multiplier."
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"time": {
|
|
43
|
+
"start": 0.0,
|
|
44
|
+
"end": 1.0,
|
|
45
|
+
"adaptive": false
|
|
46
|
+
},
|
|
47
|
+
"output": {
|
|
48
|
+
"path": "./checkpoints",
|
|
49
|
+
"num_checkpoints": 100,
|
|
50
|
+
"save": true,
|
|
51
|
+
"plot_dynamic_range": 100.0
|
|
52
|
+
},
|
|
53
|
+
"quantum": {
|
|
54
|
+
"m_22": {
|
|
55
|
+
"default": 1.0,
|
|
56
|
+
"description": "axion mass in units of 10^{-22} eV."
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"hydro": {
|
|
60
|
+
"sound_speed": {
|
|
61
|
+
"default": 1.0,
|
|
62
|
+
"description": "Isothermal sound speed (km/s)."
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"particles": {
|
|
66
|
+
"num_particles": 0,
|
|
67
|
+
"particle_mass": 1.0
|
|
68
|
+
},
|
|
69
|
+
"cosmology": {
|
|
70
|
+
"Omega_m": 0.3,
|
|
71
|
+
"Omega_Lambda": 0.7
|
|
72
|
+
},
|
|
73
|
+
"version": {
|
|
74
|
+
"default": "unknown",
|
|
75
|
+
"description": "version of the jaxion library used to create these parameters (automatically detected)."
|
|
76
|
+
}
|
|
77
|
+
}
|
jaxion/particles.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import jax
|
|
2
|
+
import jax.numpy as jnp
|
|
3
|
+
|
|
4
|
+
# Pure functions for particle-mesh calculations (stars, BHs, ...)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_cic_indices_and_weights(pos, dx, resolution):
|
|
8
|
+
"""Compute the cloud-in-cell indices and weights for the particle positions."""
|
|
9
|
+
nx = resolution
|
|
10
|
+
dxs = jnp.array([dx, dx, dx])
|
|
11
|
+
i = jnp.floor((pos - 0.5 * dxs) / dxs)
|
|
12
|
+
ip1 = i + 1.0
|
|
13
|
+
weight_i = ((ip1 + 0.5) * dxs - pos) / dxs
|
|
14
|
+
weight_ip1 = (pos - (i + 0.5) * dxs) / dxs
|
|
15
|
+
i = jnp.mod(i, jnp.array([nx, nx, nx])).astype(int)
|
|
16
|
+
ip1 = jnp.mod(ip1, jnp.array([nx, nx, nx])).astype(int)
|
|
17
|
+
return i, ip1, weight_i, weight_ip1
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def bin_particles(pos, dx, resolution, m_particle):
|
|
21
|
+
"""Bin the particles into the grid using cloud-in-cell weights."""
|
|
22
|
+
nx = resolution
|
|
23
|
+
n_particle = pos.shape[0]
|
|
24
|
+
rho = jnp.zeros((nx, nx, nx))
|
|
25
|
+
i, ip1, w_i, w_ip1 = get_cic_indices_and_weights(pos, dx, resolution)
|
|
26
|
+
|
|
27
|
+
def deposit_particle(s, rho):
|
|
28
|
+
"""Deposit the particle mass into the grid."""
|
|
29
|
+
fac = m_particle / (dx * dx * dx)
|
|
30
|
+
rho = rho.at[i[s, 0], i[s, 1], i[s, 2]].add(
|
|
31
|
+
w_i[s, 0] * w_i[s, 1] * w_i[s, 2] * fac
|
|
32
|
+
)
|
|
33
|
+
rho = rho.at[ip1[s, 0], i[s, 1], i[s, 2]].add(
|
|
34
|
+
w_ip1[s, 0] * w_i[s, 1] * w_i[s, 2] * fac
|
|
35
|
+
)
|
|
36
|
+
rho = rho.at[i[s, 0], ip1[s, 1], i[s, 2]].add(
|
|
37
|
+
w_i[s, 0] * w_ip1[s, 1] * w_i[s, 2] * fac
|
|
38
|
+
)
|
|
39
|
+
rho = rho.at[i[s, 0], i[s, 1], ip1[s, 2]].add(
|
|
40
|
+
w_i[s, 0] * w_i[s, 1] * w_ip1[s, 2] * fac
|
|
41
|
+
)
|
|
42
|
+
rho = rho.at[ip1[s, 0], ip1[s, 1], i[s, 2]].add(
|
|
43
|
+
w_ip1[s, 0] * w_ip1[s, 1] * w_i[s, 2] * fac
|
|
44
|
+
)
|
|
45
|
+
rho = rho.at[ip1[s, 0], i[s, 1], ip1[s, 2]].add(
|
|
46
|
+
w_ip1[s, 0] * w_i[s, 1] * w_ip1[s, 2] * fac
|
|
47
|
+
)
|
|
48
|
+
rho = rho.at[i[s, 0], ip1[s, 1], ip1[s, 2]].add(
|
|
49
|
+
w_i[s, 0] * w_ip1[s, 1] * w_ip1[s, 2] * fac
|
|
50
|
+
)
|
|
51
|
+
rho = rho.at[ip1[s, 0], ip1[s, 1], ip1[s, 2]].add(
|
|
52
|
+
w_ip1[s, 0] * w_ip1[s, 1] * w_ip1[s, 2] * fac
|
|
53
|
+
)
|
|
54
|
+
return rho
|
|
55
|
+
|
|
56
|
+
rho = jax.lax.fori_loop(0, n_particle, deposit_particle, rho)
|
|
57
|
+
return rho
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def get_acceleration(pos, V, kx, ky, kz, dx):
|
|
61
|
+
"""Compute the acceleration of the particles."""
|
|
62
|
+
n_particle = pos.shape[0]
|
|
63
|
+
resolution = V.shape[0]
|
|
64
|
+
i, ip1, w_i, w_ip1 = get_cic_indices_and_weights(pos, dx, resolution)
|
|
65
|
+
|
|
66
|
+
# find accelerations on the grid
|
|
67
|
+
V_hat = jnp.fft.fftn(V)
|
|
68
|
+
ax = -jnp.real(jnp.fft.ifftn(1.0j * kx * V_hat))
|
|
69
|
+
ay = -jnp.real(jnp.fft.ifftn(1.0j * ky * V_hat))
|
|
70
|
+
az = -jnp.real(jnp.fft.ifftn(1.0j * kz * V_hat))
|
|
71
|
+
a_grid = jnp.stack((ax, ay, az), axis=-1)
|
|
72
|
+
|
|
73
|
+
# interpolate the accelerations to the particle positions
|
|
74
|
+
acc = jnp.zeros((n_particle, 3))
|
|
75
|
+
acc += (w_i[:, 0] * w_i[:, 1] * w_i[:, 2])[:, None] * a_grid[
|
|
76
|
+
i[:, 0], i[:, 1], i[:, 2]
|
|
77
|
+
]
|
|
78
|
+
acc += (w_ip1[:, 0] * w_i[:, 1] * w_i[:, 2])[:, None] * a_grid[
|
|
79
|
+
ip1[:, 0], i[:, 1], i[:, 2]
|
|
80
|
+
]
|
|
81
|
+
acc += (w_i[:, 0] * w_ip1[:, 1] * w_i[:, 2])[:, None] * a_grid[
|
|
82
|
+
i[:, 0], ip1[:, 1], i[:, 2]
|
|
83
|
+
]
|
|
84
|
+
acc += (w_i[:, 0] * w_i[:, 1] * w_ip1[:, 2])[:, None] * a_grid[
|
|
85
|
+
i[:, 0], i[:, 1], ip1[:, 2]
|
|
86
|
+
]
|
|
87
|
+
acc += (w_ip1[:, 0] * w_ip1[:, 1] * w_i[:, 2])[:, None] * a_grid[
|
|
88
|
+
ip1[:, 0], ip1[:, 1], i[:, 2]
|
|
89
|
+
]
|
|
90
|
+
acc += (w_ip1[:, 0] * w_i[:, 1] * w_ip1[:, 2])[:, None] * a_grid[
|
|
91
|
+
ip1[:, 0], i[:, 1], ip1[:, 2]
|
|
92
|
+
]
|
|
93
|
+
acc += (w_i[:, 0] * w_ip1[:, 1] * w_ip1[:, 2])[:, None] * a_grid[
|
|
94
|
+
i[:, 0], ip1[:, 1], ip1[:, 2]
|
|
95
|
+
]
|
|
96
|
+
acc += (w_ip1[:, 0] * w_ip1[:, 1] * w_ip1[:, 2])[:, None] * a_grid[
|
|
97
|
+
ip1[:, 0], ip1[:, 1], ip1[:, 2]
|
|
98
|
+
]
|
|
99
|
+
return acc
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def particles_accelerate(vel, pos, V, kx, ky, kz, dx, dt):
|
|
103
|
+
"""Apply the acceleration to the particles."""
|
|
104
|
+
acc = get_acceleration(pos, V, kx, ky, kz, dx)
|
|
105
|
+
vel += acc * dt
|
|
106
|
+
return vel
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def particles_drift(pos, vel, dt, box_size):
|
|
110
|
+
pos += vel * dt
|
|
111
|
+
pos = jnp.mod(pos, jnp.array([box_size, box_size, box_size]))
|
|
112
|
+
|
|
113
|
+
return pos
|
jaxion/quantum.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import jax.numpy as jnp
|
|
2
|
+
|
|
3
|
+
# Pure functions for quantum simulation
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def quantum_kick(psi, V, m_per_hbar, dt):
|
|
7
|
+
psi = jnp.exp(-1.0j * m_per_hbar * dt * V) * psi
|
|
8
|
+
return psi
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def quantum_drift(psi, k_sq, m_per_hbar, dt):
|
|
12
|
+
psi_hat = jnp.fft.fftn(psi)
|
|
13
|
+
psi_hat = jnp.exp(dt * (-1.0j * k_sq / m_per_hbar / 2.0)) * psi_hat
|
|
14
|
+
psi = jnp.fft.ifftn(psi_hat)
|
|
15
|
+
return psi
|
jaxion/simulation.py
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import jax
|
|
2
|
+
import jax.numpy as jnp
|
|
3
|
+
import orbax.checkpoint as ocp
|
|
4
|
+
import os
|
|
5
|
+
import json
|
|
6
|
+
import time
|
|
7
|
+
|
|
8
|
+
from .constants import constants
|
|
9
|
+
from .quantum import quantum_kick, quantum_drift
|
|
10
|
+
from .gravity import calculate_gravitational_potential
|
|
11
|
+
from .hydro import hydro_fluxes, hydro_accelerate
|
|
12
|
+
from .particles import particles_accelerate, particles_drift, bin_particles
|
|
13
|
+
from .utils import set_up_parameters, print_parameters
|
|
14
|
+
from .visualization import plot_sim
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Simulation:
|
|
18
|
+
"""
|
|
19
|
+
Simulation: The base class for an astrophysics simulation.
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
params (dict): The Python dictionary that contains the simulation parameters.
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, params):
|
|
28
|
+
# start from default simulation parameters and update with user params
|
|
29
|
+
self._params = set_up_parameters(params)
|
|
30
|
+
|
|
31
|
+
# additional checks
|
|
32
|
+
if self.resolution % 2 != 0:
|
|
33
|
+
raise ValueError("Resolution must be divisible by 2.")
|
|
34
|
+
|
|
35
|
+
if self.params["output"]["save"]:
|
|
36
|
+
print("Simulation initialized with parameters:")
|
|
37
|
+
print_parameters(self.params)
|
|
38
|
+
|
|
39
|
+
# simulation state
|
|
40
|
+
self.state = {}
|
|
41
|
+
self.state["t"] = 0.0
|
|
42
|
+
if self.params["physics"]["quantum"]:
|
|
43
|
+
self.state["psi"] = (
|
|
44
|
+
jnp.zeros((self.resolution, self.resolution, self.resolution)) * 1j
|
|
45
|
+
)
|
|
46
|
+
if self.params["physics"]["external_potential"]:
|
|
47
|
+
self.state["V_ext"] = jnp.zeros(
|
|
48
|
+
(self.resolution, self.resolution, self.resolution)
|
|
49
|
+
)
|
|
50
|
+
if self.params["physics"]["hydro"]:
|
|
51
|
+
self.state["rho"] = jnp.zeros(
|
|
52
|
+
(self.resolution, self.resolution, self.resolution)
|
|
53
|
+
)
|
|
54
|
+
self.state["vx"] = jnp.zeros(
|
|
55
|
+
(self.resolution, self.resolution, self.resolution)
|
|
56
|
+
)
|
|
57
|
+
self.state["vy"] = jnp.zeros(
|
|
58
|
+
(self.resolution, self.resolution, self.resolution)
|
|
59
|
+
)
|
|
60
|
+
self.state["vz"] = jnp.zeros(
|
|
61
|
+
(self.resolution, self.resolution, self.resolution)
|
|
62
|
+
)
|
|
63
|
+
if self.params["physics"]["particles"]:
|
|
64
|
+
self.state["pos"] = jnp.zeros((self.num_particles, 3))
|
|
65
|
+
self.state["vel"] = jnp.zeros((self.num_particles, 3))
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def resolution(self):
|
|
69
|
+
return (
|
|
70
|
+
self.params["domain"]["resolution_base"]
|
|
71
|
+
* self.params["domain"]["resolution_multiplier"]
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def num_particles(self):
|
|
76
|
+
return self.params["particles"]["num_particles"]
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def box_size(self):
|
|
80
|
+
return self.params["domain"]["box_size"]
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def dx(self):
|
|
84
|
+
return self.box_size / self.resolution
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def axion_mass(self):
|
|
88
|
+
return (
|
|
89
|
+
self.params["quantum"]["m_22"]
|
|
90
|
+
* 1.0e-22
|
|
91
|
+
* constants["electron_volt"]
|
|
92
|
+
/ constants["speed_of_light"] ** 2
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def sound_speed(self):
|
|
97
|
+
return self.params["hydro"]["sound_speed"]
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def params(self):
|
|
101
|
+
return self._params
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def grid(self):
|
|
105
|
+
hx = 0.5 * self.dx
|
|
106
|
+
x_lin = jnp.linspace(hx, self.box_size - hx, self.resolution)
|
|
107
|
+
X, Y, Z = jnp.meshgrid(x_lin, x_lin, x_lin, indexing="ij")
|
|
108
|
+
return X, Y, Z
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def kgrid(self):
|
|
112
|
+
nx = self.resolution
|
|
113
|
+
k_lin = (2.0 * jnp.pi / self.box_size) * jnp.arange(-nx / 2, nx / 2)
|
|
114
|
+
kx, ky, kz = jnp.meshgrid(k_lin, k_lin, k_lin, indexing="ij")
|
|
115
|
+
kx = jnp.fft.ifftshift(kx)
|
|
116
|
+
ky = jnp.fft.ifftshift(ky)
|
|
117
|
+
kz = jnp.fft.ifftshift(kz)
|
|
118
|
+
return kx, ky, kz
|
|
119
|
+
|
|
120
|
+
def _calc_rho_bar(self, state):
|
|
121
|
+
rho_bar = 0.0
|
|
122
|
+
if self.params["physics"]["quantum"]:
|
|
123
|
+
rho_bar += jnp.mean(jnp.abs(state["psi"]) ** 2)
|
|
124
|
+
if self.params["physics"]["hydro"]:
|
|
125
|
+
rho_bar += jnp.mean(state["rho"])
|
|
126
|
+
if self.params["physics"]["particles"]:
|
|
127
|
+
m_particle = self.params["particles"]["particle_mass"]
|
|
128
|
+
n_particles = self.num_particles
|
|
129
|
+
box_size = self.box_size
|
|
130
|
+
rho_bar += m_particle * n_particles / box_size
|
|
131
|
+
return rho_bar
|
|
132
|
+
|
|
133
|
+
def _calc_grav_potential(self, state, k_sq):
|
|
134
|
+
G = constants["gravitational_constant"]
|
|
135
|
+
m_particle = self.params["particles"]["particle_mass"]
|
|
136
|
+
rho_bar = self._calc_rho_bar(self.state)
|
|
137
|
+
rho_tot = 0.0
|
|
138
|
+
if self.params["physics"]["quantum"]:
|
|
139
|
+
rho_tot += jnp.abs(state["psi"]) ** 2
|
|
140
|
+
if self.params["physics"]["hydro"]:
|
|
141
|
+
rho_tot += state["rho"]
|
|
142
|
+
if self.params["physics"]["particles"]:
|
|
143
|
+
rho_tot += bin_particles(state["pos"], self.dx, self.resolution, m_particle)
|
|
144
|
+
return calculate_gravitational_potential(rho_tot, k_sq, G, rho_bar)
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def potential(self):
|
|
148
|
+
kx, ky, kz = self.kgrid
|
|
149
|
+
k_sq = kx**2 + ky**2 + kz**2
|
|
150
|
+
return self._calc_grav_potential(self.state, k_sq)
|
|
151
|
+
|
|
152
|
+
def _evolve(self, state):
|
|
153
|
+
"""
|
|
154
|
+
This function evolves the simulation state according to the simulation parameters/physics.
|
|
155
|
+
|
|
156
|
+
Parameters
|
|
157
|
+
----------
|
|
158
|
+
state: jax.pytree
|
|
159
|
+
The current state of the simulation.
|
|
160
|
+
|
|
161
|
+
Returns
|
|
162
|
+
-------
|
|
163
|
+
state: jax.pytree
|
|
164
|
+
The evolved state of the simulation.
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
# Simulation parameters
|
|
168
|
+
dx = self.dx
|
|
169
|
+
m_per_hbar = self.axion_mass / constants["reduced_planck_constant"]
|
|
170
|
+
|
|
171
|
+
dt_fac = 1.0
|
|
172
|
+
dt_kin = dt_fac * (m_per_hbar / 6.0) * (dx * dx)
|
|
173
|
+
t_end = self.params["time"]["end"]
|
|
174
|
+
|
|
175
|
+
c_sound = self.params["hydro"]["sound_speed"]
|
|
176
|
+
box_size = self.box_size
|
|
177
|
+
|
|
178
|
+
# round up to the nearest multiple of num_checkpoints
|
|
179
|
+
num_checkpoints = self.params["output"]["num_checkpoints"]
|
|
180
|
+
nt = int(round(round(t_end / dt_kin) / num_checkpoints) * num_checkpoints)
|
|
181
|
+
nt_sub = int(round(nt / num_checkpoints))
|
|
182
|
+
dt = t_end / nt
|
|
183
|
+
|
|
184
|
+
# Fourier space variables
|
|
185
|
+
if self.params["physics"]["gravity"] or self.params["physics"]["quantum"]:
|
|
186
|
+
kx, ky, kz = self.kgrid
|
|
187
|
+
k_sq = kx**2 + ky**2 + kz**2
|
|
188
|
+
|
|
189
|
+
# Checkpointer
|
|
190
|
+
if self.params["output"]["save"]:
|
|
191
|
+
options = ocp.CheckpointManagerOptions()
|
|
192
|
+
checkpoint_dir = checkpoint_dir = os.path.join(
|
|
193
|
+
os.getcwd(), self.params["output"]["path"]
|
|
194
|
+
)
|
|
195
|
+
path = ocp.test_utils.erase_and_create_empty(checkpoint_dir)
|
|
196
|
+
async_checkpoint_manager = ocp.CheckpointManager(path, options=options)
|
|
197
|
+
|
|
198
|
+
def _kick(state, dt):
|
|
199
|
+
# Kick (half-step)
|
|
200
|
+
if (
|
|
201
|
+
self.params["physics"]["gravity"]
|
|
202
|
+
and self.params["physics"]["external_potential"]
|
|
203
|
+
):
|
|
204
|
+
V = self._calc_grav_potential(state, k_sq) + state["V_ext"]
|
|
205
|
+
elif self.params["physics"]["gravity"]:
|
|
206
|
+
V = self._calc_grav_potential(state, k_sq)
|
|
207
|
+
elif self.params["physics"]["external_potential"]:
|
|
208
|
+
V = state["V_ext"]
|
|
209
|
+
|
|
210
|
+
if (
|
|
211
|
+
self.params["physics"]["gravity"]
|
|
212
|
+
or self.params["physics"]["external_potential"]
|
|
213
|
+
):
|
|
214
|
+
if self.params["physics"]["quantum"]:
|
|
215
|
+
state["psi"] = quantum_kick(state["psi"], V, m_per_hbar, dt)
|
|
216
|
+
if self.params["physics"]["hydro"]:
|
|
217
|
+
state["vx"], state["vy"], state["vz"] = hydro_accelerate(
|
|
218
|
+
state["vx"], state["vy"], state["vz"], V, kx, ky, kz, dt
|
|
219
|
+
)
|
|
220
|
+
if self.params["physics"]["particles"]:
|
|
221
|
+
state["vel"] = particles_accelerate(
|
|
222
|
+
state["vel"], state["pos"], V, kx, ky, kz, dx, dt
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
def _drift(state, dt):
|
|
226
|
+
# Drift (full-step)
|
|
227
|
+
if self.params["physics"]["quantum"]:
|
|
228
|
+
state["psi"] = quantum_drift(state["psi"], k_sq, m_per_hbar, dt)
|
|
229
|
+
if self.params["physics"]["hydro"]:
|
|
230
|
+
state["rho"], state["vx"], state["vy"], state["vz"] = hydro_fluxes(
|
|
231
|
+
state["rho"], state["vx"], state["vy"], state["vz"], dt, dx, c_sound
|
|
232
|
+
)
|
|
233
|
+
if self.params["physics"]["particles"]:
|
|
234
|
+
state["pos"] = particles_drift(state["pos"], state["vel"], dt, box_size)
|
|
235
|
+
|
|
236
|
+
@jax.jit
|
|
237
|
+
def _update(_, state):
|
|
238
|
+
# Update the simulation state by one timestep
|
|
239
|
+
# according to a 2nd-order `kick-drift-kick` scheme
|
|
240
|
+
_kick(state, 0.5 * dt)
|
|
241
|
+
_drift(state, dt)
|
|
242
|
+
_kick(state, 0.5 * dt)
|
|
243
|
+
|
|
244
|
+
# update time
|
|
245
|
+
state["t"] += dt
|
|
246
|
+
|
|
247
|
+
return state
|
|
248
|
+
|
|
249
|
+
# save initial state
|
|
250
|
+
print("Starting simulation ...")
|
|
251
|
+
if self.params["output"]["save"]:
|
|
252
|
+
with open(os.path.join(checkpoint_dir, "params.json"), "w") as f:
|
|
253
|
+
json.dump(self.params, f, indent=2)
|
|
254
|
+
async_checkpoint_manager.save(0, args=ocp.args.StandardSave(state))
|
|
255
|
+
plot_sim(state, checkpoint_dir, 0, self.params)
|
|
256
|
+
async_checkpoint_manager.wait_until_finished()
|
|
257
|
+
|
|
258
|
+
# Simulation Main Loop
|
|
259
|
+
t_start_timer = time.time()
|
|
260
|
+
if self.params["output"]["save"]:
|
|
261
|
+
for i in range(1, num_checkpoints + 1):
|
|
262
|
+
state = jax.lax.fori_loop(0, nt_sub, _update, init_val=state)
|
|
263
|
+
jax.block_until_ready(state)
|
|
264
|
+
# save state
|
|
265
|
+
async_checkpoint_manager.save(i, args=ocp.args.StandardSave(state))
|
|
266
|
+
percent = int(100 * i / num_checkpoints)
|
|
267
|
+
elapsed = time.time() - t_start_timer
|
|
268
|
+
est_total = elapsed / i * num_checkpoints
|
|
269
|
+
est_remaining = est_total - elapsed
|
|
270
|
+
print(
|
|
271
|
+
f"{percent:.1f}%: estimated time remaining (s): {est_remaining:.1f}"
|
|
272
|
+
)
|
|
273
|
+
plot_sim(state, checkpoint_dir, i, self.params)
|
|
274
|
+
async_checkpoint_manager.wait_until_finished()
|
|
275
|
+
else:
|
|
276
|
+
state = jax.lax.fori_loop(0, nt, _update, init_val=state)
|
|
277
|
+
jax.block_until_ready(state)
|
|
278
|
+
print("Simulation Run Time (s): ", time.time() - t_start_timer)
|
|
279
|
+
|
|
280
|
+
return state
|
|
281
|
+
|
|
282
|
+
def run(self):
|
|
283
|
+
self.state = self._evolve(self.state)
|
|
284
|
+
jax.block_until_ready(self.state)
|
jaxion/utils.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
import importlib.util
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import importlib.resources
|
|
6
|
+
import json
|
|
7
|
+
from importlib.metadata import version
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def print_parameters(params):
|
|
11
|
+
print(json.dumps(params, indent=2))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def set_up_parameters(user_overwrites):
|
|
15
|
+
# first load the default params
|
|
16
|
+
params_path = importlib.resources.files("jaxion") / "params_default.json"
|
|
17
|
+
with params_path.open("r", encoding="utf-8") as f:
|
|
18
|
+
params = json.load(f)
|
|
19
|
+
|
|
20
|
+
# go down to lowest level in dict and eliminate meta-data
|
|
21
|
+
params = _eliminate_metadata(params)
|
|
22
|
+
|
|
23
|
+
# update default values with user-supplied overwrites
|
|
24
|
+
params = _update_dicts(params, user_overwrites)
|
|
25
|
+
|
|
26
|
+
# detect jaxion version
|
|
27
|
+
params["version"] = version("jaxion")
|
|
28
|
+
|
|
29
|
+
return params
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _eliminate_metadata(params):
|
|
33
|
+
for key, value in params.items():
|
|
34
|
+
if isinstance(value, dict):
|
|
35
|
+
if "default" not in value:
|
|
36
|
+
_eliminate_metadata(value)
|
|
37
|
+
else:
|
|
38
|
+
params[key] = value["default"]
|
|
39
|
+
|
|
40
|
+
return params
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _update_dicts(orig_dict, new_dict):
|
|
44
|
+
for key, value in new_dict.items():
|
|
45
|
+
if (
|
|
46
|
+
key in orig_dict
|
|
47
|
+
and isinstance(orig_dict[key], dict)
|
|
48
|
+
and isinstance(value, dict)
|
|
49
|
+
):
|
|
50
|
+
_update_dicts(orig_dict[key], value)
|
|
51
|
+
else:
|
|
52
|
+
if key in orig_dict:
|
|
53
|
+
if not isinstance(value, dict):
|
|
54
|
+
orig_dict[key] = value
|
|
55
|
+
else:
|
|
56
|
+
raise ValueError(
|
|
57
|
+
f"Value: {value} for parameter key: {key} must be a value, not dict"
|
|
58
|
+
)
|
|
59
|
+
else:
|
|
60
|
+
raise KeyError(f"Unknown parameter key: {key}")
|
|
61
|
+
return orig_dict
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def run_example_main(example_path, argv=None):
|
|
65
|
+
"""
|
|
66
|
+
Utility to run an example script's main() as if from its directory, with optional argv patching.
|
|
67
|
+
Args:
|
|
68
|
+
example_path (str or Path): Path to the example script (e.g., 'examples/foo/foo.py')
|
|
69
|
+
argv (list, optional): List of arguments to patch sys.argv with. If None, uses [script_name].
|
|
70
|
+
"""
|
|
71
|
+
example_path = Path(example_path)
|
|
72
|
+
example_dir = example_path.parent
|
|
73
|
+
script_name = example_path.name
|
|
74
|
+
old_cwd = os.getcwd()
|
|
75
|
+
old_argv = sys.argv.copy()
|
|
76
|
+
try:
|
|
77
|
+
spec = importlib.util.spec_from_file_location(
|
|
78
|
+
script_name.rstrip(".py"), example_path
|
|
79
|
+
)
|
|
80
|
+
os.chdir(example_dir)
|
|
81
|
+
sys.argv = [script_name] + (argv if argv is not None else [])
|
|
82
|
+
module = importlib.util.module_from_spec(spec)
|
|
83
|
+
sys.modules[script_name.rstrip(".py")] = module
|
|
84
|
+
spec.loader.exec_module(module)
|
|
85
|
+
if hasattr(module, "main"):
|
|
86
|
+
result = module.main()
|
|
87
|
+
else:
|
|
88
|
+
raise AttributeError(f"No main() in {example_path}")
|
|
89
|
+
finally:
|
|
90
|
+
os.chdir(old_cwd)
|
|
91
|
+
sys.argv = old_argv
|
|
92
|
+
return result
|
jaxion/visualization.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import jax.numpy as jnp
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def plot_sim(state, checkpoint_dir, i, params):
|
|
7
|
+
"""Plot the simulation state."""
|
|
8
|
+
|
|
9
|
+
dynamic_range = params["output"]["plot_dynamic_range"]
|
|
10
|
+
|
|
11
|
+
if params["physics"]["quantum"]:
|
|
12
|
+
plt.clf()
|
|
13
|
+
|
|
14
|
+
# DM projection
|
|
15
|
+
nx = state["psi"].shape[0]
|
|
16
|
+
rho_bar = jnp.mean(jnp.abs(state["psi"]) ** 2)
|
|
17
|
+
vmin = jnp.log10(rho_bar / dynamic_range)
|
|
18
|
+
vmax = jnp.log10(rho_bar * dynamic_range)
|
|
19
|
+
|
|
20
|
+
rho_proj_dm = jnp.log10(jnp.mean(jnp.abs(state["psi"]) ** 2, axis=2)).T
|
|
21
|
+
ax = plt.gca()
|
|
22
|
+
ax.imshow(
|
|
23
|
+
rho_proj_dm,
|
|
24
|
+
cmap="inferno",
|
|
25
|
+
origin="lower",
|
|
26
|
+
vmin=vmin,
|
|
27
|
+
vmax=vmax,
|
|
28
|
+
extent=[0, nx, 0, nx],
|
|
29
|
+
)
|
|
30
|
+
if params["physics"]["particles"]:
|
|
31
|
+
# draw particles
|
|
32
|
+
box_size = params["domain"]["box_size"]
|
|
33
|
+
sx = (state["pos"][:, 0] / box_size) * nx
|
|
34
|
+
sy = (state["pos"][:, 1] / box_size) * nx
|
|
35
|
+
plt.plot(sx, sy, color="cyan", marker=".", linestyle="None", markersize=2)
|
|
36
|
+
ax.set_aspect("equal")
|
|
37
|
+
ax.get_xaxis().set_visible(False)
|
|
38
|
+
ax.get_yaxis().set_visible(False)
|
|
39
|
+
|
|
40
|
+
plt.savefig(
|
|
41
|
+
os.path.join(checkpoint_dir, f"dm{i:03d}.png"),
|
|
42
|
+
bbox_inches="tight",
|
|
43
|
+
pad_inches=0,
|
|
44
|
+
)
|
|
45
|
+
plt.close()
|
|
46
|
+
|
|
47
|
+
if params["physics"]["hydro"]:
|
|
48
|
+
plt.clf()
|
|
49
|
+
|
|
50
|
+
# gas projection
|
|
51
|
+
nx = state["rho"].shape[0]
|
|
52
|
+
rho_bar = jnp.mean(state["rho"])
|
|
53
|
+
vmin = jnp.log10(rho_bar / dynamic_range)
|
|
54
|
+
vmax = jnp.log10(rho_bar * dynamic_range)
|
|
55
|
+
rho_proj_gas = jnp.log10(jnp.mean(state["rho"], axis=2)).T
|
|
56
|
+
ax = plt.gca()
|
|
57
|
+
ax.imshow(
|
|
58
|
+
rho_proj_gas,
|
|
59
|
+
cmap="viridis",
|
|
60
|
+
origin="lower",
|
|
61
|
+
vmin=vmin,
|
|
62
|
+
vmax=vmax,
|
|
63
|
+
extent=[0, nx, 0, nx],
|
|
64
|
+
)
|
|
65
|
+
ax.set_aspect("equal")
|
|
66
|
+
ax.get_xaxis().set_visible(False)
|
|
67
|
+
ax.get_yaxis().set_visible(False)
|
|
68
|
+
|
|
69
|
+
plt.savefig(
|
|
70
|
+
os.path.join(checkpoint_dir, f"gas{i:03d}.png"),
|
|
71
|
+
bbox_inches="tight",
|
|
72
|
+
pad_inches=0,
|
|
73
|
+
)
|
|
74
|
+
plt.close()
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jaxion
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A differentiable simulation library for fuzzy dark matter in JAX
|
|
5
|
+
Author-email: Philip Mocz <philip.mocz@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Documentation, https://jaxion.readthedocs.io
|
|
8
|
+
Project-URL: Homepage, https://github.com/JaxionProject/jaxion
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: jax==0.5.3
|
|
13
|
+
Requires-Dist: jaxdecomp==0.2.7
|
|
14
|
+
Requires-Dist: tensorflow
|
|
15
|
+
Requires-Dist: orbax-checkpoint==0.11.18
|
|
16
|
+
Requires-Dist: optax==0.2.5
|
|
17
|
+
Requires-Dist: numpy
|
|
18
|
+
Requires-Dist: matplotlib
|
|
19
|
+
Requires-Dist: setuptools>=70.1.1
|
|
20
|
+
Provides-Extra: cuda12
|
|
21
|
+
Requires-Dist: jax[cuda12]==0.5.3; extra == "cuda12"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# jaxion
|
|
25
|
+
|
|
26
|
+
[![Repo Status][status-badge]][status-link]
|
|
27
|
+
[![PyPI Version Status][pypi-badge]][pypi-link]
|
|
28
|
+
[![Test Status][workflow-test-badge]][workflow-test-link]
|
|
29
|
+
[![Readthedocs Status][docs-badge]][docs-link]
|
|
30
|
+
[![License][license-badge]][license-link]
|
|
31
|
+
|
|
32
|
+
[status-link]: https://www.repostatus.org/#active
|
|
33
|
+
[status-badge]: https://www.repostatus.org/badges/latest/active.svg
|
|
34
|
+
[pypi-link]: https://pypi.org/project/jaxion
|
|
35
|
+
[pypi-badge]: https://img.shields.io/pypi/v/jaxion?label=PyPI&logo=pypi
|
|
36
|
+
[workflow-test-link]: https://github.com/JaxionProject/jaxion/actions/workflows/test-package.yml
|
|
37
|
+
[workflow-test-badge]: https://github.com/JaxionProject/jaxion/actions/workflows/test-package.yml/badge.svg?event=push
|
|
38
|
+
[docs-link]: https://jaxion.readthedocs.io
|
|
39
|
+
[docs-badge]: https://readthedocs.org/projects/jaxion/badge
|
|
40
|
+
[license-link]: https://opensource.org/licenses/Apache-2.0
|
|
41
|
+
[license-badge]: https://img.shields.io/badge/License-Apache_2.0-blue.svg
|
|
42
|
+
|
|
43
|
+
A simple JAX-powered simulation library for numerical experiments of fuzzy dark matter, stars, gas + more!
|
|
44
|
+
|
|
45
|
+
Author: [Philip Mocz (@pmocz)](https://github.com/pmocz/)
|
|
46
|
+
|
|
47
|
+
⚠️ Jaxion is currently being developed and is not yet ready for use. Check back later ⚠️
|
|
48
|
+
|
|
49
|
+
Jaxion is built for multi-GPU scalability and is fully differentiable. It is a high-performance JAX-based simulation library for modeling fuzzy dark matter alongside stars, gas, and cosmological dynamics. Being differentiable, Jaxion can seemlessly integrate with piplines for inverse-problems, inference, optimization, and coupling to ML models.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Getting started
|
|
53
|
+
|
|
54
|
+
Install with:
|
|
55
|
+
|
|
56
|
+
```console
|
|
57
|
+
pip install jaxion
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
or, for GPU support use:
|
|
61
|
+
|
|
62
|
+
```console
|
|
63
|
+
pip install jaxion[cuda12]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Check out the `examples/` directory for demonstrations of using Jaxion.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
## Links
|
|
70
|
+
|
|
71
|
+
* [Code repository](https://github.com/JaxionProject/jaxion) on GitHub (this page).
|
|
72
|
+
* [Documentation](https://jaxion.readthedocs.io) for up-to-date information about installing and running jaxion.
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## Cite this repository
|
|
76
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
jaxion/__init__.py,sha256=gHrU_SvIBIbuYt-MeEeyiMyuJKwLjTTiz513OZ7CDHQ,95
|
|
2
|
+
jaxion/constants.py,sha256=b0vgqtezIEGp4O5JRJo3YK3eQC8AN6hmV84-4pYWgmc,528
|
|
3
|
+
jaxion/gravity.py,sha256=DdVOhAaoIPLXtW7ALrMK2umLPkStzxJ778l1SD2yMkY,266
|
|
4
|
+
jaxion/hydro.py,sha256=3ZFNDhIaPBw4uTBqFbjJotCLkuKG8AvRcY1T78QQ96U,6953
|
|
5
|
+
jaxion/params_default.json,sha256=4-XNPN52phGxYsP6FOeIJH0ALtICjrQxApotz-NhJEc,1782
|
|
6
|
+
jaxion/particles.py,sha256=7oJBVyddfOXUDYxQuGIs8_ByL2Hu6jkuWE1MWtshFjk,3953
|
|
7
|
+
jaxion/quantum.py,sha256=91tEotQhX1CB3HCaRCDARRPX_dEx58GIUCluY5RyPvA,377
|
|
8
|
+
jaxion/simulation.py,sha256=KcIi91LHJO5K4M0gxU4qc7e4JEeOyW1HUZOYwt8FOG0,10385
|
|
9
|
+
jaxion/utils.py,sha256=LCVx5_N9-6HsbENENOEz8tI6Czl0Z8Bit2icf1k4024,2880
|
|
10
|
+
jaxion/visualization.py,sha256=WKID2_LFbbqXwmW_TLTnVznKYHfjiDKNbjD9xS4GfLc,2209
|
|
11
|
+
jaxion-0.0.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
jaxion-0.0.1.dist-info/METADATA,sha256=HrFYMTjSNAo8RqT9PPP1kSqyjVpi1v-N-sheaxU_YAs,2811
|
|
13
|
+
jaxion-0.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
+
jaxion-0.0.1.dist-info/top_level.txt,sha256=S1OV2VdlDG_9UwpKOIji4itQGOS-VWUOWUi3GeXWzt0,7
|
|
15
|
+
jaxion-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
jaxion
|