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 Ce2 = Ce * iJ * Ce Ci2 = Ci * iJ * Ci x = np.random.rand(shape[0]) + 1j * np.random.rand(shape[0]) b = mtf.rhs(dir_data, neu_data) M = A - X print('') print(nlambda, mtf.shape, flush=True) print('') checker('A2 = J', A2, J, x) checker('exterior Proj.', Ce2, Ce, x) checker('interior Proj.', Ci2, Ci, x) checker('error-Calderon with random [no-sense]', A, J, x) print('') print('MTF classic', M.shape) 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() 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( la.norm(xd_mtf - yd_mtf - fd) / la.norm(xd_mtf), la.norm(-xn_mtf - yn_mtf - fn) / la.norm(xn_mtf))
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,