From 06de6a346f64468eabcd13b4dbad676a58441f8f Mon Sep 17 00:00:00 2001 From: rowanc1 Date: Sat, 26 Apr 2014 12:20:29 -0700 Subject: [PATCH] Changes to MeshTensor. --- simpegEM/TDEM/BaseTDEM.py | 2 +- simpegEM/TDEM/TDEM_b.py | 6 +++--- simpegEM/Tests/test_FDEM.py | 8 ++++---- simpegEM/Tests/test_FDEM_analytics.py | 13 +++++++------ simpegEM/Tests/test_TDEM_b_DerivAdjoint.py | 10 +++++----- simpegEM/Tests/test_TDEM_forward_Analytic.py | 14 +++++++------- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/simpegEM/TDEM/BaseTDEM.py b/simpegEM/TDEM/BaseTDEM.py index e4ce1140..dcee4705 100644 --- a/simpegEM/TDEM/BaseTDEM.py +++ b/simpegEM/TDEM/BaseTDEM.py @@ -38,7 +38,7 @@ class MixinInitialFieldCalc(object): raise Exception('Unknown mesh for VMD') # Initialize field object - F = FieldsTDEM(self.mesh, 1, self.times[1:].size, store=self.storeTheseFields) + F = FieldsTDEM(self.mesh, 1, self.nT, store=self.storeTheseFields) # Set initial B F.b0 = self.mesh.edgeCurl*MVP diff --git a/simpegEM/TDEM/TDEM_b.py b/simpegEM/TDEM/TDEM_b.py index 37c3a38c..9e52bdf7 100644 --- a/simpegEM/TDEM/TDEM_b.py +++ b/simpegEM/TDEM/TDEM_b.py @@ -240,9 +240,9 @@ if __name__ == '__main__': import matplotlib.pyplot as plt cs, ncx, ncz, npad = 5., 20, 6, 20 - hx = Utils.meshTensors(((0,cs), (ncx,cs), (npad,cs))) - hz = Utils.meshTensors(((npad,cs), (ncz,cs), (npad,cs))) - mesh = Mesh.CylMesh([hx,1,hz], [0,0,-hz.sum()/2]) + hx = [(cs, ncx), (cs, npad, 1.3)] + hz = [(cs, npad, -1.3), (cs, ncz), (cs, npad, 1.3)] + mesh = Mesh.CylMesh([hx,1,hz], '00C') mapping = Maps.Vertical1DMap(mesh) opts = {'txLoc':0., diff --git a/simpegEM/Tests/test_FDEM.py b/simpegEM/Tests/test_FDEM.py index 3f53684a..3b705bc9 100644 --- a/simpegEM/Tests/test_FDEM.py +++ b/simpegEM/Tests/test_FDEM.py @@ -10,10 +10,10 @@ def getProblem(fdemType, comp): cs = 5. ncx, ncy, ncz = 6, 6, 6 npad = 3 - hx = Utils.meshTensors(((npad,cs), (ncx,cs), (npad,cs))) - hy = Utils.meshTensors(((npad,cs), (ncy,cs), (npad,cs))) - hz = Utils.meshTensors(((npad,cs), (ncz,cs), (npad,cs))) - mesh = Mesh.TensorMesh([hx,hy,hz],[-hx.sum()/2., -hy.sum()/2., -hz.sum()/2.]) + hx = [(cs,npad,-1.3), (cs,ncx), (cs,npad,1.3)] + hy = [(cs,npad,-1.3), (cs,ncy), (cs,npad,1.3)] + hz = [(cs,npad,-1.3), (cs,ncz), (cs,npad,1.3)] + mesh = Mesh.TensorMesh([hx,hy,hz],['C','C','C']) mapping = Maps.ExpMap(mesh) diff --git a/simpegEM/Tests/test_FDEM_analytics.py b/simpegEM/Tests/test_FDEM_analytics.py index d0fd3482..e129d2f7 100644 --- a/simpegEM/Tests/test_FDEM_analytics.py +++ b/simpegEM/Tests/test_FDEM_analytics.py @@ -10,12 +10,13 @@ class FDEM_analyticTests(unittest.TestCase): def setUp(self): cs = 10. - ncx, ncy, ncz = 8, 8, 8 - npad = 5 - hx = Utils.meshTensors(((npad,cs), (ncx,cs), (npad,cs))) - hy = Utils.meshTensors(((npad,cs), (ncy,cs), (npad,cs))) - hz = Utils.meshTensors(((npad,cs), (ncz,cs), (npad,cs))) - mesh = Mesh.TensorMesh([hx,hy,hz], x0=[-hx.sum()/2.,-hy.sum()/2.,-hz.sum()/2.,]) + ncx, ncy, ncz = 10, 10, 10 + npad = 4 + hx = [(cs,npad,-1.3), (cs,ncx), (cs,npad,1.3)] + hy = [(cs,npad,-1.3), (cs,ncy), (cs,npad,1.3)] + hz = [(cs,npad,-1.3), (cs,ncz), (cs,npad,1.3)] + mesh = Mesh.TensorMesh([hx,hy,hz], 'CCC') + print mesh.vectorCCx mapping = Maps.ExpMap(mesh) diff --git a/simpegEM/Tests/test_TDEM_b_DerivAdjoint.py b/simpegEM/Tests/test_TDEM_b_DerivAdjoint.py index 7d136a29..993991b9 100644 --- a/simpegEM/Tests/test_TDEM_b_DerivAdjoint.py +++ b/simpegEM/Tests/test_TDEM_b_DerivAdjoint.py @@ -10,9 +10,9 @@ class TDEM_bDerivTests(unittest.TestCase): ncx = 20 ncy = 6 npad = 20 - hx = Utils.meshTensors(((0,cs), (ncx,cs), (npad,cs))) - hy = Utils.meshTensors(((npad,cs), (ncy,cs), (npad,cs))) - mesh = Mesh.CylMesh([hx,1,hy], [0,0,-hy.sum()/2]) + hx = [(cs,ncx), (cs,npad,1.3)] + hy = [(cs,npad,-1.3), (cs,ncy), (cs,npad,1.3)] + mesh = Mesh.CylMesh([hx,1,hy], '00C') active = mesh.vectorCCz<0. activeMap = Maps.ActiveCells(mesh, active, -8, nC=mesh.nCz) @@ -72,7 +72,7 @@ class TDEM_bDerivTests(unittest.TestCase): def test_AhVecVSMat_OneTS(self): prb = self.prb - prb.timeSteps = [(1e-05, 1)] + prb.timeSteps = [1e-05] sigma = self.sigma prb.makeMassMatrices(sigma) @@ -92,7 +92,7 @@ class TDEM_bDerivTests(unittest.TestCase): def test_solveAhVSMat_OneTS(self): prb = self.prb - prb.timeSteps = [(1e-05, 1)] + prb.timeSteps = [1e-05] sigma = self.sigma prb.makeMassMatrices(sigma) diff --git a/simpegEM/Tests/test_TDEM_forward_Analytic.py b/simpegEM/Tests/test_TDEM_forward_Analytic.py index ceab2249..b2733d86 100644 --- a/simpegEM/Tests/test_TDEM_forward_Analytic.py +++ b/simpegEM/Tests/test_TDEM_forward_Analytic.py @@ -8,15 +8,15 @@ import matplotlib.pyplot as plt def halfSpaceProblemAnaDiff(meshType, sig_half=1e-2, rxOffset=50., bounds=[1e-5,1e-3], showIt=False): if meshType == 'CYL': cs, ncx, ncz, npad = 5., 30, 10, 15 - hx = Utils.meshTensors(((0,cs), (ncx,cs), (npad,cs))) - hz = Utils.meshTensors(((npad,cs), (ncz,cs), (npad,cs))) - mesh = Mesh.CylMesh([hx,1,hz], [0,0,-hz.sum()/2]) + hx = [(cs,ncx), (cs,npad,1.3)] + hz = [(cs,npad,-1.3), (cs,ncz), (cs,npad,1.3)] + mesh = Mesh.CylMesh([hx,1,hz], '00C') elif meshType == 'TENSOR': cs, nc, npad = 20., 13, 5 - hx = Utils.meshTensors(((npad,cs), (nc,cs), (npad,cs))) - hy = Utils.meshTensors(((npad,cs), (nc,cs), (npad,cs))) - hz = Utils.meshTensors(((npad,cs), (nc,cs), (npad,cs))) - mesh = Mesh.TensorMesh([hx,hy,hz], [-hx.sum()/2.,-hy.sum()/2.,-hz.sum()/2.]) + hx = [(cs,npad,-1.3), (cs,nc), (cs,npad,1.3)] + hy = [(cs,npad,-1.3), (cs,nc), (cs,npad,1.3)] + hz = [(cs,npad,-1.3), (cs,nc), (cs,npad,1.3)] + mesh = Mesh.TensorMesh([hx,hy,hz], 'CCC') active = mesh.vectorCCz<0. actMap = Maps.ActiveCells(mesh, active, np.log(1e-8), nC=mesh.nCz)