def test_RhoDataNoRhoBFails(self):
     """
     resistivity set as Scalar, no value on boundary but interpolation is not possible
     """        
     model=MT2DTMModel(self.domain, fixBottom=False, useFastSolver=self.USEFASTSOLVER)
     rho=Scalar(self.RHO0, Function(self.domain))
     self.assertRaises(RuntimeError, model.setResistivity, *(rho, ))
 def test_RhoFloatNoRhoBFixedButtom(self):
     """
     resistivity set as float, no value on boundary, fixed bottom -> TRUE values are not matched exactly
     """
     PERIODS=np.logspace(2, 3, num=3, endpoint=True, base=10.0, dtype=float)
     model=MT2DTMModel(self.domain, fixBottom=True, useFastSolver=self.USEFASTSOLVER)
     model.setResistivity(self.RHO0)
     self.runModel(model, PERIODS, TOL=1.e-1)
 def test_RhoFloatNoRhoB(self):
     """
     resistivity set as float, no value on boundary, radiation condition 
     """
     PERIODS=np.logspace(-2, 2, num=5, endpoint=True, base=10.0, dtype=float)
     model=MT2DTMModel(self.domain, fixBottom=False, useFastSolver=self.USEFASTSOLVER)
     model.setResistivity(self.RHO0)
     self.runModel(model, PERIODS, TOL=1.e-3)
 def test_RhoBDataFailed(self):
     """
     resistivity set on elements, no value on boundary but interpolation is not possible fixed bottom 
     """
     PERIODS=np.logspace(2, 3, num=3, endpoint=True, base=10.0, dtype=float)
     rho=self.airLayerMaskCenter*9999999+(1-self.airLayerMaskCenter)*self.RHO0
     model=MT2DTMModel(self.domain, fixBottom=False, airLayer=self.DEPTH-self.AIR_LAYER, useFastSolver=self.USEFASTSOLVER)
     self.assertEqual(0, Lsup(model.airLayer-self.airLayerMask))
     self.assertRaises(RuntimeError, model.setResistivity, *(rho, ))
 def test_RhoDataNoRhoBFixedButtom2(self):
     """
     resistivity set as Scalar, no value on boundary, interpolation is not possible but fixed bottom -> TRUE values are not matched exactly
     """        
     PERIODS=np.logspace(2, 3, num=3, endpoint=True, base=10.0, dtype=float)
     model=MT2DTMModel(self.domain, fixBottom=True, useFastSolver=self.USEFASTSOLVER)
     rho=Scalar(self.RHO0, Function(self.domain))
     model.setResistivity(rho)
     self.runModel(model, PERIODS, TOL=1.e-1)  
 def test_RhoBFloat(self):
     """
     resistivity set on elements, radiation condition
     """
     PERIODS=np.logspace(-2, 2, num=5, endpoint=True, base=10.0, dtype=float)
     rho=self.airLayerMaskCenter*9999999+(1-self.airLayerMaskCenter)*self.RHO0
     model=MT2DTMModel(self.domain, fixBottom=False, airLayer=self.DEPTH-self.AIR_LAYER, useFastSolver=self.USEFASTSOLVER)
     self.assertEqual(0, Lsup(model.airLayer-self.airLayerMask))
     model.setResistivity(rho, rho_boundary=self.RHO0)
     self.runModel(model, PERIODS, TOL=1.e-3)
    z_top, m_top=z_top-l, m2
    
print("sigma =", sigma)
print("rho =", rho)
#
# ... create Locator to get impedance at position of observations:
#
stationX=np.linspace(OFFSET_STATION, WIDTH-OFFSET_STATION, num=NUM_STATION, endpoint=True)
loc=Locator(ReducedFunction(domain), [ (s, DEPTH-DEPTH_STATIONS) for s in stationX])

print("position of observation stations %s:"%(NUM_STATION//2,), loc.getX()[NUM_STATION//2]) # moved to the next element center!!!
#================================================================================================
FRQ=1./PERIODS
#================================================================================================
print("Start TM mode ...")
model=MT2DTMModel(domain, airLayer=DEPTH-L_AIR)
model.setResistivity(rho, rho_boundary=1/SIGMA0) # rho can be interpolated to the boundary (e.g. when conductivity is given on node) rho_boundary can be omited. 

# collects app. rho and phase for the frequencies:
arho_TM=[]
phase_TM=[]

for frq in FRQ:
    Zyx = model.getImpedance(f=frq)
    arho=model.getApparentResitivity(frq, Zyx)
    phi=model.getPhase(frq, Zyx)
    #saveVTK('sol', rho=rho, Hx=abs(self.Hx), rho=rho, phi=phi) # write to file for visualization.
    arho_TM.append(loc(arho)[NUM_STATION//2])
    phase_TM.append(loc(phi)[NUM_STATION//2])
    print("frequency %s Hz completed. app. rho = %s, phase = %s deg"%(frq, arho_TM[-1], phase_TM[-1]))