Repository navigation
sem: acoustic c² Laplacian without C-PML, one-copy node materials - #131
Merged
Merged
Conversation
The bare branch of the four acoustic classes solved div(c^2 grad u) and
flipped reflection polarity; it now keeps c^2 outside the stiffness as the
C-PML branch does. The 3-D bare CUDA kernels have the same bug and are
refused ('auto' runs eager). vp_squared_node / kappa_node read one element
copy, so the model gradient is no longer multiplied by the share count
(_CutMultiplicity removed). Tests: two-layer polarity, grid FD gradients.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugs in the constant-density acoustic SEM classes (
AcousticSEM2D,AcousticSEM2DDeformed,AcousticSEM3D,AcousticSEM3DDeformed; the second also inAcousticPotentialSEM2D).1. The bare (no C-PML) branch solved
div(c² grad u), notc² Laplace uWith
abcn=0the stiffness integral carried c², so the scheme keptc² ∂u/∂ncontinuous at a velocity jump instead of∂u/∂n, and reflections came out with the wrong sign. The C-PML branch was already right. Homogeneous tests cannot tell the two forms apart.The bare branch now uses the c²-free stiffness and multiplies by c² per node, the same scheme as the C-PML branch. K stays symmetric (the mass matrix is effectively
M / c²), so the scheme still conserves energy.The 3-D bare CUDA kernels (
acoustic3d_forward/backward, flat and deformed) have the samediv(c² grad u)form in both forward and adjoint. They are no longer routed:impl='c'raises, andimpl='auto'runs eager. The kernels are left untouched for a later csrc fix.New test
test_sem_acoustic_reflection_polarity.pysends a 1-D plane wave from 1000 into 3000 m/s (R = +0.5). The reflection/direct ratio is projected on the window shifted by the known traveltime; the 1-D response is an odd pulse, so a peak pick cannot see the polarity.The test also checks that the bare and C-PML paths agree to 1e-12 until the PML echo arrives.
2. The model gradient was multiplied by each node's share count
vp_squared_node[ibool] = c2(andkappa_node.index_put_) backpropagates the node gradient into every element copy of the node. All copies interpolate the same grid point, so the grid gradient came out multiplied by 2–4 in 2-D and 2–8 in 3-D. Every C-vs-eager test agreed because every path scaled the same way; the DD_CutMultiplicitydeliberately reproduced the factor.mesh/nodes.py: node_fieldreads one fixed copy per node (the highest-numbered one) with a gather. On one CPU thread this is bitwise the old forward. At an element-wise material jump, the old scatter's choice of copy moved with the thread count and between CUDA runs; the gather does not.The four classes and
kappa_nodeuse it._CutMultiplicityand the share-count factor on the compact DD path are removed.New test
test_sem_acoustic_grid_gradient_fd.pycomparesPropSEMgrid gradients against central differences (fp64, two step sizes, no absolute floor, outer ring untouched), with and without a C-PML. Relative error before this PR, with a C-PML:AcousticSEM2D,AcousticSEM2DDeformedAcousticSEM3D,AcousticSEM3DDeformedAcousticPotentialSEM2Dtest_sem_dd_rimnow cropsNO + 1pixels instead of 4. Rim mode's error stays in the first element outside the band, and the 5th pixel is the node that element shares with the next one. Beyond it the error is about 1e-6 before and after this PR. The old crop passed only while the overcount weighted that ring differently. The fluid-solid part of the same file already cropped band + one element.test_sem_bs_rim::test_the_configuration_actually_discriminates, which used to fail (uncropped cos 0.992, over its 0.99 bound), now passes.Tests
test/semon a GPU: 856 passed, 1 skipped. The only failure istest_sem_dd_elastic::test_dd_elastic_per_family_store_dtype, which also fails ondevand is unrelated.dev: 1490 passed, 517 s.🤖 Generated with Claude Code