Esempio n. 1
0
def main():
    np.set_printoptions(precision=3)
    w = 1
    l = 1
    h = 1
    vrt = np.array \
    ( [ [-w/2, 0, -h/2]
      , [-w/2, 0,  h/2]
      , [ w/2, 0,  h/2]
      , [ w/2, 0, -h/2]
      , [-w/2, l,  0  ]
      , [ w/2, l,  0  ] ] )
    tet = np.array \
    ( [ [0, 1, 3, 5]
      , [1, 2, 3, 5]
      , [0, 1, 4, 5] ] )
    tri = np.array \
    ( [ [0, 1, 4]
      , [2, 3, 5] ] )
    lin = np.array( [ [0, 3] ] )
    v2e, bwh = p04.edge_num_banded(tet)
    pgroups = [ (p04.racc, p01.isrc(3, [1/(0.5*h*l),0,0]), tet)
              , (p04.lacc, p01.volume(1/140e-8, p04.e0, p04.u0), tet) ]
    freq = 50
    sol = p04.solve_geom(freq, vrt, pgroups, v2e.nnz, v2e, bwh)
    print(sol)
    print(p04.isrc_v(sol, vrt, lin, v2e, [1,0,0]))
    print(140e-8*w/(0.5*h*l))
Esempio n. 2
0
def main():
    np.set_printoptions(precision=3)
    w = 1
    l = 1
    h = 1
    vrt = np.array \
    ( [ [-w/2, 0, -h/2]
      , [-w/2, 0,  h/2]
      , [ w/2, 0,  h/2]
      , [ w/2, 0, -h/2]
      , [-w/2, l,  0  ]
      , [ w/2, l,  0  ] ] )
    tet = np.array \
    ( [ [0, 1, 3, 5]
      , [1, 2, 3, 5]
      , [0, 1, 4, 5] ] )
    tri = np.array \
    ( [ [0, 1, 4]
      , [2, 3, 5] ] )
    lin = np.array([[0, 3]])
    v2e, bwh = p04.edge_num_banded(tet)
    pgroups = [(p04.racc, p01.isrc(1, [1, 0, 0]), lin),
               (p04.lacc, p01.volume(0, p04.e0, p04.u0), tet),
               (p04.pec, lambda f, p: None, tri)]
    freq = 50
    sol = p04.solve_geom(freq, vrt, pgroups, v2e.nnz, v2e, bwh)
    print(sol)
    print(p04.isrc_v(sol, vrt, lin, v2e, [1, 0, 0]))
    print(1 / (p04.e0 * 0.5 * h * l / w * 2 * np.pi * freq))
Esempio n. 3
0
def main():
    np.set_printoptions(precision=3)
    vrt, pgroups, tet, probe = get_mesh()
    tet = np.concatenate(tuple(tet))
    v2e, bwh = p04.edge_num_banded(tet)
    print(v2e.nnz, bwh)
    for freq in [1e9, 2e9]:
        sol = p04.solve_geom(freq, vrt, pgroups, v2e.nnz, v2e, bwh)
        print(sol)
        print(p04.isrc_v(sol, vrt, probe[0], v2e, [0,0,1]))
        print(2*np.pi/3*(p04.u0/p04.e0)**0.5*(0.01/(p04.c/freq))**2)
Esempio n. 4
0
def main():
    np.set_printoptions(precision=3)
    vrt, pgroups, tet, probe = get_mesh()
    vrt *= 1e-3 # [m] -> [mm]
    tet = np.concatenate(tuple(tet))
    v2e, bwh = p04.edge_num_banded(tet)
    print(v2e.nnz, bwh)
    for freq in [1, 10, 100, 1e3, 10e3, 100e6]:
        sol = p04.solve_geom(freq, vrt, pgroups, v2e.nnz, v2e, bwh)
        print(sol)
        print(p04.isrc_v(sol, vrt, probe[0], v2e, [0,1,0]))
        print(140e-8*2*np.pi*0.1/(0.01**2*np.pi))
        print(p04.u0*0.1*(np.log(8*0.1/0.01)-2)*2*np.pi*freq)
Esempio n. 5
0
def main():
    w, l, h = 1, 10, 1
    np.set_printoptions(precision=3)
    vrt, pgroups, tet, probe = get_mesh(w, l, h)
    print(pgroups)
    tet = np.concatenate(tuple(tet))
    v2e, bwh = p04.edge_num_banded(tet)
    print(v2e.nnz, bwh)
    for freq in [100, 1e3, 10e3, 100e3, 1e6]:
        sol = p04.solve_geom(freq, vrt, pgroups, v2e.nnz, v2e, bwh)
        print(sol)
        print(p04.isrc_v(sol, vrt, probe[0], v2e, [0, 0, 1]))
        print(2 * np.pi * freq * p04.u0 * (l * h) / w)
Esempio n. 6
0
def main():
    #np.set_printoptions(precision=3)
    w = 1
    l = 1
    h = 1
    vrt = np.array \
    ( [ [-w/2, 0, -h/2]
      , [-w/2, 0,  h/2]
      , [ w/2, 0,  h/2]
      , [ w/2, 0, -h/2]
      , [-w/2, l, -h/2]
      , [-w/2, l,  h/2]
      , [ w/2, l,  h/2]
      , [ w/2, l, -h/2] ] )
    tet = np.array \
    ( [ [0, 1, 3, 7]
      , [0, 1, 4, 7]
      , [1, 2, 3, 7]
      , [1, 2, 6, 7]
      , [1, 4, 5, 7]
      , [1, 5, 6, 7] ] )
    pec = np.array \
    ( [ [0, 3, 7]
      , [0, 4, 7]
      , [1, 2, 6]
      , [1, 5, 6] ] )
    isrc = np.array \
    ( [ [0, 1, 3]
      , [1, 2, 3] ])
    absorb = np.array \
    ( [ [4, 5, 7]
      , [5, 6, 7] ])
    v2e, bwh = p04.edge_num_banded(tet)
    print(v2e)
    pgroups = [('e2', ([0, 0, 1], ), isrc), ('a', (), isrc), ('a', (), absorb),
               ('v', (0, p04.e0, p04.u0), tet), ('b', (), pec)]
    freq = 1e6
    sol = p04.solve_geom(freq, vrt, pgroups, v2e.nnz, v2e, bwh)
    print(sol)
    print(0.5 * (p04.u0 / p04.e0)**0.5 * h)
    print(-2 * np.pi * freq * l / p04.c * 180 / np.pi)
    v_src = p04.isrc_v(sol, vrt, np.array([[0, 1]]), v2e, [0, 0, 1])
    print(v_src)
    print(np.angle(-v_src) * 180 / np.pi)
    v_out = p04.isrc_v(sol, vrt, np.array([[4, 5]]), v2e, [0, 0, 1])
    print(v_out)
    print(np.abs(v_out))
    print(np.angle(-v_out) * 180 / np.pi)
Esempio n. 7
0
def main():
    np.set_printoptions(precision=3)
    vrt, pgroups = get_mesh()
    vrt = np.moveaxis(vrt, 0, 1)
    tet = []
    for ptype, _, nodes in pgroups:
        if ptype == 'v':
            tet.append(nodes)
    print(pgroups)
    tet = np.concatenate(tuple(tet))
    v2e, bwh = p04.edge_num_banded(tet)
    for freq in [100, 1e3, 10e3, 100e3, 1e6]:
        sol = p04.solve_geom(freq, vrt, pgroups, v2e.nnz, v2e, bwh)
        print(sol)
        for ptype, attr, nodes in pgroups:
            if ptype == 'e':
                print(p04.isrc_v(sol, vrt, nodes, v2e, attr[0]))
        print(1 / (p04.e0 * 0.5 * 2 * np.pi * freq))
Esempio n. 8
0
def main():
    np.set_printoptions(precision=3)
    w = 4
    l = 14
    h = 2
    vrt = np.array \
    ( [ [   0, 0, -h/2]
      , [   0, 0,  h/2]
      , [-w/2, l,    0]
      , [ w/2, l,    0] ] )
    tet = np.array \
    ( [ [0, 1, 2, 3] ] )
    lin = np.array([[0, 1]])
    v2e, bwh = p04.edge_num_banded(tet)
    pgroups = [(p04.racc, p01.isrc(1, [0, 0, 1]), tet),
               (p04.lacc, p01.volume(0, p04.e0, p04.u0), tet)]
    freq = 50
    sol = p04.solve_geom(freq, vrt, pgroups, v2e.nnz, v2e, bwh)
    print(sol)
    print(p04.isrc_v(sol, vrt, lin, v2e, [0, 0, 1]))
    print(2 * (1 / freq) / 4 * (2 / np.pi) / (4 * np.pi * p04.e0 * 0.5 * h))
Esempio n. 9
0
import numpy as np
import p04 as dut

tet = np.array \
( [ [0, 1, 2, 4]
      , [1, 2, 3, 4]
      , [0, 1, 4, 5] ] )

dut.edge_num_banded(tet)