diff --git a/SimPEG/Maps.py b/SimPEG/Maps.py index 4ab79e64..4ceb35bd 100644 --- a/SimPEG/Maps.py +++ b/SimPEG/Maps.py @@ -221,6 +221,26 @@ class ExpMap(IdentityMap): """ return Utils.sdiag(np.exp(Utils.mkvc(m))) +class ReciprocalMap(IdentityMap): + """ + Reciprocal mapping. For example, electrical resistivity and conductivity. + + .. math:: + + \\rho = \\frac{1}{\sigma} + + """ + def _transform(self, m): + return 1.0 / Utils.mkvc(m) + + def inverse(self, D): + return 1.0 / Utils.mkvc(m) + + def deriv(self, m): + # TODO: if this is a tensor, you might have a problem. + return Utils.sdiag( - Utils.mkvc(m)**(-2) ) + + class LogMap(IdentityMap): """ diff --git a/SimPEG/Tests/test_maps.py b/SimPEG/Tests/test_maps.py index 9f8fef3c..437e51fa 100644 --- a/SimPEG/Tests/test_maps.py +++ b/SimPEG/Tests/test_maps.py @@ -6,8 +6,8 @@ from scipy.sparse.linalg import dsolve TOL = 1e-14 -MAPS_TO_TEST_2D = ["CircleMap", "ComplexMap", "ExpMap", "IdentityMap", "Vertical1DMap", "Weighting"] -MAPS_TO_TEST_3D = [ "ComplexMap", "ExpMap", "IdentityMap", "Vertical1DMap", "Weighting"] +MAPS_TO_TEST_2D = ["CircleMap", "ComplexMap", "ExpMap", "IdentityMap", "Vertical1DMap", "Weighting", "ReciprocalMap"] +MAPS_TO_TEST_3D = [ "ComplexMap", "ExpMap", "IdentityMap", "Vertical1DMap", "Weighting", "ReciprocalMap"] class MapTests(unittest.TestCase):