<s> import numpy as np , SimPEG as simpeg <EOL> from MT1Danalytic import getEHfields <EOL> from scipy . constants import mu_0 <EOL> def get1DEfields ( m1d , sigma , freq , sourceAmp = <NUM_LIT:1.0> ) : <EOL> """<STR_LIT>""" <EOL> G = m1d . nodalGrad <EOL> Mmu = simpeg . Utils . sdiag ( m1d . vol * ( <NUM_LIT:1.0> / mu_0 ) ) <EOL> Msig = m1d . getFaceInnerProduct ( sigma ) <EOL> A = G . T * Mmu * G + <NUM_LIT> * <NUM_LIT> * np . pi * freq * Msig <EOL> Aii = A [ <NUM_LIT:1> : - <NUM_LIT:1> , <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> Aio = A [ <NUM_LIT:1> : - <NUM_LIT:1> , [ <NUM_LIT:0> , - <NUM_LIT:1> ] ] <EOL> Ed , Eu , Hd , Hu = getEHfields ( m1d , sigma , freq , m1d . vectorNx ) <EOL> Etot = ( Ed + Eu ) <EOL> if sourceAmp is not None : <EOL> Etot = ( ( Etot / Etot [ - <NUM_LIT:1> ] ) * sourceAmp ) <EOL> bc = np . r_ [ Etot [ <NUM_LIT:0> ] , Etot [ - <NUM_LIT:1> ] ] <EOL> rhs = Aio * bc <EOL> Aii_inv = simpeg . Solver ( Aii ) <EOL> eii = Aii_inv * rhs <EOL> e = np . r_ [ bc [ <NUM_LIT:0> ] , eii , bc [ <NUM_LIT:1> ] ] <EOL> return e <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> hz = [ ( <NUM_LIT> , <NUM_LIT> ) ] <EOL> M = simpeg . Mesh . TensorMesh ( [ hz ] , '<STR_LIT:C>' ) <EOL> sig = np . zeros ( M . nC ) + <NUM_LIT> <EOL> sig [ M . vectorCCx <= <NUM_LIT:0> ] = sigHalf </s>
