Skip to content

Commit 440d3ef

Browse files
authored
Merge pull request #209 from MiraGeoscience/GEOPY-2190
GEOPY-2190: Non-zero evaluation of the rotated gradient of a constant model
2 parents d7c8653 + 05b2711 commit 440d3ef

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

simpeg_drivers/utils/regularization.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,10 @@ def set_rotated_operators(
418418
grad_op_active = function.regularization_mesh.Pac.T @ (
419419
grad_op @ function.regularization_mesh.Pac
420420
)
421-
active_faces = grad_op_active.max(axis=1).toarray().ravel() > 0
421+
active_faces = np.isclose(
422+
grad_op_active @ np.ones(function.regularization_mesh.n_cells), 0
423+
)
424+
active_faces &= grad_op_active.max(axis=1).toarray().ravel() != 0
422425

423426
setattr(
424427
function.regularization_mesh,

tests/run_tests/driver_mvi_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# To test the full run and validate the inversion.
3737
# Move this file out of the test directory and run.
3838

39-
target_mvi_run = {"data_norm": 6.3559205278626525, "phi_d": 0.0091, "phi_m": 0.00603}
39+
target_mvi_run = {"data_norm": 6.3559205278626525, "phi_d": 0.00933, "phi_m": 0.00401}
4040

4141

4242
def test_magnetic_vector_fwr_run(

tests/run_tests/driver_rotated_gradients_test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# To test the full run and validate the inversion.
3636
# Move this file out of the test directory and run.
3737

38-
target_run = {"data_norm": 0.006830937520353864, "phi_d": 0.0276, "phi_m": 0.0288}
38+
target_run = {"data_norm": 0.006830937520353864, "phi_d": 0.0309, "phi_m": 0.028}
3939

4040

4141
def test_gravity_rotated_grad_fwr_run(
@@ -142,13 +142,20 @@ def test_rotated_grad_run(
142142
inactive_ind = run_ws.get_entity("active_cells")[0].values == 0
143143
assert np.all(nan_ind == inactive_ind)
144144

145+
# Smooth functions should be zero for uniform model
146+
for obj in driver.regularization.objfcts:
147+
for smooth in obj.objfcts[1:]:
148+
np.testing.assert_allclose(
149+
smooth(np.ones(driver.models.n_active)), 0, atol=1e-6
150+
)
151+
145152

146153
if __name__ == "__main__":
147154
# Full run
148155
test_gravity_rotated_grad_fwr_run(
149156
Path("./"),
150157
n_grid_points=10,
151-
refinement=(4, 8),
158+
refinement=(6, 8),
152159
)
153160

154161
test_rotated_grad_run(

0 commit comments

Comments
 (0)