diff --git a/.travis.yml b/.travis.yml index 6aef1f7f..c64ba7f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ python: # Setup anaconda before_install: - - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.3.0-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.3.0-Linux-x86_64.sh -O miniconda.sh; fi + - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.8.3-Linux-x86_64.sh -O miniconda.sh; fi - chmod +x miniconda.sh - ./miniconda.sh -b - export PATH=/home/travis/anaconda/bin:/home/travis/miniconda/bin:$PATH @@ -17,7 +17,7 @@ before_install: install: - conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib cython - pip install nose-cov python-coveralls - # Remove this when SimPEG is on pip + # Remove this when SimPEG is on pip - git clone https://github.com/simpeg/simpeg.git - cd simpeg/ - python setup.py install @@ -35,3 +35,4 @@ notifications: email: - rowanc1@gmail.com - sgkang09@gmail.com + - lindseyheagy@gmail.com diff --git a/simpegEM/Base.py b/simpegEM/Base.py index da7e4a86..e2298ed0 100644 --- a/simpegEM/Base.py +++ b/simpegEM/Base.py @@ -17,15 +17,31 @@ class BaseEMProblem(Problem.BaseProblem): verbose = False + + #################################################### + # Mu Model + #################################################### + @property + def mu(self): + if getattr(self, '_mu', None) is None: + self._mu = mu_0 + return self._mu + @mu.setter + def mu(self, value): + if getattr(self, '_MfMui', None) is not None: + del self._MfMui + self._mu = value + + + #################################################### # Mass Matrices #################################################### @property def MfMui(self): - #TODO: assuming constant mu if getattr(self, '_MfMui', None) is None: - self._MfMui = self.mesh.getFaceInnerProduct(1/mu_0) + self._MfMui = self.mesh.getFaceInnerProduct(1/self.mu) return self._MfMui @property diff --git a/simpegEM/Tests/test_FDEM.py b/simpegEM/Tests/test_FDEM.py index a76ad539..e1d8f1c5 100644 --- a/simpegEM/Tests/test_FDEM.py +++ b/simpegEM/Tests/test_FDEM.py @@ -2,9 +2,12 @@ import unittest from SimPEG import * import simpegEM as EM import sys +from scipy.constants import mu_0 TOL = 1e-4 CONDUCTIVITY = 1e3 +MU = mu_0 +addrandoms = True def getProblem(fdemType, comp): cs = 5. @@ -44,7 +47,14 @@ def adjointTest(fdemType, comp): prb = getProblem(fdemType, comp) print 'Adjoint %s formulation - %s' % (fdemType, comp) - m = np.log(np.ones(prb.mesh.nC)*CONDUCTIVITY) + m = np.log(np.ones(prb.mesh.nC)*CONDUCTIVITY) + mu = np.log(np.ones(prb.mesh.nC)*MU) + + if addrandoms is True: + m = m + np.random.randn(prb.mesh.nC)*CONDUCTIVITY*1e-3 + mu = mu + np.random.randn(prb.mesh.nC)*MU*1e-3 + + prb.mu = mu survey = prb.survey v = np.random.rand(survey.nD) @@ -61,6 +71,13 @@ def derivTest(fdemType, comp): prb = getProblem(fdemType, comp) print '%s formulation - %s' % (fdemType, comp) x0 = np.log(np.ones(prb.mesh.nC)*CONDUCTIVITY) + mu = np.log(np.ones(prb.mesh.nC)*MU) + + if addrandoms is True: + x0 = x0 + np.random.randn(prb.mesh.nC)*CONDUCTIVITY*1e-3 + mu = mu + np.random.randn(prb.mesh.nC)*MU*1e-3 + + prb.mu = mu survey = prb.survey def fun(x): return survey.dpred(x), lambda x: prb.Jvec(x0, x)