From 71881c7ce8d51055b0dace1fee876f820d1ac1bb Mon Sep 17 00:00:00 2001 From: Lindsey Date: Tue, 24 Feb 2015 11:43:59 -0800 Subject: [PATCH 1/4] - added capability for adding a mu model - added variable mu in the FDEM testing - also added capability to add a small random vector to sigma and mu for testing --- simpegEM/Tests/test_FDEM.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/simpegEM/Tests/test_FDEM.py b/simpegEM/Tests/test_FDEM.py index a76ad539..af727785 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)*CONDUCTIVITY) + + if addrandoms is True: + m = m + np.random.randn(prb.mesh.nC)*CONDUCTIVITY*1e-3 + mu = mu + np.random.randn(prb.mesh.nC)*CONDUCTIVITY*1e-3 + + prb.mu = mu survey = prb.survey v = np.random.rand(survey.nD) @@ -61,6 +71,11 @@ def derivTest(fdemType, comp): prb = getProblem(fdemType, comp) print '%s formulation - %s' % (fdemType, comp) x0 = np.log(np.ones(prb.mesh.nC)*CONDUCTIVITY) + + if addrandoms is True: + x0 = x0 + np.random.randn(prb.mesh.nC)*CONDUCTIVITY*1e-3 + mu = mu + np.random.randn(prb.mesh.nC)*CONDUCTIVITY*1e-3 + survey = prb.survey def fun(x): return survey.dpred(x), lambda x: prb.Jvec(x0, x) From 0a98c5f1c35771316bc8254fc22f91e1189efe28 Mon Sep 17 00:00:00 2001 From: Lindsey Date: Tue, 24 Feb 2015 12:54:45 -0800 Subject: [PATCH 2/4] Fixed Travis? --- .travis.yml | 6 ++---- simpegEM/Base.py | 20 ++++++++++++++++++-- simpegEM/Tests/test_FDEM.py | 10 ++++++---- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6aef1f7f..59c1fa2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,11 +17,8 @@ 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 - - git clone https://github.com/simpeg/simpeg.git - - cd simpeg/ + # - pip install -r requirements.txt - python setup.py install - - cd ../ # Run test script: @@ -35,3 +32,4 @@ notifications: email: - rowanc1@gmail.com - sgkang09@gmail.com + - lindseyheagy@gmail.com diff --git a/simpegEM/Base.py b/simpegEM/Base.py index 373cee75..c22252fa 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 af727785..e1d8f1c5 100644 --- a/simpegEM/Tests/test_FDEM.py +++ b/simpegEM/Tests/test_FDEM.py @@ -7,7 +7,7 @@ from scipy.constants import mu_0 TOL = 1e-4 CONDUCTIVITY = 1e3 MU = mu_0 -addrandoms = True +addrandoms = True def getProblem(fdemType, comp): cs = 5. @@ -48,11 +48,11 @@ def adjointTest(fdemType, comp): print 'Adjoint %s formulation - %s' % (fdemType, comp) m = np.log(np.ones(prb.mesh.nC)*CONDUCTIVITY) - mu = 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)*CONDUCTIVITY*1e-3 + mu = mu + np.random.randn(prb.mesh.nC)*MU*1e-3 prb.mu = mu survey = prb.survey @@ -71,11 +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)*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) From 2a53b78ccd08b957ace15d6bc239b53e79a885de Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Tue, 24 Feb 2015 17:08:37 -0500 Subject: [PATCH 3/4] Update the miniconda version 3.3.0 --> 3.8.3 Reverse other changes. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 59c1fa2c..22abed51 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 - # - pip install -r requirements.txt + - pip install -r requirements.txt - python setup.py install # Run test From 629bb5618537449d94228dfe9ee6d97dd04e0457 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Tue, 24 Feb 2015 17:15:00 -0500 Subject: [PATCH 4/4] minor updates to travis. --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 22abed51..c64ba7f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,11 @@ before_install: install: - conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib cython - pip install nose-cov python-coveralls - - pip install -r requirements.txt + # Remove this when SimPEG is on pip + - git clone https://github.com/simpeg/simpeg.git + - cd simpeg/ - python setup.py install + - cd ../ # Run test script: