From 0f7ae7f0fbca317f1d1f5fd5be49735ae2b066df Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Fri, 12 Feb 2016 15:05:42 -0800 Subject: [PATCH] start of checks for solvePrimary --- SimPEG/EM/FDEM/SrcFDEM.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/SimPEG/EM/FDEM/SrcFDEM.py b/SimPEG/EM/FDEM/SrcFDEM.py index a2f006ad..8c2e7a42 100644 --- a/SimPEG/EM/FDEM/SrcFDEM.py +++ b/SimPEG/EM/FDEM/SrcFDEM.py @@ -580,10 +580,25 @@ class PrimSecSigma(BaseSrc): self.integrate = False BaseSrc.__init__(self, rxList) + def _solvePrimary(self): + # check if I have fields + # if not, solve the primary to get fields object + if self._primarySurvey.ispaired: + if self._primarySurvey.prob is not self._primaryProblem: + raise Exception "The survey object is already paired to a problem. Use survey.unpair()" + else: + self._primaryProblem.pair(self._primarySurvey) + + return + def ePrimary(self,prob): + # check if a primary problem is defined 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." + + self._ePrimary = self._solvePrimary[:,'e'] + return self._ePrimary def S_e(self,prob): @@ -594,7 +609,7 @@ class PrimSecSigma(BaseSrc): def S_eDeriv(self, prob, v, adjoint = False): MeSigmaDeriv = prob.MeSigmaDeriv if adjoint is not True: - return MeSigmaDeriv(Utils.mkvc(self._ePrimary)) * v # TODO: This is really sloppy and will not work if more than one freq + return MeSigmaDeriv(Utils.mkvc(self._ePrimary)) * v return MeSigmaDeriv(Utils.mkvc(self._ePrimary)) * v