def beam_ex1(): """ :return: """ bm = Beam("MyBeam", (0, 0, 0), (1.5, 0, 0), "IPE400") a = Assembly("Test", creator="Kristoffer H. Andersen") / [Part("MyPart") / bm] h = 0.2 r = 0.02 normal = [0, 1, 0] xdir = [-1, 0, 0] # Polygon Extrusions origin = np.array([0.2, -0.1, -0.1]) points = [(0, 0), (0.1, 0), (0.05, 0.1)] bm.add_penetration(PrimExtrude("Poly1", points, h, normal, origin, xdir)) origin += np.array([0.2, 0, 0]) points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)] bm.add_penetration(PrimExtrude("Poly2", points, h, normal, origin, xdir)) origin += np.array([0.2, 0, 0]) points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0.0, 0.2, r)] bm.add_penetration(PrimExtrude("Poly3", points, h, normal, origin, xdir)) # Cylinder Extrude x = origin[0] + 0.2 bm.add_penetration(PrimCyl("cylinder", (x, -0.1, 0), (x, 0.1, 0), 0.1)) # Box Extrude x += 0.2 bm.add_penetration(PrimBox("box", (x, -0.1, -0.1), (x + 0.2, 0.1, 0.1))) # Create a FEM analysis of the beam as a cantilever subjected to gravity loads create_beam_mesh(bm, a.get_part("MyPart").fem, "shell") # Add a set containing ALL elements (necessary for Calculix loads). fs = a.fem.add_set(FemSet("Eall", [el for el in a.get_part("MyPart").fem.elements.elements], "elset")) step = a.fem.add_step(Step("gravity", "static", nl_geom=True, init_incr=100.0, total_time=100.0)) step.add_load(Load("grav", "gravity", -9.81, fem_set=fs)) a.fem.add_bc(Bc("Fixed", FemSet("bc_nodes", get_beam_end_nodes(bm), "nset"), [1, 2, 3])) return a
def pfem(): a = Assembly() / (Part("BeamFEM") / Beam( "bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red")) part = a.get_part("BeamFEM") with GmshSession(silent=True) as gs: gs.add_obj(a.get_by_name("bm1"), geom_repr="line") gs.mesh(0.1) part.fem = gs.get_fem() return part
def test_merge_materials(): plates = [] for i in range(1, 10): mat = Material(f"mat{i}", CarbonSteel("S355")) plates.append( Plate(f"pl{i}", [(0, 0, 0), (0, 1, 0), (1, 1, 0)], 20e-3, mat=mat)) a = Assembly() / (Part("MyPart") / plates) p = a.get_part("MyPart") mats = p.materials assert len(mats) == 9 mats.merge_materials_by_properties() assert len(mats) == 1
def beam_ex1(p1=(0, 0, 0), p2=(1.5, 0, 0), profile="IPE400", geom_repr=ElemType.SHELL) -> Assembly: mat_grade = CarbonSteel.TYPES.S355 bm = Beam("MyBeam", p1, p2, profile, Material("S355", mat_model=CarbonSteel(mat_grade))) bm.material.model.plasticity_model = DnvGl16Mat(bm.section.t_w, mat_grade) a = Assembly("Test", user=User("krande")) / [Part("MyPart") / bm] add_random_cutouts(bm) # Create a FEM analysis of the beam as a cantilever subjected to gravity loads p = a.get_part("MyPart") p.fem = bm.to_fem_obj(0.1, geom_repr) # Add a set containing ALL elements (necessary for Calculix loads). fs = p.fem.add_set(FemSet("Eall", [el for el in p.fem.elements], FemSet.TYPES.ELSET)) step = a.fem.add_step(StepImplicit("gravity", nl_geom=True, init_incr=100.0, total_time=100.0)) step.add_load(Load("grav", Load.TYPES.GRAVITY, -9.81 * 800, fem_set=fs)) fix_set = p.fem.add_set(FemSet("bc_nodes", get_beam_end_nodes(bm), FemSet.TYPES.NSET)) a.fem.add_bc(Bc("Fixed", fix_set, [1, 2, 3])) return a