From 645594efac748a74d6d648694feeb97afdb56f6b Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Wed, 10 Feb 2016 16:55:08 -0800 Subject: [PATCH] start of being able to provide a primary problem --- SimPEG/EM/FDEM/SrcFDEM.py | 7 ++++++- SimPEG/EM/Utils/testingUtils.py | 7 +++++++ tests/em/fdem/inverse/adjoint/test_FDEM_adjoint.py | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/SimPEG/EM/FDEM/SrcFDEM.py b/SimPEG/EM/FDEM/SrcFDEM.py index 6b6dd099..a2f006ad 100644 --- a/SimPEG/EM/FDEM/SrcFDEM.py +++ b/SimPEG/EM/FDEM/SrcFDEM.py @@ -571,14 +571,19 @@ class CircularLoop(BaseSrc): class PrimSecSigma(BaseSrc): # TODO: This will only work for E-B formulation - def __init__(self, rxList, freq, ePrimary, sigmaPrimary): + def __init__(self, rxList, freq, sigmaPrimary, ePrimary=None, primaryProblem=None, primarySurvey=None): self.freq = float(freq) self._ePrimary = ePrimary self.sigmaPrimary = sigmaPrimary + self._primaryProblem = primaryProblem + self._primarySurvey = primarySurvey self.integrate = False BaseSrc.__init__(self, rxList) def ePrimary(self,prob): + if getattr(self, '_ePrimary', None) is None: + if self._primaryProblem is None or self._primarySurvey is None: + raise Exception "if Not specifying a ePrimary, a primarySurvey and primaryProblem must be provided." return self._ePrimary def S_e(self,prob): diff --git a/SimPEG/EM/Utils/testingUtils.py b/SimPEG/EM/Utils/testingUtils.py index 8c703083..4971c589 100644 --- a/SimPEG/EM/Utils/testingUtils.py +++ b/SimPEG/EM/Utils/testingUtils.py @@ -42,6 +42,13 @@ def getFDEMProblem(fdemType, comp, SrcList, freq, verbose=False): S_m[Utils.closestPoints(mesh,[0.,0.,0.],'Ez') + np.sum(mesh.vnE[:1])] = 1. S_e[Utils.closestPoints(mesh,[0.,0.,0.],'Fz') + np.sum(mesh.vnF[:1])] = 1. Src.append(EM.FDEM.Src.RawVec([Rx0], freq, S_m, S_e)) + elif SrcType is 'PrimSecSigma': + if fdemType is 'e' or fdemType is 'b': + S_m = np.zeros(mesh.nF) + S_e = np.zeros(mesh.nE) + S_m[Utils.closestPoints(mesh,[0.,0.,0.],'Fz') + np.sum(mesh.vnF[:1])] = 1. + S_e[Utils.closestPoints(mesh,[0.,0.,0.],'Ez') + np.sum(mesh.vnE[:1])] = 1. + Src.append(EM.FDEM.Src.RawVec([Rx0], freq, S_m, S_e)) if verbose: print ' Fetching %s problem' % (fdemType) diff --git a/tests/em/fdem/inverse/adjoint/test_FDEM_adjoint.py b/tests/em/fdem/inverse/adjoint/test_FDEM_adjoint.py index f77f2131..289aa561 100644 --- a/tests/em/fdem/inverse/adjoint/test_FDEM_adjoint.py +++ b/tests/em/fdem/inverse/adjoint/test_FDEM_adjoint.py @@ -17,7 +17,7 @@ MU = mu_0 freq = 1e-1 addrandoms = True -SrcType = 'RawVec' #or 'MAgDipole_Bfield', 'CircularLoop', 'RawVec' +SrcType = 'PrimSecSigma', #'RawVec' #or 'MAgDipole_Bfield', 'CircularLoop', 'RawVec' def adjointTest(fdemType, comp): prb = getFDEMProblem(fdemType, comp, [SrcType], freq)