From 649525fa884b5ade974d160e45c7d44b6e17794d Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Fri, 19 Feb 2016 17:31:43 -0800 Subject: [PATCH] keep track of _v with notation --- SimPEG/EM/FDEM/FDEM.py | 46 +++++++++--------- SimPEG/EM/FDEM/FieldsFDEM.py | 94 ++++++++++++++++++------------------ 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/SimPEG/EM/FDEM/FDEM.py b/SimPEG/EM/FDEM/FDEM.py index d026e4b5..d19f2ad1 100644 --- a/SimPEG/EM/FDEM/FDEM.py +++ b/SimPEG/EM/FDEM/FDEM.py @@ -84,15 +84,15 @@ class BaseFDEMProblem(BaseEMProblem): for src in self.survey.getSrcByFreq(freq): ftype = self._fieldType + 'Solution' u_src = u[src, ftype] - dA_dm = self.getADeriv_m(freq, u_src, v) - dRHS_dm = self.getRHSDeriv_m(freq, src, v) - du_dm = Ainv * ( - dA_dm + dRHS_dm ) + dA_dm_v = self.getADeriv(freq, u_src, v) + dRHS_dm_v = self.getRHSDeriv(freq, src, v) + du_dm_v = Ainv * ( - dA_dm_v + dRHS_dm_v ) for rx in src.rxList: df_dmFun = getattr(u, '_%sDeriv'%rx.projField, None) - df_dm = df_dmFun(src, du_dm, v, adjoint=False) - Df_Dm = np.array(df_dm,dtype=complex) - Jv[src, rx] = rx.projectFieldsDeriv(src, self.mesh, u, Df_Dm) + df_dm_v = df_dmFun(src, du_dm_v, v, adjoint=False) + df_dm_v = np.array(df_dm_v,dtype=complex) + Jv[src, rx] = rx.projectFieldsDeriv(src, self.mesh, u, df_dm_v) Ainv.clean() return Utils.mkvc(Jv) @@ -135,8 +135,8 @@ class BaseFDEMProblem(BaseEMProblem): ATinvdf_duT = ATinv * df_duT - dA_dmT = self.getADeriv_m(freq, u_src, ATinvdf_duT, adjoint=True) - dRHS_dmT = self.getRHSDeriv_m(freq, src, ATinvdf_duT, adjoint=True) + dA_dmT = self.getADeriv(freq, u_src, ATinvdf_duT, adjoint=True) + dRHS_dmT = self.getRHSDeriv(freq, src, ATinvdf_duT, adjoint=True) du_dmT = -dA_dmT + dRHS_dmT df_dmT += du_dmT @@ -228,7 +228,7 @@ class Problem_e(BaseFDEMProblem): return C.T*MfMui*C + 1j*omega(freq)*MeSigma - def getADeriv_m(self, freq, u, v, adjoint=False): + def getADeriv(self, freq, u, v, adjoint=False): """ Product of the derivative of our system matrix with respect to the model and a vector @@ -269,7 +269,7 @@ class Problem_e(BaseFDEMProblem): return C.T * (MfMui * S_m) -1j * omega(freq) * S_e - def getRHSDeriv_m(self, freq, src, v, adjoint=False): + def getRHSDeriv(self, freq, src, v, adjoint=False): """ Derivative of the right hand side with respect to the model @@ -343,7 +343,7 @@ class Problem_b(BaseFDEMProblem): return MfMui.T*A return A - def getADeriv_m(self, freq, u, v, adjoint=False): + def getADeriv(self, freq, u, v, adjoint=False): """ Product of the derivative of our system matrix with respect to the model and a vector @@ -400,7 +400,7 @@ class Problem_b(BaseFDEMProblem): return RHS - def getRHSDeriv_m(self, freq, src, v, adjoint=False): + def getRHSDeriv(self, freq, src, v, adjoint=False): """ Derivative of the right hand side with respect to the model @@ -492,7 +492,7 @@ class Problem_j(BaseFDEMProblem): return A - def getADeriv_m(self, freq, u, v, adjoint=False): + def getADeriv(self, freq, u, v, adjoint=False): """ Product of the derivative of our system matrix with respect to the model and a vector @@ -513,16 +513,16 @@ class Problem_j(BaseFDEMProblem): MeMuI = self.MeMuI MfRho = self.MfRho C = self.mesh.edgeCurl - MfRhoDeriv_m = self.MfRhoDeriv(u) + MfRhoDeriv = self.MfRhoDeriv(u) if adjoint: if self._makeASymmetric is True: v = MfRho * v - return MfRhoDeriv_m.T * (C * (MeMuI.T * (C.T * v))) + return MfRhoDeriv.T * (C * (MeMuI.T * (C.T * v))) if self._makeASymmetric is True: - return MfRho.T * (C * ( MeMuI * (C.T * (MfRhoDeriv_m * v) ))) - return C * (MeMuI * (C.T * (MfRhoDeriv_m * v))) + return MfRho.T * (C * ( MeMuI * (C.T * (MfRhoDeriv * v) ))) + return C * (MeMuI * (C.T * (MfRhoDeriv * v))) def getRHS(self, freq): @@ -549,7 +549,7 @@ class Problem_j(BaseFDEMProblem): return RHS - def getRHSDeriv_m(self, freq, src, v, adjoint=False): + def getRHSDeriv(self, freq, src, v, adjoint=False): """ Derivative of the right hand side with respect to the model @@ -624,7 +624,7 @@ class Problem_h(BaseFDEMProblem): return C.T * (MfRho * C) + 1j*omega(freq)*MeMu - def getADeriv_m(self, freq, u, v, adjoint=False): + def getADeriv(self, freq, u, v, adjoint=False): """ Product of the derivative of our system matrix with respect to the model and a vector @@ -641,11 +641,11 @@ class Problem_h(BaseFDEMProblem): MeMu = self.MeMu C = self.mesh.edgeCurl - MfRhoDeriv_m = self.MfRhoDeriv(C*u) + MfRhoDeriv = self.MfRhoDeriv(C*u) if adjoint: - return MfRhoDeriv_m.T * (C * v) - return C.T * (MfRhoDeriv_m * v) + return MfRhoDeriv.T * (C * v) + return C.T * (MfRhoDeriv * v) def getRHS(self, freq): """ @@ -666,7 +666,7 @@ class Problem_h(BaseFDEMProblem): return S_m + C.T * ( MfRho * S_e ) - def getRHSDeriv_m(self, freq, src, v, adjoint=False): + def getRHSDeriv(self, freq, src, v, adjoint=False): """ Derivative of the right hand side with respect to the model diff --git a/SimPEG/EM/FDEM/FieldsFDEM.py b/SimPEG/EM/FDEM/FieldsFDEM.py index da4b1749..8d8c16f4 100644 --- a/SimPEG/EM/FDEM/FieldsFDEM.py +++ b/SimPEG/EM/FDEM/FieldsFDEM.py @@ -88,12 +88,12 @@ class Fields(SimPEG.Problem.Fields): return self._jPrimary(solution, srcList) + self._jSecondary(solution, srcList) - def _eDeriv(self, src, du_dm, v, adjoint = False): + def _eDeriv(self, src, du_dm_v, v, adjoint = False): """ Total derivative of e with respect to the inversion model. Returns :math:`d\mathbf{e}/d\mathbf{m}` for forward and (:math:`d\mathbf{e}/d\mathbf{u}`, :math:`d\mathb{u}/d\mathbf{m}`) for the adjoint :param Src src: sorce - :param numpy.ndarray du_dm: derivative of the solution vector with respect to the model times a vector (is None for adjoint) + :param numpy.ndarray du_dm_v: derivative of the solution vector with respect to the model times a vector (is None for adjoint) :param numpy.ndarray v: vector to take sensitivity product with :param bool adjoint: adjoint? :rtype: numpy.ndarray @@ -104,14 +104,14 @@ class Fields(SimPEG.Problem.Fields): if adjoint: return self._eDeriv_u(src, v, adjoint), self._eDeriv_m(src, v, adjoint) - return self._eDeriv_u(src, du_dm, adjoint) + self._eDeriv_m(src, v, adjoint) + return self._eDeriv_u(src, du_dm_v, adjoint) + self._eDeriv_m(src, v, adjoint) - def _bDeriv(self, src, du_dm, v, adjoint = False): + def _bDeriv(self, src, du_dm_v, v, adjoint = False): """ Total derivative of b with respect to the inversion model. Returns :math:`d\mathbf{b}/d\mathbf{m}` for forward and (:math:`d\mathbf{b}/d\mathbf{u}`, :math:`d\mathb{u}/d\mathbf{m}`) for the adjoint :param Src src: sorce - :param numpy.ndarray du_dm: derivative of the solution vector with respect to the model times a vector (is None for adjoint) + :param numpy.ndarray du_dm_v: derivative of the solution vector with respect to the model times a vector (is None for adjoint) :param numpy.ndarray v: vector to take sensitivity product with :param bool adjoint: adjoint? :rtype: numpy.ndarray @@ -122,14 +122,14 @@ class Fields(SimPEG.Problem.Fields): if adjoint: return self._bDeriv_u(src, v, adjoint), self._bDeriv_m(src, v, adjoint) - return self._bDeriv_u(src, du_dm, adjoint) + self._bDeriv_m(src, v, adjoint) + return self._bDeriv_u(src, du_dm_v, adjoint) + self._bDeriv_m(src, v, adjoint) - def _hDeriv(self, src, du_dm, v, adjoint = False): + def _hDeriv(self, src, du_dm_v, v, adjoint = False): """ Total derivative of h with respect to the inversion model. Returns :math:`d\mathbf{h}/d\mathbf{m}` for forward and (:math:`d\mathbf{h}/d\mathbf{u}`, :math:`d\mathb{u}/d\mathbf{m}`) for the adjoint :param Src src: sorce - :param numpy.ndarray du_dm: derivative of the solution vector with respect to the model times a vector (is None for adjoint) + :param numpy.ndarray du_dm_v: derivative of the solution vector with respect to the model times a vector (is None for adjoint) :param numpy.ndarray v: vector to take sensitivity product with :param bool adjoint: adjoint? :rtype: numpy.ndarray @@ -140,14 +140,14 @@ class Fields(SimPEG.Problem.Fields): if adjoint: return self._hDeriv_u(src, v, adjoint), self._hDeriv_m(src, v, adjoint) - return self._hDeriv_u(src, du_dm, adjoint) + self._hDeriv_m(src, v, adjoint) + return self._hDeriv_u(src, du_dm_v, adjoint) + self._hDeriv_m(src, v, adjoint) - def _jDeriv(self, src, du_dm, v, adjoint = False): + def _jDeriv(self, src, du_dm_v, v, adjoint = False): """ Total derivative of j with respect to the inversion model. Returns :math:`d\mathbf{j}/d\mathbf{m}` for forward and (:math:`d\mathbf{j}/d\mathbf{u}`, :math:`d\mathb{u}/d\mathbf{m}`) for the adjoint :param Src src: sorce - :param numpy.ndarray du_dm: derivative of the solution vector with respect to the model times a vector (is None for adjoint) + :param numpy.ndarray du_dm_v: derivative of the solution vector with respect to the model times a vector (is None for adjoint) :param numpy.ndarray v: vector to take sensitivity product with :param bool adjoint: adjoint? :rtype: numpy.ndarray @@ -158,7 +158,7 @@ class Fields(SimPEG.Problem.Fields): if adjoint: return self._jDeriv_u(src, v, adjoint), self._jDeriv_m(src, v, adjoint) - return self._jDeriv_u(src, du_dm, adjoint) + self._jDeriv_m(src, v, adjoint) + return self._jDeriv_u(src, du_dm_v, adjoint) + self._jDeriv_m(src, v, adjoint) class Fields_e(Fields): @@ -277,12 +277,12 @@ class Fields_e(Fields): b[:,i] = b[:,i]+ 1./(1j*omega(src.freq)) * S_m return b - def _bSecondaryDeriv_u(self, src, du_dm, adjoint = False): + def _bSecondaryDeriv_u(self, src, du_dm_v, adjoint = False): """ Derivative of the secondary magnetic flux density with respect to the thing we solved for :param SimPEG.EM.FDEM.Src src: source - :param numpy.ndarray du_dm: vector to take product with + :param numpy.ndarray du_dm_v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray :return: product of the derivative of the secondary magnetic flux density with respect to the field we solved for with a vector @@ -290,8 +290,8 @@ class Fields_e(Fields): C = self._edgeCurl if adjoint: - return - 1./(1j*omega(src.freq)) * (C.T * du_dm) - return - 1./(1j*omega(src.freq)) * (C * du_dm) + return - 1./(1j*omega(src.freq)) * (C.T * du_dm_v) + return - 1./(1j*omega(src.freq)) * (C * du_dm_v) def _bSecondaryDeriv_m(self, src, v, adjoint = False): """ @@ -308,18 +308,18 @@ class Fields_e(Fields): return 1./(1j * omega(src.freq)) * S_mDeriv - def _bDeriv_u(self, src, du_dm, adjoint=False): + def _bDeriv_u(self, src, du_dm_v, adjoint=False): """ Partial derivative of the total magnetic flux density with respect to the thing we solved for :param SimPEG.EM.FDEM.Src src: source - :param numpy.ndarray du_dm: vector to take product with + :param numpy.ndarray du_dm_v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray :return: product of the derivative of the magnetic flux density with respect to the field we solved for with a vector """ - return self._bSecondaryDeriv_u(src, du_dm, adjoint) + return self._bSecondaryDeriv_u(src, du_dm_v, adjoint) def _bDeriv_m(self, src, v, adjoint=False): """ @@ -393,19 +393,19 @@ class Fields_b(Fields): return bSolution - def _bDeriv_u(self, src, du_dm, adjoint=False): + def _bDeriv_u(self, src, du_dm_v, adjoint=False): """ Partial derivative of the total magnetic flux density with respect to the thing we solved for. :param SimPEG.EM.FDEM.Src src: source - :param numpy.ndarray du_dm: vector to take product with + :param numpy.ndarray du_dm_v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray :return: product of the derivative of the magnetic flux density with respect to the field we solved for with a vector """ - return Identity()*du_dm + return Identity()*du_dm_v def _bDeriv_m(self, src, v, adjoint=False): """ @@ -453,7 +453,7 @@ class Fields_b(Fields): e[:,i] = e[:,i]+ -self._MeSigmaI * S_e return e - def _eSecondaryDeriv_u(self, src, du_dm, adjoint=False): + def _eSecondaryDeriv_u(self, src, du_dm_v, adjoint=False): """ Derivative of the secondary electric field with respect to the thing we solved for @@ -465,9 +465,9 @@ class Fields_b(Fields): """ if not adjoint: - return self._MeSigmaI * ( self._edgeCurl.T * ( self._MfMui * du_dm) ) + return self._MeSigmaI * ( self._edgeCurl.T * ( self._MfMui * du_dm_v) ) else: - return self._MfMui.T * (self._edgeCurl * (self._MeSigmaI.T * du_dm)) + return self._MfMui.T * (self._edgeCurl * (self._MeSigmaI.T * du_dm_v)) def _eSecondaryDeriv_m(self, src, v, adjoint=False): """ @@ -501,18 +501,18 @@ class Fields_b(Fields): return de_dm - def _eDeriv_u(self, src, du_dm, adjoint=False): + def _eDeriv_u(self, src, du_dm_v, adjoint=False): """ Partial derivative of the total electric field with respect to the thing we solved for :param SimPEG.EM.FDEM.Src src: source - :param numpy.ndarray du_dm: vector to take product with + :param numpy.ndarray du_dm_v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray :return: product of the derivative of the electric field with respect to the field we solved for with a vector """ - return self._eSecondaryDeriv_u(src, du_dm, adjoint) + return self._eSecondaryDeriv_u(src, du_dm_v, adjoint) def _eDeriv_m(self, src, v, adjoint=False): """ @@ -599,7 +599,7 @@ class Fields_j(Fields): return self._jPrimary(jSolution, srcList) + self._jSecondary(jSolution, srcList) - def _jDeriv_u(self, src, du_dm, adjoint=False): + def _jDeriv_u(self, src, du_dm_v, adjoint=False): """ Partial derivative of the total current density with respect to the thing we solved for. @@ -611,7 +611,7 @@ class Fields_j(Fields): :return: product of the derivative of the current density with respect to the field we solved for with a vector """ - return Identity()*du_dm + return Identity()*du_dm_v def _jDeriv_m(self, src, v, adjoint=False): @@ -661,21 +661,21 @@ class Fields_j(Fields): return h - def _hSecondaryDeriv_u(self, src, du_dm, adjoint=False): + def _hSecondaryDeriv_u(self, src, du_dm_v, adjoint=False): """ Derivative of the secondary magnetic field with respect to the thing we solved for :param SimPEG.EM.FDEM.Src src: source - :param numpy.ndarray du_dm: vector to take product with + :param numpy.ndarray du_dm_v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray :return: product of the derivative of the secondary magnetic field with respect to the field we solved for with a vector """ if not adjoint: - return -1./(1j*omega(src.freq)) * self._MeMuI * (self._edgeCurl.T * (self._MfRho * du_dm) ) + return -1./(1j*omega(src.freq)) * self._MeMuI * (self._edgeCurl.T * (self._MfRho * du_dm_v) ) elif adjoint: - return -1./(1j*omega(src.freq)) * self._MfRho.T * (self._edgeCurl * ( self._MeMuI.T * du_dm)) + return -1./(1j*omega(src.freq)) * self._MfRho.T * (self._edgeCurl * ( self._MeMuI.T * du_dm_v)) def _hSecondaryDeriv_m(self, src, v, adjoint=False): """ @@ -711,18 +711,18 @@ class Fields_j(Fields): return hDeriv_m - def _hDeriv_u(self, src, du_dm, adjoint=False): + def _hDeriv_u(self, src, du_dm_v, adjoint=False): """ Partial derivative of the total magnetic field with respect to the thing we solved for :param SimPEG.EM.FDEM.Src src: source - :param numpy.ndarray du_dm: vector to take product with + :param numpy.ndarray du_dm_v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray :return: product of the derivative of the magnetic field with respect to the field we solved for with a vector """ - return self._hSecondaryDeriv_u(src, du_dm, adjoint) + return self._hSecondaryDeriv_u(src, du_dm_v, adjoint) def _hDeriv_m(self, src, v, adjoint=False): """ @@ -795,19 +795,19 @@ class Fields_h(Fields): return hSolution - def _hDeriv_u(self, src, du_dm, adjoint=False): + def _hDeriv_u(self, src, du_dm_v, adjoint=False): """ Partial derivative of the total magnetic field with respect to the thing we solved for. :param SimPEG.EM.FDEM.Src src: source - :param numpy.ndarray du_dm: vector to take product with + :param numpy.ndarray du_dm_v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray :return: product of the derivative of the magnetic field with respect to the field we solved for with a vector """ - return Identity()*du_dm + return Identity()*du_dm_v def _hDeriv_m(self, src, v, adjoint=False): """ @@ -855,21 +855,21 @@ class Fields_h(Fields): j[:,i] = j[:,i]+ -S_e return j - def _jSecondaryDeriv_u(self, src, du_dm, adjoint=False): + def _jSecondaryDeriv_u(self, src, du_dm_v, adjoint=False): """ Derivative of the secondary current density with respect to the thing we solved for :param SimPEG.EM.FDEM.Src src: source - :param numpy.ndarray du_dm: vector to take product with + :param numpy.ndarray du_dm_v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray :return: product of the derivative of the secondary current density with respect to the field we solved for with a vector """ if not adjoint: - return self._edgeCurl*du_dm + return self._edgeCurl*du_dm_v elif adjoint: - return self._edgeCurl.T*du_dm + return self._edgeCurl.T*du_dm_v def _jSecondaryDeriv_m(self, src, v, adjoint=False): """ @@ -886,18 +886,18 @@ class Fields_h(Fields): return -S_eDeriv - def _jDeriv_u(self, src, du_dm, adjoint=False): + def _jDeriv_u(self, src, du_dm_v, adjoint=False): """ Partial derivative of the total current density with respect to the thing we solved for :param SimPEG.EM.FDEM.Src src: source - :param numpy.ndarray du_dm: vector to take product with + :param numpy.ndarray du_dm_v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray :return: product of the derivative of the current density with respect to the field we solved for with a vector """ - return self._jSecondaryDeriv_u(src,du_dm,adjoint) + return self._jSecondaryDeriv_u(src,du_dm_v,adjoint) def _jDeriv_m(self, src, v, adjoint=False): """