Пример #1
0
 def set_pde(self):
     # construct mesh
     self.mesh_obj,self.el_pos=mesh.create(self.n_el, bbox=self.bbox, h0=self.meshsz)
     # extract node, element
     self.pts=self.mesh_obj['node']
     self.tri=self.mesh_obj['element']
     # initialize forward solver using the unstructured mesh object and the positions of electrodes
     self.fwd=Forward(self.mesh_obj, self.el_pos)
     # boundary condition
     self.ex_mat=eit_scan_lines(self.n_el,self.el_dist)
      # count PDE solving times
     self.soln_count = np.zeros(2)
Пример #2
0
from __future__ import division, absolute_import, print_function

import numpy as np

import pyeit.mesh as mesh
from pyeit.mesh import quality
import pyeit.mesh.plot as mplot
from pyeit.eit.fem import Forward
from pyeit.eit.pde import pdeprtni
from pyeit.eit.utils import eit_scan_lines

# build tetrahedron
# 3D tetrahedron must have a bbox
bbox = [[-1, -1, -1], [1, 1, 1]]
# save calling convention as distmesh 2D
ms, el_pos = mesh.create(h0=0.15, bbox=bbox)

no2xy = ms['node']
el2no = ms['element']

# report the status of the 2D mesh
quality.stats(no2xy, el2no)
""" 1. FEM forward simulations """
# setup EIT scan conditions
el_dist, step = 7, 1
ex_mat = eit_scan_lines(16, el_dist)

# calculate simulated data
fwd = Forward(ms, el_pos)

# in python, index start from 0
Пример #3
0
""" demo on static solving using JAC (experimental) """
# Copyright (c) Benyuan Liu. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
from __future__ import division, absolute_import, print_function

import numpy as np
import matplotlib.pyplot as plt

# pyEIT 2D algorithms modules
from pyeit.mesh import create, set_perm
from pyeit.eit.fem import Forward
from pyeit.eit.utils import eit_scan_lines
import pyeit.eit.jac as jac
""" 1. setup """
n_el = 16
mesh_obj, el_pos = create(n_el, h0=0.1)

# test function for altering the permittivity in mesh
anomaly = [
    {
        "x": 0.4,
        "y": 0.4,
        "d": 0.2,
        "perm": 10
    },
    {
        "x": -0.4,
        "y": -0.4,
        "d": 0.2,
        "perm": 0.1
    },
Пример #4
0
# coding: utf-8
""" daeger pulmovista .eit file reading and dynamic EIT imaging """
# Copyright (c) Benyuan Liu. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
from __future__ import division, absolute_import, print_function
import numpy as np
import matplotlib.pyplot as plt

import pyeit.mesh as mesh
from pyeit.eit.utils import eit_scan_lines
from pyeit.io import DAEGER_EIT
import pyeit.eit.greit as greit
""" 0. construct mesh """
# note: you should match your electrodes orientation CCW/CW and locations
mesh_obj, el_pos = mesh.create(16, h0=0.1)
# extract node, element, sigma
pts = mesh_obj["node"]
tri = mesh_obj["element"]

# plot the mesh, visualize the electrodes locations
fig, ax = plt.subplots(figsize=(6, 6))
ax.triplot(pts[:, 0], pts[:, 1], tri, linewidth=1)
ax.plot(pts[el_pos, 0], pts[el_pos, 1], "ro")
for i, el in enumerate(el_pos):
    ax.text(pts[el, 0], pts[el, 1], str(i), fontsize=12)
ax.axis("equal")
ax.axis([-1.2, 1.2, -1.2, 1.2])
""" 1. load data """
fname = "./ID_SC_10_60.eit"
model = DAEGER_EIT(fname)
data = model.load()
Пример #5
0
# demo using stacked exMtx (the devil is in the details)
# [email protected]
# 2015-07-23

import numpy as np
import matplotlib.pyplot as plt

# pyEIT 2D algo modules
import pyeit.mesh as mesh
from pyeit.eit.fem import forward
from pyeit.eit.utils import eit_scan_lines
import pyeit.eit.jac as jac

""" 1. setup """
ms, elPos = mesh.create(16)

# test function for altering the 'alpha' in mesh dictionary
anomaly = [{'x': 0.4, 'y': 0.4, 'd': 0.2, 'alpha': 100}]
ms1 = mesh.set_alpha(ms, anom=anomaly, background=1.)

# extract node, element, alpha
no2xy = ms['node']
el2no = ms['element']
alpha = ms1['alpha'] - ms['alpha']

# show alpha
fig = plt.figure()
plt.tripcolor(no2xy[:, 0], no2xy[:, 1], el2no,
              np.real(alpha), shading='flat')
plt.colorbar()
plt.title(r'$\Delta$ Permitivity')
Пример #6
0
# author: benyuan liu <*****@*****.**>
# date: 2015-07-23
""" demo using stacked exMtx (the devil is in the details) """
from __future__ import division, absolute_import, print_function

import numpy as np
import matplotlib.pyplot as plt

# pyEIT 2D algorithm modules
import pyeit.mesh as mesh
from pyeit.eit.fem import Forward
from pyeit.eit.utils import eit_scan_lines
import pyeit.eit.jac as jac

""" 1. setup """
ms, el_pos = mesh.create(16)

# test function for altering the 'alpha' in mesh dictionary
anomaly = [{'x': 0.4, 'y': 0.4, 'd': 0.2, 'alpha': 100}]
ms1 = mesh.set_alpha(ms, anomaly=anomaly, background=1.)

# extract node, element, alpha
no2xy = ms['node']
el2no = ms['element']
alpha = ms1['alpha'] - ms['alpha']

# show alpha
fig, ax = plt.subplots(figsize=(6, 4))
im = ax.tripcolor(no2xy[:, 0], no2xy[:, 1], el2no,
                  np.real(alpha), shading='flat')
fig.colorbar(im)
Пример #7
0
""" demo on GREIT """

import numpy as np
import matplotlib.pyplot as plt

import pyeit.mesh as mesh
from pyeit.eit.fem import forward
from pyeit.eit.utils import eit_scan_lines
import pyeit.eit.greit as greit

""" 0. construct mesh """
ms, elPos = mesh.create(16, h0=0.1)

# extract node, element, alpha
no2xy = ms['node']
el2no = ms['element']

""" 1. problem setup """
# this step is not needed, actually
ms0 = mesh.set_alpha(ms, background=1.0)

# test function for altering the 'alpha' in mesh dictionary
anomaly = [{'x': 0.4,  'y': 0,    'd': 0.1, 'alpha': 10},
           {'x': -0.4, 'y': 0,    'd': 0.1, 'alpha': 10},
           {'x': 0,    'y': 0.5,  'd': 0.1, 'alpha': 0.1},
           {'x': 0,    'y': -0.5, 'd': 0.1, 'alpha': 0.1}]
ms1 = mesh.set_alpha(ms, anom=anomaly, background=1.0)
alpha = np.real(ms1['alpha'] - ms0['alpha'])

# show alpha
fig = plt.figure()
Пример #8
0
import numpy as np
import matplotlib.pyplot as plt
# import matplotlib
# matplotlib.rcParams.update({'font.size': 3})
import matplotlib.gridspec as gridspec

# pyEIT 2D algorithm modules
import pyeit.mesh as mesh
from pyeit.eit.fem import Forward
from pyeit.eit.pde import pdeprtni
from pyeit.eit.utils import eit_scan_lines
import pyeit.eit.greit as greit
import pyeit.eit.bp as bp
import pyeit.eit.jac as jac
""" 0. construct mesh structure """
ms, el_pos = mesh.create(16, h0=0.1)

# extract node, element, alpha
no2xy = ms['node']
el2no = ms['element']
""" 1. problem setup """
# this step is not needed, actually
ms0 = mesh.set_alpha(ms, background=1.0)

# test function for altering the 'alpha' in mesh dictionary
anomaly = [{
    'x': 0.4,
    'y': 0,
    'd': 0.1,
    'alpha': 10
}, {
Пример #9
0
import numpy as np

import pyeit.mesh as mesh
from pyeit.mesh import quality
import pyeit.mesh.plot as mplot
from pyeit.eit.fem import Forward
from pyeit.eit.interp2d import sim2pts
from pyeit.eit.utils import eit_scan_lines
import pyeit.eit.jac as jac

# build tetrahedron
# 3D tetrahedron must have a bbox
bbox = [[-1, -1, -1], [1, 1, 1]]
# save calling convention as distmesh 2D
mesh_obj, el_pos = mesh.create(h0=0.2, bbox=bbox)

pts = mesh_obj['node']
tri = mesh_obj['element']

# report the status of the 2D mesh
quality.stats(pts, tri)
""" 1. FEM forward simulations """
# setup EIT scan conditions
el_dist, step = 7, 1
ex_mat = eit_scan_lines(16, el_dist)

# calculate simulated data
fwd = Forward(mesh_obj, el_pos)

# in python, index start from 0
Пример #10
0
# coding: utf-8
""" demo using stacked ex_mat (the devil is in the details) """
# Copyright (c) Benyuan Liu. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
from __future__ import division, absolute_import, print_function

import numpy as np
import matplotlib.pyplot as plt

# pyEIT 2D algorithm modules
import pyeit.mesh as mesh
from pyeit.eit.fem import Forward
from pyeit.eit.utils import eit_scan_lines
import pyeit.eit.jac as jac
""" 1. setup """
mesh_obj, el_pos = mesh.create(16)

# test function for altering the permittivity in mesh
anomaly = [{"x": 0.4, "y": 0.4, "d": 0.2, "perm": 100}]
mesh_new = mesh.set_perm(mesh_obj, anomaly=anomaly, background=1.0)

# extract node, element, alpha
pts = mesh_obj["node"]
tri = mesh_obj["element"]
delta_perm = mesh_new["perm"] - mesh_obj["perm"]

# show alpha
fig, ax = plt.subplots(figsize=(6, 4))
im = ax.tripcolor(pts[:, 0],
                  pts[:, 1],
                  tri,
Пример #11
0
# coding: utf-8
# pylint: disable=invalid-name
# author: benyuan liu
""" demo for distmesh """
from __future__ import division, absolute_import, print_function

import numpy as np

import pyeit.mesh as mesh
import pyeit.mesh.plot as mplot

# build tetrahedron
# 3D tetrahedron must have a bbox
bbox = [[-1, -1, -1], [1, 1, 1]]

# save calling convention as distmesh 2D
ms, elPos = mesh.create(h0=0.2, bbox=bbox)
p = ms['node']
t = ms['element']

# print mesh quality
print('points =', p.shape)
print('simplices =', t.shape)

# create random color
f = np.random.randn(p.shape[0])
# mplot.tetplot(p, t, edge_color=(0.2, 0.2, 1.0, 1.0), alpha=0.01)
mplot.tetplot(p, t, f, alpha=0.25)
Пример #12
0
# coding: utf-8
# author: benyuan liu
""" demo on static solving using JAC (experimental) """
from __future__ import division, absolute_import, print_function

import numpy as np
import matplotlib.pyplot as plt

# pyEIT 2D algorithms modules
from pyeit.mesh import create, set_alpha
from pyeit.eit.fem import Forward
from pyeit.eit.utils import eit_scan_lines
import pyeit.eit.jac as jac
""" 1. setup """
n_el = 16
ms, el_pos = create(n_el, h0=0.1)

# test function for altering the 'alpha' in mesh dictionary
anomaly = [{
    'x': 0.4,
    'y': 0.4,
    'd': 0.2,
    'alpha': 10
}, {
    'x': -0.4,
    'y': -0.4,
    'd': 0.2,
    'alpha': 0.1
}]
# TODO: even if background changed to values other than 1.0 will fail
ms1 = set_alpha(ms, anomaly=anomaly, background=1.)
Пример #13
0
# test
# pylint: disable=no-member
""" demo for distmesh """
from __future__ import absolute_import

import numpy as np

import pyeit.mesh as mesh
import pyeit.mesh.plot as mplot

# build tetrahedron
# 3D tetrahedron must have a bbox
bbox = [[-1, -1, -1], [1, 1, 1]]

# save calling convention as distmesh 2D
ms, elPos = mesh.create(h0=0.2, bbox=bbox)
p = ms['node']
t = ms['element']

# print mesh quality
print('points =', p.shape)
print('simplices =', t.shape)

# create random color
f = np.random.randn(p.shape[0])
# mplot.tetplot(p, t, edge_color=(0.2, 0.2, 1.0, 1.0), alpha=0.01)
mplot.tetplot(p, t, f, alpha=0.25)
Пример #14
0
 def _construct_mesh(self):
     mesh_obj, el_pos = mesh.create(16, h0=0.17)
     return mesh_obj, el_pos
Пример #15
0
""" demo on static solving using JAC (experimental) """

import numpy as np
import matplotlib.pyplot as plt

# pyEIT 2D algo modules
from pyeit.mesh import create, set_alpha
from pyeit.eit.fem import forward
from pyeit.eit.utils import eit_scan_lines
import pyeit.eit.jac as jac

""" 1. setup """
numEl = 16
ms, elPos = create(numEl, h0=0.1)

# test function for altering the 'alpha' in mesh dictionary
anomaly = [{'x': 0.4, 'y': 0.4, 'd': 0.2, 'alpha': 10},
           {'x': -0.4, 'y': -0.4, 'd': 0.2, 'alpha': 0.1}]
# TODO: even if background changed to values other than 1.0 will fail
ms1 = set_alpha(ms, anom=anomaly, background=1.)

# extract node, element, alpha
no2xy = ms['node']
el2no = ms['element']
alpha = ms1['alpha']

# show
fig = plt.figure()
plt.tripcolor(no2xy[:, 0], no2xy[:, 1], el2no,
              np.real(alpha), shading='flat')
plt.colorbar()