From 599847126c607a542ff3fccc77cff956508fbcf4 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Fri, 15 May 2015 13:02:59 -0700 Subject: [PATCH] updates to source and rx conventions --- simpegDC/BaseDC.py | 16 ++++++++++------ simpegDC/Examples/Verification.py | 10 ++++++++-- simpegDC/Examples/WennerArray.py | 4 ++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/simpegDC/BaseDC.py b/simpegDC/BaseDC.py index c873a1a4..76671433 100644 --- a/simpegDC/BaseDC.py +++ b/simpegDC/BaseDC.py @@ -1,16 +1,20 @@ from SimPEG import * -class DipoleSrc(Survey.BaseSrc): +class SrcDipole(Survey.BaseSrc): """A dipole source, locA and locB are moved to the closest cell-centers""" current = 1 + loc = None + _rhsDict = None - def __init__(self, locA, locB, rxList, **kwargs): - super(DipoleSrc, self).__init__((locA, locB), 'dipole', rxList, **kwargs) - self._rhsDict = {} + def __init__(self, rxList, locA, locB, **kwargs): + self.loc = (locA, locB) + super(SrcDipole, self).__init__(rxList, **kwargs) def getRhs(self, mesh): + if getattr(self, '_rhsDict', None) is None: + self._rhsDict = {} if mesh not in self._rhsDict: pts = [self.loc[0], self.loc[1]] inds = Utils.closestPoints(mesh, pts) @@ -20,12 +24,12 @@ class DipoleSrc(Survey.BaseSrc): return self._rhsDict[mesh] -class DipoleRx(Survey.BaseRx): +class RxDipole(Survey.BaseRx): """A dipole source, locA and locB are moved to the closest cell-centers""" def __init__(self, locsM, locsN, **kwargs): locs = (locsM, locsN) assert locsM.shape == locsN.shape, 'locs must be the same shape.' - super(DipoleRx, self).__init__(locs, 'dipole', storeProjections=False, **kwargs) + super(RxDipole, self).__init__(locs, 'dipole', storeProjections=False, **kwargs) @property def nD(self): diff --git a/simpegDC/Examples/Verification.py b/simpegDC/Examples/Verification.py index 00e3bd62..b331e955 100644 --- a/simpegDC/Examples/Verification.py +++ b/simpegDC/Examples/Verification.py @@ -2,6 +2,7 @@ from SimPEG import * import simpegDC as DC import matplotlib.pyplot as plt + def run(plotIt=False): cs = 25. hx = [(cs,7, -1.3),(cs,21),(cs,7, 1.3)] @@ -22,11 +23,16 @@ def run(plotIt=False): # ax.plot(xyz_rxP[:,0],xyz_rxP[:,1], 'w.') # ax.plot(xyz_rxN[:,0],xyz_rxN[:,1], 'r.', ms = 3) - rx = DC.DipoleRx(xyz_rxP, xyz_rxN) - src = DC.DipoleSrc([-200, 0, -12.5],[+200, 0, -12.5], [rx]) + rx = DC.RxDipole(xyz_rxP, xyz_rxN) + src = DC.SrcDipole([rx], [-200, 0, -12.5], [+200, 0, -12.5]) survey = DC.SurveyDC([src]) problem = DC.ProblemDC(mesh) problem.pair(survey) + try: + from pymatsolver import MumpsSolver + problem.Solver = MumpsSolver + except Exception, e: + pass data = survey.dpred(sigma) def DChalf(srclocP, srclocN, rxloc, sigma, I=1.): diff --git a/simpegDC/Examples/WennerArray.py b/simpegDC/Examples/WennerArray.py index 4e0edb24..50041861 100644 --- a/simpegDC/Examples/WennerArray.py +++ b/simpegDC/Examples/WennerArray.py @@ -32,8 +32,8 @@ def getSrcList(nElecs, aSpacing, in2D=False, plotIt=False): getLoc = lambda ii, abmn: np.r_[elocs[WENNER[ii,abmn]],0, 0] srcList = [] for i in range(WENNER.shape[0]): - rx = DC.DipoleRx(getLoc(i,1),getLoc(i,2)) - src = DC.DipoleSrc(getLoc(i,0),getLoc(i,3), [rx]) + rx = DC.RxDipole(getLoc(i,1),getLoc(i,2)) + src = DC.SrcDipole([rx], getLoc(i,0),getLoc(i,3)) srcList += [src] return srcList