def test_all(): n1, n2, T_BC = get_test_params(6) box_size=10. airgap=5. depth=25. model_parameters = {} model_parameters['n1']=n1 model_parameters['n2']=n2 model_parameters['box_size']=box_size model_parameters['airgap']=airgap model_parameters['T_BC']=T_BC model_parameters['x'] =n1*box_size+(n1+1)*airgap model_parameters['y'] =depth model_parameters['z'] =n2*box_size+(n2+1)*airgap model_parameters['default_mesh_size'] = 10 #If default mesh size is smaller than given mesh sizes, fallback value is used. model_parameters['bar_mesh_sizes'] = 2 model_parameters['air_mesh_sizes'] = 2 default_mesh_size = model_parameters['default_mesh_size'] entities_dict = create_solids(model_parameters) solid_objects = get_solids_from_entities_dict(entities_dict) fit_view() mesh_object, compound_filter = create_mesh_object_and_compound_filter(solid_objects, default_mesh_size, doc) find_boundaries_with_entities_dict(mesh_object, compound_filter, entities_dict, doc) find_bodies_with_entities_dict(mesh_object, compound_filter, entities_dict, doc) define_mesh_sizes(mesh_object, compound_filter, entities_dict, doc) create_mesh(mesh_object) export_path=PWD+u"/variable_topology.unv" run_elmergrid(export_path, mesh_object) create_sif(model_parameters)
def test_all(): model_parameters = {} model_parameters['coil_inner_radius'] = 0.11 / 2 model_parameters['coil_outer_radius'] = 0.11 / 2 + 0.1 model_parameters['coil_height'] = 0.1 model_parameters['z'] = .0 model_parameters['core_height'] = .31 model_parameters['core_diameter'] = .32 model_parameters['core_center_length'] = .11 model_parameters['core_center_diameter'] = .1 model_parameters['airgap'] = .005 model_parameters[ 'default_mesh_size'] = 0.04 #If default mesh size is smaller than given mesh sizes, fallback value is used. model_parameters['coil_mesh_sizes'] = {'L1': 0.02, 'alpha0': 0.01} model_parameters['core_mesh_sizes'] = {'core': 0.04} model_parameters['air_mesh_sizes'] = {'air': 0.009} default_mesh_size = model_parameters['default_mesh_size'] entities_dict = create_solids(model_parameters) solid_objects = get_solids_from_entities_dict(entities_dict) mesh_object, compound_filter = create_mesh_object_and_compound_filter( solid_objects, default_mesh_size, doc) find_boundaries_with_entities_dict(mesh_object, compound_filter, entities_dict, doc) find_bodies_with_entities_dict(mesh_object, compound_filter, entities_dict, doc) define_mesh_sizes(mesh_object, compound_filter, entities_dict, doc) fit_view() create_mesh(mesh_object) export_path = PWD + "/circuits_harmonic_massive/1962.unv" run_elmergrid(export_path, mesh_object)
def create_core(h, w, a, b, name, mesh_sizes=None): core = doc.addObject('PartDesign::Body', name + '_obj') sketch = core.newObject('Sketcher::SketchObject', name + ' sketch') #sketch.Support = (doc.XY_Plane, ['']) sketch.MapMode = 'FlatFace' sketch.addGeometry( Part.LineSegment(App.Vector(0, -h / 2, 0), App.Vector(0, h / 2, 0)), False) sketch.addGeometry( Part.LineSegment(App.Vector(0, h / 2, 0), App.Vector(w / 2, h / 2, 0)), False) sketch.addGeometry( Part.LineSegment(App.Vector(w / 2, h / 2, 0), App.Vector(w / 2, a / 2, 0)), False) sketch.addGeometry( Part.LineSegment(App.Vector(w / 2, a / 2, 0), App.Vector(b / 2, a / 2, 0)), False) sketch.addGeometry( Part.LineSegment(App.Vector(b / 2, a / 2, 0), App.Vector(b / 2, -a / 2, 0)), False) sketch.addGeometry( Part.LineSegment(App.Vector(b / 2, -a / 2, 0), App.Vector(w / 2, -a / 2, 0)), False) sketch.addGeometry( Part.LineSegment(App.Vector(w / 2, -a / 2, 0), App.Vector(w / 2, -h / 2, 0)), False) sketch.addGeometry( Part.LineSegment(App.Vector(w / 2, -h / 2, 0), App.Vector(0, -h / 2, 0)), False) doc.recompute() fit_view() rev = core.newObject("PartDesign::Revolution", name + " rev") rev.Profile = sketch rev.ReferenceAxis = (sketch, ['V_Axis']) rev.Angle = 180 rev.Reversed = 1 doc.recompute() # #fit_view() # Here we define the entities dictionary. face_picks = [('infinity_xz0', 6), ('infinity_xz1', 0), ('cylinder_lateral_surface', 1), ('cylinder_lateral_surface', 5), ('xy0', 7), ('xy0', 8)] faces = pick_faces_from_geometry(core, face_picks) solids = [] add_entity_in_list(solids, name, core, mesh_sizes=mesh_sizes) entities_out = create_entities_dict(name, faces, solids, main_object=core) return entities_out
def create_coil(r, R, h, z, name, face_entities=True, mesh_sizes=None): coil = doc.addObject('PartDesign::Body', name + '_obj') sketch = coil.newObject('Sketcher::SketchObject', name + ' sketch') #sketch.Support = (doc.XY_Plane, ['']) sketch.MapMode = 'FlatFace' sketch.addGeometry( Part.LineSegment(App.Vector(r, -h / 2 + z, 0), App.Vector(r, h / 2 + z, 0)), False) sketch.addGeometry( Part.LineSegment(App.Vector(r, h / 2 + z, 0), App.Vector(R, h / 2 + z, 0)), False) sketch.addGeometry( Part.LineSegment(App.Vector(R, h / 2 + z, 0), App.Vector(R, -h / 2 + z, 0)), False) sketch.addGeometry( Part.LineSegment(App.Vector(R, -h / 2 + z, 0), App.Vector(r, -h / 2 + z, 0)), False) doc.recompute() fit_view() rev = coil.newObject("PartDesign::Revolution", name + " rev") rev.Profile = sketch rev.ReferenceAxis = (sketch, ['V_Axis']) rev.Angle = 180 rev.Reversed = 1 doc.recompute() coil_faces = coil.Shape.Faces # Here we define the entities dictionary. Note that each coil contain the same # names for each geometric entity. That is why the 'name' key is required # in the dictionary. # Naming of the faces can be avoided by giving face_entities=False as argument faces = [] if (face_entities): face_picks = [('gamma0', 4), ('gamma1', 5)] faces = pick_faces_from_geometry(coil, face_picks) solids = [] add_entity_in_list(solids, name, coil, mesh_sizes=mesh_sizes) entities_out = create_entities_dict(name, faces, solids, main_object=coil) return entities_out