AMReX-Astro / AMReX-Astro/Castro
`gwstrain` STF projection subtracts only diagonal element instead of full trace
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 340
- Forks
- 105
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 8
Description
Summary
In Castro::gwstrain, the symmetric trace-free (STF) projection is documented as
STF(A^{ij}) = 1/2 A^{ij} + 1/2 A^{ji} - 1/3 delta^{ij} sum_k A^{kk}, but the implementation subtracts only dQtt(m,m) for each diagonal component. This does not remove the full trace and yields an incorrect STF tensor.
Location
Source/driver/sum_utils.cpp:476Source/driver/sum_utils.cpp:486
Problem Details
Current code:
dQ(l,m) = 0.5_rt * dQtt(l,m) + 0.5_rt * dQtt(m,l);
if (l == m) {
dQ(l,m) -= (1.0_rt / 3.0_rt) * dQtt(m,m);
}
For diagonal entries, the subtraction must use the full trace
dQtt(0,0) + dQtt(1,1) + dQtt(2,2), not the single matching diagonal element.
Impact
- Incorrect gravitational-wave quadrupole STF tensor.
- Biased
h_plus/h_crossdiagnostics, especially when anisotropy is significant.
Suggested Patch
diff --git a/Source/driver/sum_utils.cpp b/Source/driver/sum_utils.cpp
--- a/Source/driver/sum_utils.cpp
+++ b/Source/driver/sum_utils.cpp
@@
- for (int l = 0; l < 3; ++l) {
+ const Real tr = dQtt(0,0) + dQtt(1,1) + dQtt(2,2);
+
+ for (int l = 0; l < 3; ++l) {
for (int m = 0; m < 3; ++m) {
dQ(l,m) = 0.5_rt * dQtt(l,m) + 0.5_rt * dQtt(m,l);
if (l == m) {
- dQ(l,m) -= (1.0_rt / 3.0_rt) * dQtt(m,m);
+ dQ(l,m) -= (1.0_rt / 3.0_rt) * tr;
}
}
}
Prepared by Codex
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Source/driver/sum_utils.cpp at lines 476 and 486, where Castro::gwstrain constructs the symmetric trace-free tensor. Compare the implementation with the documented STF formula and inspect the diagonal calculation. Done means the computed tensor removes the complete three-dimensional trace and preserves the intended h_plus and h_cross diagnostics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- hpc
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100