cmap=plt.cm.viridis) ax.set_title(r'$\Delta$ Conductivities') fig.colorbar(im) ax.axis('equal') fig.set_size_inches(6, 4) # fig.savefig('demo_bp_0.png', dpi=96) plt.show() """ 2. FEM forward simulations """ # setup EIT scan conditions # adjacent stimulation (el_dist=1), adjacent measures (step=1) el_dist, step = 1, 1 ex_mat = eit_scan_lines(16, el_dist) # calculate simulated data fwd = Forward(mesh_obj, el_pos) f0 = fwd.solve_eit(ex_mat, step=step, perm=mesh_obj['perm']) f1 = fwd.solve_eit(ex_mat, step=step, perm=mesh_new['perm']) """ 3. naive inverse solver using back-projection """ eit = bp.BP(mesh_obj, el_pos, ex_mat=ex_mat, step=1, parser='std') eit.setup(weight='none') ds = 192.0 * eit.solve(f1.v, f0.v) # plot fig = plt.figure() ax1 = fig.add_subplot(111) im = ax1.tripcolor(pts[:, 0], pts[:, 1], tri, ds, cmap=plt.cm.viridis) ax1.set_title(r'$\Delta$ Conductivities') ax1.axis('equal') fig.colorbar(im)
perm = mesh_new['perm'] # show fig, ax = plt.subplots(figsize=(6, 4)) im = ax.tripcolor(pts[:, 0], pts[:, 1], tri, np.real(perm), shading='flat', cmap=plt.cm.viridis) fig.colorbar(im) ax.axis('equal') ax.set_title(r'$\Delta$ Conductivities') plt.show() """ 2. calculate simulated data """ el_dist, step = 1, 1 ex_mat = eit_scan_lines(n_el, el_dist) fwd = Forward(mesh_obj, el_pos) f1 = fwd.solve_eit(ex_mat, step, perm=mesh_new['perm'], parser='std') """ 3. solve_eit using gaussian-newton (with regularization) """ # number of stimulation lines/patterns eit = jac.JAC(mesh_obj, el_pos, ex_mat, step, perm=1.0, parser='std') eit.setup(p=0.25, lamb=1.0, method='lm') # lamb = lamb * lamb_decay ds = eit.gn(f1.v, lamb_decay=0.1, lamb_min=1e-5, maxiter=20, verbose=True) # plot fig, ax = plt.subplots(figsize=(6, 4)) im = ax.tripcolor(pts[:, 0], pts[:, 1], tri, np.real(ds), shading='flat', alpha=1.0, cmap=plt.cm.viridis) fig.colorbar(im) ax.axis('equal') ax.set_title('Conductivities Reconstructed')
fig, ax = plt.subplots(figsize=(6, 4)) im = ax.tripcolor(pts[:, 0], pts[:, 1], tri, np.real(perm), shading="flat", cmap=plt.cm.viridis) fig.colorbar(im) ax.axis("equal") ax.set_title(r"$\Delta$ Conductivities") plt.show() """ 2. calculate simulated data """ el_dist, step = 1, 1 ex_mat = eit_scan_lines(n_el, el_dist) fwd = Forward(mesh_obj, el_pos) f1 = fwd.solve_eit(ex_mat, step, perm=mesh_new["perm"], parser="std") """ 3. solve_eit using gaussian-newton (with regularization) """ # number of stimulation lines/patterns eit = jac.JAC(mesh_obj, el_pos, ex_mat, step, perm=1.0, parser="std") eit.setup(p=0.25, lamb=1.0, method="lm") # lamb = lamb * lamb_decay ds = eit.gn(f1.v, lamb_decay=0.1, lamb_min=1e-5, maxiter=20, verbose=True) # plot fig, ax = plt.subplots(figsize=(6, 4)) im = ax.tripcolor( pts[:, 0], pts[:, 1], tri, np.real(ds), shading="flat",
pts = mesh_obj["node"] tri = mesh_obj["element"] x, y = pts[:, 0], pts[:, 1] """ 1. problem setup """ mesh_obj["alpha"] = np.random.rand(tri.shape[0]) * 200 + 100 anomaly = [{"x": 0.5, "y": 0.5, "d": 0.1, "perm": 1000.0}] mesh_new = mesh.set_perm(mesh_obj, anomaly=anomaly) """ 2. FEM simulation """ el_dist, step = 1, 1 ex_mat = eit_scan_lines(16, el_dist) # calculate simulated data fwd = Forward(mesh_obj, el_pos) f0 = fwd.solve_eit(ex_mat, step=step, perm=mesh_obj["perm"]) f1 = fwd.solve_eit(ex_mat, step=step, perm=mesh_new["perm"]) """ 3. JAC solver """ # Note: if the jac and the real-problem are generated using the same mesh, # then, data normalization in solve are not needed. # However, when you generate jac from a known mesh, but in real-problem # (mostly) the shape and the electrode positions are not exactly the same # as in mesh generating the jac, then data must be normalized. eit = jac.JAC( mesh_obj, el_pos, ex_mat=ex_mat, step=step, perm=1.0, parser="fmmu",