Пример #1
0
    def setUp(self):
        self.problem = a2d.problem(clear = True)
        self.problem.time_step_method = "fixed"
        self.problem.time_method_order = 2
        self.problem.time_total = 10
        self.problem.time_steps = 10
        
        self.field = a2d.field("heat")
        self.field.analysis_type = "transient"
        self.field.transient_initial_condition = 293.15
        self.field.number_of_refinements = 0
        self.field.polynomial_order = 1
        self.field.adaptivity_type = "hp-adaptivity"

        self.field.add_boundary("Neumann", "heat_heat_flux", {"heat_heat_flux" : 0, "heat_convection_heat_transfer_coefficient" : 0,
                                                              "heat_convection_external_temperature" : 0, "heat_radiation_emissivity" : 0,
                                                              "heat_radiation_ambient_temperature" : 0})
        self.field.add_boundary("Dirichlet", "heat_temperature", {"heat_temperature" : { "expression" : "293.15*(time<4) + 393.15*(time>=4)" }})

        self.field.add_material("Material", {"heat_conductivity" : 237, "heat_volume_heat" : 0, "heat_density" : 2700, "heat_specific_heat" : 896})

        geometry = a2d.geometry
        geometry.add_edge(0.25, 0, 0, 0.25, angle = 90, boundaries = {"heat" : "Neumann"})
        geometry.add_edge(0, 0.25, -0.25, 0, angle = 90, boundaries = {"heat" : "Neumann"})
        geometry.add_edge(-0.25, 0, 0, -0.25, angle = 90, boundaries = {"heat" : "Neumann"})
        geometry.add_edge(0, -0.25, 0.25, 0, angle = 90, boundaries = {"heat" : "Neumann"})
        geometry.add_edge(0.05, 0, 0, 0.05, boundaries = {"heat" : "Dirichlet"})
        geometry.add_edge(0, 0.05, -0.05, 0, boundaries = {"heat" : "Dirichlet"})
        geometry.add_edge(-0.05, 0, 0, -0.05, boundaries = {"heat" : "Dirichlet"})
        geometry.add_edge(0, -0.05, 0.05, 0, boundaries = {"heat" : "Dirichlet"})

        geometry.add_label(0, 0, materials = {"heat" : "none"})
        geometry.add_label(0.15, 0, materials = {"heat" : "Material"})
        a2d.view.zoom_best_fit()
Пример #2
0
    def setUpClass(cls):
        problem = a2d.problem(clear = True)
        problem.coordinate_type = "planar"
        problem.mesh_type = "triangle"

        electrostatic = a2d.field("electrostatic")
        electrostatic.analysis_type = "steadystate"
        electrostatic.matrix_solver = "mumps"
        electrostatic.number_of_refinements = 1
        electrostatic.polynomial_order = 2
        electrostatic.adaptivity_type = "disabled"
        electrostatic.solver = "linear"

        electrostatic.add_boundary("Source", "electrostatic_potential", {"electrostatic_potential" : 0})
        electrostatic.add_boundary("Ground", "electrostatic_potential", {"electrostatic_potential" : 0})
        electrostatic.add_boundary("Neumann", "electrostatic_surface_charge_density", {"electrostatic_surface_charge_density" : 0})
        electrostatic.add_material("Air", {"electrostatic_permittivity" : 1, "electrostatic_charge_density" : 0})

        geometry = a2d.geometry

        d = 1
        h = 1

        geometry.add_edge(-d/2.0, 0, d/2.0, 0, boundaries = {"electrostatic" : "Neumann"})
        geometry.add_edge(d/2.0, 0, d/2.0, h, boundaries = {"electrostatic" : "Ground"})
        geometry.add_edge(d/2.0, h, -d/2.0, h, boundaries = {"electrostatic" : "Neumann"})
        geometry.add_edge(-d/2.0, h, -d/2.0, 0, boundaries = {"electrostatic" : "Source"})

        geometry.add_label(0, h/2.0, materials = {"electrostatic" : "Air"})
        a2d.view.zoom_best_fit()

        problem.solve()
Пример #3
0
    def setUp(self):
        self.problem = a2d.problem(clear=True)
        self.problem.time_step_method = "fixed"
        self.problem.time_total = 1e2
        self.problem.time_steps = 10

        heat = a2d.field('heat')
        heat.analysis_type = 'transient'
        heat.add_boundary(
            "Convection", "heat_heat_flux", {
                "heat_convection_heat_transfer_coefficient": 10,
                "heat_convection_external_temperature": 293
            })
        heat.add_material(
            "Copper", {
                "heat_conductivity": 200,
                "heat_volume_heat": 1e3,
                "heat_density": 8700,
                "heat_specific_heat": 385
            })

        a2d.geometry.add_rect(0,
                              0,
                              1,
                              1,
                              boundaries={'heat': 'Convection'},
                              materials={'heat': 'Copper'})
Пример #4
0
 def setUp(self):  
     # model
     self.problem = agros2d.problem(clear = True)
     self.problem.coordinate_type = "planar"
     self.problem.mesh_type = "triangle"
     self.problem.frequency = 100
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.magnetic = agros2d.field("magnetic")
     self.magnetic.analysis_type = "steadystate"
     self.magnetic.number_of_refinements = 1
     self.magnetic.polynomial_order = 5
     self.magnetic.solver = "linear"
     
     self.magnetic.add_boundary("A = 0", "magnetic_potential", {"magnetic_potential_real" : 0})
     
     self.magnetic.add_material("Fe", {"magnetic_permeability" : 500}) 
     self.magnetic.add_material("Air", {"magnetic_permeability" : 1}) 
     self.magnetic.add_material("Magnet", {"magnetic_permeability" : 1.11, "magnetic_remanence" : 0.1, "magnetic_remanence_angle" : -30}) 
     self.magnetic.add_material("Velocity", {"magnetic_permeability" : 1, "magnetic_conductivity" : 1e7, "magnetic_velocity_x" : 2})
     
     # geometry
     self.geometry = agros2d.geometry
     
     # edges
     self.geometry.add_edge(-0.5, 1, 0.5, 1, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(0.5, -1, -0.5, -1, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(-0.2, 0.6, 0, 0.6)
     self.geometry.add_edge(0, 0.3, 0, 0.6)
     self.geometry.add_edge(-0.2, 0.3, 0, 0.3)
     self.geometry.add_edge(-0.2, 0.6, -0.2, 0.3)
     self.geometry.add_edge(-0.035, 0.135, 0.035, 0.135)
     self.geometry.add_edge(0.035, 0.135, 0.035, -0.04)
     self.geometry.add_edge(0.035, -0.04, -0.035, -0.04)
     self.geometry.add_edge(-0.035, 0.135, -0.035, -0.04)
     self.geometry.add_edge(0, -0.5, 0.3, -0.5)
     self.geometry.add_edge(0.3, -0.5, 0.3, -0.32)
     self.geometry.add_edge(0.3, -0.32, 0, -0.32)
     self.geometry.add_edge(0, -0.32, 0, -0.5)
     self.geometry.add_edge(-0.5, 1, -0.5, -0.15, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(-0.5, -0.15, -0.5, -0.2, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(-0.5, -0.2, -0.5, -1, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(0.5, 1, 0.5, -0.15, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(0.5, -0.15, 0.5, -0.2, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(0.5, -0.2, 0.5, -1, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(0.5, -0.2, -0.5, -0.2)
     self.geometry.add_edge(0.5, -0.15, -0.5, -0.15)
     
     # labels
     self.geometry.add_label(-0.0959509, 0.445344, area = 0.0002, materials = {"magnetic" : "Fe"})
     self.geometry.add_label(-0.145434, -0.706253, area = 0.01, materials = {"magnetic" : "Air"})
     self.geometry.add_label(0.143596, -0.364811, materials = {"magnetic" : "Magnet"})
     self.geometry.add_label(0.310203, 0.631164, materials = {"magnetic" : "Air"})
     self.geometry.add_label(-0.295858, -0.182894, materials = {"magnetic" : "Velocity"})
     
     agros2d.view.zoom_best_fit()
Пример #5
0
def simple_model():
    problem = a2d.problem(clear = True)
    problem.coordinate_type = "axisymmetric"

    field = a2d.field("electrostatic")
    field.adaptivity_type = "hp-adaptivity"
    field.number_of_refinements = 1
    field.polynomial_order = 2
    field.adaptivity_parameters["steps"] = 10
    field.adaptivity_parameters["tolerance"] = 1
    
    field.add_boundary("Source", "electrostatic_potential", {"electrostatic_potential" : 1000})
    field.add_boundary("Ground", "electrostatic_potential", {"electrostatic_potential" : 0})
    field.add_boundary("Border", "electrostatic_surface_charge_density", {"electrostatic_surface_charge_density" : 0})
    field.add_material("Air", {"electrostatic_permittivity" : 1, "electrostatic_charge_density" : 0})
    
    geometry = a2d.geometry
    geometry.add_edge(0.2, 0.6, 0, 0.1, boundaries = {"electrostatic" : "Source"})
    geometry.add_edge(0, 0.1, 0, -0.1, boundaries = {"electrostatic" : "Border"})
    geometry.add_edge(0, -0.6, 0, -1.6, boundaries = {"electrostatic" : "Border"})
    geometry.add_edge(0, 0.6, 0.2, 0.6, boundaries = {"electrostatic" : "Source"})
    geometry.add_edge(0, 1.6, 0, 0.6, boundaries = {"electrostatic" : "Border"})
    geometry.add_edge(0, -0.1, 0.2, -0.6, boundaries = {"electrostatic" : "Ground"})
    geometry.add_edge(0, -0.6, 0.2, -0.6, boundaries = {"electrostatic" : "Ground"})
    geometry.add_edge(0, 1.6, 1.6, 1.6, boundaries = {"electrostatic" : "Border"})
    geometry.add_edge(1.6, 1.6, 1.6, -1.6, boundaries = {"electrostatic" : "Border"})
    geometry.add_edge(1.6, -1.6, 0, -1.6, boundaries = {"electrostatic" : "Border"})    
    geometry.add_label(0.8, 0.8, materials = {"electrostatic" : "Air"})
Пример #6
0
    def create(self):

        # startup script
        R1 = self.parameters["R1"]
        R2 = self.parameters["R2"]
        R3 = self.parameters["R3"]
        R4 = self.parameters["R4"]
        L = self.parameters["L"]
        RB = 3.0*R4
        
        self.U = 10
        eps1 = 3
        eps2 = 4
        
        # problem
        self.problem = a2d.problem(clear = True)
        self.problem.coordinate_type = "axisymmetric"
        self.problem.mesh_type = "triangle"
        
        # electrostatic
        self.electrostatic = a2d.field("electrostatic")
        self.electrostatic.analysis_type = "steadystate"
        self.electrostatic.matrix_solver = "mumps"
        self.electrostatic.number_of_refinements = 1
        self.electrostatic.polynomial_order = 4
        self.electrostatic.adaptivity_type = "disabled"
        self.electrostatic.solver = "linear"        
        
        # boundaries
        self.electrostatic.add_boundary("Source", "electrostatic_potential", {"electrostatic_potential" : self.U})
        self.electrostatic.add_boundary("Ground", "electrostatic_potential", {"electrostatic_potential" : 0})
        self.electrostatic.add_boundary("Neumann", "electrostatic_surface_charge_density", {"electrostatic_surface_charge_density" : 0})
                
        # materials
        self.electrostatic.add_material("Air", {"electrostatic_permittivity" : 1, "electrostatic_charge_density" : 0})
        self.electrostatic.add_material("Dielectric 1", {"electrostatic_permittivity" : eps1, "electrostatic_charge_density" : 0})
        self.electrostatic.add_material("Dielectric 2", {"electrostatic_permittivity" : eps2, "electrostatic_charge_density" : 0})
        
        # geometry
        geometry = a2d.geometry
        geometry.add_edge(0, RB, 0, L, boundaries = {"electrostatic" : "Neumann"})
        geometry.add_edge(R1, L, R1, 0, refinements = {"electrostatic" : 1}, boundaries = {"electrostatic" : "Source"})
        geometry.add_edge(R1, 0, R2, 0, boundaries = {"electrostatic" : "Neumann"})
        geometry.add_edge(R2, 0, R2, L)
        geometry.add_edge(R2, L, R3, L)
        geometry.add_edge(R3, 0, R2, 0, boundaries = {"electrostatic" : "Neumann"})
        geometry.add_edge(R3, L, R3, 0, refinements = {"electrostatic" : 1}, boundaries = {"electrostatic" : "Ground"})
        geometry.add_edge(R4, 0, R4, L, boundaries = {"electrostatic" : "Ground"})
        geometry.add_edge(R3, L, R4, L, refinements = {"electrostatic" : 1}, boundaries = {"electrostatic" : "Ground"})
        geometry.add_edge(R4, 0, RB, 0, boundaries = {"electrostatic" : "Neumann"})
        geometry.add_edge(RB, 0, 0, RB, angle = 90, boundaries = {"electrostatic" : "Neumann"})
        geometry.add_edge(R1, L, R2, L)
        geometry.add_edge(R1, L, 0, L, refinements = {"electrostatic" : 1}, boundaries = {"electrostatic" : "Source"})
        
        geometry.add_label((R1+R2)/2.0, L/2.0, materials = {"electrostatic" : "Dielectric 1"})
        geometry.add_label((R2+R3)/2.0, L/2.0, materials = {"electrostatic" : "Dielectric 2"})
        geometry.add_label(R1, RB-R1, materials = {"electrostatic" : "Air"})
        
        a2d.view.zoom_best_fit()
Пример #7
0
    def setUp(self):         
        # problem
        problem = agros2d.problem(clear = True)
        problem.coordinate_type = "planar"
        problem.mesh_type = "gmsh_quad_delaunay"        
        
        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()

        # flow
        self.flow = agros2d.field("flow")
        self.flow.analysis_type = "steadystate"
        self.flow.number_of_refinements = 2
        self.flow.polynomial_order = 2
        
        self.flow.solver = "newton"
        self.flow.solver_parameters['residual'] = 0.0001
        self.flow.solver_parameters['damping'] = 'automatic'
        self.flow.solver_parameters['damping_factor'] = 1.0
        self.flow.solver_parameters['jacobian_reuse'] = False
        
        # boundaries        
        self.flow.add_boundary("Inlet", "flow_velocity", {"flow_velocity_x" : { "expression" : "cos((y-0.135)/0.035*pi/2)" }, "flow_velocity_y" : 0})
        self.flow.add_boundary("Wall", "flow_velocity", {"flow_velocity_x" : 0, "flow_velocity_y" : 0})
        self.flow.add_boundary("Outlet", "flow_outlet", {})
        
        # materials        
        self.flow.add_material("Water", {"flow_density" : 1, "flow_force_x" : 0, "flow_force_y" : 0, "flow_viscosity" : 0.001})
        
        # geometry
        geometry = agros2d.geometry
        geometry.add_edge(-0.35, 0.05, 0.4, 0.05, boundaries = {"flow" : "Wall"})
        geometry.add_edge(0.4, 0.05, 0.4, 0.25, boundaries = {"flow" : "Wall"})
        geometry.add_edge(-0.25, 0.1, -0.2, 0.1, boundaries = {"flow" : "Wall"}, angle = 90)
        geometry.add_edge(-0.2, 0.1, -0.2, 0.2, boundaries = {"flow" : "Wall"}, angle = 90)
        geometry.add_edge(-0.2, 0.2, -0.25, 0.2, boundaries = {"flow" : "Wall"}, angle = 90)
        geometry.add_edge(-0.25, 0.2, -0.25, 0.1, boundaries = {"flow" : "Wall"}, angle = 90)
        geometry.add_edge(-0.35, 0.2, -0.05, 0.3, boundaries = {"flow" : "Wall"})
        geometry.add_edge(-0.05, 0.3, 0, 0.15, boundaries = {"flow" : "Wall"})
        geometry.add_edge(0, 0.15, 0.05, 0.1, boundaries = {"flow" : "Wall"}, angle = 90)
        geometry.add_edge(0.05, 0.1, 0.1, 0.15, boundaries = {"flow" : "Wall"}, angle = 90)
        geometry.add_edge(0.2, 0.3, 0.1, 0.15, boundaries = {"flow" : "Wall"})
        geometry.add_edge(0.3, 0.3, 0.3, 0.25, boundaries = {"flow" : "Wall"})
        geometry.add_edge(0.3, 0.25, 0.4, 0.25, boundaries = {"flow" : "Wall"})
        geometry.add_edge(0.2, 0.3, 0.3, 0.3, boundaries = {"flow" : "Outlet"})
        geometry.add_edge(-0.4, 0.17, -0.4, 0.1, boundaries = {"flow" : "Inlet"})
        geometry.add_edge(-0.35, 0.2, -0.35, 0.17, boundaries = {"flow" : "Wall"})
        geometry.add_edge(-0.4, 0.17, -0.35, 0.17, boundaries = {"flow" : "Wall"})
        geometry.add_edge(-0.4, 0.1, -0.35, 0.1, boundaries = {"flow" : "Wall"})
        geometry.add_edge(-0.35, 0.1, -0.35, 0.05, boundaries = {"flow" : "Wall"})
        
        geometry.add_label(-0.086153, 0.205999, materials = {"flow" : "Water"}, area = 0.00048)
        geometry.add_label(-0.224921, 0.126655, materials = {"flow" : "none"})
        
        agros2d.view.zoom_best_fit()
        
        # solve problem
        problem.solve()
Пример #8
0
    def setUp(self):
        self.problem = a2d.problem(clear = True)
        self.geometry = a2d.geometry

        for i in range(100):
            self.geometry.add_node(i*sin(i), i*cos(i))

        self.geometry.select_nodes()
Пример #9
0
    def setUp(self):
        self.problem = a2d.problem(clear = True)
        self.geometry = a2d.geometry

        for i in range(100):
            self.geometry.add_node(i*sin(i), i*cos(i))

        self.geometry.select_nodes()
Пример #10
0
 def setUp(self):  
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "axisymmetric"
     problem.mesh_type = "triangle"
     problem.frequency = 100
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.magnetic = agros2d.field("magnetic")
     self.magnetic.analysis_type = "harmonic"
     self.magnetic.matrix_solver = "mumps"
     self.magnetic.number_of_refinements = 2
     self.magnetic.polynomial_order = 3
     self.magnetic.adaptivity_type = "disabled"
     self.magnetic.solver = "linear"
             
     # boundaries
     self.magnetic.add_boundary("A = 0", "magnetic_potential", {"magnetic_potential_real" : 0, "magnetic_potential_imag" : 0})        
     
     # materials
     self.magnetic.add_material("Coil", {"magnetic_permeability" : 1, "magnetic_conductivity" : 0, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 1e+06, "magnetic_current_density_external_imag" : 0, "magnetic_total_current_prescribed" : 0, "magnetic_total_current_real" : 0, "magnetic_total_current_imag" : 0})
     self.magnetic.add_material("Iron", {"magnetic_permeability" : 50, "magnetic_conductivity" : 5000, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0, "magnetic_current_density_external_imag" : 0, "magnetic_total_current_prescribed" : 0, "magnetic_total_current_real" : 0, "magnetic_total_current_imag" : 0})
     self.magnetic.add_material("Air", {"magnetic_permeability" : 1, "magnetic_conductivity" : 0, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0, "magnetic_current_density_external_imag" : 0, "magnetic_total_current_prescribed" : 0, "magnetic_total_current_real" : 0, "magnetic_total_current_imag" : 0})
     self.magnetic.add_material("Coil2", {"magnetic_permeability" : 1, "magnetic_conductivity" : 1e6, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0, "magnetic_current_density_external_imag" : 0, "magnetic_total_current_prescribed" : 1, "magnetic_total_current_real" : 5000, "magnetic_total_current_imag" : 20000})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(0, -0.17, 0.15, -0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.15, -0.17, 0.15, 0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.15, 0.17, 0, 0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.035, -0.03, 0.055, -0.03)
     geometry.add_edge(0.055, -0.03, 0.055, 0.11)
     geometry.add_edge(0.055, 0.11, 0.035, 0.11)
     geometry.add_edge(0.035, 0.11, 0.035, -0.03)
     geometry.add_edge(0, -0.05, 0.03, -0.05)
     geometry.add_edge(0.03, -0.05, 0.03, 0.05)
     geometry.add_edge(0.03, 0.05, 0, 0.05)
     geometry.add_edge(0, 0.05, 0, -0.05, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0, 0.17, 0, 0.05, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0, -0.05, 0, -0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.06, -0.05, 0.04, -0.07, angle = 90)
     geometry.add_edge(0.04, -0.07, 0.06, -0.09, angle = 90)
     geometry.add_edge(0.06, -0.09, 0.08, -0.07, angle = 90)
     geometry.add_edge(0.08, -0.07, 0.06, -0.05, angle = 90)
     
     geometry.add_label(0.109339, 0.112786, materials = {"magnetic" : "Air"})
     geometry.add_label(0.0442134, 0.0328588, materials = {"magnetic" : "Coil"})
     geometry.add_label(0.0116506, -0.00740064, materials = {"magnetic" : "Iron"})
     geometry.add_label(0.0612934, -0.075856, materials = {"magnetic" : "Coil2"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #11
0
 def setUp(self):                 
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "axisymmetric"
     problem.mesh_type = "triangle"
     problem.time_step_method = "fixed"
     problem.time_method_order = 2
     problem.time_total = 0.008
     problem.time_steps = 200
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     # acoustic
     self.acoustic = agros2d.field("acoustic")
     self.acoustic.analysis_type = "transient"
     self.acoustic.transient_initial_condition = 0
     self.acoustic.number_of_refinements = 2
     self.acoustic.polynomial_order = 2
     self.acoustic.adaptivity_type = "disabled"
     self.acoustic.solver = "linear"
     
     # boundaries
     self.acoustic.add_boundary("Wall", "acoustic_normal_acceleration", {"acoustic_normal_acceleration_real" : 0})
     self.acoustic.add_boundary("Source", "acoustic_pressure", {"acoustic_pressure_real" : { "expression" : "sin(2*pi*(time/(1.0/500)))" }, "acoustic_pressure_time_derivative" : { "expression" : "2*pi*(1.0/(1.0/500))*cos(2*pi*(time/(1.0/500)))" }})
     self.acoustic.add_boundary("Matched boundary", "acoustic_impedance", {"acoustic_impedance" : { "expression" : "345*1.25" }})
     self.acoustic.add_boundary("Pressure", "acoustic_pressure", {"acoustic_pressure_real" : 0, "acoustic_pressure_time_derivative" : 0})
     
     # materials
     self.acoustic.add_material("Air", {"acoustic_density" : 1.25, "acoustic_speed" : 343})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(0, -0.8, 0.5, -1.05, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(0.5, -1.05, 0.6, -1.05, boundaries = {"acoustic" : "Source"})
     geometry.add_edge(0.6, -1.05, 0.9, -0.55, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(0.2, -0.25, 0.9, -0.55, angle = 60, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(0.5, 0.15, 0.2, -0.25, angle = 60, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(0.5, 0.15, 0.65, 0.65, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(0.65, 0.65, 1.5, 1.2, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(1.5, 1.2, 0, 1.2, angle = 90, boundaries = {"acoustic" : "Matched boundary"})
     geometry.add_edge(0, 1.2, 0, 1, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(0, 1, 0.2, 0.55, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(0.2, 0.55, 0, -0.8, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(0.4, 0.8, 0.5, 0.9, angle = 90, boundaries = {"acoustic" : "Pressure"})
     geometry.add_edge(0.5, 0.9, 0.4, 1, angle = 90, boundaries = {"acoustic" : "Pressure"})
     geometry.add_edge(0.3, 0.9, 0.4, 0.8, angle = 90, boundaries = {"acoustic" : "Pressure"})
     geometry.add_edge(0.4, 1, 0.3, 0.9, angle = 90, boundaries = {"acoustic" : "Pressure"})
     
     geometry.add_label(0.663165, 1.16386, materials = {"acoustic" : "Air"})
     geometry.add_label(0.387614, 0.929226, materials = {"acoustic" : "none"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #12
0
 def setUp(self):  
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "axisymmetric"
     problem.mesh_type = "triangle"
     problem.frequency = 100
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.magnetic = agros2d.field("magnetic")
     self.magnetic.analysis_type = "harmonic"
     self.magnetic.matrix_solver = "mumps"
     self.magnetic.number_of_refinements = 2
     self.magnetic.polynomial_order = 3
     self.magnetic.adaptivity_type = "disabled"
     self.magnetic.solver = "linear"
             
     # boundaries
     self.magnetic.add_boundary("A = 0", "magnetic_potential", {"magnetic_potential_real" : 0, "magnetic_potential_imag" : 0})        
     
     # materials
     self.magnetic.add_material("Coil", {"magnetic_permeability" : 1, "magnetic_conductivity" : 0, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 1e+06, "magnetic_current_density_external_imag" : 0, "magnetic_total_current_prescribed" : 0, "magnetic_total_current_real" : 0, "magnetic_total_current_imag" : 0})
     self.magnetic.add_material("Iron", {"magnetic_permeability" : 50, "magnetic_conductivity" : 5000, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0, "magnetic_current_density_external_imag" : 0, "magnetic_total_current_prescribed" : 0, "magnetic_total_current_real" : 0, "magnetic_total_current_imag" : 0})
     self.magnetic.add_material("Air", {"magnetic_permeability" : 1, "magnetic_conductivity" : 0, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0, "magnetic_current_density_external_imag" : 0, "magnetic_total_current_prescribed" : 0, "magnetic_total_current_real" : 0, "magnetic_total_current_imag" : 0})
     self.magnetic.add_material("Coil2", {"magnetic_permeability" : 1, "magnetic_conductivity" : 1e6, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0, "magnetic_current_density_external_imag" : 0, "magnetic_total_current_prescribed" : 1, "magnetic_total_current_real" : 5000, "magnetic_total_current_imag" : 20000})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(0, -0.17, 0.15, -0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.15, -0.17, 0.15, 0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.15, 0.17, 0, 0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.035, -0.03, 0.055, -0.03)
     geometry.add_edge(0.055, -0.03, 0.055, 0.11)
     geometry.add_edge(0.055, 0.11, 0.035, 0.11)
     geometry.add_edge(0.035, 0.11, 0.035, -0.03)
     geometry.add_edge(0, -0.05, 0.03, -0.05)
     geometry.add_edge(0.03, -0.05, 0.03, 0.05)
     geometry.add_edge(0.03, 0.05, 0, 0.05)
     geometry.add_edge(0, 0.05, 0, -0.05, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0, 0.17, 0, 0.05, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0, -0.05, 0, -0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.06, -0.05, 0.04, -0.07, angle = 90)
     geometry.add_edge(0.04, -0.07, 0.06, -0.09, angle = 90)
     geometry.add_edge(0.06, -0.09, 0.08, -0.07, angle = 90)
     geometry.add_edge(0.08, -0.07, 0.06, -0.05, angle = 90)
     
     geometry.add_label(0.109339, 0.112786, materials = {"magnetic" : "Air"})
     geometry.add_label(0.0442134, 0.0328588, materials = {"magnetic" : "Coil"})
     geometry.add_label(0.0116506, -0.00740064, materials = {"magnetic" : "Iron"})
     geometry.add_label(0.0612934, -0.075856, materials = {"magnetic" : "Coil2"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #13
0
    def setUp(self):  
        # problem
        problem = agros2d.problem(clear = True)
        problem.coordinate_type = "planar"
        problem.mesh_type = "triangle"
        
        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()
        
        # fields
        # elasticity
        self.elasticity = agros2d.field("elasticity")
        self.elasticity.analysis_type = "steadystate"
        self.elasticity.matrix_solver = "mumps"
        self.elasticity.number_of_refinements = 0
        self.elasticity.polynomial_order = 1
        self.elasticity.adaptivity_type = "hp-adaptivity"
        self.elasticity.adaptivity_parameters['steps'] = 3
        self.elasticity.adaptivity_parameters['tolerance'] = 0
        self.elasticity.adaptivity_parameters['threshold'] = 0.6
        self.elasticity.adaptivity_parameters['stopping_criterion'] = "singleelement"
        self.elasticity.adaptivity_parameters['error_calculator'] = "h1"
        self.elasticity.adaptivity_parameters['anisotropic_refinement'] = True
        self.elasticity.adaptivity_parameters['finer_reference_solution'] = False
        self.elasticity.adaptivity_parameters['space_refinement'] = True
        self.elasticity.adaptivity_parameters['order_increase'] = 1
        self.elasticity.solver = "linear"
                
        # boundaries
        self.elasticity.add_boundary("Wall", "elasticity_fixed_fixed", {"elasticity_displacement_x" : 0, "elasticity_displacement_y" : 0})
        self.elasticity.add_boundary("Free", "elasticity_free_free", {"elasticity_force_x" : 0, "elasticity_force_y" : 0})
        self.elasticity.add_boundary("Load", "elasticity_free_free", {"elasticity_force_x" : 0, "elasticity_force_y" : -200})
                
        # materials
        self.elasticity.add_material("Steel", {"elasticity_young_modulus" : 2e11, "elasticity_poisson_ratio" : 0.33, "elasticity_volume_force_x" : 0, "elasticity_volume_force_y" : { "expression" : "-9.81*7800" }, "elasticity_alpha" : 0, "elasticity_temperature_difference" : 0, "elasticity_temperature_reference" : 0})
        
        # geometry
        geometry = agros2d.geometry
        geometry.add_edge(0.3, 0, 0, 0, boundaries = {"elasticity" : "Load"})
        geometry.add_edge(0, 0, 0, -0.3, boundaries = {"elasticity" : "Wall"})
        geometry.add_edge(0, -0.3, 0.03, -0.27, angle = 90, boundaries = {"elasticity" : "Free"})
        geometry.add_edge(0.27, -0.03, 0.3, 0, angle = 90, boundaries = {"elasticity" : "Free"})
        geometry.add_edge(0.03, -0.03, 0.03, -0.15, boundaries = {"elasticity" : "Free"})
        geometry.add_edge(0.03, -0.03, 0.15, -0.03, boundaries = {"elasticity" : "Free"})
        geometry.add_edge(0.27, -0.03, 0.03, -0.27, angle = 90, boundaries = {"elasticity" : "Free"})
        geometry.add_edge(0.03, -0.15, 0.030625, -0.150375, angle = 90, boundaries = {"elasticity" : "Free"})
        geometry.add_edge(0.030625, -0.150375, 0.031, -0.15, angle = 30, boundaries = {"elasticity" : "Free"})
        geometry.add_edge(0.150375, -0.030625, 0.15, -0.03, angle = 90, boundaries = {"elasticity" : "Free"})
        geometry.add_edge(0.15, -0.031, 0.150375, -0.030625, angle = 30, boundaries = {"elasticity" : "Free"})
        geometry.add_edge(0.15, -0.031, 0.031, -0.15, angle = 45, boundaries = {"elasticity" : "Free"})
        
        geometry.add_label(0.19805, -0.0157016, materials = {"elasticity" : "Steel"})
        geometry.add_label(0.0484721, -0.0490752, materials = {"elasticity" : "none"})

        agros2d.view.zoom_best_fit()       
                                                                                                                
        problem.solve()
Пример #14
0
    def create_problem(self, frequency):
        # ToDo: Set up?
        h = 1
        p = 2

        self.CFL = self.config.settings_CFLnumber
        self.sound_speed = self.config.parameters_air_sound_speed
        self.number_elements_per_wavelenght = 4.

        self.element_size = self.sound_speed / (self.number_elements_per_wavelenght * frequency)
        self.config.element_area = self.element_size**2 * np.sqrt(3) / 4

        
        time_step = self.element_size * self.CFL / self.sound_speed        
        time_total = 0.025
        time_steps = time_total / time_step
        pulse_period = 1.0 / frequency                


        self.problem = a2d.problem(clear = True)
        self.problem.coordinate_type = "planar"
        self.problem.mesh_type = "triangle"
        self.problem.time_step_method = "fixed"
        self.problem.time_method_order = 2
        self.problem.time_total = time_total
        self.problem.time_steps = time_steps  
   
        self.acoustic = a2d.field("acoustic")
        self.acoustic.analysis_type = "transient"
        self.acoustic.matrix_solver = "mumps"
        self.acoustic.transient_initial_condition = 0
        self.acoustic.number_of_refinements = h
        self.acoustic.polynomial_order = p
        self.acoustic.adaptivity_type = "disabled"
        self.acoustic.solver = "linear"
        self.acoustic.adaptivity_type = "disabled" 
        
               
            
        if self.config.parameters_acoustic_impedance_room_matched == True:
            bc_room = self.config.parameters_air_mass_density * self.config.parameters_air_sound_speed
        else:
            bc_room = self.config.parameters_acoustic_impedance_room
    
        # boundaries
        if self.config.parameters_source == 'Sine':
            self.acoustic.add_boundary("Source", "acoustic_pressure", {"acoustic_pressure_real" : { "expression" : "1.0*sin(2*pi*{0}*time)*(time<{1})".format(frequency, pulse_period)}, "acoustic_pressure_time_derivative" : { "expression" : "1.0*cos(2*pi*{0}*time)*2*pi*{0}*(time<{1})".format(frequency, pulse_period)}})
        else:
            self.acoustic.add_boundary("Source", "acoustic_pressure", {"acoustic_pressure_real" : { "expression" : "1.0 * exp( - (pi**2) * ({0}**2) * ((time - (1.0/{0}))**2) )".format(frequency)}, "acoustic_pressure_time_derivative" : { "expression" : "1.0 * exp( - (pi**2) * ({0}**2) * ((time - (1.0/{0}))**2)) * (- (pi**2) * ({0}**2) * 2 * (time - (1.0/{0})) )".format(frequency) }})
    
        self.acoustic.add_boundary("Source_back", "acoustic_normal_acceleration", {"acoustic_normal_acceleration_real" : 0})
        self.acoustic.add_boundary("Reflective_element", "acoustic_normal_acceleration", {"acoustic_normal_acceleration_real" : self.config.parameters_acoustic_impedance_diffuser})
        self.acoustic.add_boundary("Axis", "acoustic_normal_acceleration", {"acoustic_normal_acceleration_real" : 0})
        self.acoustic.add_boundary("Matched_boundary", "acoustic_impedance", {"acoustic_impedance" : bc_room})
    
        # materials
        self.acoustic.add_material("Air", {"acoustic_density" : self.config.parameters_air_mass_density, "acoustic_speed" : self.config.parameters_air_sound_speed})
Пример #15
0
 def setUp(self):                                                                                                                         
     # model
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "planar"
     problem.mesh_type = "triangle"        
     problem.frequency = 50
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.magnetic = agros2d.field("magnetic")
     self.magnetic.analysis_type = "harmonic"
     self.magnetic.number_of_refinements = 1
     self.magnetic.polynomial_order = 3
     self.magnetic.solver = "linear"
     
     self.magnetic.add_boundary("A = 0", "magnetic_potential", {"magnetic_potential_real" : 0})
     
     self.magnetic.add_material("Air", {"magnetic_permeability" : 1}) 
     self.magnetic.add_material("Cond 1", {"magnetic_permeability" : 1, "magnetic_current_density_external_real" : 2e7, "magnetic_conductivity" : 5.7e7}) 
     self.magnetic.add_material("Cond 2", {"magnetic_permeability" : 1, "magnetic_current_density_external_real" : 3e7, "magnetic_conductivity" : 5.7e7}) 
     self.magnetic.add_material("Magnet", {"magnetic_permeability" : 1.1, "magnetic_remanence" : 0.1, "magnetic_remanence_angle" : 20})    
     
     # geometry
     geometry = agros2d.geometry
     
     # edges
     geometry.add_edge(-0.075, 0.06, 0.075, 0.06, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.075, 0.06, 0.075, -0.06, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.075, -0.06, -0.075, -0.06, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(-0.075, -0.06, -0.075, 0.06, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(-0.015, -0.01, -0.015, 0.01)
     geometry.add_edge(-0.015, 0.01, -0.005, 0.01)
     geometry.add_edge(-0.015, -0.01, -0.005, -0.01)
     geometry.add_edge(-0.005, -0.01, -0.005, 0.01)
     geometry.add_edge(0.005, 0.02, 0.005, 0)
     geometry.add_edge(0.005, 0, 0.015, 0)
     geometry.add_edge(0.015, 0, 0.015, 0.02)
     geometry.add_edge(0.015, 0.02, 0.005, 0.02)
     geometry.add_edge(0.01, -0.01, 0.03, -0.01)
     geometry.add_edge(0.03, -0.03, 0.01, -0.03)
     geometry.add_edge(0.01, -0.01, 0.01, -0.03)
     geometry.add_edge(0.03, -0.01, 0.03, -0.03)
     
     # labels
     geometry.add_label(0.035349, 0.036683, materials = {"magnetic" : "Air"}, area=0)
     geometry.add_label(0.00778124, 0.00444642, materials = {"magnetic" : "Cond 1"}, area=1e-05)
     geometry.add_label(-0.0111161, -0.00311249, materials = {"magnetic" : "Cond 2"}, area=1e-05)
     geometry.add_label(0.016868, -0.0186625, materials = {"magnetic" : "Magnet"}, area=0)
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()        
Пример #16
0
 def setUp(self):          
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "planar"
     problem.mesh_type = "triangle"
     problem.time_step_method = "fixed"
     problem.time_method_order = 2
     problem.time_method_tolerance = 1
     problem.time_total = 0.001
     problem.time_steps = 250
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     # acoustic
     self.acoustic = agros2d.field("acoustic")
     self.acoustic.analysis_type = "transient"
     self.acoustic.transient_initial_condition = 0
     self.acoustic.number_of_refinements = 0
     self.acoustic.polynomial_order = 2
     self.acoustic.solver = "linear"
     self.acoustic.adaptivity_type = "disabled"
     
     # boundaries
     self.acoustic.add_boundary("Matched bundary", "acoustic_impedance", {"acoustic_impedance" : 345*1.25 })
     self.acoustic.add_boundary("Source", "acoustic_pressure", {"acoustic_pressure_real" : { "expression" : "sin(2*pi*(time/(1.0/1000)))" }, "acoustic_pressure_time_derivative" : { "expression" : "2*pi*(1.0/(1.0/1000))*cos(2*pi*(time/(1.0/1000)))" }})
     self.acoustic.add_boundary("Hard wall", "acoustic_normal_acceleration", {"acoustic_normal_acceleration_real" : 0})
     self.acoustic.add_boundary("Soft wall", "acoustic_pressure", {"acoustic_pressure_real" : 0, "acoustic_pressure_time_derivative" : 0})
     
     # materials
     self.acoustic.add_material("Air", {"acoustic_density" : 1.25, "acoustic_speed" : 343})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(-0.4, 0.05, 0.1, 0.2, boundaries = {"acoustic" : "Matched bundary"})
     geometry.add_edge(0.1, -0.2, -0.4, -0.05, boundaries = {"acoustic" : "Matched bundary"})
     geometry.add_edge(-0.4, 0.05, -0.4, -0.05, boundaries = {"acoustic" : "Soft wall"})
     geometry.add_edge(-0.18, -0.06, -0.17, -0.05, angle = 90, boundaries = {"acoustic" : "Source"})
     geometry.add_edge(-0.17, -0.05, -0.18, -0.04, angle = 90, boundaries = {"acoustic" : "Source"})
     geometry.add_edge(-0.18, -0.04, -0.19, -0.05, angle = 90, boundaries = {"acoustic" : "Source"})
     geometry.add_edge(-0.19, -0.05, -0.18, -0.06, angle = 90, boundaries = {"acoustic" : "Source"})
     geometry.add_edge(0.1, -0.2, 0.1, 0.2, angle = 90, boundaries = {"acoustic" : "Matched bundary"})
     geometry.add_edge(0.03, 0.1, -0.04, -0.05, angle = 90, boundaries = {"acoustic" : "Hard wall"})
     geometry.add_edge(-0.04, -0.05, 0.08, -0.04, boundaries = {"acoustic" : "Hard wall"})
     geometry.add_edge(0.08, -0.04, 0.03, 0.1, boundaries = {"acoustic" : "Hard wall"})
     
     geometry.add_label(-0.0814934, 0.0707097, area = 10e-05, materials = {"acoustic" : "Air"})
     geometry.add_label(-0.181474, -0.0504768, materials = {"acoustic" : "none"})
     geometry.add_label(0.0314514, 0.0411749, materials = {"acoustic" : "none"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #17
0
 def setUp(self):  
     # model
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "planar"
     problem.mesh_type = "triangle"
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.electrostatic = agros2d.field("electrostatic")
     self.electrostatic.analysis_type = "steadystate"
     self.electrostatic.number_of_refinements = 2
     self.electrostatic.polynomial_order = 3
     self.electrostatic.solver = "linear"
     
     self.electrostatic.add_boundary("Neumann", "electrostatic_surface_charge_density", {"electrostatic_surface_charge_density" : 0})
     self.electrostatic.add_boundary("U = 0 V", "electrostatic_potential", {"electrostatic_potential" : 0})
     self.electrostatic.add_boundary("U = 1000 V", "electrostatic_potential", {"electrostatic_potential" : 1000})
     
     self.electrostatic.add_material("Dieletric", {"electrostatic_charge_density" : 0, "electrostatic_permittivity" : 3})
     self.electrostatic.add_material("Air", {"electrostatic_charge_density" : 0, "electrostatic_permittivity" : 1})
     self.electrostatic.add_material("Source", {"electrostatic_charge_density" : 4e-10, "electrostatic_permittivity" : 10})
     
     # geometry
     geometry = agros2d.geometry
     
     # edges
     geometry.add_edge(1, 2, 1, 1, boundaries = {"electrostatic" : "U = 1000 V"})
     geometry.add_edge(4, 1, 1, 1, boundaries = {"electrostatic" : "U = 1000 V"})
     geometry.add_edge(1, 2, 4, 2, boundaries = {"electrostatic" : "U = 1000 V"})
     geometry.add_edge(4, 2, 4, 1, boundaries = {"electrostatic" : "U = 1000 V"})
     geometry.add_edge(20, 24, 20, 1, boundaries = {"electrostatic" : "Neumann"})
     geometry.add_edge(20, 1, 20, 0, boundaries = {"electrostatic" : "Neumann"})
     geometry.add_edge(4, 1, 20, 1, boundaries = {})
     geometry.add_edge(0, 24, 0, 1, boundaries = {"electrostatic" : "Neumann"})
     geometry.add_edge(0, 0, 0, 1, boundaries = {"electrostatic" : "Neumann"})
     geometry.add_edge(0, 0, 20, 0, boundaries = {"electrostatic" : "U = 0 V"})
     geometry.add_edge(0, 24, 20, 24, boundaries = {"electrostatic" : "Neumann"})
     geometry.add_edge(0, 1, 1, 1, boundaries = {})
     geometry.add_edge(7, 13, 14, 13, boundaries = {})
     geometry.add_edge(14, 13, 14, 18, boundaries = {})
     geometry.add_edge(14, 18, 7, 18, boundaries = {})
     geometry.add_edge(7, 18, 7, 13, boundaries = {})
     
     # labels
     geometry.add_label(2.78257, 1.37346, materials = {"electrostatic" : "none"})
     geometry.add_label(10.3839, 15.7187, area = 0.2, materials = {"electrostatic" : "Source"})
     geometry.add_label(3.37832, 15.8626, materials = {"electrostatic" : "Air"})
     geometry.add_label(12.3992, 0.556005, materials = {"electrostatic" : "Dieletric"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #18
0
    def setUp(self):  
        # problem
        problem = agros2d.problem(clear = True)
        problem.coordinate_type = "planar"
        problem.mesh_type = "triangle"
        problem.frequency = 1.6e+10
        
        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()

        # fields
        # rf_te
        self.rf_te = agros2d.field("rf_te")
        self.rf_te.analysis_type = "harmonic"
        self.rf_te.matrix_solver = "mumps"
        self.rf_te.number_of_refinements = 0
        self.rf_te.polynomial_order = 1
        self.rf_te.adaptivity_type = "hp-adaptivity"
        self.rf_te.adaptivity_parameters['steps'] = 6
        self.rf_te.adaptivity_parameters['tolerance'] = 0
        self.rf_te.adaptivity_parameters['threshold'] = 0.7
        self.rf_te.adaptivity_parameters['stopping_criterion'] = "cumulative"
        self.rf_te.adaptivity_parameters['error_calculator'] = "l2"
        self.rf_te.adaptivity_parameters['anisotropic_refinement'] = True
        self.rf_te.adaptivity_parameters['finer_reference_solution'] = False
        self.rf_te.adaptivity_parameters['space_refinement'] = False
        self.rf_te.adaptivity_parameters['order_increase'] = 2
        self.rf_te.solver = "linear"
                
        # boundaries
        self.rf_te.add_boundary("Perfect electric conductor", "rf_te_electric_field", {"rf_te_electric_field_real" : 0, "rf_te_electric_field_imag" : 0})
        self.rf_te.add_boundary("Matched boundary", "rf_te_magnetic_field", {"rf_te_magnetic_field_real" : 0, "rf_te_magnetic_field_imag" : 0})
        self.rf_te.add_boundary("Source", "rf_te_electric_field", {"rf_te_electric_field_real" : { "expression" : "cos(y/0.01143*pi/2)" }, "rf_te_electric_field_imag" : 0})
                
        # materials
        self.rf_te.add_material("Air", {"rf_te_permittivity" : 1, "rf_te_permeability" : 1, "rf_te_conductivity" : 0, "rf_te_current_density_external_real" : 0, "rf_te_current_density_external_imag" : 0})
        
        # geometry
        geometry = agros2d.geometry
        geometry.add_edge(0.17, -0.01143, 0.17, 0.01143, boundaries = {"rf_te" : "Matched boundary"})
        geometry.add_edge(0, 0.01143, 0, -0.01143, boundaries = {"rf_te" : "Source"})
        geometry.add_edge(0.076, 0.01143, 0.076, 0.0045, boundaries = {"rf_te" : "Perfect electric conductor"})
        geometry.add_edge(0.076, 0.0045, 0.081, 0.0045, boundaries = {"rf_te" : "Perfect electric conductor"})
        geometry.add_edge(0.081, 0.0045, 0.081, 0.01143, boundaries = {"rf_te" : "Perfect electric conductor"})
        geometry.add_edge(0.081, -0.0045, 0.081, -0.01143, boundaries = {"rf_te" : "Perfect electric conductor"})
        geometry.add_edge(0.081, -0.0045, 0.076, -0.0045, boundaries = {"rf_te" : "Perfect electric conductor"})
        geometry.add_edge(0.076, -0.0045, 0.076, -0.01143, boundaries = {"rf_te" : "Perfect electric conductor"})
        geometry.add_edge(0, -0.01143, 0.076, -0.01143, boundaries = {"rf_te" : "Perfect electric conductor"})
        geometry.add_edge(0.081, -0.01143, 0.17, -0.01143, boundaries = {"rf_te" : "Perfect electric conductor"})
        geometry.add_edge(0.17, 0.01143, 0.081, 0.01143, boundaries = {"rf_te" : "Perfect electric conductor"})
        geometry.add_edge(0.076, 0.01143, 0, 0.01143, boundaries = {"rf_te" : "Perfect electric conductor"})
        
        geometry.add_label(0.0367388, 0.0025708, area = 1e-05, materials = {"rf_te" : "Air"})
        agros2d.view.zoom_best_fit()
        problem.solve()
Пример #19
0
    def setUp(self):
        # model
        problem = agros2d.problem(clear=True)
        problem.coordinate_type = "axisymmetric"
        problem.mesh_type = "triangle"

        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()

        # fields
        self.current = agros2d.field("current")
        self.current.analysis_type = "steadystate"
        self.current.number_of_refinements = 1
        self.current.polynomial_order = 4
        self.current.solver = "linear"

        self.current.add_boundary("Neumann", "current_inward_current_flow",
                                  {"current_inward_current_flow": 0})
        self.current.add_boundary("Ground", "current_potential",
                                  {"current_potential": 0})
        self.current.add_boundary("Voltage", "current_potential",
                                  {"current_potential": 10})
        self.current.add_boundary("Inlet", "current_inward_current_flow",
                                  {"current_inward_current_flow": -3e9})

        self.current.add_material("Copper", {"current_conductivity": 5.7e7})

        # geometry
        geometry = agros2d.geometry

        # edges
        geometry.add_edge(0, 0.45, 0, 0, boundaries={"current": "Neumann"})
        geometry.add_edge(0, 0, 0.2, 0, boundaries={"current": "Ground"})
        geometry.add_edge(0.2, 0, 0.2, 0.15, boundaries={"current": "Inlet"})
        geometry.add_edge(0.2,
                          0.15,
                          0.35,
                          0.45,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.35,
                          0.45,
                          0,
                          0.45,
                          boundaries={"current": "Voltage"})

        # labels
        geometry.add_label(0.0933957,
                           0.350253,
                           materials={"current": "Copper"})

        agros2d.view.zoom_best_fit()

        # solve problem
        problem.solve()
Пример #20
0
 def setUp(self):  
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "axisymmetric"
     problem.mesh_type = "triangle"
     
     problem.time_step_method = "fixed"
     problem.time_method_order = 2
     problem.time_total = 0.30
     problem.time_steps = 30
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.magnetic = agros2d.field("magnetic")
     self.magnetic.analysis_type = "transient"
     self.magnetic.transient_initial_condition = 0
     self.magnetic.number_of_refinements = 3
     self.magnetic.polynomial_order = 2
     self.magnetic.adaptivity_type = "disabled"
     self.magnetic.solver = "linear"
     
     # boundaries
     self.magnetic.add_boundary("A = 0", "magnetic_potential", {"magnetic_potential_real" : 0})
     
     # materials
     self.magnetic.add_material("Air", {"magnetic_permeability" : 1, "magnetic_conductivity" : 0, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0})
     self.magnetic.add_material("Coil", {"magnetic_permeability" : 1, "magnetic_conductivity" : 0, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : { "expression" : "1e7*(exp(-10/0.7*time) - exp(-12/0.7*time))" }})
     self.magnetic.add_material("Copper", {"magnetic_permeability" : 1, "magnetic_conductivity" : 5.7e+07, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(0, -0.5, 0.5, 0, angle = 90, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.5, 0, 0, 0.5, angle = 90, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0, 0.5, 0, 0.15, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0, 0.15, 0, -0.15, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0, -0.15, 0, -0.5, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.05, 0.15, 0, 0.15)
     geometry.add_edge(0.05, 0.15, 0.1, -0.15)
     geometry.add_edge(0.1, -0.15, 0, -0.15)
     geometry.add_edge(0.15, -0.05, 0.25, -0.05)
     geometry.add_edge(0.25, 0.05, 0.15, 0.05)
     geometry.add_edge(0.15, 0.05, 0.15, -0.05)
     geometry.add_edge(0.25, 0.05, 0.25, -0.05)
     
     geometry.add_label(0.19253, -0.00337953, materials = {"magnetic" : "Coil"})
     geometry.add_label(0.051315, -0.0143629, materials = {"magnetic" : "Copper"})
     geometry.add_label(0.165856, 0.213151, materials = {"magnetic" : "Air"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #21
0
    def setUp(self):  
        # model
        problem = agros2d.problem(clear = True)
        problem.coordinate_type = "planar"
        problem.mesh_type = "triangle"

        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()

        # fields
        self.heat = agros2d.field("heat")
        self.heat.analysis_type = "steadystate"
        self.heat.number_of_refinements = 2
        self.heat.polynomial_order = 2

        self.heat.solver = "newton"
        self.heat.solver_parameters['residual'] = 0.0001
        self.heat.solver_parameters['damping'] = 'automatic'
        self.heat.solver_parameters['damping_factor'] = 0.8
        self.heat.solver_parameters['jacobian_reuse'] = True
        self.heat.solver_parameters['jacobian_reuse_ratio'] = 0.3
        self.heat.solver_parameters['jacobian_reuse_steps'] = 20

        self.heat.add_boundary("Left", "heat_temperature", {"heat_temperature" : 10})
        self.heat.add_boundary("Radiace", "heat_heat_flux", {"heat_convection_external_temperature" : 0, "heat_convection_heat_transfer_coefficient" : 0, "heat_heat_flux" : 0, "heat_radiation_ambient_temperature" : 20, "heat_radiation_emissivity" : 0.9})
        self.heat.add_boundary("Neumann", "heat_heat_flux", {"heat_convection_external_temperature" : 0, "heat_convection_heat_transfer_coefficient" : 0, "heat_heat_flux" : 0, "heat_radiation_ambient_temperature" : 0, "heat_radiation_emissivity" : 0})
        self.heat.add_boundary("Convection", "heat_heat_flux", {"heat_convection_external_temperature" : 20, "heat_convection_heat_transfer_coefficient" : 50, "heat_heat_flux" : 0, "heat_radiation_ambient_temperature" : 0, "heat_radiation_emissivity" : 0})

        self.heat.add_material("Material - nonlin", {"heat_conductivity" : { "x" : [0,100,200,290,500,1000], "y" : [210,280,380,430,310,190], "interpolation" : "cubic_spline", "extrapolation" : "constant", "derivative_at_endpoints" : "first"}, "heat_volume_heat" : 2e6})
        self.heat.add_material("Material", {"heat_conductivity" : 230, "heat_volume_heat" : 0})

        # geometry
        geometry = agros2d.geometry

        # edges
        geometry.add_edge(-0.25, 0.25, -0.1, 0.1, boundaries = {"heat" : "Convection"})
        geometry.add_edge(-0.1, 0.1, 0.05, 0.2, boundaries = {"heat" : "Convection"})
        geometry.add_edge(0.05, 0.2, 0.25, 0.25, boundaries = {"heat" : "Neumann"})
        geometry.add_edge(0.25, 0.25, 0.1, 0.1, boundaries = {"heat" : "Radiace"})
        geometry.add_edge(0.1, 0.1, 0.25, -0.25, boundaries = {"heat" : "Radiace"})
        geometry.add_edge(0.25, -0.25, 0.05, -0.05, boundaries = {"heat" : "Neumann"})
        geometry.add_edge(0.05, -0.05, -0.25, -0.25, boundaries = {"heat" : "Neumann"}, angle = 90)
        geometry.add_edge(-0.25, -0.05, 0.1, 0.1, boundaries = {})
        geometry.add_edge(-0.25, 0.25, -0.25, -0.05, boundaries = {"heat" : "Left"})
        geometry.add_edge(-0.25, -0.05, -0.25, -0.25, boundaries = {"heat" : "Left"})

        # labels
        geometry.add_label(-0.0150215, 0.018161, materials = {"heat" : "Material"})
        geometry.add_label(-0.183934, 0.0732177, materials = {"heat" : "Material - nonlin"})

        agros2d.view.zoom_best_fit()

        # solve problem
        problem.solve()
Пример #22
0
 def setUp(self):  
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "planar"
     problem.mesh_type = "triangle"
     
     problem.time_step_method = "fixed"
     problem.time_method_order = 2
     problem.time_total = 0.4
     problem.time_steps = 50
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # magnetic
     self.magnetic = agros2d.field("magnetic")
     self.magnetic.analysis_type = "transient"
     self.magnetic.transient_initial_condition = 0
     self.magnetic.number_of_refinements = 3
     self.magnetic.polynomial_order = 2
     self.magnetic.adaptivity_type = "disabled"
     self.magnetic.solver = "linear"
     
     # boundaries
     self.magnetic.add_boundary("A = 0", "magnetic_potential", {"magnetic_potential_real" : 0})
     
     # materials
     self.magnetic.add_material("Copper", {"magnetic_permeability" : 1, "magnetic_conductivity" : 57e6, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0})
     self.magnetic.add_material("Coil", {"magnetic_permeability" : 1, "magnetic_conductivity" : 0, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : { "expression" : "1e7*(exp(-10/0.7*time) - exp(-12/0.7*time))" }})
     self.magnetic.add_material("Air", {"magnetic_permeability" : 1, "magnetic_conductivity" : 0, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(-0.75, 0.75, -0.75, -0.25, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(-0.75, 0.75, 0.75, 0.75, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.75, 0.75, 0.75, -0.25, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.75, -0.25, -0.75, -0.25, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(-0.25, 0, 0.2, 0.05)
     geometry.add_edge(0.1, 0.2, 0.2, 0.05)
     geometry.add_edge(0.1, 0.2, -0.2, 0.1)
     geometry.add_edge(-0.2, 0.1, -0.25, 0)
     geometry.add_edge(-0.2, 0.2, -0.05, 0.25)
     geometry.add_edge(-0.05, 0.35, -0.05, 0.25)
     geometry.add_edge(-0.05, 0.35, -0.2, 0.35)
     geometry.add_edge(-0.2, 0.35, -0.2, 0.2)
     
     geometry.add_label(0.1879, 0.520366, materials = {"magnetic" : "Air"})
     geometry.add_label(-0.15588, 0.306142, materials = {"magnetic" : "Coil"})
     geometry.add_label(-0.00331733, 0.106999, materials = {"magnetic" : "Copper"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #23
0
    def setUp(self):  
        # problem
        problem = agros2d.problem(clear = True)
        problem.coordinate_type = "planar"
        problem.mesh_type = "triangle"
        problem.frequency = 50000

        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()
        
        # fields
        # magnetic
        self.magnetic = agros2d.field("magnetic")
        self.magnetic.analysis_type = "harmonic"
        self.magnetic.matrix_solver = "mumps"
        self.magnetic.number_of_refinements = 0
        self.magnetic.polynomial_order = 1
        self.magnetic.adaptivity_type = "hp-adaptivity"
        self.magnetic.adaptivity_parameters['steps'] = 5
        self.magnetic.adaptivity_parameters['tolerance'] = 0
        self.magnetic.adaptivity_parameters['threshold'] = 0.6
        self.magnetic.adaptivity_parameters['stopping_criterion'] = "singleelement"
        self.magnetic.adaptivity_parameters['error_calculator'] = "h1"
        self.magnetic.adaptivity_parameters['anisotropic_refinement'] = True
        self.magnetic.adaptivity_parameters['finer_reference_solution'] = False
        self.magnetic.adaptivity_parameters['space_refinement'] = True
        self.magnetic.adaptivity_parameters['order_increase'] = 1
        self.magnetic.solver = "linear"
                
        # boundaries
        self.magnetic.add_boundary("Neumann", "magnetic_surface_current", {"magnetic_surface_current_real" : 0, "magnetic_surface_current_imag" : 0})
        self.magnetic.add_boundary("A = 0", "magnetic_potential", {"magnetic_potential_real" : 0, "magnetic_potential_imag" : 0})        
        
        # materials
        self.magnetic.add_material("Air", {"magnetic_permeability" : 1, "magnetic_conductivity" : 0, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0, "magnetic_current_density_external_imag" : 0, "magnetic_total_current_prescribed" : 0, "magnetic_total_current_real" : 0, "magnetic_total_current_imag" : 0})
        self.magnetic.add_material("Copper", {"magnetic_permeability" : 1, "magnetic_conductivity" : 57e6, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, "magnetic_current_density_external_real" : 0, "magnetic_current_density_external_imag" : 0, "magnetic_total_current_prescribed" : 1, "magnetic_total_current_real" : 0.25, "magnetic_total_current_imag" : 0})
        
        # geometry
        geometry = agros2d.geometry
        geometry.add_edge(0, 0.002, 0, 0.000768, boundaries = {"magnetic" : "Neumann"})
        geometry.add_edge(0, 0.000768, 0, 0, boundaries = {"magnetic" : "Neumann"})
        geometry.add_edge(0, 0, 0.000768, 0, boundaries = {"magnetic" : "Neumann"})
        geometry.add_edge(0.000768, 0, 0.002, 0, boundaries = {"magnetic" : "Neumann"})
        geometry.add_edge(0.002, 0, 0, 0.002, angle = 90, boundaries = {"magnetic" : "A = 0"})
        geometry.add_edge(0.000768, 0, 0.000576, 0.000192, angle = 90)
        geometry.add_edge(0.000576, 0.000192, 0.000384, 0.000192)
        geometry.add_edge(0.000192, 0.000384, 0.000384, 0.000192, angle = 90)
        geometry.add_edge(0.000192, 0.000576, 0.000192, 0.000384)
        geometry.add_edge(0.000192, 0.000576, 0, 0.000768, angle = 90)
        
        geometry.add_label(0.000585418, 0.00126858, materials = {"magnetic" : "Air"})
        geometry.add_label(0.000109549, 8.6116e-05, materials = {"magnetic" : "Copper"})
        agros2d.view.zoom_best_fit()                                                                                                                
        problem.solve()
Пример #24
0
 def setUp(self):          
     # model
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "planar"
     problem.mesh_type = "triangle"
     
     problem.frequency = 1.6e10
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.rf = agros2d.field("rf_te")
     self.rf.analysis_type = "harmonic"
     self.rf.number_of_refinements = 3	
     self.rf.polynomial_order = 3
     self.rf.solver = "linear"
     
     # boundaries
     self.rf.add_boundary("Perfect electric conductor", "rf_te_electric_field")
     self.rf.add_boundary("Matched boundary", "rf_te_impedance", { "rf_te_impedance" : 377 })
     self.rf.add_boundary("Surface current", "rf_te_surface_current", {"rf_te_surface_current_real" : 1, "rf_te_surface_current_imag" : 0.5})
     
     self.rf.add_material("Air", {"rf_te_permittivity" : 1, "rf_te_permeability" : 1, "rf_te_conductivity" : 3e-2})
     
     # geometry
     geometry = agros2d.geometry
     
     # edges
     geometry.add_edge(-0.01, 0.02286, -0.01, 0, 0, boundaries = {"rf_te" : "Surface current"})
     geometry.add_edge(0.06907, 0.02286, 0.076, 0.01593, 90, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.076, 0.01593, 0.081, 0.01593, 0, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.081, 0.01593, 0.081, 0.02286, 0, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.086, 0.00693, 0.086, 0, 0, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.086, 0.00693, 0.081, 0.00693, 0, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.081, 0.00693, 0.05907, 0, 20, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(-0.01, 0, 0.05907, 0, 0, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.17, 0.02286, 0.081, 0.02286, 0, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.06907, 0.02286, -0.01, 0.02286, 0, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.19286, 0, 0.17, 0.02286, 90, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.19286, 0, 0.19286, -0.04, 0, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.175, -0.04, 0.175, -0.015, 0, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.175, -0.015, 0.16, 0, 90, boundaries = {"rf_te" : "Perfect electric conductor"})
     geometry.add_edge(0.175, -0.04, 0.19286, -0.04, 0, boundaries = {"rf_te" : "Matched boundary"})
     geometry.add_edge(0.086, 0, 0.16, 0, 0, boundaries = {"rf_te" : "Perfect electric conductor"})
     
     # labels
     geometry.add_label(0.0359418, 0.0109393, materials = {"rf_te" : "Air"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #25
0
 def setUp(self):  
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "axisymmetric"
     problem.mesh_type = "gmsh_quad"
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # flow
     self.flow = agros2d.field("flow")
     self.flow.analysis_type = "steadystate"
     self.flow.number_of_refinements = 1
     self.flow.polynomial_order = 2
     self.flow.adaptivity_type = "disabled"
     
     self.flow.solver = "newton"
     self.flow.solver_parameters['residual'] = 0.0001
     self.flow.solver_parameters['damping'] = 'automatic'
     self.flow.solver_parameters['damping_factor'] = 1.0
     self.flow.solver_parameters['jacobian_reuse'] = False
     
     # boundaries
     self.flow.add_boundary("inlet", "flow_velocity", {"flow_velocity_x" : 0, "flow_velocity_y" : { "expression" : "-cos(r/0.25*pi/2)" }})
     self.flow.add_boundary("outlet", "flow_outlet", {})
     self.flow.add_boundary("wall", "flow_velocity", {"flow_velocity_x" : 0, "flow_velocity_y" : 0})
     self.flow.add_boundary("symmetry", "flow_symmetry", {})
     
     # materials
     self.flow.add_material("fluid", {"flow_viscosity" : 0.001, "flow_density" : 1, "flow_force_x" : 0, "flow_force_y" : 0})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(0, 0.5, 0.25, 0.5, boundaries = {"flow" : "inlet"})
     geometry.add_edge(0.25, 0.5, 0.25, -0.05, boundaries = {"flow" : "wall"})
     geometry.add_edge(0.25, -0.05, 0.15, -0.15, boundaries = {"flow" : "wall"})
     geometry.add_edge(0.15, -0.15, 0.15, -0.5, boundaries = {"flow" : "wall"})
     geometry.add_edge(0.05, -0.5, 0.05, -0.05, boundaries = {"flow" : "wall"})
     geometry.add_edge(0.05, -0.05, 0.15, -0.05, boundaries = {"flow" : "wall"})
     geometry.add_edge(0.15, -0.05, 0, 0.1, angle = 90, boundaries = {"flow" : "wall"})
     geometry.add_edge(0, 0.1, 0, 0.5, boundaries = {"flow" : "symmetry"})
     geometry.add_edge(0.05, -0.5, 0, -0.5, boundaries = {"flow" : "wall"})
     geometry.add_edge(0, -0.5, 0, -1.3, boundaries = {"flow" : "symmetry"})
     geometry.add_edge(0, -1.3, 0.15, -1.3, boundaries = {"flow" : "outlet"})
     geometry.add_edge(0.15, -1.3, 0.15, -0.55, boundaries = {"flow" : "wall"})
     geometry.add_edge(0.15, -0.55, 0.15, -0.5, boundaries = {"flow" : "wall"})
     
     geometry.add_label(0.127882, 0.157169, materials = {"flow" : "fluid"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #26
0
 def setUp(self): 
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "planar"
     problem.mesh_type = "triangle"
             
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     # electrostatic
     electrostatic = agros2d.field("electrostatic")
     electrostatic.analysis_type = "steadystate"
     electrostatic.number_of_refinements = 1
     electrostatic.polynomial_order = 2
     electrostatic.adaptivity_type = "disabled"
     electrostatic.solver = "linear"
             
     # boundaries
     electrostatic.add_boundary("Voltage", "electrostatic_potential", {"electrostatic_potential" : 1e4})
     electrostatic.add_boundary("Ground", "electrostatic_potential", {"electrostatic_potential" : 0})
     electrostatic.add_boundary("Neumann", "electrostatic_surface_charge_density", {"electrostatic_surface_charge_density" : 0})
             
     # materials
     electrostatic.add_material("Air", {"electrostatic_permittivity" : 1, "electrostatic_charge_density" : 0})
     electrostatic.add_material("Screen", {"electrostatic_permittivity" : 2, "electrostatic_charge_density" : 0})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(0.075, -0.022, 0.075, 0.022, angle = 90)
     geometry.add_edge(0.075, -0.022, 0.079, -0.026)
     geometry.add_edge(0.079, -0.026, 0.079, 0.026, angle = 90)
     geometry.add_edge(0.079, 0.026, 0.075, 0.022)
     geometry.add_edge(0, 0.06, 0, -0.06, boundaries = {"electrostatic" : "Neumann"})
     geometry.add_edge(0, -0.06, 0.118, -0.06, boundaries = {"electrostatic" : "Neumann"})
     geometry.add_edge(0.118, -0.06, 0.118, 0.06, boundaries = {"electrostatic" : "Neumann"})
     geometry.add_edge(0.118, 0.06, 0, 0.06, boundaries = {"electrostatic" : "Neumann"})
     geometry.add_edge(0.062, 0.01, 0.04, 0.01, boundaries = {"electrostatic" : "Voltage"})
     geometry.add_edge(0.04, 0.017, 0.04, 0.01, boundaries = {"electrostatic" : "Voltage"})
     geometry.add_edge(0.04, 0.017, 0.062, 0.017, boundaries = {"electrostatic" : "Voltage"})
     geometry.add_edge(0.062, 0.017, 0.062, 0.01, boundaries = {"electrostatic" : "Voltage"})
     geometry.add_edge(0.05, -0.01, 0.05, -0.017, boundaries = {"electrostatic" : "Ground"})
     geometry.add_edge(0.05, -0.017, 0.04, -0.017, boundaries = {"electrostatic" : "Ground"})
     geometry.add_edge(0.04, -0.01, 0.04, -0.017, boundaries = {"electrostatic" : "Ground"})
     geometry.add_edge(0.04, -0.01, 0.05, -0.01, boundaries = {"electrostatic" : "Ground"})
     
     geometry.add_label(0.0805206, 0.0216256, materials = {"electrostatic" : "Screen"})
     geometry.add_label(0.0504445, 0.0129438, materials = {"electrostatic" : "none"})
     geometry.add_label(0.0452163, -0.0148758, materials = {"electrostatic" : "none"})
     geometry.add_label(0.109507, 0.050865, materials = {"electrostatic" : "Air"})
     agros2d.view.zoom_best_fit()
     
     problem.solve()
Пример #27
0
 def setUp(self):  
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "planar"
     problem.mesh_type = "triangle"
     problem.time_step_method = "fixed"
     problem.time_method_order = 2
     problem.time_total = 1.1
     problem.time_steps = 20
     
     # math_coeff
     self.math_coeff = agros2d.field("math_coeff")
     self.math_coeff.analysis_type = "transient"
     self.math_coeff.matrix_solver = "mumps"
     self.math_coeff.transient_initial_condition = 0
     self.math_coeff.number_of_refinements = 3
     self.math_coeff.polynomial_order = 3
     self.math_coeff.adaptivity_type = "disabled"
     self.math_coeff.solver = "linear"
     
     # boundaries
     self.math_coeff.add_boundary("Source 1", "math_coeff_solution", {"math_coeff_solution" : { "expression" : "exp(-10/5*time) - exp(-20/5*time)" }, "math_coeff_solution_time_derivative" : { "expression" : "-10/5*exp(-10/5*time) + 20/5*exp(-20/5*time)" }})
     self.math_coeff.add_boundary("Neumann", "math_coeff_flux", {"math_coeff_flux" : 10})
     self.math_coeff.add_boundary("Source 2", "math_coeff_solution", {"math_coeff_solution" : { "expression" : "sin(2*pi*0.5/0.75*time)" }, "math_coeff_solution_time_derivative" : { "expression" : "2*pi*0.5/0.75*cos(2*pi*0.5/0.75*time)" }})
     
     # materials
     self.math_coeff.add_material("Material", {"math_coeff_ea" : 300, "math_coeff_da" : 280, "math_coeff_c" : 3, "math_coeff_a" : 4, "math_coeff_beta_x" : 2, "math_coeff_beta_y" : -2, "math_coeff_f" : 5})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(-0.22, 0.055, 0.045, 0.08, boundaries = {"math_coeff" : "Neumann"})
     geometry.add_edge(0.045, 0.08, 0.095, 0.005, boundaries = {"math_coeff" : "Neumann"})
     geometry.add_edge(0.095, 0.005, 0.05, -0.095, boundaries = {"math_coeff" : "Neumann"})
     geometry.add_edge(0.05, -0.095, -0.215, -0.045, boundaries = {"math_coeff" : "Neumann"})
     geometry.add_edge(-0.22, 0.055, -0.215, -0.045, boundaries = {"math_coeff" : "Neumann"})
     geometry.add_edge(-0.025, 0.04, 0.015, -0.03, boundaries = {"math_coeff" : "Source 1"})
     geometry.add_edge(0.04, 0.015, 0.06, -0.02, boundaries = {"math_coeff" : "Source 1"})
     geometry.add_edge(0.06, -0.02, 0.015, -0.03, boundaries = {"math_coeff" : "Source 1"})
     geometry.add_edge(-0.025, 0.04, 0.04, 0.015, boundaries = {"math_coeff" : "Source 1"})
     geometry.add_edge(-0.16, 0.025, -0.16, -0.02, boundaries = {"math_coeff" : "Source 2"})
     geometry.add_edge(-0.16, 0.025, -0.09, 0.03, boundaries = {"math_coeff" : "Source 2"})
     geometry.add_edge(-0.09, 0.03, -0.115, -0.005, boundaries = {"math_coeff" : "Source 2"})
     geometry.add_edge(-0.095, -0.03, -0.115, -0.005, boundaries = {"math_coeff" : "Source 2"})
     geometry.add_edge(-0.16, -0.02, -0.095, -0.03, boundaries = {"math_coeff" : "Source 2"})
     
     geometry.add_label(0.0350372, -0.00349351, materials = {"math_coeff" : "none"})
     geometry.add_label(0.0270465, 0.0500445, materials = {"math_coeff" : "Material"})
     geometry.add_label(-0.150064, 0.00228808, materials = {"math_coeff" : "none"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #28
0
 def setUp(self):         
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "axisymmetric"
     problem.mesh_type = "triangle"
     
     problem.frequency = 1e+09
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     # rf
     self.rf = agros2d.field("rf_te")
     self.rf.analysis_type = "harmonic"
     self.rf.number_of_refinements = 3
     self.rf.polynomial_order = 3
     self.rf.adaptivity_type = "disabled"
     self.rf.solver = "linear"
     
     # boundaries
     self.rf.add_boundary("PEC", "rf_te_electric_field", {"rf_te_electric_field_real" : 0, "rf_te_electric_field_imag" : 0})
     self.rf.add_boundary("Source", "rf_te_electric_field", {"rf_te_electric_field_real" : 1, "rf_te_electric_field_imag" : 0})
     self.rf.add_boundary("Impedance", "rf_te_impedance", {"rf_te_impedance" : 377})
     self.rf.add_boundary("PMC", "rf_te_magnetic_field", {"rf_te_magnetic_field_real" : 0, "rf_te_magnetic_field_imag" : 0})
     
     # materials
     self.rf.add_material("Air", {"rf_te_permittivity" : 1, "rf_te_permeability" : 1, "rf_te_conductivity" : 0, "rf_te_current_density_external_real" : 0, "rf_te_current_density_external_imag" : 0})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(0, 1, 0, -1, boundaries = {"rf_te" : "PEC"})
     geometry.add_edge(0, -1, 1, -1, boundaries = {"rf_te" : "Impedance"})
     geometry.add_edge(1, -1, 1, -0.75, boundaries = {"rf_te" : "Impedance"})
     geometry.add_edge(1, -0.75, 1.7, 0.65, boundaries = {"rf_te" : "Impedance"})
     geometry.add_edge(1.7, 0.65, 0.9, 0.35, boundaries = {"rf_te" : "Impedance"})
     geometry.add_edge(0.9, 0.35, 0, 1, boundaries = {"rf_te" : "Impedance"})
     geometry.add_edge(0.5, -0.25, 0.25, -0.5, angle = 90, boundaries = {"rf_te" : "Source"})
     geometry.add_edge(0.25, -0.5, 0.5, -0.75, angle = 90, boundaries = {"rf_te" : "Source"})
     geometry.add_edge(0.5, -0.75, 0.75, -0.5, angle = 90, boundaries = {"rf_te" : "Source"})
     geometry.add_edge(0.75, -0.5, 0.5, -0.25, angle = 90, boundaries = {"rf_te" : "Source"})
     geometry.add_edge(0.4, 0.25, 0.3, -0.05, boundaries = {"rf_te" : "PMC"})
     geometry.add_edge(0.4, 0.25, 0.75, 0.2, boundaries = {"rf_te" : "PMC"})
     geometry.add_edge(0.75, 0.2, 0.85, -0.1, boundaries = {"rf_te" : "PMC"})
     geometry.add_edge(0.3, -0.05, 0.85, -0.1, boundaries = {"rf_te" : "PMC"})
     
     geometry.add_label(0.399371, 0.440347, materials = {"rf_te" : "Air"})
     geometry.add_label(0.484795, -0.434246, materials = {"rf_te" : "none"})
     geometry.add_label(0.57193, 0.0710058, materials = {"rf_te" : "none"})
     agros2d.view.zoom_best_fit()
     
     problem.solve()
Пример #29
0
 def setUp(self):         
     # model
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "axisymmetric"
     problem.mesh_type = "triangle"
     problem.frequency = 700
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.acoustic = agros2d.field("acoustic")
     self.acoustic.analysis_type = "harmonic"
     self.acoustic.number_of_refinements = 3
     self.acoustic.polynomial_order = 2
     self.acoustic.solver = "linear"
     
     self.acoustic.add_boundary("Wall", "acoustic_normal_acceleration", {"acoustic_normal_acceleration_real" : 0, "acoustic_normal_acceleration_imag" : 0})
     self.acoustic.add_boundary("Source acceleration", "acoustic_normal_acceleration", {"acoustic_normal_acceleration_real" : 10, "acoustic_normal_acceleration_imag" : 0})
     self.acoustic.add_boundary("Matched boundary", "acoustic_impedance", {"acoustic_impedance" : 1.25*343})
     self.acoustic.add_boundary("Source pressure", "acoustic_pressure", {"acoustic_pressure_real" : 0.2, "acoustic_pressure_imag" : 0})
         
     self.acoustic.add_material("Air", {"acoustic_density" : 1.25, "acoustic_speed" : 343})
     
     # geometry
     geometry = agros2d.geometry
     
     # edges
     geometry.add_edge(0, 1.5, 1.05, 1.25, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(1.05, 1.25, 0.25, 0, boundaries = {"acoustic" : "Matched boundary"})
     geometry.add_edge(0.25, 0, 0, 0, boundaries = {"acoustic" : "Source acceleration"})
     geometry.add_edge(0, 0, 0, 0.7, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(0, 1, 0, 1.5, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(0, 0.7, 0.15, 0.85, boundaries = {"acoustic" : "Wall"}, angle=90)
     geometry.add_edge(0.15, 0.85, 0, 1, boundaries = {"acoustic" : "Wall"}, angle=90)
     geometry.add_edge(0.35, 1.15, 0.65, 1, boundaries = {"acoustic" : "Matched boundary"})
     geometry.add_edge(0.65, 1, 0.35, 0.9, boundaries = {"acoustic" : "Matched boundary"})
     geometry.add_edge(0.35, 1.15, 0.35, 0.9, boundaries = {"acoustic" : "Matched boundary"})
     geometry.add_edge(0.6, 1.2, 0.6, 1.25, boundaries = {"acoustic" : "Source pressure"})
     geometry.add_edge(0.6, 1.2, 0.65, 1.2, boundaries = {"acoustic" : "Source pressure"})
     geometry.add_edge(0.6, 1.25, 0.65, 1.2, boundaries = {"acoustic" : "Source pressure"})
     
     # labels
     geometry.add_label(0.163662, 0.383133, materials = {"acoustic" : "Air"})
     geometry.add_label(0.426096, 1.03031, materials = {"acoustic" : "none"})
     geometry.add_label(0.616273, 1.21617, materials = {"acoustic" : "none"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #30
0
 def setUp(self): 
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "planar"
     problem.mesh_type = "triangle"
     
     problem.frequency = 1e10
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # rf_tm
     self.rf_tm = agros2d.field("rf_tm")
     self.rf_tm.analysis_type = "harmonic"
     self.rf_tm.number_of_refinements = 4
     self.rf_tm.polynomial_order = 3
     self.rf_tm.adaptivity_type = "disabled"
     self.rf_tm.solver = "linear"
     
     # boundaries
     self.rf_tm.add_boundary("Perfect electric conductor", "rf_tm_magnetic_field", {"rf_tm_magnetic_field_real" : 0, "rf_tm_magnetic_field_imag" : 0})
     self.rf_tm.add_boundary("Matched boundary", "rf_tm_impedance", {"rf_tm_impedance" : 377})
     self.rf_tm.add_boundary("Surface current", "rf_tm_magnetic_field", {"rf_tm_magnetic_field_real" : 1, "rf_tm_magnetic_field_imag" : 1})
     
     # materials
     self.rf_tm.add_material("Air", {"rf_tm_permittivity" : 1, "rf_tm_permeability" : 1, "rf_tm_conductivity" : 0})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(-0.01, 0.02286, -0.01, 0, boundaries = {"rf_tm" : "Surface current"})
     geometry.add_edge(0.06907, 0.02286, 0.076, 0.01593, angle = 90, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.076, 0.01593, 0.081, 0.01593, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.081, 0.01593, 0.081, 0.02286, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.086, 0.00693, 0.086, 0, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.086, 0.00693, 0.081, 0.00693, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.081, 0.00693, 0.05907, 0, angle = 20, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(-0.01, 0, 0.05907, 0, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.17, 0.02286, 0.081, 0.02286, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.06907, 0.02286, -0.01, 0.02286, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.19286, 0, 0.17, 0.02286, angle = 90, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.19286, 0, 0.19286, -0.04, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.175, -0.04, 0.175, -0.015, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.175, -0.015, 0.16, 0, angle = 90, boundaries = {"rf_tm" : "Perfect electric conductor"})
     geometry.add_edge(0.175, -0.04, 0.19286, -0.04, boundaries = {"rf_tm" : "Matched boundary"})
     geometry.add_edge(0.086, 0, 0.16, 0, boundaries = {"rf_tm" : "Perfect electric conductor"})
     
     geometry.add_label(0.0359418, 0.0109393, materials = {"rf_tm" : "Air"})
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #31
0
 def setUp(self):  
     # model
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "planar"
     problem.mesh_type = "triangle"
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.math_coeff = agros2d.field("math_coeff")
     self.math_coeff.analysis_type = "steadystate"
     self.math_coeff.matrix_solver = "mumps"
     self.math_coeff.number_of_refinements = 3
     self.math_coeff.polynomial_order = 3
     self.math_coeff.adaptivity_type = "disabled"
     self.math_coeff.solver = "linear"
     
     # boundaries
     self.math_coeff.add_boundary("Source", "math_coeff_solution", {"math_coeff_solution" : 1})
     self.math_coeff.add_boundary("Neumann", "math_coeff_flux", {"math_coeff_flux" : 10})
     
     # materials
     self.math_coeff.add_material("Material", {"math_coeff_c" : 2, "math_coeff_a" : 3, "math_coeff_beta_x" : 1, "math_coeff_beta_y" : 2, "math_coeff_f" : 5})
     
     # geometry
     geometry = agros2d.geometry
     
     # edges
     geometry.add_edge(-0.95, 0.6, 0.45, 0.8, boundaries = {"math_coeff" : "Neumann"})
     geometry.add_edge(0.45, 0.8, 0.95, 0.05, boundaries = {"math_coeff" : "Neumann"})
     geometry.add_edge(0.95, 0.05, 0.5, -0.95, boundaries = {"math_coeff" : "Neumann"})
     geometry.add_edge(0.5, -0.95, -1.05, -0.3, boundaries = {"math_coeff" : "Neumann"})
     geometry.add_edge(-0.95, 0.6, -1.05, -0.3, boundaries = {"math_coeff" : "Neumann"})
     geometry.add_edge(0.1, 0.2, 0.15, -0.3, boundaries = {"math_coeff" : "Source"})
     geometry.add_edge(0.4, 0.15, 0.6, -0.2, boundaries = {"math_coeff" : "Source"})
     geometry.add_edge(0.6, -0.2, 0.15, -0.3, boundaries = {"math_coeff" : "Source"})
     geometry.add_edge(0.1, 0.2, 0.4, 0.15, boundaries = {"math_coeff" : "Source"})
     geometry.add_edge(-0.55, 0.3, -0.7, 0.1, boundaries = {"math_coeff" : "Source"})
     geometry.add_edge(-0.55, 0.3, -0.4, 0.2, boundaries = {"math_coeff" : "Source"})
     geometry.add_edge(-0.7, 0.1, -0.4, 0.2, boundaries = {"math_coeff" : "Source"})
     
     # labels
     geometry.add_label(0.350372, -0.0349351, materials = {"math_coeff" : "none"})
     geometry.add_label(0.270465, 0.500445, materials = {"math_coeff" : "Material"})
     geometry.add_label(-0.540581, 0.239645, materials = {"math_coeff" : "none"})
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #32
0
    def setUp(self):  
        # model
        problem = agros2d.problem(clear = True)
        problem.coordinate_type = "axisymmetric"
        problem.mesh_type = "triangle"
        
        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()
        
        # fields
        self.math_coeff = agros2d.field("math_coeff")
        self.math_coeff.analysis_type = "steadystate"
        self.math_coeff.matrix_solver = "mumps"
        self.math_coeff.number_of_refinements = 3
        self.math_coeff.polynomial_order = 3
        self.math_coeff.solver = "linear"
        
        self.math_coeff.add_boundary("Dirichlet 1", "math_coeff_solution", {"math_coeff_solution" : 10})
        self.math_coeff.add_boundary("Dirichlet 2", "math_coeff_solution", {"math_coeff_solution" : -5})
        self.math_coeff.add_boundary("Flux", "math_coeff_flux", {"math_coeff_flux" : -30})
        self.math_coeff.add_boundary("Zero flux", "math_coeff_flux", {"math_coeff_flux" : 0})
        
        self.math_coeff.add_material("Material 1", {"math_coeff_c" : 5, "math_coeff_a" : 0, "math_coeff_beta_x" : 5, "math_coeff_beta_y" : 8, "math_coeff_f" : -50})
        self.math_coeff.add_material("Material 2", {"math_coeff_c" : 3, "math_coeff_a" : 0, "math_coeff_beta_x" : -3, "math_coeff_beta_y" : 4, "math_coeff_f" : 0})

        # geometry
        geometry = agros2d.geometry
        
        # edges
        geometry.add_edge(0, 1.6, 0, 0.95, boundaries = {"math_coeff" : "Zero flux"})
        geometry.add_edge(0, 0.95, 0.35, 0.45, boundaries = {"math_coeff" : "Zero flux"})
        geometry.add_edge(0.35, 0.45, 0.25, 0, boundaries = {"math_coeff" : "Zero flux"})
        geometry.add_edge(0.25, 0, 0, -0.25, boundaries = {"math_coeff" : "Zero flux"})
        geometry.add_edge(0, -0.25, 0.9, -0.75, boundaries = {"math_coeff" : "Dirichlet 1"})
        geometry.add_edge(0.9, -0.75, 1.65, 0.15, boundaries = {"math_coeff" : "Flux"})
        geometry.add_edge(1.65, 0.15, 1.25, 1.7, boundaries = {"math_coeff" : "Flux"})
        geometry.add_edge(1.25, 1.7, 0, 1.6, boundaries = {"math_coeff" : "Dirichlet 2"})
        geometry.add_edge(0.6, 1.1, 1.15, 0.95, boundaries = {"math_coeff" : "Zero flux"})
        geometry.add_edge(0.95, 0.6, 0.6, 1.1, boundaries = {"math_coeff" : "Zero flux"})
        geometry.add_edge(1.15, 0.95, 0.95, 0.6, boundaries = {"math_coeff" : "Zero flux"})
        geometry.add_edge(0.35, 0.45, 1.65, 0.15)
        
        # labels
        geometry.add_label(0.888828, 0.877296, materials = {"math_coeff" : "none"})
        geometry.add_label(0.301166, 0.88379, materials = {"math_coeff" : "Material 1"})
        geometry.add_label(0.755711, -0.216858, materials = {"math_coeff" : "Material 2"})
        
        agros2d.view.zoom_best_fit()
        
        # solve problem
        problem.solve()
Пример #33
0
 def setUp(self):                                                                                                                         
     # model
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "axisymmetric"
     problem.mesh_type = "triangle"        
     problem.frequency = 100
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.magnetic = agros2d.field("magnetic")
     self.magnetic.analysis_type = "harmonic"
     self.magnetic.number_of_refinements = 1
     self.magnetic.polynomial_order = 3
     self.magnetic.solver = "linear"
     
     self.magnetic.add_boundary("A = 0", "magnetic_potential", {"magnetic_potential_real" : 0})
     
     self.magnetic.add_material("Coil", {"magnetic_permeability" : 1, "magnetic_current_density_external_real" : 1e6}) 
     self.magnetic.add_material("Iron", {"magnetic_permeability" : 50, "magnetic_conductivity" : 5e3}) 
     self.magnetic.add_material("Air", {"magnetic_permeability" : 1}) 
     
     # geometry
     geometry = agros2d.geometry
     
     # edges
     geometry.add_edge(0, -0.17, 0.15, -0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.15, -0.17, 0.15, 0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.15, 0.17, 0, 0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.035, -0.03, 0.055, -0.03)
     geometry.add_edge(0.055, -0.03, 0.055, 0.11)
     geometry.add_edge(0.055, 0.11, 0.035, 0.11)
     geometry.add_edge(0.035, 0.11, 0.035, -0.03)
     geometry.add_edge(0, -0.05, 0.03, -0.05)
     geometry.add_edge(0.03, -0.05, 0.03, 0.05)
     geometry.add_edge(0.03, 0.05, 0, 0.05)
     geometry.add_edge(0, 0.05, 0, -0.05, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0, 0.17, 0, 0.05, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0, -0.05, 0, -0.17, boundaries = {"magnetic" : "A = 0"})
     
     # labels
     geometry.add_label(0.109339, 0.112786, materials = {"magnetic" : "Air"}, area=0)
     geometry.add_label(0.0442134, 0.0328588, materials = {"magnetic" : "Coil"}, area=0)
     geometry.add_label(0.0116506, -0.00740064, materials = {"magnetic" : "Iron"}, area=0)
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #34
0
 def setUp(self):                                                                                                                         
     # model
     self.problem = agros2d.problem(clear = True)
     self.problem.coordinate_type = "planar"
     self.problem.mesh_type = "triangle"        
     self.problem.frequency = 50
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.magnetic = agros2d.field("magnetic")
     self.magnetic.analysis_type = "harmonic"
     self.magnetic.number_of_refinements = 1
     self.magnetic.polynomial_order = 3
     self.magnetic.solver = "linear"
     
     self.magnetic.add_boundary("A = 0", "magnetic_potential", {"magnetic_potential_real" : 0})
     
     self.magnetic.add_material("Air", {"magnetic_permeability" : 1}) 
     self.magnetic.add_material("Cond 2", {"magnetic_permeability" : 1, "magnetic_current_density_external_real" : 3e7, "magnetic_conductivity" : 5.7e7}) 
     self.magnetic.add_material("Magnet", {"magnetic_permeability" : 1.1, "magnetic_remanence" : 0.1, "magnetic_remanence_angle" : 20})    
     
     # geometry
     self.geometry = agros2d.geometry
     
     # edges
     self.geometry.add_edge(-0.075, 0.06, 0.075, 0.06, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(0.075, 0.06, 0.075, -0.06, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(0.075, -0.06, -0.075, -0.06, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(-0.075, -0.06, -0.075, 0.06, boundaries = {"magnetic" : "A = 0"})
     self.geometry.add_edge(-0.015, -0.01, -0.015, 0.01)
     self.geometry.add_edge(-0.015, 0.01, -0.005, 0.01)
     self.geometry.add_edge(-0.015, -0.01, -0.005, -0.01)
     self.geometry.add_edge(-0.005, -0.01, -0.005, 0.01)
     self.geometry.add_edge(0.005, 0.02, 0.005, 0)
     self.geometry.add_edge(0.005, 0, 0.015, 0)
     self.geometry.add_edge(0.015, 0, 0.015, 0.02)
     self.geometry.add_edge(0.015, 0.02, 0.005, 0.02)
     self.geometry.add_edge(0.01, -0.01, 0.03, -0.01)
     self.geometry.add_edge(0.03, -0.03, 0.01, -0.03)
     self.geometry.add_edge(0.01, -0.01, 0.01, -0.03)
     self.geometry.add_edge(0.03, -0.01, 0.03, -0.03)
     
     # labels
     self.geometry.add_label(0.035349, 0.036683, materials = {"magnetic" : "Air"}, area=0)
     self.geometry.add_label(-0.0111161, -0.00311249, materials = {"magnetic" : "Cond 2"}, area=1e-05)
     self.geometry.add_label(0.016868, -0.0186625, materials = {"magnetic" : "Magnet"}, area=0)
     
     agros2d.view.zoom_best_fit()
Пример #35
0
 def setUp(self):       
     # model
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "axisymmetric"
     problem.mesh_type = "triangle"
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.electrostatic = agros2d.field("electrostatic")
     self.electrostatic.analysis_type = "steadystate"
     self.electrostatic.number_of_refinements = 1
     self.electrostatic.polynomial_order = 5
     self.electrostatic.solver = "linear"
     
     self.electrostatic.add_boundary("Source electrode", "electrostatic_potential", {"electrostatic_potential" : 10})
     self.electrostatic.add_boundary("Ground electrode", "electrostatic_potential", {"electrostatic_potential" : 0})
     self.electrostatic.add_boundary("Neumann BC", "electrostatic_surface_charge_density", {"electrostatic_surface_charge_density" : 0})
     
     self.electrostatic.add_material("Air", {"electrostatic_charge_density" : 0, "electrostatic_permittivity" : 1})
     self.electrostatic.add_material("Dielectric n.1", {"electrostatic_charge_density" : 1e-5, "electrostatic_permittivity" : 10})
     self.electrostatic.add_material("Dielectric n.2", {"electrostatic_charge_density" : 0, "electrostatic_permittivity" : 3})
     
     # geometry
     geometry = agros2d.geometry
     
     # edges
     geometry.add_edge(0, 0.2, 0, 0.08, boundaries = {"electrostatic" : "Neumann BC"})
     geometry.add_edge(0.01, 0.08, 0.01, 0, boundaries = {"electrostatic" : "Source electrode"})
     geometry.add_edge(0.01, 0, 0.03, 0, boundaries = {"electrostatic" : "Neumann BC"})
     geometry.add_edge(0.03, 0, 0.03, 0.08)
     geometry.add_edge(0.03, 0.08, 0.05, 0.08)
     geometry.add_edge(0.05, 0, 0.03, 0, boundaries = {"electrostatic" : "Neumann BC"})
     geometry.add_edge(0.05, 0.08, 0.05, 0, boundaries = {"electrostatic" : "Ground electrode"})
     geometry.add_edge(0.06, 0, 0.06, 0.08, boundaries = {"electrostatic" : "Ground electrode"})
     geometry.add_edge(0.05, 0.08, 0.06, 0.08, boundaries = {"electrostatic" : "Ground electrode"})
     geometry.add_edge(0.06, 0, 0.2, 0, boundaries = {"electrostatic" : "Neumann BC"})
     geometry.add_edge(0.01, 0.08, 0.03, 0.08)
     geometry.add_edge(0.01, 0.08, 0, 0.08, boundaries = {"electrostatic" : "Source electrode"})
     geometry.add_edge(0.2, 0, 0, 0.2, boundaries = {"electrostatic" : "Neumann BC"}, angle=90)
     
     # labels
     geometry.add_label(0.019, 0.021, materials = {"electrostatic" : "Dielectric n.1"})
     geometry.add_label(0.0379, 0.051, materials = {"electrostatic" : "Dielectric n.2"})
     geometry.add_label(0.0284191, 0.123601, materials = {"electrostatic" : "Air"})
     
     # solve
     agros2d.view.zoom_best_fit()
     problem.solve()
Пример #36
0
 def setUp(self):                                                                                                                         
     # model
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "axisymmetric"
     problem.mesh_type = "triangle"        
     problem.frequency = 100
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.magnetic = agros2d.field("magnetic")
     self.magnetic.analysis_type = "harmonic"
     self.magnetic.number_of_refinements = 1
     self.magnetic.polynomial_order = 3
     self.magnetic.solver = "linear"
     
     self.magnetic.add_boundary("A = 0", "magnetic_potential", {"magnetic_potential_real" : 0})
     
     self.magnetic.add_material("Coil", {"magnetic_permeability" : 1, "magnetic_current_density_external_real" : 1e6}) 
     self.magnetic.add_material("Iron", {"magnetic_permeability" : 50, "magnetic_conductivity" : 5e3}) 
     self.magnetic.add_material("Air", {"magnetic_permeability" : 1}) 
     
     # geometry
     geometry = agros2d.geometry
     
     # edges
     geometry.add_edge(0, -0.17, 0.15, -0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.15, -0.17, 0.15, 0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.15, 0.17, 0, 0.17, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0.035, -0.03, 0.055, -0.03)
     geometry.add_edge(0.055, -0.03, 0.055, 0.11)
     geometry.add_edge(0.055, 0.11, 0.035, 0.11)
     geometry.add_edge(0.035, 0.11, 0.035, -0.03)
     geometry.add_edge(0, -0.05, 0.03, -0.05)
     geometry.add_edge(0.03, -0.05, 0.03, 0.05)
     geometry.add_edge(0.03, 0.05, 0, 0.05)
     geometry.add_edge(0, 0.05, 0, -0.05, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0, 0.17, 0, 0.05, boundaries = {"magnetic" : "A = 0"})
     geometry.add_edge(0, -0.05, 0, -0.17, boundaries = {"magnetic" : "A = 0"})
     
     # labels
     geometry.add_label(0.109339, 0.112786, materials = {"magnetic" : "Air"}, area=0)
     geometry.add_label(0.0442134, 0.0328588, materials = {"magnetic" : "Coil"}, area=0)
     geometry.add_label(0.0116506, -0.00740064, materials = {"magnetic" : "Iron"}, area=0)
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #37
0
def simple_model():
    problem = a2d.problem(clear=True)
    problem.coordinate_type = "axisymmetric"

    field = a2d.field("electrostatic")
    field.adaptivity_type = "hp-adaptivity"
    field.number_of_refinements = 1
    field.polynomial_order = 2
    field.adaptivity_parameters["steps"] = 10
    field.adaptivity_parameters["tolerance"] = 1

    field.add_boundary("Source", "electrostatic_potential",
                       {"electrostatic_potential": 1000})
    field.add_boundary("Ground", "electrostatic_potential",
                       {"electrostatic_potential": 0})
    field.add_boundary("Border", "electrostatic_surface_charge_density",
                       {"electrostatic_surface_charge_density": 0})
    field.add_material("Air", {
        "electrostatic_permittivity": 1,
        "electrostatic_charge_density": 0
    })

    geometry = a2d.geometry
    geometry.add_edge(0.2, 0.6, 0, 0.1, boundaries={"electrostatic": "Source"})
    geometry.add_edge(0, 0.1, 0, -0.1, boundaries={"electrostatic": "Border"})
    geometry.add_edge(0, -0.6, 0, -1.6, boundaries={"electrostatic": "Border"})
    geometry.add_edge(0, 0.6, 0.2, 0.6, boundaries={"electrostatic": "Source"})
    geometry.add_edge(0, 1.6, 0, 0.6, boundaries={"electrostatic": "Border"})
    geometry.add_edge(0,
                      -0.1,
                      0.2,
                      -0.6,
                      boundaries={"electrostatic": "Ground"})
    geometry.add_edge(0,
                      -0.6,
                      0.2,
                      -0.6,
                      boundaries={"electrostatic": "Ground"})
    geometry.add_edge(0, 1.6, 1.6, 1.6, boundaries={"electrostatic": "Border"})
    geometry.add_edge(1.6,
                      1.6,
                      1.6,
                      -1.6,
                      boundaries={"electrostatic": "Border"})
    geometry.add_edge(1.6,
                      -1.6,
                      0,
                      -1.6,
                      boundaries={"electrostatic": "Border"})
    geometry.add_label(0.8, 0.8, materials={"electrostatic": "Air"})
Пример #38
0
    def setUp(self):  
        # model
        problem = agros2d.problem(clear = True)
        problem.coordinate_type = "planar"
        problem.mesh_type = "triangle"
        
        problem.frequency = 50
        
        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()
        
        # fields
        self.magnetic = agros2d.field("magnetic")
        self.magnetic.analysis_type = "harmonic"
        self.magnetic.number_of_refinements = 1
        self.magnetic.polynomial_order = 3
        
        self.magnetic.solver = "newton"
        self.magnetic.solver_parameters['residual'] = 0.01
        self.magnetic.solver_parameters['damping_factor'] = 0.7
        self.magnetic.solver_parameters['damping'] = 'automatic'
        self.magnetic.solver_parameters['jacobian_reuse'] = True
        self.magnetic.solver_parameters['jacobian_reuse_ratio'] = 0.9
        self.magnetic.solver_parameters['jacobian_reuse_steps'] = 20        

        self.magnetic.add_boundary("A = 0", "magnetic_potential", {"magnetic_potential_imag" : 0, "magnetic_potential_real" : 0})
        
        self.magnetic.add_material("Zelezo", {"magnetic_conductivity" : 5e6, "magnetic_current_density_external_imag" : 0, "magnetic_current_density_external_real" : 3e6, "magnetic_permeability" : { "value" : 5000, 
            "x" : [0,0.227065,0.45413,0.681195,0.90826,1.13533,1.36239,1.58935,1.81236,2.01004,2.13316,2.19999,2.25479,2.29993,2.34251,2.37876,2.41501,2.45126,2.4875,2.52375,2.56,3,5,10,20], 
            "y" : [13001,13001,13001,12786,12168,10967,7494,1409,315,90,41,26,19,15,12,11,9,8,8,7,6,4,3,3,2] 
            }, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_angular" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0})
        
        # geometry
        geometry = agros2d.geometry
        
        # edges
        geometry.add_edge(0, 0.0035, -0.0035, 0, boundaries = {"magnetic" : "A = 0"}, angle = 90)
        geometry.add_edge(-0.0035, 0, 0, -0.0035, boundaries = {"magnetic" : "A = 0"}, angle = 90)
        geometry.add_edge(0, -0.0035, 0.0035, 0, boundaries = {"magnetic" : "A = 0"}, angle = 90)
        geometry.add_edge(0.0035, 0, 0, 0.0035, boundaries = {"magnetic" : "A = 0"}, angle = 90)
        
        # labels
        geometry.add_label(0, 0, materials = {"magnetic" : "Zelezo"}, area = 5e-07)
        
        agros2d.view.zoom_best_fit()
        
        # solve problem
        problem.solve()
Пример #39
0
 def setUp(self):  
     # model
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "planar"
     problem.mesh_type = "triangle"
     problem.frequency = 2000
     
     # disable view
     agros2d.view.mesh.disable()
     agros2d.view.post2d.disable()
     
     # fields
     self.acoustic = agros2d.field("acoustic")
     self.acoustic.analysis_type = "harmonic"
     self.acoustic.number_of_refinements = 3
     self.acoustic.polynomial_order = 2
     self.acoustic.solver = "linear"
     
     self.acoustic.add_boundary("Source", "acoustic_pressure", {"acoustic_pressure_real" : 0.01, "acoustic_pressure_imag" : 0})
     self.acoustic.add_boundary("Wall", "acoustic_normal_acceleration", {"acoustic_normal_acceleration_real" : 0, "acoustic_normal_acceleration_imag" : 0})
     self.acoustic.add_boundary("Matched boundary", "acoustic_impedance", {"acoustic_impedance" : 1.25*343})
     
     self.acoustic.add_material("Air", {"acoustic_speed" : 343, "acoustic_density" : 1.25})
     
     # geometry
     geometry = agros2d.geometry
     
     # edges
     geometry.add_edge(-0.4, 0.05, 0.1, 0.2, boundaries = {"acoustic" : "Matched boundary"})
     geometry.add_edge(0.1, -0.2, -0.4, -0.05, boundaries = {"acoustic" : "Matched boundary"})
     geometry.add_edge(-0.4, 0.05, -0.4, -0.05, boundaries = {"acoustic" : "Matched boundary"})
     geometry.add_edge(-0.18, -0.06, -0.17, -0.05, boundaries = {"acoustic" : "Source"}, angle=90)
     geometry.add_edge(-0.17, -0.05, -0.18, -0.04, boundaries = {"acoustic" : "Source"}, angle=90)
     geometry.add_edge(-0.18, -0.04, -0.19, -0.05, boundaries = {"acoustic" : "Source"}, angle=90)
     geometry.add_edge(-0.19, -0.05, -0.18, -0.06, boundaries = {"acoustic" : "Source"}, angle=90)
     geometry.add_edge(0.1, -0.2, 0.1, 0.2, boundaries = {"acoustic" : "Matched boundary"}, angle=90)
     geometry.add_edge(0.03, 0.1, -0.04, -0.05, boundaries = {"acoustic" : "Wall"}, angle=90)
     geometry.add_edge(-0.04, -0.05, 0.08, -0.04, boundaries = {"acoustic" : "Wall"})
     geometry.add_edge(0.08, -0.04, 0.03, 0.1, boundaries = {"acoustic" : "Wall"})
     
     # labels
     geometry.add_label(-0.0814934, 0.0707097, materials = {"acoustic" : "Air"})
     geometry.add_label(-0.181474, -0.0504768)
     geometry.add_label(0.0314514, 0.0411749)
     
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #40
0
 def setUp(self):  
     # problem
     problem = agros2d.problem(clear = True)
     problem.coordinate_type = "axisymmetric"
     problem.mesh_type = "triangle"
     problem.frequency = 50
     
     # magnetic
     self.magnetic = agros2d.field("magnetic")
     self.magnetic.analysis_type = "harmonic"
     self.magnetic.matrix_solver = "mumps"
     self.magnetic.number_of_refinements = 3
     self.magnetic.polynomial_order = 3
     self.magnetic.adaptivity_type = "disabled"
     self.magnetic.solver = "newton"
     self.magnetic.solver_parameters['residual'] = 0.01
     self.magnetic.solver_parameters['damping'] = "automatic"
     self.magnetic.solver_parameters['damping_factor'] = 0.8
     self.magnetic.solver_parameters['jacobian_reuse'] = True
     self.magnetic.solver_parameters['jacobian_reuse_ratio'] = 0.8
     self.magnetic.solver_parameters['damping_factor_decrease_ratio'] = 1.2
     self.magnetic.solver_parameters['jacobian_reuse_steps'] = 20
     self.magnetic.solver_parameters['damping_factor_increase_steps'] = 1
             
     # boundaries
     self.magnetic.add_boundary("A=0", "magnetic_potential", {"magnetic_potential_real" : 0, "magnetic_potential_imag" : 0})
             
     # materials
     self.magnetic.add_material("new material", {"magnetic_permeability" : { "value" : 9300, 
         "x" : [0,0.227065,0.45413,0.681195,0.90826,1.13533,1.36239,1.58935,1.81236,2.01004,2.13316,2.19999,2.25479,2.29993,2.34251,2.37876,2.41501,2.45126,2.4875,2.52375,2.56,3,5,10,20], 
         "y" : [13001,13001,13001,12786,12168,10967,7494,1409,315,90,41,26,19,15,12,11,9,8,8,7,6,4,3,3,2], 
         "interpolation" : "piecewise_linear", "extrapolation" : "constant", "derivative_at_endpoints" : "first" }, 
         "magnetic_conductivity" : 5e6, "magnetic_remanence" : 0, "magnetic_remanence_angle" : 0, "magnetic_velocity_x" : 0, "magnetic_velocity_y" : 0, "magnetic_velocity_angular" : 0, 
         "magnetic_current_density_external_real" : 1e6, "magnetic_current_density_external_imag" : 0, "magnetic_total_current_prescribed" : 0, "magnetic_total_current_real" : 0, "magnetic_total_current_imag" : 0})
     
     # geometry
     geometry = agros2d.geometry
     geometry.add_edge(0.004, 0, 0.007, -0.003, angle = 90, boundaries = {"magnetic" : "A=0"})
     geometry.add_edge(0.007, -0.003, 0.01, 0, angle = 90, boundaries = {"magnetic" : "A=0"})
     geometry.add_edge(0.01, 0, 0.007, 0.003, angle = 90, boundaries = {"magnetic" : "A=0"})
     geometry.add_edge(0.007, 0.003, 0.004, 0, angle = 90, boundaries = {"magnetic" : "A=0"})
     
     geometry.add_label(0.0069576, -0.000136791, materials = {"magnetic" : "new material"})
     agros2d.view.zoom_best_fit()
     
     # solve problem
     problem.solve()
Пример #41
0
def get_energy(dphi, Jext):
    problem = agros2d.problem()
    magnetic = agros2d.field("magnetic")

    for coil in Jext:
        magnetic.modify_material(
            "Copper {0}+".format(coil),
            {"magnetic_current_density_external_real": +Jext[coil]})
        magnetic.modify_material(
            "Copper {0}-".format(coil),
            {"magnetic_current_density_external_real": -Jext[coil]})

    geometry = agros2d.geometry
    geometry.select_edges(range(64, 80))
    geometry.rotate_selection(0, 0, dphi)

    problem.solve()
    return magnetic.volume_integrals()['Wm']
Пример #42
0
    def model(self):
        self.problem = a2d.problem(clear = True)

        self.electrostatic = a2d.field("electrostatic")
        self.electrostatic.add_boundary("Source", "electrostatic_potential", {"electrostatic_potential" : 10})
        self.electrostatic.add_boundary("Ground", "electrostatic_potential", {"electrostatic_potential" : 0})
        self.electrostatic.add_boundary("Neumann", "electrostatic_surface_charge_density", {"electrostatic_surface_charge_density" : 0})
        self.electrostatic.add_material("Dielectricum", {"electrostatic_permittivity" : 3, "electrostatic_charge_density" : 0})

        self.a = 1
        self.b = 1

        self.geometry = a2d.geometry
        self.geometry.add_edge(0, 0, self.a, 0, boundaries = {"electrostatic" : "Neumann"})
        self.geometry.add_edge(self.a, 0, self.a, self.b, boundaries = {"electrostatic" : "Ground"})
        self.geometry.add_edge(self.a, self.b, 0, self.b, boundaries = {"electrostatic" : "Neumann"})
        self.geometry.add_edge(0, self.b, 0, 0, boundaries = {"electrostatic" : "Source"})
        self.geometry.add_label(self.a/2.0, self.b/2.0, materials = {"electrostatic" : "Dielectricum"})
Пример #43
0
    def setUp(self):
        self.problem = a2d.problem(clear = True)
        current = a2d.field('current')
        current.add_boundary("Source", "current_potential", {"current_potential" : 10})
        current.add_boundary("Ground", "current_potential", {"current_potential" : 0})
        current.add_boundary("Neumann", "current_inward_current_flow", {"current_inward_current_flow" : 0})
        current.add_material("Copper", {"current_conductivity" : 33e6})

        self.heat = a2d.field('heat')
        self.heat.analysis_type = 'transient'
        self.heat.add_boundary("Convection", "heat_heat_flux", {"heat_convection_heat_transfer_coefficient" : 10,
                                                                "heat_convection_external_temperature" : 293})
        self.heat.add_material("Copper", {"heat_conductivity" : 200, "heat_density" : 8700, "heat_specific_heat" : 385})

        a2d.geometry.add_edge(0, 0, 1, 0, boundaries = {'current' : 'Neumann', 'heat' : 'Convection'})
        a2d.geometry.add_edge(1, 0, 1, 1, boundaries = {'current' : 'Ground', 'heat' : 'Convection'})
        a2d.geometry.add_edge(1, 1, 0, 1, boundaries = {'current' : 'Neumann', 'heat' : 'Convection'})
        a2d.geometry.add_edge(0, 1, 0, 0, boundaries = {'current' : 'Source', 'heat' : 'Convection'})
        a2d.geometry.add_label(0.5, 0.5, materials = {'current' : 'Copper', 'heat' : 'Copper'})
Пример #44
0
def save_solution_test():
    problem = agros2d.problem()
    field = agros2d.field('magnetic')
    problem.solve()

    values_from_solution = [
        field.local_values(0.05, 0),
        field.surface_integrals([0, 1, 2]),
        field.volume_integrals()
    ]

    from os import path
    filename = '{0}/temp.a2d'.format(path.dirname(pythonlab.tempname()))
    agros2d.save_file(filename, True)
    agros2d.open_file(filename, True)

    field = agros2d.field('magnetic')
    values_from_file = [
        field.local_values(0.05, 0),
        field.surface_integrals([0, 1, 2]),
        field.volume_integrals()
    ]

    return compare(values_from_solution, values_from_file)
Пример #45
0
    def setUp(self):
        # model
        self.problem = agros2d.problem(clear=True)
        self.problem.coordinate_type = "axisymmetric"
        self.problem.mesh_type = "triangle"

        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()

        # fields
        self.magnetic = agros2d.field("magnetic")
        self.magnetic.analysis_type = "steadystate"
        self.magnetic.number_of_refinements = 0
        self.magnetic.polynomial_order = 7
        self.magnetic.solver = "linear"

        self.magnetic.add_boundary("A = 0", "magnetic_potential",
                                   {"magnetic_potential_real": 0})

        self.magnetic.add_material("Fe", {"magnetic_permeability": 300})
        self.magnetic.add_material("Air", {"magnetic_permeability": 1})
        self.magnetic.add_material(
            "Magnet", {
                "magnetic_permeability": 1.1,
                "magnetic_remanence": 0.6,
                "magnetic_remanence_angle": 90
            })

        # geometry
        self.geometry = agros2d.geometry

        # edges
        self.geometry.add_edge(0.01, 0.01, 0.01, 0)
        self.geometry.add_edge(
            0.01,
            0,
            0.04,
            0,
        )
        self.geometry.add_edge(
            0.04,
            0.1,
            0,
            0.1,
        )
        self.geometry.add_edge(0,
                               0.1,
                               0,
                               0.08,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0, 0.08, 0.01, 0.08)
        self.geometry.add_edge(0.01, 0.09, 0.03, 0.09)
        self.geometry.add_edge(0.01, 0.09, 0.01, 0.08)
        self.geometry.add_edge(0.01, 0.01, 0.03, 0.01)
        self.geometry.add_edge(0.012, 0.088, 0.012, 0.012)
        self.geometry.add_edge(0.012, 0.012, 0.028, 0.012)
        self.geometry.add_edge(0.028, 0.012, 0.028, 0.088)
        self.geometry.add_edge(0.028, 0.088, 0.012, 0.088)
        self.geometry.add_edge(0, 0.05, 0.009, 0.05)
        self.geometry.add_edge(0.009, 0.05, 0.009, -0.02)
        self.geometry.add_edge(0,
                               0.05,
                               0,
                               -0.02,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0, -0.02, 0.009, -0.02)
        self.geometry.add_edge(0,
                               0.15,
                               0,
                               0.1,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0,
                               0.08,
                               0,
                               0.05,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0,
                               -0.02,
                               0,
                               -0.05,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0,
                               -0.05,
                               0.1,
                               0.05,
                               boundaries={"magnetic": "A = 0"},
                               angle=90)
        self.geometry.add_edge(0.1,
                               0.05,
                               0,
                               0.15,
                               boundaries={"magnetic": "A = 0"},
                               angle=90)
        self.geometry.add_edge(0.03, 0.09, 0.03, 0.078)
        self.geometry.add_edge(0.03, 0.078, 0.04, 0.078)
        self.geometry.add_edge(0.04, 0.078, 0.04, 0.1)
        self.geometry.add_edge(0.04, 0.078, 0.04, 0.052)
        self.geometry.add_edge(0.03, 0.078, 0.03, 0.052)
        self.geometry.add_edge(0.03, 0.052, 0.04, 0.052)
        self.geometry.add_edge(0.04, 0.052, 0.04, 0)
        self.geometry.add_edge(0.03, 0.01, 0.03, 0.052)

        # labels
        self.geometry.add_label(0.0348743,
                                0.0347237,
                                materials={"magnetic": "Fe"})
        self.geometry.add_label(0.00512569,
                                -0.0070852,
                                area=0.8e-06,
                                materials={"magnetic": "Fe"})
        self.geometry.add_label(0.0141705,
                                0.12445,
                                materials={"magnetic": "Air"})
        self.geometry.add_label(0.0346923,
                                0.0892198,
                                materials={"magnetic": "Fe"})
        self.geometry.add_label(0.036093,
                                0.0654078,
                                materials={"magnetic": "Magnet"})

        agros2d.view.zoom_best_fit()
Пример #46
0
    def setUp(self):
        # model
        self.problem = agros2d.problem(clear=True)
        self.problem.coordinate_type = "planar"
        self.problem.mesh_type = "triangle"
        self.problem.frequency = 100

        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()

        # fields
        self.magnetic = agros2d.field("magnetic")
        self.magnetic.analysis_type = "steadystate"
        self.magnetic.number_of_refinements = 1
        self.magnetic.polynomial_order = 5
        self.magnetic.solver = "linear"

        self.magnetic.add_boundary("A = 0", "magnetic_potential",
                                   {"magnetic_potential_real": 0})

        self.magnetic.add_material("Fe", {"magnetic_permeability": 500})
        self.magnetic.add_material("Air", {"magnetic_permeability": 1})
        self.magnetic.add_material(
            "Magnet", {
                "magnetic_permeability": 1.11,
                "magnetic_remanence": 0.1,
                "magnetic_remanence_angle": -30
            })
        self.magnetic.add_material(
            "Velocity", {
                "magnetic_permeability": 1,
                "magnetic_conductivity": 1e7,
                "magnetic_velocity_x": 2
            })

        # geometry
        self.geometry = agros2d.geometry

        # edges
        self.geometry.add_edge(-0.5,
                               1,
                               0.5,
                               1,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0.5,
                               -1,
                               -0.5,
                               -1,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(-0.2, 0.6, 0, 0.6)
        self.geometry.add_edge(0, 0.3, 0, 0.6)
        self.geometry.add_edge(-0.2, 0.3, 0, 0.3)
        self.geometry.add_edge(-0.2, 0.6, -0.2, 0.3)
        self.geometry.add_edge(-0.035, 0.135, 0.035, 0.135)
        self.geometry.add_edge(0.035, 0.135, 0.035, -0.04)
        self.geometry.add_edge(0.035, -0.04, -0.035, -0.04)
        self.geometry.add_edge(-0.035, 0.135, -0.035, -0.04)
        self.geometry.add_edge(0, -0.5, 0.3, -0.5)
        self.geometry.add_edge(0.3, -0.5, 0.3, -0.32)
        self.geometry.add_edge(0.3, -0.32, 0, -0.32)
        self.geometry.add_edge(0, -0.32, 0, -0.5)
        self.geometry.add_edge(-0.5,
                               1,
                               -0.5,
                               -0.15,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(-0.5,
                               -0.15,
                               -0.5,
                               -0.2,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(-0.5,
                               -0.2,
                               -0.5,
                               -1,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0.5,
                               1,
                               0.5,
                               -0.15,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0.5,
                               -0.15,
                               0.5,
                               -0.2,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0.5,
                               -0.2,
                               0.5,
                               -1,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0.5, -0.2, -0.5, -0.2)
        self.geometry.add_edge(0.5, -0.15, -0.5, -0.15)

        # labels
        self.geometry.add_label(-0.0959509,
                                0.445344,
                                area=0.0002,
                                materials={"magnetic": "Fe"})
        self.geometry.add_label(-0.145434,
                                -0.706253,
                                area=0.01,
                                materials={"magnetic": "Air"})
        self.geometry.add_label(0.143596,
                                -0.364811,
                                materials={"magnetic": "Magnet"})
        self.geometry.add_label(0.310203,
                                0.631164,
                                materials={"magnetic": "Air"})
        self.geometry.add_label(-0.295858,
                                -0.182894,
                                materials={"magnetic": "Velocity"})

        agros2d.view.zoom_best_fit()
Пример #47
0
    def setUp(self):
        # model
        problem = agros2d.problem(clear=True)
        problem.coordinate_type = "axisymmetric"
        problem.mesh_type = "triangle"

        # magnetic
        self.magnetic = agros2d.field("magnetic")
        self.magnetic.analysis_type = "steadystate"
        self.magnetic.matrix_solver = "mumps"
        self.magnetic.number_of_refinements = 0
        self.magnetic.polynomial_order = 7
        self.magnetic.adaptivity_type = "disabled"
        self.magnetic.solver = "newton"
        self.magnetic.solver_parameters['residual'] = 1e-06
        self.magnetic.solver_parameters['relative_change_of_solutions'] = 0.01
        self.magnetic.solver_parameters['damping'] = "automatic"
        self.magnetic.solver_parameters['damping_factor'] = 0.8
        self.magnetic.solver_parameters['damping_factor_increase_steps'] = 1
        self.magnetic.solver_parameters['damping_factor_decrease_ratio'] = 1.2
        self.magnetic.solver_parameters['jacobian_reuse'] = True
        self.magnetic.solver_parameters['jacobian_reuse_ratio'] = 0.8
        self.magnetic.solver_parameters['jacobian_reuse_steps'] = 20

        # boundaries
        self.magnetic.add_boundary("A = 0", "magnetic_potential",
                                   {"magnetic_potential_real": 0})

        # materials
        self.magnetic.add_material(
            "Cu", {
                "magnetic_permeability": 1,
                "magnetic_conductivity": 0,
                "magnetic_remanence": 0,
                "magnetic_remanence_angle": 0,
                "magnetic_velocity_x": 0,
                "magnetic_velocity_y": 0,
                "magnetic_velocity_angular": 0,
                "magnetic_current_density_external_real": 2e+06,
                "magnetic_total_current_prescribed": 0,
                "magnetic_total_current_real": 0
            })
        self.magnetic.add_material(
            "Fe", {
                "magnetic_permeability": {
                    "value":
                    300,
                    "x": [
                        0, 0.170911, 0.177249, 0.20487, 0.212115, 0.253777,
                        0.275513, 0.282755, 0.328941, 0.405909, 0.424924,
                        0.771689, 0.858155, 1.2092, 1.33438, 1.3589, 1.51368,
                        1.60909, 1.64417, 1.66552, 1.69157, 1.73858, 1.79572,
                        1.82437, 1.93984, 1.9929, 2.00005, 2.01811, 2.07161,
                        2.08962, 2.20335, 2.30633, 2.48983
                    ],
                    "y": [
                        729.678, 982.941, 1008.92, 1119.05, 1146.74, 1289.7,
                        1357.53, 1378.93, 1508.03, 1696.32, 1739.63, 2274.94,
                        2330.44, 2002.5, 1706.76, 1633.54, 997.751, 638.141,
                        524.418, 464.22, 399.375, 297.585, 211.579, 176.496,
                        87.0871, 62.8709, 59.9063, 53.3691, 37.7024, 33.2283,
                        16.7621, 10.3287, 6.16704
                    ],
                    "interpolation":
                    "piecewise_linear",
                    "extrapolation":
                    "constant",
                    "derivative_at_endpoints":
                    "first"
                },
                "magnetic_conductivity": 0,
                "magnetic_remanence": 0,
                "magnetic_remanence_angle": 0,
                "magnetic_velocity_x": 0,
                "magnetic_velocity_y": 0,
                "magnetic_velocity_angular": 0,
                "magnetic_current_density_external_real": 0,
                "magnetic_total_current_prescribed": 0,
                "magnetic_total_current_real": 0
            })
        self.magnetic.add_material(
            "Air", {
                "magnetic_permeability": 1,
                "magnetic_conductivity": 0,
                "magnetic_remanence": 0,
                "magnetic_remanence_angle": 0,
                "magnetic_velocity_x": 0,
                "magnetic_velocity_y": 0,
                "magnetic_velocity_angular": 0,
                "magnetic_current_density_external_real": 0,
                "magnetic_total_current_prescribed": 0,
                "magnetic_total_current_real": 0
            })
        self.magnetic.add_material(
            "Magnet", {
                "magnetic_permeability": 1.1,
                "magnetic_conductivity": 0,
                "magnetic_remanence": 0.6,
                "magnetic_remanence_angle": 90,
                "magnetic_velocity_x": 0,
                "magnetic_velocity_y": 0,
                "magnetic_velocity_angular": 0,
                "magnetic_current_density_external_real": 0,
                "magnetic_total_current_prescribed": 0,
                "magnetic_total_current_real": 0
            })

        # geometry
        geometry = agros2d.geometry
        geometry.add_edge(0.01, 0.01, 0.01, 0)
        geometry.add_edge(0.01, 0, 0.04, 0)
        geometry.add_edge(0.04, 0.1, 0, 0.1)
        geometry.add_edge(0, 0.1, 0, 0.08, boundaries={"magnetic": "A = 0"})
        geometry.add_edge(0, 0.08, 0.01, 0.08)
        geometry.add_edge(0.01, 0.09, 0.03, 0.09)
        geometry.add_edge(0.01, 0.09, 0.01, 0.08)
        geometry.add_edge(0.01, 0.01, 0.03, 0.01)
        geometry.add_edge(0.012, 0.088, 0.012, 0.012)
        geometry.add_edge(0.012, 0.012, 0.028, 0.012)
        geometry.add_edge(0.028, 0.012, 0.028, 0.088)
        geometry.add_edge(0.028, 0.088, 0.012, 0.088)
        geometry.add_edge(0, 0.05, 0.009, 0.05)
        geometry.add_edge(0.009, 0.05, 0.009, -0.02)
        geometry.add_edge(0, 0.05, 0, -0.02, boundaries={"magnetic": "A = 0"})
        geometry.add_edge(0, -0.02, 0.009, -0.02)
        geometry.add_edge(0, 0.15, 0, 0.1, boundaries={"magnetic": "A = 0"})
        geometry.add_edge(0, 0.08, 0, 0.05, boundaries={"magnetic": "A = 0"})
        geometry.add_edge(0, -0.02, 0, -0.05, boundaries={"magnetic": "A = 0"})
        geometry.add_edge(0,
                          -0.05,
                          0.1,
                          0.05,
                          angle=90,
                          boundaries={"magnetic": "A = 0"})
        geometry.add_edge(0.1,
                          0.05,
                          0,
                          0.15,
                          angle=90,
                          boundaries={"magnetic": "A = 0"})
        geometry.add_edge(0.03, 0.09, 0.03, 0.078)
        geometry.add_edge(0.03, 0.078, 0.04, 0.078)
        geometry.add_edge(0.04, 0.078, 0.04, 0.1)
        geometry.add_edge(0.04, 0.078, 0.04, 0.052)
        geometry.add_edge(0.03, 0.078, 0.03, 0.052)
        geometry.add_edge(0.03, 0.052, 0.04, 0.052)
        geometry.add_edge(0.04, 0.052, 0.04, 0)
        geometry.add_edge(0.03, 0.01, 0.03, 0.052)

        geometry.add_label(0.0348743, 0.0347237, materials={"magnetic": "Fe"})
        geometry.add_label(0.00512569,
                           -0.0070852,
                           area=8e-07,
                           materials={"magnetic": "Fe"})
        geometry.add_label(0.021206, 0.0692964, materials={"magnetic": "Cu"})
        geometry.add_label(0.0141705, 0.12445, materials={"magnetic": "Air"})
        geometry.add_label(0.0346923, 0.0892198, materials={"magnetic": "Fe"})
        geometry.add_label(0.036093,
                           0.0654078,
                           materials={"magnetic": "Magnet"})

        agros2d.view.zoom_best_fit()

        # solve problem
        problem.solve()
Пример #48
0
    def setUpGeneral(self, curr_heat, heat_elast):
        # problem
        problem = agros2d.problem(clear=True)
        problem.coordinate_type = "planar"
        problem.mesh_type = "triangle"

        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()

        # fields
        # current
        self.current = agros2d.field("current")
        self.current.analysis_type = "steadystate"
        self.current.matrix_solver = "mumps"
        self.current.number_of_refinements = 1
        self.current.polynomial_order = 2
        self.current.adaptivity_type = "disabled"

        # boundaries
        self.current.add_boundary("Source", "current_potential",
                                  {"current_potential": 10})
        self.current.add_boundary("Ground", "current_potential",
                                  {"current_potential": 0})
        self.current.add_boundary("Neumann", "current_inward_current_flow",
                                  {"current_inward_current_flow": 0})

        # materials
        self.current.add_material("Cond 1", {"current_conductivity": 3.3e+07})
        self.current.add_material("Cond 2", {"current_conductivity": 5.7e+07})

        if (curr_heat == "hard"):
            self.current.solver = "newton"
        else:
            self.current.solver = "linear"

        # heat
        self.heat = agros2d.field("heat")
        self.heat.analysis_type = "steadystate"
        self.heat.matrix_solver = "mumps"
        self.heat.number_of_refinements = 1
        self.heat.polynomial_order = 2
        self.heat.adaptivity_type = "disabled"

        # boundaries
        self.heat.add_boundary(
            "zero flux", "heat_heat_flux", {
                "heat_heat_flux": 0,
                "heat_convection_heat_transfer_coefficient": 5,
                "heat_convection_external_temperature": 20,
                "heat_radiation_emissivity": 0,
                "heat_radiation_ambient_temperature": 20
            })
        self.heat.add_boundary("t=0", "heat_temperature",
                               {"heat_temperature": 0})

        # materials
        self.heat.add_material(
            "heat", {
                "heat_conductivity": 385,
                "heat_volume_heat": 0,
                "heat_velocity_x": 0,
                "heat_velocity_y": 0,
                "heat_velocity_angular": 0,
                "heat_density": 0,
                "heat_specific_heat": 0
            })
        self.heat.add_material(
            "heat2", {
                "heat_conductivity": 38500,
                "heat_volume_heat": 0,
                "heat_velocity_x": 0,
                "heat_velocity_y": 0,
                "heat_velocity_angular": 0,
                "heat_density": 0,
                "heat_specific_heat": 0
            })

        if (curr_heat == "hard"):
            self.heat.solver = "newton"
        else:
            self.heat.solver = "linear"

        # elasticity
        self.elasticity = agros2d.field("elasticity")
        self.elasticity.analysis_type = "steadystate"
        self.elasticity.matrix_solver = "mumps"
        self.elasticity.number_of_refinements = 0
        self.elasticity.polynomial_order = 3
        self.elasticity.adaptivity_type = "disabled"

        # boundaries
        self.elasticity.add_boundary("fixed", "elasticity_fixed_fixed", {
            "elasticity_displacement_x": 0,
            "elasticity_displacement_y": 0
        })
        self.elasticity.add_boundary("fixed-free", "elasticity_fixed_free", {
            "elasticity_displacement_x": 0,
            "elasticity_force_y": 0
        })

        # materials
        self.elasticity.add_material(
            "structural", {
                "elasticity_young_modulus": 1e+11,
                "elasticity_poisson_ratio": 0.3,
                "elasticity_volume_force_x": 0,
                "elasticity_volume_force_y": 0,
                "elasticity_alpha": 1e-05,
                "elasticity_temperature_difference": 0,
                "elasticity_temperature_reference": 0
            })

        if ((heat_elast == "hard") and (self.heat.solver == "newton")):
            self.elasticity.solver = "newton"
        else:
            self.elasticity.solver = "linear"

        # electrostatic
        self.electrostatic = agros2d.field("electrostatic")
        self.electrostatic.analysis_type = "steadystate"
        self.electrostatic.matrix_solver = "mumps"
        self.electrostatic.number_of_refinements = 1
        self.electrostatic.polynomial_order = 2
        self.electrostatic.adaptivity_type = "disabled"
        self.electrostatic.solver = "linear"

        # boundaries
        self.electrostatic.add_boundary("electrode1",
                                        "electrostatic_potential",
                                        {"electrostatic_potential": 1000})
        self.electrostatic.add_boundary("electrode2",
                                        "electrostatic_potential",
                                        {"electrostatic_potential": 0})
        self.electrostatic.add_boundary(
            "neuman", "electrostatic_surface_charge_density",
            {"electrostatic_surface_charge_density": 0})

        # materials
        self.electrostatic.add_material("electrostatic", {
            "electrostatic_permittivity": 1,
            "electrostatic_charge_density": 0
        })

        # coupling
        problem.set_coupling_type("current", "heat", curr_heat)
        problem.set_coupling_type("heat", "elasticity", heat_elast)

        # geometry
        geometry = agros2d.geometry
        geometry.add_edge(0, 0.1, 0, 0, boundaries={"current": "Source"})
        geometry.add_edge(0.15, 0, 0.15, 0.1, boundaries={"current": "Ground"})
        geometry.add_edge(0, 0, 0.05, 0, boundaries={"current": "Neumann"})
        geometry.add_edge(0.05, 0, 0.15, 0, boundaries={"current": "Neumann"})
        geometry.add_edge(0.05, 0.1, 0.05, 0)
        geometry.add_edge(0.05, 0.1, 0, 0.1, boundaries={"current": "Neumann"})
        geometry.add_edge(0.05,
                          0.1,
                          0.15,
                          0.1,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.085,
                          0.065,
                          0.085,
                          0.06,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.085,
                          0.06,
                          0.09,
                          0.06,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.09,
                          0.06,
                          0.09,
                          0.065,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.09,
                          0.065,
                          0.085,
                          0.065,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.065,
                          0.03,
                          0.065,
                          0.01,
                          boundaries={"heat": "zero flux"})
        geometry.add_edge(0.065, 0.01, 0.09, 0.01, boundaries={"heat": "t=0"})
        geometry.add_edge(0.07,
                          0.025,
                          0.075,
                          0.025,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.075,
                          0.025,
                          0.075,
                          0.015,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.075,
                          0.015,
                          0.07,
                          0.015,
                          boundaries={"elasticity": "fixed"})
        geometry.add_edge(0.07,
                          0.015,
                          0.07,
                          0.025,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.08,
                          0.025,
                          0.08,
                          0.015,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.08,
                          0.015,
                          0.085,
                          0.015,
                          boundaries={"elasticity": "fixed"})
        geometry.add_edge(0.06,
                          0.07,
                          0.06,
                          0.06,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.065,
                          0.06,
                          0.06,
                          0.06,
                          boundaries={"elasticity": "fixed"})
        geometry.add_edge(0.065,
                          0.06,
                          0.065,
                          0.07,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.065,
                          0.07,
                          0.06,
                          0.07,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.115,
                          0.02,
                          0.12,
                          0.02,
                          boundaries={"elasticity": "fixed"})
        geometry.add_edge(0.12,
                          0.03,
                          0.115,
                          0.03,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.12,
                          0.04,
                          0.145,
                          0.04,
                          boundaries={"heat": "zero flux"})
        geometry.add_edge(0.145,
                          0.04,
                          0.145,
                          0.02,
                          boundaries={"heat": "zero flux"})
        geometry.add_edge(0.145, 0.02, 0.12, 0.02, boundaries={"heat": "t=0"})
        geometry.add_edge(0.125,
                          0.035,
                          0.125,
                          0.025,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.13,
                          0.025,
                          0.13,
                          0.035,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.135,
                          0.035,
                          0.135,
                          0.025,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.135,
                          0.025,
                          0.14,
                          0.025,
                          boundaries={"elasticity": "fixed"})
        geometry.add_edge(0.14,
                          0.025,
                          0.14,
                          0.035,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.14,
                          0.035,
                          0.135,
                          0.035,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.1, 0.09, 0.1, 0.055, boundaries={"heat": "t=0"})
        geometry.add_edge(0.1, 0.055, 0.14, 0.055, boundaries={"heat": "t=0"})
        geometry.add_edge(0.14, 0.055, 0.14, 0.09, boundaries={"heat": "t=0"})
        geometry.add_edge(0.14, 0.09, 0.1, 0.09, boundaries={"heat": "t=0"})
        geometry.add_edge(0.105,
                          0.085,
                          0.105,
                          0.06,
                          boundaries={"heat": "t=0"})
        geometry.add_edge(0.105, 0.06, 0.135, 0.06, boundaries={"heat": "t=0"})
        geometry.add_edge(0.135,
                          0.06,
                          0.135,
                          0.085,
                          boundaries={"heat": "t=0"})
        geometry.add_edge(0.135,
                          0.085,
                          0.105,
                          0.085,
                          boundaries={"heat": "t=0"})
        geometry.add_edge(0.125,
                          0.07,
                          0.125,
                          0.065,
                          boundaries={
                              "elasticity": "fixed-free",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.13,
                          0.065,
                          0.125,
                          0.065,
                          boundaries={
                              "elasticity": "fixed",
                              "heat": "t=0"
                          })
        geometry.add_edge(0.13,
                          0.065,
                          0.13,
                          0.07,
                          boundaries={
                              "elasticity": "fixed-free",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.13,
                          0.07,
                          0.125,
                          0.07,
                          boundaries={
                              "elasticity": "fixed-free",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.115,
                          0.08,
                          0.115,
                          0.075,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.11,
                          0.075,
                          0.115,
                          0.075,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.11,
                          0.075,
                          0.11,
                          0.08,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.11,
                          0.08,
                          0.115,
                          0.08,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.115,
                          0.07,
                          0.115,
                          0.065,
                          boundaries={
                              "elasticity": "fixed-free",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.115,
                          0.065,
                          0.12,
                          0.065,
                          boundaries={
                              "elasticity": "fixed",
                              "heat": "t=0"
                          })
        geometry.add_edge(0.12,
                          0.065,
                          0.12,
                          0.07,
                          boundaries={
                              "elasticity": "fixed-free",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.12,
                          0.07,
                          0.115,
                          0.07,
                          boundaries={
                              "elasticity": "fixed-free",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.125,
                          0.08,
                          0.125,
                          0.075,
                          boundaries={
                              "current": "Neumann",
                              "elasticity": "fixed-free",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.125,
                          0.075,
                          0.13,
                          0.075,
                          boundaries={
                              "current": "Neumann",
                              "elasticity": "fixed",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.13,
                          0.08,
                          0.13,
                          0.075,
                          boundaries={
                              "current": "Neumann",
                              "elasticity": "fixed-free",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.13,
                          0.08,
                          0.125,
                          0.08,
                          boundaries={
                              "current": "Neumann",
                              "elasticity": "fixed-free",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.015,
                          0.085,
                          0.015,
                          0.07,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.015,
                          0.085,
                          0.04,
                          0.085,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.04,
                          0.085,
                          0.04,
                          0.07,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.04,
                          0.07,
                          0.015,
                          0.07,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.02,
                          0.075,
                          0.025,
                          0.075,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.025,
                          0.08,
                          0.02,
                          0.08,
                          boundaries={"current": "Neumann"})
        geometry.add_edge(0.025,
                          0.075,
                          0.025,
                          0.08,
                          boundaries={"current": "Ground"})
        geometry.add_edge(0.02,
                          0.08,
                          0.02,
                          0.075,
                          boundaries={"current": "Source"})
        geometry.add_edge(0.03,
                          0.075,
                          0.03,
                          0.08,
                          boundaries={
                              "current": "Source",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.035,
                          0.08,
                          0.035,
                          0.075,
                          boundaries={
                              "current": "Ground",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.035,
                          0.075,
                          0.03,
                          0.075,
                          boundaries={
                              "current": "Neumann",
                              "heat": "t=0"
                          })
        geometry.add_edge(0.03,
                          0.08,
                          0.035,
                          0.08,
                          boundaries={
                              "current": "Neumann",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.065,
                          0.03,
                          0.0825,
                          0.03,
                          boundaries={"heat": "zero flux"})
        geometry.add_edge(0.0825,
                          0.03,
                          0.09,
                          0.03,
                          boundaries={"heat": "zero flux"})
        geometry.add_edge(0.08,
                          0.025,
                          0.0825,
                          0.025,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.0825,
                          0.025,
                          0.085,
                          0.025,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.085,
                          0.025,
                          0.085,
                          0.0225,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.085,
                          0.0225,
                          0.085,
                          0.015,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.09,
                          0.0225,
                          0.09,
                          0.03,
                          boundaries={"heat": "zero flux"})
        geometry.add_edge(0.09,
                          0.0225,
                          0.09,
                          0.01,
                          boundaries={"heat": "zero flux"})
        geometry.add_edge(0.115,
                          0.03,
                          0.115,
                          0.0225,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.115,
                          0.0225,
                          0.115,
                          0.02,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.12,
                          0.03,
                          0.12,
                          0.0225,
                          boundaries={
                              "elasticity": "fixed-free",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.12,
                          0.0225,
                          0.12,
                          0.02,
                          boundaries={
                              "elasticity": "fixed-free",
                              "heat": "zero flux"
                          })
        geometry.add_edge(0.125,
                          0.025,
                          0.1275,
                          0.025,
                          boundaries={"elasticity": "fixed"})
        geometry.add_edge(0.1275,
                          0.025,
                          0.13,
                          0.025,
                          boundaries={"elasticity": "fixed"})
        geometry.add_edge(0.125,
                          0.035,
                          0.1275,
                          0.035,
                          boundaries={
                              "elasticity": "fixed-free",
                              "electrostatic": "electrode2"
                          })
        geometry.add_edge(0.1275,
                          0.035,
                          0.13,
                          0.035,
                          boundaries={"elasticity": "fixed-free"})
        geometry.add_edge(0.12,
                          0.04,
                          0.12,
                          0.035,
                          boundaries={"heat": "zero flux"})
        geometry.add_edge(0.12,
                          0.035,
                          0.12,
                          0.03,
                          boundaries={"heat": "zero flux"})
        geometry.add_edge(0.0825,
                          0.045,
                          0.0825,
                          0.03,
                          boundaries={"electrostatic": "neuman"})
        geometry.add_edge(0.0825,
                          0.03,
                          0.0825,
                          0.025,
                          boundaries={"electrostatic": "neuman"})
        geometry.add_edge(0.0825,
                          0.025,
                          0.0825,
                          0.0225,
                          boundaries={"electrostatic": "electrode1"})
        geometry.add_edge(0.0825,
                          0.0225,
                          0.085,
                          0.0225,
                          boundaries={"electrostatic": "electrode1"})
        geometry.add_edge(0.085,
                          0.0225,
                          0.09,
                          0.0225,
                          boundaries={"electrostatic": "neuman"})
        geometry.add_edge(0.09,
                          0.0225,
                          0.115,
                          0.0225,
                          boundaries={"electrostatic": "neuman"})
        geometry.add_edge(0.115,
                          0.0225,
                          0.12,
                          0.0225,
                          boundaries={"electrostatic": "neuman"})
        geometry.add_edge(0.12,
                          0.0225,
                          0.1275,
                          0.0225,
                          boundaries={"electrostatic": "neuman"})
        geometry.add_edge(0.1275,
                          0.0225,
                          0.1275,
                          0.025,
                          boundaries={"electrostatic": "neuman"})
        geometry.add_edge(0.1275,
                          0.025,
                          0.1275,
                          0.035,
                          boundaries={"electrostatic": "neuman"})
        geometry.add_edge(0.125,
                          0.035,
                          0.12,
                          0.035,
                          boundaries={"electrostatic": "electrode2"})
        geometry.add_edge(0.12,
                          0.035,
                          0.0825,
                          0.045,
                          boundaries={"electrostatic": "neuman"})

        geometry.add_label(0.0266815,
                           0.0278347,
                           materials={
                               "current": "Cond 1",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "none"
                           })
        geometry.add_label(0.104249,
                           0.0211345,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "none"
                           })
        geometry.add_label(0.0887109,
                           0.0616798,
                           materials={
                               "current": "none",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "none"
                           })
        geometry.add_label(0.0758851,
                           0.0176937,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "heat"
                           })
        geometry.add_label(0.0727184,
                           0.0222517,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "structural",
                               "electrostatic": "none",
                               "heat": "heat"
                           })
        geometry.add_label(0.0832365,
                           0.0204127,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "structural",
                               "electrostatic": "none",
                               "heat": "heat"
                           })
        geometry.add_label(0.0621138,
                           0.0653831,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "structural",
                               "electrostatic": "none",
                               "heat": "none"
                           })
        geometry.add_label(0.117585,
                           0.0258373,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "structural",
                               "electrostatic": "electrostatic",
                               "heat": "none"
                           })
        geometry.add_label(0.12689,
                           0.0303108,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "structural",
                               "electrostatic": "electrostatic",
                               "heat": "heat"
                           })
        geometry.add_label(0.132079,
                           0.0217217,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "heat"
                           })
        geometry.add_label(0.136911,
                           0.0290582,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "structural",
                               "electrostatic": "none",
                               "heat": "heat"
                           })
        geometry.add_label(0.10226,
                           0.0648003,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "heat"
                           })
        geometry.add_label(0.111193,
                           0.0684784,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "none"
                           })
        geometry.add_label(0.127832,
                           0.0677778,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "heat"
                           })
        geometry.add_label(0.111368,
                           0.0772358,
                           materials={
                               "current": "none",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "none"
                           })
        geometry.add_label(0.117608,
                           0.0666663,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "structural",
                               "electrostatic": "none",
                               "heat": "none"
                           })
        geometry.add_label(0.126893,
                           0.0779052,
                           materials={
                               "current": "none",
                               "elasticity": "structural",
                               "electrostatic": "none",
                               "heat": "heat"
                           })
        geometry.add_label(0.0195236,
                           0.0823198,
                           materials={
                               "current": "none",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "none"
                           })
        geometry.add_label(0.0225718,
                           0.0771613,
                           materials={
                               "current": "Cond 1",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "none"
                           })
        geometry.add_label(0.0333576,
                           0.0783337,
                           materials={
                               "current": "Cond 1",
                               "elasticity": "none",
                               "electrostatic": "none",
                               "heat": "heat2"
                           })
        geometry.add_label(0.101318,
                           0.0322917,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "none",
                               "electrostatic": "electrostatic",
                               "heat": "none"
                           })
        geometry.add_label(0.0872661,
                           0.0274572,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "none",
                               "electrostatic": "electrostatic",
                               "heat": "heat"
                           })
        geometry.add_label(0.084043,
                           0.0239763,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "structural",
                               "electrostatic": "electrostatic",
                               "heat": "heat"
                           })
        geometry.add_label(0.118077,
                           0.0212412,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "structural",
                               "electrostatic": "none",
                               "heat": "none"
                           })
        geometry.add_label(0.122094,
                           0.0238927,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "none",
                               "electrostatic": "electrostatic",
                               "heat": "heat"
                           })
        geometry.add_label(0.128557,
                           0.0273469,
                           materials={
                               "current": "Cond 2",
                               "elasticity": "structural",
                               "electrostatic": "none",
                               "heat": "heat"
                           })

        agros2d.view.zoom_best_fit()

        # solve problem
        problem.solve()
Пример #49
0
    def model(self, solver):
        # problem
        problem = agros2d.problem(clear=True)
        problem.coordinate_type = "axisymmetric"
        problem.mesh_type = "triangle"

        # fields
        # electrostatic
        electrostatic = agros2d.field("electrostatic")
        electrostatic.analysis_type = "steadystate"
        electrostatic.matrix_solver = solver
        electrostatic.number_of_refinements = 1
        electrostatic.polynomial_order = 2
        electrostatic.adaptivity_type = "disabled"
        electrostatic.solver = "linear"

        # boundaries
        electrostatic.add_boundary("Source", "electrostatic_potential",
                                   {"electrostatic_potential": 1e9})
        electrostatic.add_boundary("Ground", "electrostatic_potential",
                                   {"electrostatic_potential": 0})
        electrostatic.add_boundary("Neumann",
                                   "electrostatic_surface_charge_density",
                                   {"electrostatic_surface_charge_density": 0})

        # materials
        electrostatic.add_material("Air", {
            "electrostatic_permittivity": 1,
            "electrostatic_charge_density": 1
        })
        electrostatic.add_material("Dielectric 1", {
            "electrostatic_permittivity": 3,
            "electrostatic_charge_density": 20
        })
        electrostatic.add_material("Dielectric 2", {
            "electrostatic_permittivity": 4,
            "electrostatic_charge_density": 30
        })

        # geometry
        geometry = agros2d.geometry
        geometry.add_edge(0,
                          0.2,
                          0,
                          0.08,
                          boundaries={"electrostatic": "Neumann"})
        geometry.add_edge(0.01,
                          0.08,
                          0.01,
                          0,
                          refinements={"electrostatic": 1},
                          boundaries={"electrostatic": "Source"})
        geometry.add_edge(0.01,
                          0,
                          0.03,
                          0,
                          boundaries={"electrostatic": "Neumann"})
        geometry.add_edge(0.03, 0, 0.03, 0.08)
        geometry.add_edge(0.03, 0.08, 0.05, 0.08)
        geometry.add_edge(0.05,
                          0,
                          0.03,
                          0,
                          boundaries={"electrostatic": "Neumann"})
        geometry.add_edge(0.05,
                          0.08,
                          0.05,
                          0,
                          refinements={"electrostatic": 1},
                          boundaries={"electrostatic": "Ground"})
        geometry.add_edge(0.06,
                          0,
                          0.06,
                          0.08,
                          boundaries={"electrostatic": "Ground"})
        geometry.add_edge(0.05,
                          0.08,
                          0.06,
                          0.08,
                          refinements={"electrostatic": 1},
                          boundaries={"electrostatic": "Ground"})
        geometry.add_edge(0.06,
                          0,
                          0.2,
                          0,
                          boundaries={"electrostatic": "Neumann"})
        geometry.add_edge(0.2,
                          0,
                          0,
                          0.2,
                          angle=90,
                          boundaries={"electrostatic": "Neumann"})
        geometry.add_edge(0.01, 0.08, 0.03, 0.08)
        geometry.add_edge(0.01,
                          0.08,
                          0,
                          0.08,
                          refinements={"electrostatic": 1},
                          boundaries={"electrostatic": "Source"})

        geometry.add_label(0.019,
                           0.021,
                           materials={"electrostatic": "Dielectric 1"})
        geometry.add_label(0.0379,
                           0.051,
                           materials={"electrostatic": "Dielectric 2"})
        geometry.add_label(0.0284191,
                           0.123601,
                           materials={"electrostatic": "Air"})

        agros2d.view.zoom_best_fit()
        problem.solve()

        return electrostatic.filename_matrix(), electrostatic.filename_rhs()
Пример #50
0
    def __init__(self, Rarm, Harm, S, Rcir, Hcir, Tcir, Hsp, Tsc, G, Iext,
                 Next, mur_arm, mur_cir):
        Scoil = (Hcir - 2 * Tcir - 2 * G) * ((Rcir - Tcir - G) - (Rarm + G))
        Jext = Next * Iext / Scoil

        self.problem = a2d.problem(clear=True)
        self.problem.coordinate_type = "axisymmetric"
        self.problem.mesh_type = "triangle"

        self.magnetic = a2d.field("magnetic")
        self.magnetic.analysis_type = "steadystate"
        self.magnetic.matrix_solver = "mumps"
        self.magnetic.number_of_refinements = 1
        self.magnetic.polynomial_order = 2
        self.magnetic.adaptivity_type = "disabled"
        self.magnetic.solver = "linear"

        self.magnetic.add_boundary("A = 0", "magnetic_potential",
                                   {"magnetic_potential_real": 0})

        self.magnetic.add_material("Armature",
                                   {"magnetic_permeability": mur_arm})
        self.magnetic.add_material("Magnetic circuit",
                                   {"magnetic_permeability": mur_cir})
        self.magnetic.add_material(
            "Coil", {
                "magnetic_permeability": 1,
                "magnetic_current_density_external_real": Jext
            })
        self.magnetic.add_material("Air", {"magnetic_permeability": 1})

        self.geometry = a2d.geometry

        # magnetic circuit
        self.geometry.add_edge(Rarm + G + Tsc, 0, Rcir, 0)
        self.geometry.add_edge(Rcir, 0, Rcir, Hcir)
        self.geometry.add_edge(Rcir, Hcir, 0, Hcir)
        self.geometry.add_edge(0,
                               Hcir,
                               0,
                               Hcir - Hsp,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0, Hcir - Hsp, Rarm, Hcir - Hsp)
        self.geometry.add_edge(Rarm, Hcir - Hsp, Rarm, Hcir - Tcir)
        self.geometry.add_edge(Rarm, Hcir - Tcir, Rcir - Tcir, Hcir - Tcir)
        self.geometry.add_edge(Rcir - Tcir, Hcir - Tcir, Rcir - Tcir, Tcir)
        self.geometry.add_edge(Rcir - Tcir, Tcir, Rarm + G + Tsc, Tcir)
        self.geometry.add_edge(Rarm + G + Tsc, Tcir, Rarm + G + Tsc, 0)
        self.geometry.add_label(Rcir - Tcir / 2.0,
                                Hcir / 2.0,
                                area=5e-06,
                                materials={"magnetic": "Magnetic circuit"})

        # coil
        self.geometry.add_edge(Rarm + G, Tcir + G, Rcir - Tcir - G, Tcir + G)
        self.geometry.add_edge(Rcir - Tcir - G, Tcir + G, Rcir - Tcir - G,
                               Hcir - Tcir - G)
        self.geometry.add_edge(Rcir - Tcir - G, Hcir - Tcir - G, Rarm + G,
                               Hcir - Tcir - G)
        self.geometry.add_edge(Rarm + G, Hcir - Tcir - G, Rarm + G, Tcir + G)
        self.geometry.add_label(Rarm + G + ((Rcir - Tcir - G) -
                                            (Rarm + G)) / 2.0,
                                Hcir / 2.0,
                                materials={"magnetic": "Coil"})

        # armature
        Darm = Hcir - Hsp - S
        last_edges_count = self.geometry.edges_count()
        self.geometry.add_edge(0, Darm - Harm, Rarm, Darm - Harm)
        self.geometry.add_edge(Rarm, Darm - Harm, Rarm, Darm)
        self.geometry.add_edge(Rarm, Darm, 0, Darm)
        self.geometry.add_edge(0,
                               Darm,
                               0,
                               Darm - Harm,
                               boundaries={"magnetic": "A = 0"})
        self.moved_label = self.geometry.add_label(
            Rarm / 2.0,
            Darm - Harm / 2.0,
            area=5e-06,
            materials={"magnetic": "Armature"})
        self.moved_edges = range(last_edges_count, self.geometry.edges_count())

        # sliding contact
        #self.geometry.add_edge(Rarm + G, 0, Rarm + G + Tsc, 0)
        #self.geometry.add_edge(Rarm + G + Tsc, Tcir, Rarm + G, Tcir)
        #self.geometry.add_edge(Rarm + G, Tcir, Rarm + G, 0)

        # fictinious boundary
        Dfic = 0.15
        self.geometry.add_edge(0,
                               Darm - Harm,
                               0,
                               Darm - Harm - Dfic,
                               boundaries={"magnetic": "A = 0"})
        self.moved_edges.append(
            self.geometry.add_edge(0,
                                   Darm - Harm - Dfic,
                                   Dfic,
                                   Darm - Harm - Dfic,
                                   boundaries={"magnetic": "A = 0"}))
        self.geometry.add_edge(Dfic,
                               Darm - Harm - Dfic,
                               Dfic,
                               Hcir + Dfic,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(Dfic,
                               Hcir + Dfic,
                               0,
                               Hcir + Dfic,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0,
                               Hcir,
                               0,
                               Hcir + Dfic,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_edge(0,
                               Hcir - Hsp,
                               0,
                               Darm,
                               boundaries={"magnetic": "A = 0"})
        self.geometry.add_label(Dfic / 2.0,
                                Hcir / 2.0,
                                materials={"magnetic": "Air"})

        a2d.view.zoom_best_fit()
Пример #51
0
import pythonlab
import pylab as pl
import agros2d as a2d

# problem
problem = a2d.problem(clear=True)
problem.coordinate_type = "axisymmetric"
problem.mesh_type = "triangle"

# fields
# electrostatic
electrostatic = a2d.field("electrostatic")
electrostatic.analysis_type = "steadystate"
electrostatic.number_of_refinements = 1
electrostatic.polynomial_order = 2
electrostatic.adaptivity_type = "disabled"
electrostatic.solver = "linear"

# variables
r1 = 0.01
r2 = 0.03
r3 = 0.05
r4 = 0.055
l = 0.2
eps1 = 10
eps2 = 3
U = 10
dr = 0.003

# boundaries
electrostatic.add_boundary("Source", "electrostatic_potential",
Пример #52
0
    def setUp(self):
        # model
        self.problem = agros2d.problem(clear=True)
        self.problem.coordinate_type = "planar"
        self.problem.mesh_type = "triangle"

        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()

        # fields
        self.heat = agros2d.field("heat")
        self.heat.analysis_type = "steadystate"
        self.heat.number_of_refinements = 2
        self.heat.polynomial_order = 2
        self.heat.solver = "linear"

        self.heat.add_boundary("T inner", "heat_temperature",
                               {"heat_temperature": -15})
        self.heat.add_boundary(
            "T outer", "heat_heat_flux", {
                "heat_heat_flux": 0,
                "heat_convection_heat_transfer_coefficient": 20,
                "heat_convection_external_temperature": 20
            })
        self.heat.add_boundary(
            "Neumann", "heat_heat_flux", {
                "heat_heat_flux": 0,
                "heat_convection_heat_transfer_coefficient": 0,
                "heat_convection_external_temperature": 0
            })

        self.heat.add_material(
            "Material 1", {
                "heat_volume_heat": 0,
                "heat_conductivity": 2,
                "heat_density": 7800,
                "heat_velocity_x": 0.00002,
                "heat_velocity_y": -0.00003,
                "heat_specific_heat": 300,
                "heat_velocity_angular": 0
            })
        self.heat.add_material(
            "Material 2", {
                "heat_volume_heat": 70000,
                "heat_conductivity": 10,
                "heat_density": 0,
                "heat_velocity_x": 0,
                "heat_velocity_y": 0,
                "heat_specific_heat": 0,
                "heat_velocity_angular": 0
            })

        # geometry
        geometry = agros2d.geometry

        # edges
        geometry.add_edge(0.1, 0.15, 0, 0.15, boundaries={"heat": "T outer"})
        geometry.add_edge(0, 0.15, 0, 0.1, boundaries={"heat": "Neumann"})
        geometry.add_edge(0, 0.1, 0.05, 0.1, boundaries={"heat": "T inner"})
        geometry.add_edge(0.05, 0.1, 0.05, 0, boundaries={"heat": "T inner"})
        geometry.add_edge(0.05, 0, 0.1, 0, boundaries={"heat": "Neumann"})
        geometry.add_edge(0.05, 0.1, 0.1, 0.1)
        geometry.add_edge(0.1, 0.15, 0.1, 0.1, boundaries={"heat": "T outer"})
        geometry.add_edge(0.1, 0.1, 0.1, 0, boundaries={"heat": "T outer"})

        # labels
        geometry.add_label(0.0553981,
                           0.124595,
                           materials={"heat": "Material 1"},
                           area=0.0003)
        geometry.add_label(0.070091,
                           0.068229,
                           materials={"heat": "Material 2"},
                           area=0.0003)

        agros2d.view.zoom_best_fit()
Пример #53
0
 def test(self):
     agros2d.open_file(example)
     agros2d.problem().solve()
Пример #54
0
 def test(self):
     agros2d.open_file(example)
     script = agros2d.get_script_from_model()
     exec script in globals(), locals()
     agros2d.problem().solve()
Пример #55
0
 def setUp(self):
     self.problem = a2d.problem(clear = True)
     self.geometry = a2d.geometry
Пример #56
0
    def setUp(self):
        # model
        problem = agros2d.problem(clear=True)
        problem.coordinate_type = "planar"
        problem.mesh_type = "triangle"

        # disable view
        agros2d.view.mesh.disable()
        agros2d.view.post2d.disable()

        # fields
        self.magnetic = agros2d.field("magnetic")
        self.magnetic.analysis_type = "steadystate"
        self.magnetic.number_of_refinements = 1
        self.magnetic.polynomial_order = 3

        self.magnetic.solver = "newton"
        self.magnetic.solver_parameters['residual'] = 0.1
        self.magnetic.solver_parameters['damping_factor'] = 0.6
        self.magnetic.solver_parameters['damping'] = 'automatic'
        self.magnetic.solver_parameters['jacobian_reuse'] = True
        self.magnetic.solver_parameters['jacobian_reuse_ratio'] = 0.9
        self.magnetic.solver_parameters['jacobian_reuse_steps'] = 20

        self.magnetic.add_boundary("A = 0", "magnetic_potential",
                                   {"magnetic_potential_real": 0})

        self.magnetic.add_material(
            "Civka 1", {
                "magnetic_conductivity": 0,
                "magnetic_current_density_external_real": 5e6,
                "magnetic_permeability": 1,
                "magnetic_remanence": 0,
                "magnetic_remanence_angle": 0,
                "magnetic_velocity_angular": 0,
                "magnetic_velocity_x": 0,
                "magnetic_velocity_y": 0
            })
        self.magnetic.add_material(
            "Civka 2", {
                "magnetic_conductivity": 0,
                "magnetic_current_density_external_real": -5e6,
                "magnetic_permeability": 1,
                "magnetic_remanence": 0,
                "magnetic_remanence_angle": 0,
                "magnetic_velocity_angular": 0,
                "magnetic_velocity_x": 0,
                "magnetic_velocity_y": 0
            })
        self.magnetic.add_material(
            "Iron", {
                "magnetic_conductivity": 0,
                "magnetic_current_density_external_real": 0,
                "magnetic_permeability": {
                    "value":
                    995,
                    "x": [
                        0, 0.2, 0.5, 0.8, 1.15, 1.3, 1.45, 1.6, 1.69, 2, 2.2,
                        2.5, 3, 5, 10, 20
                    ],
                    "y": [
                        995, 995, 991, 933, 771, 651, 473, 311, 245, 40, 30,
                        25, 20, 8, 5, 2
                    ]
                },
                "magnetic_remanence": 0,
                "magnetic_remanence_angle": 0,
                "magnetic_velocity_angular": 0,
                "magnetic_velocity_x": 0,
                "magnetic_velocity_y": 0
            })
        self.magnetic.add_material(
            "Air", {
                "magnetic_conductivity": 0,
                "magnetic_current_density_external_real": 0,
                "magnetic_permeability": 1,
                "magnetic_remanence": 0,
                "magnetic_remanence_angle": 0,
                "magnetic_velocity_angular": 0,
                "magnetic_velocity_x": 0,
                "magnetic_velocity_y": 0
            })

        # geometry
        geometry = agros2d.geometry

        # edges
        geometry.add_edge(-0.05, -0.01, 0.05, -0.01, boundaries={})
        geometry.add_edge(0.05, -0.01, 0.05, -0.005, boundaries={})
        geometry.add_edge(0.05, -0.005, -0.05, -0.005, boundaries={})
        geometry.add_edge(-0.05, -0.005, -0.05, -0.01, boundaries={})
        geometry.add_edge(-0.05, 0.06, -0.05, 0.04, boundaries={})
        geometry.add_edge(-0.03, 0, -0.05, 0, boundaries={})
        geometry.add_edge(-0.05, 0, -0.05, 0.04, boundaries={})
        geometry.add_edge(-0.05, 0.06, 0.05, 0.06, boundaries={})
        geometry.add_edge(0.05, 0.06, 0.05, 0.04, boundaries={})
        geometry.add_edge(0.05, 0, 0.05, 0.04, boundaries={})
        geometry.add_edge(0.03, 0, 0.05, 0, boundaries={})
        geometry.add_edge(-0.028, 0.04, 0.028, 0.04, boundaries={})
        geometry.add_edge(-0.15,
                          -0.1,
                          0.15,
                          -0.1,
                          boundaries={"magnetic": "A = 0"})
        geometry.add_edge(0.15,
                          -0.1,
                          0.15,
                          0.15,
                          boundaries={"magnetic": "A = 0"})
        geometry.add_edge(0.15,
                          0.15,
                          -0.15,
                          0.15,
                          boundaries={"magnetic": "A = 0"})
        geometry.add_edge(-0.15,
                          0.15,
                          -0.15,
                          -0.1,
                          boundaries={"magnetic": "A = 0"})
        geometry.add_edge(-0.028, 0.074, 0.028, 0.074, boundaries={})
        geometry.add_edge(0.028, 0.074, 0.028, 0.062, boundaries={})
        geometry.add_edge(-0.028, 0.074, -0.028, 0.062, boundaries={})
        geometry.add_edge(-0.028, 0.062, 0.028, 0.062, boundaries={})
        geometry.add_edge(-0.028, 0.038, -0.028, 0.026, boundaries={})
        geometry.add_edge(-0.028, 0.038, 0.028, 0.038, boundaries={})
        geometry.add_edge(0.028, 0.038, 0.028, 0.026, boundaries={})
        geometry.add_edge(0.028, 0.026, -0.028, 0.026, boundaries={})
        geometry.add_edge(0.03, 0.038, 0.028, 0.04, boundaries={}, angle=90)
        geometry.add_edge(0.03, 0, 0.03, 0.038, boundaries={})
        geometry.add_edge(-0.03, 0.038, -0.03, 0, boundaries={})
        geometry.add_edge(-0.028, 0.04, -0.03, 0.038, boundaries={}, angle=90)

        # labels
        geometry.add_label(0.076268, 0.119048, materials={"magnetic": "Air"})
        geometry.add_label(-0.0126334,
                           0.0554136,
                           materials={"magnetic": "Iron"},
                           area=2e-05)
        geometry.add_label(0.0173943,
                           -0.00630466,
                           materials={"magnetic": "Iron"})
        geometry.add_label(0.00305095,
                           0.0688963,
                           materials={"magnetic": "Civka 2"})
        geometry.add_label(-0.00501291,
                           0.0328188,
                           materials={"magnetic": "Civka 1"})

        agros2d.view.zoom_best_fit()

        # solve problem
        problem.solve()