Skip to content

BUG: getJ methods for 1D and 2D NSEM simulations #1541

Open

Description

@dccowan

Describe the issue:

For the 1D and 2D finite volume NSEM simulation classes, the getJ method does not work. All of these simulation classes currently inherit getJ from BaseFDEMSimulation. Functionality must be fixed or attempting to call getJ should throw a NotImplementedError.

Reproducible code example:

import numpy as np
from scipy.constants import mu_0

from simpeg.electromagnetics import natural_source as nsem
from simpeg import maps
from discretize import TensorMesh, TreeMesh, CylindricalMesh
from pymatsolver import Pardiso

def create_simulation_1d(sim_type, deriv_type):
    cs = 100
    ncz = 200
    npad = 20
    pf = 1.2

    hz = [(cs, npad, -pf), (cs, ncz), (cs, npad)]

    mesh = TensorMesh(
        [
            hz,
        ]
    )
    mesh.x0 = np.r_[-mesh.h[0][:-npad].sum()]

    frequencies = np.logspace(-2, 1, 30)

    rx_list = [
        nsem.receivers.PointNaturalSource([[0]], orientation="xy", component="real"),
        nsem.receivers.PointNaturalSource([[0]], orientation="xy", component="imag"),
        nsem.receivers.PointNaturalSource(
            [[0]], orientation="xy", component="apparent_resistivity"
        ),
        nsem.receivers.PointNaturalSource([[0]], orientation="xy", component="phase"),
        nsem.receivers.PointNaturalSource([[0]], orientation="yx", component="real"),
        nsem.receivers.PointNaturalSource([[0]], orientation="yx", component="imag"),
        nsem.receivers.PointNaturalSource(
            [[0]], orientation="yx", component="apparent_resistivity"
        ),
        nsem.receivers.PointNaturalSource([[0]], orientation="yx", component="phase"),
    ]
    src_list = [nsem.sources.Planewave(rx_list, frequency=f) for f in frequencies]
    survey = nsem.Survey(src_list)

    sigma_back = 1e-1
    sigma_right = 1e-3
    sigma_air = 1e-8

    sigma_1d = np.ones(mesh.n_cells) * sigma_back
    sigma_1d[-npad:] = sigma_air
    sigma_1d[50:-npad] = sigma_right

    if deriv_type == "sigma":
        sim_kwargs = {"sigmaMap": maps.ExpMap()}
        test_mod = np.log(sigma_1d)
    else:
        sim_kwargs = {"muMap": maps.ExpMap(), "sigma": sigma_1d}
        test_mod = np.log(mu_0) * np.ones(mesh.n_cells)
    if sim_type.lower() == "e":
        sim = nsem.simulation.Simulation1DElectricField(
            mesh,
            survey=survey,
            **sim_kwargs,
            solver=Pardiso,
        )
    else:
        sim = nsem.simulation.Simulation1DMagneticField(
            mesh,
            survey=survey,
            **sim_kwargs,
            solver=Pardiso,
        )
    return sim, test_mod


sim, test_mod = create_simulation_1d("e", "sigma")
J = sim.getJ(test_mod)

sim, test_mod = create_simulation_1d("h", "sigma")
J = sim.getJ(test_mod)

Error message:

No response

Runtime information:

Almost instant for this.

Context for the issue:

No response

Activity

  1. added this to the 0.23.0 milestone on Sep 25, 2024
  2. modified the milestones: 0.23.0, 0.24.0 on Feb 24, 2025
  3. santisoler commented on Apr 24, 2025

    @santisoler
    Member

    I merged #1653 to make the getJ methods to raise a NotImplementedError for now. I'll leave this issue open as reminder that we should implement them.

  4. modified the milestones: 0.24.0, 0.25.0 on Apr 24, 2025
  5. modified the milestones: 0.25.0, 0.26.0 on Oct 8, 2025
  6. modified the milestones: 0.26.0, 0.27.0 on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions