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) A = 2.0 * At A2 = A * iJ * A Ce = 0.5 * J - At Ci = 0.5 * J + At
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:] x_mtf = solve(mtf, rhs_mtf) xd_mtf, xn_mtf = x_mtf[0:shape], x_mtf[shape:2 * shape] yd_mtf, yn_mtf = x_mtf[2 * shape:3 * shape], x_mtf[3 * shape:4 * shape] print('') print('l2 norm (relative)') print(la.norm(xd_mtf - xd_stf), la.norm(xn_mtf - xn_stf)) print(
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)) print('\nSTF restart={0} maxiter={1}'.format(restart, maxiter), flush=True) Mat, b = stf, rhs_stf print('size: ', stf.shape, 2*shape) del res res = [] tt = time() x_stf, info = gmres(Mat, b, orthog='mgs', tol=tol, residuals=res,