Esempio n. 1
0
    def test_TE_modes(self):
        mesh = dolfin.UnitSquare ( 5, 5 )
        a = 1.0
        b = 1.0
        mesh.coordinates()[:,0] = a*mesh.coordinates()[:,0]
        mesh.coordinates()[:,1] = b*mesh.coordinates()[:,1]
        
        pec_walls = PECWallsBoundaryCondition ()
        pec_walls.init_with_mesh ( mesh )
        
        # Use 3rd order basis functions 
        order = 3
        # Set up the eigen problem
        ep = EigenProblem()
        ep.set_mesh(mesh)
        ep.set_basis_order(order)
        ep.set_boundary_conditions(pec_walls)
        ep.init_problem()
        
        # Set up eigen problem solver where sigma is the shift to use
        # in the shift-invert process
        sigma = 1.5
        es = DefaultEigenSolver()
        es.set_eigenproblem(ep)
        es.set_sigma(sigma)

        # Solve the eigenproblem
        eigs_w, eigs_v = es.solve_problem(10)

        # Output the results
        res = np.array(sorted(eigs_w)[0:])
        res = np.sqrt(res)/np.pi
        
        steps = 5
        abd = (a, b)
        ids = []
        values = []
        for m in range(steps):
            for n in range(steps):
                l = 0
                i = (m,n)
                if i.count(0) < 2:
                    ids.append((m,n,l))
                    values.append(k_mnl ( abd, m, n, l, True ))

        r = 0;
        errors = np.zeros_like(res)
        for i in np.argsort(values).tolist():
            if r < len(res):
                errors[r] = np.linalg.norm( res[r] - values[i])/np.linalg.norm( values[i] )
                
                r += 1
            else:
                break;

        np.testing.assert_array_almost_equal( errors, np.zeros_like(res), 4 )
Esempio n. 2
0
mesh = dol.UnitCube(4, 4, 4)
a = 1.0
b = 1.0
d = 1.0
mesh.coordinates()[:, 0] = a * mesh.coordinates()[:, 0]
mesh.coordinates()[:, 1] = b * mesh.coordinates()[:, 1]
mesh.coordinates()[:, 2] = d * mesh.coordinates()[:, 2]

# init the PEC walls boundary condition
pec_walls = PECWallsBoundaryCondition()
pec_walls.init_with_mesh(mesh)

# Use 3rd order basis functions
order = 3
# Set up the eigen problem
ep = EigenProblem()
ep.set_mesh(mesh)
ep.set_basis_order(order)
ep.set_boundary_conditions(pec_walls)
ep.init_problem()

# Set up eigen problem solver where sigma is the shift to use in the shift-invert process
sigma = 1.1
es = DefaultEigenSolver()
es.set_eigenproblem(ep)
es.set_sigma(sigma)

# Solve the eigenproblem
eigs_w, eigs_v = es.solve_problem(10)

# Output the results
Esempio n. 3
0
mesh = dol.UnitCube ( 4, 4, 4 )
a = 1.0
b = 1.0
d = 1.0
mesh.coordinates()[:,0] = a*mesh.coordinates()[:,0]
mesh.coordinates()[:,1] = b*mesh.coordinates()[:,1]
mesh.coordinates()[:,2] = d*mesh.coordinates()[:,2]

# init the PEC walls boundary condition
pec_walls = PECWallsBoundaryCondition ()
pec_walls.init_with_mesh ( mesh ) 

# Use 3rd order basis functions 
order = 3
# Set up the eigen problem
ep = EigenProblem()
ep.set_mesh(mesh)
ep.set_basis_order(order)
ep.set_boundary_conditions ( pec_walls )
ep.init_problem()

# Set up eigen problem solver where sigma is the shift to use in the shift-invert process
sigma = 1.1
es = DefaultEigenSolver()
es.set_eigenproblem(ep)
es.set_sigma(sigma)

# Solve the eigenproblem
eigs_w, eigs_v = es.solve_problem(10)

# Output the results
Esempio n. 4
0
# Define mesh
# mesh = dol.UnitCube(1,1,1)
# mesh.coordinates()[:] *= [cdims.a,cdims.b,cdims.c]
#mesh_file = 'lee_mittra92_fig6b.xml'
#mesh_file = 'lee_mittra92_fig6c.xml'
mesh_file = '../../examples/albani_bernardi74/mesh/albani_bernardi74_fig2VII.xml'
materials_mesh_file = "%s_physical_region%s" % (os.path.splitext(mesh_file))
mesh = dol.Mesh(mesh_file)
material_mesh_func = dol.MeshFunction('uint', mesh, materials_mesh_file)
materials = {1000: dict(eps_r=16), 1001: dict(eps_r=1)}
order = 3
sigma = 1.5

# Set up eigen problem
ep = EigenProblem()
ep.set_mesh(mesh)
ep.set_basis_order(order)
ep.set_material_regions(materials)
ep.set_region_meshfunction(material_mesh_func)
ep.init_problem()

# Set up eigen problem linear solution
es = DefaultEigenSolver()
es.set_eigenproblem(ep)
es.set_sigma(sigma)
eigs_w, eigs_v = es.solve_problem(10)

res = N.array(sorted(eigs_w)[0:10])
print N.sqrt(res)
print c0 * N.sqrt(res) / 2 / N.pi / 1e6
Esempio n. 5
0
# Load the mesh and the material region markers
mesh_file = os.path.join(script_path, "mesh/albani_bernardi74_fig2VII.xml")
materials_mesh_file = "%s_physical_region%s" % (os.path.splitext(mesh_file))
mesh = dol.Mesh(mesh_file)
material_mesh_func = dol.MeshFunction("uint", mesh, materials_mesh_file)
# Define the dielectric properties of the regions in the mesh
materials = {1000: dict(eps_r=16), 1001: dict(eps_r=1)}

# init the PEC walls boundary condition
pec_walls = PECWallsBoundaryCondition()
pec_walls.init_with_mesh(mesh)

# Use 3rd order basis functions
order = 3
# Set up the eigen problem
ep = EigenProblem()
ep.set_mesh(mesh)
ep.set_basis_order(order)
ep.set_boundary_conditions(pec_walls)
ep.set_material_regions(materials)
ep.set_region_meshfunction(material_mesh_func)
ep.init_problem()

# Set up eigen problem solver where sigma is the shift to use in the shift-invert process
sigma = 1.5
es = DefaultEigenSolver()
es.set_eigenproblem(ep)
es.set_sigma(sigma)

# Solve the eigenproblem
eigs_w, eigs_v = es.solve_problem(10)
Esempio n. 6
0
from sucemfem.ProblemConfigurations.EMVectorWaveEigenproblem import DefaultEigenSolver
from sucemfem.Consts import c0
del sys.path[0]

script_path = os.path.dirname(__file__)
# Load the mesh and the material region markers
mesh = dol.UnitSquare(5, 5)
a = 1.0
b = 1.0
mesh.coordinates()[:, 0] = a * mesh.coordinates()[:, 0]
mesh.coordinates()[:, 1] = b * mesh.coordinates()[:, 1]

# Use 4th order basis functions
order = 4
# Set up the eigen problem
ep = EigenProblem()
ep.set_mesh(mesh)
ep.set_basis_order(order)
ep.init_problem()

# Set up eigen problem solver where sigma is the shift to use in the
# shift-invert process
sigma = 1.5
es = DefaultEigenSolver()
es.set_eigenproblem(ep)
es.set_sigma(sigma)

# Solve the eigenproblem
eigs_w, eigs_v = es.solve_problem(10)

# Output the results
Esempio n. 7
0
from sucemfem.ProblemConfigurations.EMVectorWaveEigenproblem import DefaultEigenSolver
from sucemfem.Consts import c0
del sys.path[0]

script_path = os.path.dirname(__file__)
# Load the mesh and the material region markers
mesh = dol.UnitSquare ( 5, 5 )
a = 1.0
b = 1.0
mesh.coordinates()[:,0] = a*mesh.coordinates()[:,0]
mesh.coordinates()[:,1] = b*mesh.coordinates()[:,1]
 
# Use 4th order basis functions 
order = 4
# Set up the eigen problem
ep = EigenProblem()
ep.set_mesh(mesh)
ep.set_basis_order(order)
ep.init_problem()

# Set up eigen problem solver where sigma is the shift to use in the
# shift-invert process
sigma = 1.5
es = DefaultEigenSolver()
es.set_eigenproblem(ep)
es.set_sigma(sigma)

# Solve the eigenproblem
eigs_w, eigs_v = es.solve_problem(10)

# Output the results
Esempio n. 8
0
# Define mesh
# mesh = dol.UnitCube(1,1,1)
# mesh.coordinates()[:] *= [cdims.a,cdims.b,cdims.c]
#mesh_file = 'lee_mittra92_fig6b.xml'
#mesh_file = 'lee_mittra92_fig6c.xml'
mesh_file = '../../examples/albani_bernardi74/mesh/albani_bernardi74_fig2VII.xml'
materials_mesh_file = "%s_physical_region%s" % (os.path.splitext(mesh_file))
mesh = dol.Mesh(mesh_file)
material_mesh_func = dol.MeshFunction('uint', mesh, materials_mesh_file)
materials = {1000:dict(eps_r=16),
             1001:dict(eps_r=1)}
order = 3
sigma = 1.5

# Set up eigen problem
ep = EigenProblem()
ep.set_mesh(mesh)
ep.set_basis_order(order)
ep.set_material_regions(materials)
ep.set_region_meshfunction(material_mesh_func)
ep.init_problem()

# Set up eigen problem linear solution
es = DefaultEigenSolver()
es.set_eigenproblem(ep)
es.set_sigma(sigma)
eigs_w, eigs_v = es.solve_problem(10)


res = N.array(sorted(eigs_w)[0:10])
print N.sqrt(res)
Esempio n. 9
0
 def test_gmsh_resonant_cavity(self):
     mesh_folder = os.path.join(get_module_path(__file__), "data/meshes")
     mesh_base_name = "rectangular_prism"
     mesh_extension = ".xml"
     mesh = dolfin.Mesh ( os.path.join (mesh_folder, mesh_base_name + mesh_extension))
     
     a = 1.0;
     b = 0.5;
     d = 0.25;
     # load the mesh function defining the boundaries
     pec_filename = os.path.join(mesh_folder, "%s_%s%s" % (
         mesh_base_name, "facet_region", mesh_extension))
     pec_mesh_function = dolfin.MeshFunction ( 'uint', mesh, pec_filename)
     
     pec_walls = PECWallsBoundaryCondition ()
     pec_walls.init_with_meshfunction ( pec_mesh_function, 1 )
     
     order = 4;
     ep = EigenProblem()
     ep.set_mesh(mesh)
     ep.set_basis_order(order)
     ep.set_boundary_conditions ( pec_walls )
     ep.init_problem()
     
     # Set up eigen problem solver where sigma is the shift to use
     # in the shift-invert process
     sigma = 1.1
     es = DefaultEigenSolver()
     es.set_eigenproblem(ep)
     es.set_sigma(sigma)
     
     # Solve the eigenproblem
     eigs_w, eigs_v = es.solve_problem(10)
     
     # Output the results
     res = np.array(sorted(eigs_w)[0:])
     res = np.sqrt(res)/np.pi
     
     steps = 5
     abd = (a, b, d)
     ids = []
     values = []
     for m in range(steps):
         for n in range(steps):
             for l in range(steps):
                 i = (m,n,l)
                 if i.count(0) < 2:
                     ids.append((m,n,l))
                     values.append(k_mnl ( abd, m, n, l, True ))
                 
                 # mode is both a TE and TM mode            
                 if i.count( 0 ) == 0:
                     ids.append((m,n,l))
                     values.append(k_mnl ( abd, m, n, l, True ))
     
     r = 0;
     errors = np.zeros_like(res)
     for i in np.argsort(values).tolist():
         if r < len(res):
             errors[r] = np.linalg.norm(
                 res[r] - values[i])/np.linalg.norm( values[i] )
             r += 1
         else:
             break;
     
     np.testing.assert_array_almost_equal( errors, np.zeros_like(res), 4 )