Example #1
0
File: eg.py Project: zimoun/mtf
n = 4

l = 400

tolrank, tolres = 1e-5, 1e-8
mu, a, b = 3.5, 1, 0.25

t = 2*np.pi * np.linspace(0, 1, N+1, endpoint=True)
psi = lambda t: mu + a * np.cos(t) + 1j * b * np.sin(t)
phi = lambda t: - a * np.sin(t) + 1j * b * np.cos(t)
Psi, Phi = psi(t), phi(t)

kmax = np.max(np.abs(Psi))

tinit = time()
xtf = xTF(kmax, n)
Met = MET(xtf)
met = Met.get()

print('inital assemb time:', time() - tinit)
print('size MET: ', met.shape)
print(bem.global_parameters.assembly.boundary_operator_assembly_type)

m = met.shape[0]

space = xtf.space
if MET == MTF:
    Vhat1 = rhs(m/2, l, xtf.space, rand=True)
    Vhat2 = rhs(m/2, l, xtf.space, rand=True)
    Vhat = np.concatenate((Vhat1, Vhat2), axis=0)
else:
Example #2
0
tol = 1e-6
res = []
restart = None
maxiter = 300


def dir_data(x, normal, dom_ind, result):
    result[0] = -np.exp(1j * kRef * x[1])


def neu_data(x, normal, dom_ind, result):
    result[0] = -1j * normal[1] * kRef * np.exp(1j * kRef * x[1])


xtf = xTF(kRef, n)
xtf.setRHS(dir_data, neu_data)

space = xtf.space
shape = xtf.shape
fd, fn = xtf.getDir(), xtf.getNeu()
fdir, fneu = xtf.getGFdir(), xtf.getGFneu()

STF, MTF = STF(xtf), MTF(xtf)

stf, rhs_stf = STF.get(), STF.rhs()
mtf, rhs_mtf = MTF.get(), MTF.rhs()

x_stf = solve(stf, rhs_stf)
xd_stf, xn_stf = x_stf[0:shape], x_stf[shape:]
Example #3
0
dEl2_stf, dEnl2_stf = [], []
dEL2_stf, dEnL2_stf = [], []

nEl2_stf, nEnl2_stf = [], []
nEL2_stf, nEnL2_stf = [], []

for nlambda in nlambdas:

    print('\n')
    print('##################')
    print('\n')

    H.append(ll / nlambda)

    xtf = xTF(kRef, eps, nlambda)
    xtf.setRHS(dir_data, neu_data)
    # xtf.uncollect()
    # xtf.collect()
    # xtf.weak_form()

    mtf = MTF(xtf)

    Aw = mtf.get_A()

    At, X, J, iJ = mtf.tolinop()

    shape = mtf.shape
    size, _ = shape
    Size.append(size)
Example #4
0
from xtf import xTF, STF, MTF
from xtf import STF2, MTF2, iSTF
from algo import rhs, solve

its = False
MET = iSTF

N = 10
n = 4

k = np.linspace(2.5, 3.5, N + 1, endpoint=True)

E = []
for kk in k:
    xtf = xTF(kk, n)
    Met = MET(xtf)
    met = Met.get()

    xtf.update(1j * kk)
    cMet = MET(xtf)
    cmet = cMet.get()

    print(' ')
    print('kk=', kk)
    print('shape(MET)=', met.shape)
    print(' ')

    print('converting...', end=' ', flush=True)
    A = bem.as_matrix(met)
    print('x', end=' ', flush=True)
Example #5
0
File: eg-4.py Project: zimoun/mtf
n = 4

l = 400

tolrank, tolres = 1e-9, 1e-7
mu, a, b = 3.8, 1, 0.25

t = 2 * np.pi * np.linspace(0, 1, N + 1, endpoint=True)
psi = lambda t: mu + a * np.cos(t) + 1j * b * np.sin(t)
phi = lambda t: -a * np.sin(t) + 1j * b * np.cos(t)
Psi, Phi = psi(t), phi(t)

kmax = np.max(np.abs(Psi))

tinit = time()
xtf = xTF(kmax, n)
Met = MET(xtf)
met = Met.get()

print('inital assemb time:', time() - tinit)
print('size MET: ', met.shape)
print(bem.global_parameters.assembly.boundary_operator_assembly_type)

m = met.shape[0]

# Vhat = np.random.rand(m, l) + 1j * np.random.rand(m, l)
Vhat = np.eye(m)
VVhat = Vhat[:, 0:l]
Vhat = np.zeros((m, 1), dtype=np.complex)
space = xtf.space
for v in VVhat.T:
Example #6
0
dEl2_stf, dEnl2_stf = [], []
dEL2_stf, dEnL2_stf = [], []

nEl2_stf, nEnl2_stf = [], []
nEL2_stf, nEnL2_stf = [], []

for nlambda in nlambdas:

    print('\n')
    print('##################')
    print('\n')

    H.append(ll / nlambda)

    xtf = xTF(kRef, eps, nlambda)
    xtf.setRHS(dir_data, neu_data)
    # xtf.uncollect()
    # xtf.collect()
    # xtf.weak_form()

    mtf = MTF(xtf)

    Aw = mtf.get_A()

    At, X, J, iJ = mtf.tolinop()

    shape = mtf.shape
    size, _ = shape
    Size.append(size)
Example #7
0
File: eg-2.py Project: zimoun/mtf
kRef = 1.

tol = 1e-6
res = []
restart = None
maxiter = 300

def dir_data(x, normal, dom_ind, result):
    result[0] =  -np.exp( 1j * kRef * x[1])

def neu_data(x, normal, dom_ind, result):
    result[0] = -1j * normal[1] * kRef * np.exp( 1j * kRef * x[1])


xtf = xTF(kRef, n)
xtf.setRHS(dir_data, neu_data)

space = xtf.space
shape = xtf.shape
fd, fn = xtf.getDir(), xtf.getNeu()
fdir, fneu = xtf.getGFdir(), xtf.getGFneu()

STF, MTF = STF(xtf), MTF(xtf)

stf, rhs_stf = STF.get(), STF.rhs()
mtf, rhs_mtf = MTF.get(), MTF.rhs()



rescaleRes = lambda res, P, rhs: res / la.norm(P(rhs))
Example #8
0
from xtf import xTF, STF, MTF
from xtf import STF2, MTF2, iSTF
from algo import rhs, solve

its = False
MET = iSTF

N = 10
n = 4

k = np.linspace(2.5, 3.5, N+1, endpoint=True)

E = []
for kk in k:
    xtf = xTF(kk, n)
    Met = MET(xtf)
    met = Met.get()

    xtf.update(1j * kk)
    cMet = MET(xtf)
    cmet = cMet.get()

    print(' ')
    print('kk=', kk)
    print('shape(MET)=', met.shape)
    print(' ')

    print('converting...', end=' ', flush=True)
    A = bem.as_matrix(met)
    print('x', end=' ', flush=True)