How to use the discretize.base.BaseMesh function in discretize

To help you get started, we’ve selected a few discretize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simpeg / simpeg / SimPEG / EM / Utils / AnalyticUtils.py View on Github external
"""

    if isinstance(orientation, str):
        if orientation.upper() != 'Z':
            raise NotImplementedError('Only Z oriented loops implemented')
    elif not np.allclose(orientation, np.r_[0., 0., 1.]):
        raise NotImplementedError('Only Z oriented loops implemented')

    if type(component) in [list, tuple]:
        out = list(range(len(component)))
        for i, comp in enumerate(component):
            out[i] = MagneticLoopVectorPotential(srcLoc, obsLoc, comp, radius,
                                                 orientation, mu)
        return np.concatenate(out)

    if isinstance(obsLoc, BaseMesh):
        mesh = obsLoc
        assert component in ['Ex','Ey','Ez','Fx','Fy','Fz'], "Components must be in: ['Ex','Ey','Ez','Fx','Fy','Fz']"
        return MagneticLoopVectorPotential(srcLoc, getattr(mesh,'grid'+component), component[1], radius, mu)

    srcLoc = np.atleast_2d(srcLoc)
    obsLoc = np.atleast_2d(obsLoc)

    n = obsLoc.shape[0]
    nSrc = srcLoc.shape[0]

    if component=='z':
        A = np.zeros((n, nSrc))
        if nSrc ==1:
            return A.flatten()
        return A
github simpeg / simpeg / SimPEG / EM / Static / DC / IODC.py View on Github external
line_inds = properties.Array(
        "Line indices",
        required=True,
        shape=('*',),
        dtype=int  # data are floats
    )
    sort_inds = properties.Array(
        "Sorting indices from ABMN",
        required=True,
        shape=('*',),
        dtype=int  # data are floats
    )

    # Related to Physics and Discretization
    mesh = properties.Instance(
        "Mesh for discretization", BaseMesh, required=True
    )

    dx = properties.Float(
        "Length of corecell in x-direction", required=True,
    )
    dy = properties.Float(
        "Length of corecell in y-direction", required=True
    )
    dy = properties.Float(
        "Length of corecell in z-direction", required=True
    )

    npad_x = properties.Integer(
        "The number of padding cells x-direction",
        required=True,
        default=5
github simpeg / simpeg / SimPEG / simulation.py View on Github external
"""
    Class for a linear simulation of the form
    .. math::
        d = Gm
    where :math:`d` is a vector of the data, `G` is the simulation matrix and
    :math:`m` is the model.
    Inherit this class to build a linear simulatio.
    """

    linear_model, model_map, model_deriv = props.Invertible(
        "The model for a linear problem"
    )

    mesh = properties.Instance(
        "a discretize mesh instance",
        BaseMesh,
        required=True
    )

    def __init__(self, mesh=None, **kwargs):
        super(LinearSimulation, self).__init__(mesh=mesh, **kwargs)
        self.survey = BaseSurvey()

        # set the number of data
        if getattr(self, 'G', None) is not None:
            self.survey._vnD = np.r_[self.G.shape[0]]

    @property
    def G(self):
        warnings.warn("G has not been implemented for the simulation")
        return None