def test_beam_offset(ifc_roundtrip_test_dir): bm1 = ada.Beam( "bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE300", colour="red", up=(0, 0, 1), e1=(0, 0, -0.1), e2=(0, 0, -0.1), ) bm2 = ada.Beam( "bm2", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE300", colour="blue", up=(0, 0, -1), e1=(0, 0, -0.1), e2=(0, 0, -0.1), ) a = ada.Assembly("Toplevel") / [ada.Part("MyPart") / [bm1, bm2]] _ = a.to_ifc(ifc_roundtrip_test_dir / "beams_offset.ifc", return_file_obj=True)
def test_beam_directions(ifc_roundtrip_test_dir): sec = "HP200x10" beams = [ ada.Beam("bm_test2X0", n1=[0, 0, 0], n2=[5, 0, 0], angle=0, sec=sec), ada.Beam("bm_test2X90", n1=[0, 0, 1], n2=[5, 0, 1], angle=90, sec=sec), ada.Beam("bm_test2Y0", n1=[0, 0, 2], n2=[0, 5, 2], angle=0, sec=sec), ada.Beam("bm_test2Y90", n1=[0, 0, 3], n2=[0, 5, 3], angle=90, sec=sec), ] a = ada.Assembly("AdaRotatedProfiles") / (ada.Part("Part") / beams) _ = a.to_ifc(ifc_roundtrip_test_dir / "my_angled_profiles.ifc", return_file_obj=True)
def test_surface_beam(surfaces_test_dir): from ada.fem.meshing import GmshOptions # Build Model bm = ada.Beam("MyBeam", (0, 0, 0), (0, 0, 1), "BG200x150x6x6") p = ada.Part("MyBmPart") / [bm] a = ada.Assembly() / p # Create FEM mesh p.fem = p.to_fem_obj(0.10, "solid", interactive=False, options=GmshOptions(Mesh_ElementOrder=2)) # Add Step step = a.fem.add_step(ada.fem.StepImplicit("MyStep")) # Add Boundary Condition start_of_beam = bm.bbox.sides.back(return_fem_nodes=True) p.fem.add_bc( ada.fem.Bc("fix", ada.fem.FemSet("bc_fix", start_of_beam), [1, 2, 3])) # Add Surface Load surface_top = p.fem.add_surface( bm.bbox.sides.top(return_surface=True, surf_name="TopSurface")) step.add_load(ada.fem.LoadPressure("PressureTop", 1e6, surface_top)) a.to_fem("MyFemBeam_100mm_2nd_order", "abaqus", overwrite=True, execute=False, scratch_dir=surfaces_test_dir)
def test_beam_orientation(ifc_roundtrip_test_dir): props = dict(n1=[0, 0, 0], n2=[2, 0, 0], sec="HP200x10") bm1 = ada.Beam("bm_up", **props, up=(0, 0, 1)) bm2 = ada.Beam("bm_down", **props, up=(0, 0, -1)) fp = (ada.Assembly("MyAssembly") / (ada.Part("MyPart") / [bm1, bm2])).to_ifc(ifc_roundtrip_test_dir / "up_down", return_file_obj=True) a = ada.from_ifc(fp) bm_d: ada.Beam = a.get_by_name("bm_down") bm_u: ada.Beam = a.get_by_name("bm_up") assert tuple(bm_u.up) == tuple(bm1.up) assert tuple(bm_d.up) == tuple(bm2.up)
def beam() -> ada.Beam: return ada.Beam( "MyBeam", (0, 0.5, 0.5), (3, 0.5, 0.5), "IPE400", ada.Material("S420", CarbonSteel("S420", plasticity_model=DnvGl16Mat(15e-3, "S355"))), )
def test_beam_mesh_with_hole(test_meshing_dir): bm = ada.Beam("bm1", n1=[0, 0, 0], n2=[1, 0, 0], sec="IPE220") p = ada.Part("MyFem") / bm bm.add_penetration(ada.PrimCyl("Cylinder", (0.5, -0.5, 0), (0.5, 0.5, 0), 0.05)) p.fem = bm.to_fem_obj(0.5, "line", interactive=False) el_types = {el_type: list(group) for el_type, group in p.fem.elements.group_by_type()} assert len(el_types.keys()) == 1 assert len(el_types["LINE"]) == 2 assert len(p.fem.nodes) == 3
def test_merge_fem_sections(test_merge_sections_dir): bm1 = ada.Beam("Bm1", (0, 0, 0), (10, 0, 0), "IPE300") bm2 = ada.Beam("Bm2", (10, 0, 0), (10, 10, 0), "IPE400") a = ada.Assembly() / (ada.Part("MyPart") / [bm1, bm2]) p = a.get_part("MyPart") p.fem = p.to_fem_obj(2, "line") assert len(p.fem.sections) == 2 name = "Merges_Sections" fem_format = "sesam" a.to_fem(name, fem_format, overwrite=True, scratch_dir=test_merge_sections_dir) inp_path = default_fem_inp_path(name, test_merge_sections_dir)[fem_format] b = ada.from_fem(inp_path) pb = b.get_part("T1") assert len(pb.fem.sections) == 10 pb.fem.sections.merge_by_properties() assert len(pb.fem.sections) == 2
def test_edges_intersect(test_meshing_dir): bm_name = Counter(1, "bm") pl = ada.Plate("pl1", [(0, 0), (1, 0), (1, 1), (0, 1)], 10e-3) points = pl.poly.points3d objects = [pl] # Beams along 3 of 4 along circumference for p1, p2 in zip(points[:-1], points[1:]): objects.append(ada.Beam(next(bm_name), p1, p2, "IPE100")) # Beam along middle in x-dir objects.append( ada.Beam(next(bm_name), (0, 0.5, 0.0), (1, 0.5, 0), "IPE100")) # Beam along diagonal objects.append(ada.Beam(next(bm_name), (0, 0, 0.0), (1, 1, 0), "IPE100")) a = ada.Assembly() / (ada.Part("MyPart") / objects) p = a.get_part("MyPart") # p.connections.find() p.fem = p.to_fem_obj(0.1, interactive=False)
def test_quad_meshed_beam(test_meshing_dir): bm = ada.Beam("pl1", (0, 0, 0), (1, 0, 0), "IPE400") with GmshSession(silent=True) as gs: gs.add_obj(bm, "shell") gs.mesh(0.1, use_quads=True) fem = gs.get_fem() el_types = { el_type: list(group) for el_type, group in fem.elements.group_by_type() } assert len(el_types.keys()) == 1 assert len(el_types["QUAD"]) == 120
def test_hex20_meshed_beam(test_meshing_dir): bm = ada.Beam("bm1", (0, 0, 0), (1, 0, 0), "IPE400") with GmshSession(silent=True, options=GmshOptions(Mesh_ElementOrder=2)) as gs: gs.add_obj(bm, "solid") gs.mesh(0.1, use_hex=True) fem = gs.get_fem() el_types = {el_type: list(group) for el_type, group in fem.elements.group_by_type()} # (ada.Assembly() / (ada.Part("MyPart", fem=fem) / bm)).to_fem( # "HexMesh_beam_ca", "code_aster", overwrite=True, scratch_dir=test_meshing_dir # ) assert len(el_types.keys()) == 1 assert len(el_types["HEXAHEDRON20"]) == 140
def bm_ipe300(): return ada.Beam("MyIPE300", (0, 0, 0), (5, 0, 0), "IPE300")
def test_shell_beam() -> ada.Assembly: bm = ada.Beam("Bm", (0, 0, 0), (1, 0, 0), "IPE300") return ada.Assembly("MyAssembly") / ( ada.Part("MyPart", fem=bm.to_fem_obj(0.1, "shell")) / bm)