Skip to content

Commit f1f6434

Browse files
committed
fix: Typo in gravitational energy
9b17f30 (#152) introduced a bug in the gravitational energy. The arguments of E_gravity_density are reversed. This doesn't show up in tests because the psi used is real, so the incorrect energy density can be coerced to be real. Fix this and update the tests of summaries so that psi is complex.
1 parent a555b8f commit f1f6434

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "UltraDark"
22
uuid = "1c8d022d-dfc0-4b41-80ab-3fc7e88cdfea"
33
authors = ["Nathan Musoke <n.musoke@auckland.ac.nz>"]
4-
version = "0.9.4"
4+
version = "0.9.5"
55

66
[deps]
77
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/grids.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ end
467467
468468
Gravitational energy density of field `psi` in gravitational potential `Phi`
469469
"""
470-
function E_gravity_density(psi::Number, Phi::Number)
470+
function E_gravity_density(psi::Number, Phi::Real)::Real
471471
Phi .* abs2.(psi) / 2.0
472472
end
473473

@@ -478,7 +478,7 @@ end
478478
Gravitational potential energy
479479
"""
480480
function E_grav(grids, psi)
481-
Folds.mapreduce(E_gravity_density, +, grids.Φx, psi) * dV(grids)
481+
Folds.mapreduce(E_gravity_density, +, psi, grids.Φx) * dV(grids)
482482
end
483483

484484
function E_grav(grids::AbstractGrids)

test/summary.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pencilgrids = PencilGrids(1.0, 8)
2828
external_states = ()
2929

3030
for g in [grids, pencilgrids]
31-
g.ψx .= 1.0
31+
g.ψx .= 1.0 + im
3232
@. g.ρx = abs2(g.ψx)
3333
end
3434

0 commit comments

Comments
 (0)