diff --git a/SimPEG/utils/Geophysics/__init__.py b/SimPEG/utils/Geophysics/__init__.py new file mode 100644 index 00000000..bcf01943 --- /dev/null +++ b/SimPEG/utils/Geophysics/__init__.py @@ -0,0 +1 @@ +import emSources \ No newline at end of file diff --git a/SimPEG/utils/Geophysics/emSources/MagneticDipoleVectorPotential.py b/SimPEG/utils/Geophysics/emSources/MagneticDipoleVectorPotential.py new file mode 100644 index 00000000..16c5a1fb --- /dev/null +++ b/SimPEG/utils/Geophysics/emSources/MagneticDipoleVectorPotential.py @@ -0,0 +1,39 @@ +import numpy as np +from scipy.constants import mu_0, pi + +def MagneticDipoleVectorPotential(txLoc, obsLoc, component, dipoleMoment=(0., 0., 1.)): + """ + Calculate the vector potential of a set of magnetic dipoles + at given locations 'ref. ' + + :param numpy.ndarray txLoc: Location of the transmitter(s) (x, y, z) + :param numpy.ndarray obsLoc: Where the potentials will be calculated (x, y, z) + :param str component: The component to calculate - 'x', 'y', or 'z' + :param numpy.ndarray dipoleMoment: The vector dipole moment + :rtype: numpy.ndarray + :return: The vector potential each dipole at each observation location + """ + + if component=='x': + dimInd = 0 + elif component=='y': + dimInd = 1 + elif component=='z': + dimInd = 2 + else: + raise ValueError('Invalid component') + + txLoc = np.atleast_2d(txLoc) + obsLoc = np.atleast_2d(obsLoc) + + nEdges = obsLoc.shape[0] + nTx = txLoc.shape[0] + + m = np.array(dipoleMoment).repeat(nEdges, axis=0) + A = np.empty((nEdges, nTx)) + for i in range(nTx): + dR = obsLoc - txLoc[i, np.newaxis].repeat(nEdges, axis=0) + mCr = np.cross(m, dR) + r = np.sqrt((dR**2).sum(axis=1)) + A[:, i] = -(mu_0/(4*pi)) * mCr[:,dimInd]/(r**3) + return A \ No newline at end of file diff --git a/SimPEG/utils/Geophysics/emSources/__init__.py b/SimPEG/utils/Geophysics/emSources/__init__.py new file mode 100644 index 00000000..b4e675ef --- /dev/null +++ b/SimPEG/utils/Geophysics/emSources/__init__.py @@ -0,0 +1 @@ +from MagneticDipoleVectorPotential import MagneticDipoleVectorPotential \ No newline at end of file diff --git a/SimPEG/utils/__init__.py b/SimPEG/utils/__init__.py index d2170721..843e1ff0 100644 --- a/SimPEG/utils/__init__.py +++ b/SimPEG/utils/__init__.py @@ -10,6 +10,7 @@ from interputils import interpmat from ipythonUtils import easyAnimate as animate import Solver from Solver import Solver +import Geophysics def setKwargs(obj, **kwargs): """Sets key word arguments (kwargs) that are present in the object, throw an error if they don't exist."""