Пример #1
0
    def test_basic_module_to_from_ifc(self):
        a = Assembly("ParametricSite")
        a.add_part(SimpleStru("ParametricModel"))
        a.to_ifc(test_folder / "param1.ifc")

        a2 = Assembly("ImportedParam")
        a2.read_ifc(test_folder / "param1.ifc")
        a2.to_ifc(test_folder / "param1_reimported.ifc")
Пример #2
0
    def test_export_layers(self):
        bm = Beam(
            "MyBeam",
            (0, 0, 0),
            (2, 0, 0),
            Section("MySec", from_str="BG300x200x10x20"),
            metadata=dict(hidden=True),
        )

        webh = bm.section.h - bm.section.t_fbtn * 2

        pl1 = Plate(
            "Web1",
            [(0, 0), (2, 0), (2, webh), (0, webh)],
            bm.section.t_w,
            origin=(0, -bm.section.w_btn / 2 + bm.section.t_w, -webh / 2),
            normal=(0, -1, 0),
            xdir=(1, 0, 0),
        )

        pl2 = Plate(
            "Web2",
            [(0, 0), (2, 0), (2, webh), (0, webh)],
            bm.section.t_w,
            origin=(0, bm.section.w_btn / 2, -webh / 2),
            normal=(0, -1, 0),
            xdir=(1, 0, 0),
        )

        pl3 = Plate(
            "Fla1",
            [(0, 0), (2, 0), (2, bm.section.w_top), (0, bm.section.w_top)],
            bm.section.t_fbtn,
            origin=(0, -bm.section.w_btn / 2, -bm.section.h / 2),
            normal=(0, 0, 1),
            xdir=(1, 0, 0),
        )

        pl4 = Plate(
            "Fla2",
            [(0, 0), (2, 0), (2, bm.section.w_top), (0, bm.section.w_top)],
            bm.section.t_fbtn,
            origin=(0, -bm.section.w_btn / 2,
                    bm.section.h / 2 - bm.section.t_fbtn),
            normal=(0, 0, 1),
            xdir=(1, 0, 0),
        )
        p = Part("MyBldg", metadata=dict(ifctype="building"))
        a = Assembly("MySite", project="MyLayersProject") / [
            p / [bm, pl1, pl2, pl3, pl4]
        ]

        ifc_name = "MyLayerTest.ifc"
        a.to_ifc(test_folder / ifc_name)

        b = Assembly("MyImportedLayers")
        b.read_ifc(test_folder / ifc_name)
Пример #3
0
    def test_ifc_roundtrip(self):
        a = Assembly("my_test_assembly")
        a.add_part(SimpleStru("my_simple_stru"))
        a.to_ifc(test_folder / "my_test.ifc")

        b = Assembly("MyReImport")
        b.read_ifc(test_folder / "my_test.ifc")
        b.to_ifc(test_folder / "my_test_re_exported.ifc")

        all_parts = b.get_all_parts_in_assembly()
        assert len(all_parts) == 3
Пример #4
0
    def test_material_ifc_roundtrip(self):

        ifc_name = 'my_material.ifc'

        a = Assembly('MyAssembly')
        p = Part('MyPart')
        p.add_material(Material('my_mat'))
        a.add_part(p)
        a.to_ifc(test_folder / ifc_name)

        b = Assembly('MyImport')
        b.read_ifc(test_folder / ifc_name)
Пример #5
0
    def test_material_ifc_roundtrip(self):

        ifc_name = "my_material.ifc"

        a = Assembly("MyAssembly")
        p = Part("MyPart")
        p.add_material(Material("my_mat"))
        a.add_part(p)
        a.to_ifc(test_folder / ifc_name)

        b = Assembly("MyImport")
        b.read_ifc(test_folder / ifc_name)
Пример #6
0
    def test_read_write_portal_frame(self):

        name = "portal"

        a = Assembly()
        a.read_fem(example_files / "fem_files/code_aster/portal_01.med", "code_aster", name=name)
        a.to_fem(name, "code_aster", overwrite=True)

        b = Assembly()
        b.read_fem((Settings.scratch_dir / name / name).with_suffix(".med"), fem_format="code_aster")

        p_a = a.parts[name]
        p_b = b.parts[name]

        compare_fem_objects(p_a.fem, p_b.fem)
Пример #7
0
    def test_read_write_box(self):

        name = "box"

        a = Assembly()
        a.read_fem(example_files / "fem_files/meshes/med/box.med", "code_aster", name="box")
        a.to_fem(name, "code_aster", overwrite=True)

        b = Assembly()
        b.read_fem((Settings.scratch_dir / name / name).with_suffix(".med"), fem_format="code_aster")

        p_a = a.parts["box"]
        p_b = b.parts["box"]

        compare_fem_objects(p_a.fem, p_b.fem)
Пример #8
0
    def test_ex2(self):
        origin = [362857.44778571784, 100000.0, 561902.5557556185]
        csys = [
            [0.0, 1.0, 0.0],
            [-0.9756456931466083, 0.0, 0.2193524138104576],
            [0.2193524138104576, 0.0, 0.9756456931466083],
        ]
        local_points2d = [
            [-35.000000000029075, 246.8832348783828],
            [-15.0, 154.3],
            [6.4472604556706474e-15, 74.98044924694155],
            [0.0, -170.7],
            [-3.376144703353855e-14, -320.6997855533479],
            [-330.0, -320.7, -1.0189517968329821e-10],
            [-400.0, -235.7, 50.0],
            [-400.0, -70.7, 50.0],
            [-325.0, 154.3, 50.0],
            [-85.00004587117287, 500.03303441608927, 24.99999999997542],
            [-34.99999999999994, 500.0330344161669, -7.881391015070461e-12],
        ]
        thick = 30
        pl = Plate("test2", local_points2d, thick, origin=origin, normal=csys[2], xdir=csys[0], units="mm")

        a = Assembly(units="mm") / [Part("te", units="mm") / pl]
        a.to_ifc(test_folder / "error_plate2.ifc")
Пример #9
0
    def test_write_simple_stru(self):
        from ada.param_models.basic_module import SimpleStru

        a = Assembly("MyTest")
        p = a.add_part(SimpleStru("SimpleStru"))
        p.gmsh.mesh()
        a.to_fem("MyTest", fem_format="sesam", overwrite=True)
Пример #10
0
def test_meter_to_millimeter(test_units_dir):
    p = Part(
        "MyTopSpatialLevel",
        metadata=dict(ifctype="storey", description="MyTopLevelSpace"),
    )
    bm1 = Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red")

    p2 = Part(
        "MySecondLevel",
        metadata=dict(ifctype="storey", description="MySecondLevelSpace"),
    )
    bm2 = Beam("bm2", n1=[0, 0, 0], n2=[0, 2, 0], sec="IPE220", colour="blue")

    p3 = Part(
        "MyThirdLevel",
        metadata=dict(ifctype="storey", description="MyThirdLevelSpace"),
    )
    bm3 = Beam("bm3", n1=[0, 0, 0], n2=[0, 0, 2], sec="IPE220", colour="green")
    pl1 = Plate(
        "pl1",
        [(0, 0, 0), (0, 0, 2), (0, 2, 2), (0, 2.0, 0.0)],
        0.01,
        use3dnodes=True,
    )

    a = Assembly("MySiteName", project="MyTestProject") / [
        p / [bm1, p2 / [bm2, p3 / [bm3, pl1]]]
    ]

    # a.to_ifc(test_units_dir / "my_test_in_meter.ifc")

    a.units = "mm"
    assert tuple(bm3.n2.p) == (0, 0, 2000)
    assert pl1.t == 10
Пример #11
0
def test_beam_rotation_by_angle():
    # Define beam rotations using vectors
    angles = [0, 90, 180, 270]
    vectorX = [(0, 0, 1), (0, -1, 0), (0, 0, -1), (0, 1, 0)]
    vectorY = [(0, 0, 1), (1, 0, 0), (0, 0, -1), (-1, 0, 0)]
    vectorZ = [(0, 1, 0), (-1, 0, 0), (0, -1, 0), (1, 0, 0)]

    a = Assembly("AdaRotatedProfiles")
    p = a.add_part(Part("RotatedBeams"))
    sec = "HP200x10"
    d1 = dict(n1=(0, 0, 0), n2=(5, 0, 0), sec=sec)
    d2 = dict(n1=(0, 0, 0), n2=(0, 5, 0), sec=sec)
    d3 = dict(n1=(0, 0, 0), n2=(0, 0, 5), sec=sec)

    for i, angle in enumerate(angles):
        # Along X-Axis
        bm = p.add_beam(Beam(f"bmX_n{i}_a", **d1, angle=angle))
        assert all([x == y for x, y in zip(bm.up, vectorX[i])]) is True
        p.add_beam(Beam(f"bmX_n{i}_v", **d1, up=vectorX[i]))

        # Along Y-Axis
        bm = p.add_beam(Beam(f"bmY_n{i}_a", **d2, angle=angle))
        assert all([x == y for x, y in zip(bm.up, vectorY[i])]) is True
        p.add_beam(Beam(f"bmY_n{i}_v", **d2, up=vectorY[i]))

        # Along Z-Axis
        bm = p.add_beam(Beam(f"bmZ_n{i}_a", **d3, angle=angle))
        assert all([x == y for x, y in zip(bm.up, vectorZ[i])]) is True
        p.add_beam(Beam(f"bmZ_n{i}_v", **d3, up=vectorZ[i]))
Пример #12
0
def test_mix_extrude():

    bm = Beam("MyBeam", (0, 0, 0), (1.5, 0, 0),
              Section("myIPE", from_str="IPE400"))
    a = Assembly("Test", user=User("krande")) / [Part("MyPart") / bm]

    h = 0.2
    r = 0.02

    # Polygon Extrusions
    origin = np.array([0.1, 0.1, -0.1])
    normal = np.array([0, -1, 0])
    xdir = np.array([1, 0, 0])
    points = [(0, 0), (0.05, 0.1), (0.1, 0)]
    bm.add_penetration(PrimExtrude("my_pen", points, h, normal, origin, xdir))

    origin = np.array([0.3, 0.1, -0.1])
    points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)]
    bm.add_penetration(PrimExtrude("my_pen3", points, h, normal, origin, xdir))

    origin = np.array([0.5, 0.1, -0.1])
    points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0.0, 0.2, r)]
    bm.add_penetration(PrimExtrude("my_pen4", points, h, normal, origin, xdir))

    # Cylinder Extrude
    x = 0.8
    bm.add_penetration(PrimCyl("my_pen5", (x, -0.1, 0), (x, 0.1, 0), 0.1))

    # Box Extrude
    x = 1.0
    bm.add_penetration(PrimBox("my_pen6", (x, -0.1, -0.1),
                               (x + 0.2, 0.1, 0.1)))

    _ = a.to_ifc(test_dir / "penetrations_mix.ifc", return_file_obj=True)
Пример #13
0
def test_viz_structural():
    components = [
        Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red"),
        Beam("bm2", n1=[0, 0, 1], n2=[2, 0, 1], sec="HP220x10", colour="blue"),
        Beam("bm3",
             n1=[0, 0, 2],
             n2=[2, 0, 2],
             sec="BG800x400x20x40",
             colour="green"),
        Beam("bm4", n1=[0, 0, 3], n2=[2, 0, 3], sec="CIRC200", colour="green"),
        Beam("bm5",
             n1=[0, 0, 4],
             n2=[2, 0, 4],
             sec="TUB200x10",
             colour="green"),
        Plate(
            "pl1",
            [(0, 0, 0), (0, 0, 1), (0, 1, 1), (0, 1, 0)],
            0.01,
            use3dnodes=True,
        ),
    ]
    a = Assembly("my_test_assembly") / components

    res = a.to_vis_mesh(auto_merge_by_color=False)
    merged = res.merge_objects_in_parts_by_color()

    assert res.num_polygons == 416
    assert len(res.world[0].id_map.values()) == 6
    assert merged.num_polygons == 416
    assert len(merged.world[0].id_map.values()) == 4
Пример #14
0
    def test_ex1(self):
        origin = [362237.0037951513, 100000.0, 560985.9095763591]
        csys = [
            [0.0, -1.0, 0.0],
            [-0.4626617625735456, 0.0, 0.8865348799975894],
            [-0.8865348799975894, 0.0, -0.4626617625735456],
        ]
        local_points2d = [
            [4.363213751783499e-11, 229.80445306040926],
            [1.4557793281525672e-11, -57.217605078163196],
            [2.912511939794014e-11, -207.22885580839431],
            [-330.0, -207.25, -4.518217213237464e-11],
            [-400.0, -122.2, 50.0],
            [-400.0, 42.79, 50.0],
            [-325.0, 267.83, 50.0],
            [-85.00004587126028, 650.0198678083951, 24.999999999931404],
            [-35.0, 650.02, -7.881391015070461e-12],
            [-35.0, 350.1],
            [-15.14, 261.52],
        ]
        thick = 30
        pl = Plate("test", local_points2d, thick, origin=origin, normal=csys[2], xdir=csys[0], units="mm")

        a = Assembly() / [Part("te") / pl]
        a.to_ifc(test_folder / "error_plate.ifc")
Пример #15
0
def test_export_layers():
    bm = Beam(
        "MyBeam",
        (0, 0, 0),
        (2, 0, 0),
        Section("MySec", from_str="BG300x200x10x20"),
        metadata=dict(hidden=True),
    )

    webh = bm.section.h - bm.section.t_fbtn * 2

    pl1 = Plate(
        "Web1",
        [(0, 0), (2, 0), (2, webh), (0, webh)],
        bm.section.t_w,
        placement=Placement(origin=(0, -bm.section.w_btn / 2 + bm.section.t_w,
                                    -webh / 2),
                            zdir=(0, -1, 0),
                            xdir=(1, 0, 0)),
    )

    pl2 = Plate(
        "Web2",
        [(0, 0), (2, 0), (2, webh), (0, webh)],
        bm.section.t_w,
        placement=Placement(origin=(0, bm.section.w_btn / 2, -webh / 2),
                            zdir=(0, -1, 0),
                            xdir=(1, 0, 0)),
    )

    pl3 = Plate(
        "Fla1",
        [(0, 0), (2, 0), (2, bm.section.w_top), (0, bm.section.w_top)],
        bm.section.t_fbtn,
        placement=Placement(origin=(0, -bm.section.w_btn / 2,
                                    -bm.section.h / 2),
                            zdir=(0, 0, 1),
                            xdir=(1, 0, 0)),
    )

    pl4 = Plate(
        "Fla2",
        [(0, 0), (2, 0), (2, bm.section.w_top), (0, bm.section.w_top)],
        bm.section.t_fbtn,
        placement=Placement(
            origin=(0, -bm.section.w_btn / 2,
                    bm.section.h / 2 - bm.section.t_fbtn),
            zdir=(0, 0, 1),
            xdir=(1, 0, 0),
        ),
    )
    p = Part("MyBldg", metadata=dict(ifctype="building"))
    a = Assembly("MySite",
                 project="MyLayersProject") / (p / [bm, pl1, pl2, pl3, pl4])

    ifc_name = "MyLayerTest.ifc"
    fp = a.to_ifc(test_dir / ifc_name, return_file_obj=True)
    print(a)
    b = ada.from_ifc(fp)
    print(b)
Пример #16
0
    def test_roundtrip_fillets(self):
        a = Assembly("ExportedPlates")
        p = Part("MyPart")
        a.add_part(p)
        pl1 = Plate("MyPl", [(0, 0, 0.2), (5, 0), (5, 5), (0, 5)], 20e-3, **atts)
        p.add_plate(pl1)

        atts2 = dict(origin=(0, 0, 0), xdir=(1, 0, 0), normal=(0, -1, 0))
        pl2 = Plate("MyPl2", [(0, 0, 0.2), (5, 0, 0.2), (5, 5), (0, 5)], 20e-3, **atts2)
        p.add_plate(pl2)

        a.to_ifc(test_folder / "my_plate_simple.ifc")

        b = Assembly("MyReimport")
        b.read_ifc(test_folder / "my_plate_simple.ifc")
        b.to_ifc(test_folder / "my_plate_simple_re_exported.ifc")
Пример #17
0
def test_poly_extrude():
    bm = Beam("MyBeam", (0, 0, 0), (2, 0, 0),
              Section("myIPE", from_str="IPE400"))
    a = Assembly("Test") / [Part("MyPart") / bm]

    h = 0.2
    r = 0.02

    origin = np.array([0.1, 0.1, -0.1])
    normal = np.array([0, -1, 0])
    xdir = np.array([1, 0, 0])

    points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)]
    bm.add_penetration(PrimExtrude("my_pen1", 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.2, r)]
    bm.add_penetration(PrimExtrude("my_pen2", points, h, normal, origin, xdir))

    origin += np.array([0.2, 0, 0])
    points = [(0, 0, r), (0.2, 0, r), (0.25, 0.1, r), (0.25, 0.25, r),
              (0, 0.25, r)]
    bm.add_penetration(PrimExtrude("my_pen3", points, h, normal, origin, xdir))

    origin += np.array([0.4, 0, 0])
    points = [
        (0, 0, r),
        (0.2, 0, r),
        (0.25, 0.1, r),
        (0.5, 0.0, r),
        (0.5, 0.25, r),
        (0, 0.25, r),
    ]
    bm.add_penetration(PrimExtrude("my_pen4", points, h, normal, origin, xdir))
    _ = a.to_ifc(test_dir / "penetrations_poly.ifc", return_file_obj=True)
Пример #18
0
 def test_profiles_to_ifc(self):
     a = Assembly("MyAssembly")
     p = Part("MyPart")
     p.add_beam(
         Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220",
              colour="red"))
     p.add_beam(
         Beam("bm2",
              n1=[0, 0, 1],
              n2=[2, 0, 1],
              sec="HP220x10",
              colour="blue"))
     p.add_beam(
         Beam("bm3",
              n1=[0, 0, 2],
              n2=[2, 0, 2],
              sec="BG800x400x20x40",
              colour="green"))
     p.add_beam(
         Beam("bm4",
              n1=[0, 0, 3],
              n2=[2, 0, 3],
              sec="CIRC200",
              colour="green"))
     p.add_beam(
         Beam("bm5",
              n1=[0, 0, 4],
              n2=[2, 0, 4],
              sec="TUB200x10",
              colour="green"))
     a.add_part(p)
     a.to_ifc(test_folder / "my_beam_profiles.ifc")
Пример #19
0
    def test_beam_offset(self):
        bm1 = Beam(
            "bm1",
            n1=[0, 0, 0],
            n2=[2, 0, 0],
            sec="IPE300",
            mat=Material("SteelMat", CarbonSteel("S420")),
            colour="red",
            up=(0, 0, 1),
            e1=(0, 0, -0.1),
            e2=(0, 0, -0.1),
        )
        bm2 = Beam(
            "bm2",
            n1=[0, 0, 0],
            n2=[2, 0, 0],
            sec="IPE300",
            mat=Material("SteelMat", CarbonSteel("S420")),
            colour="blue",
            up=(0, 0, -1),
            e1=(0, 0, -0.1),
            e2=(0, 0, -0.1),
        )

        a = Assembly("Toplevel") / [Part("MyPart") / [bm1, bm2]]
        a.to_ifc(test_folder / "beams_offset.ifc")
Пример #20
0
    def test_cone_beam(self):
        s_o = [(375.0, 375.0, 375.0), (375.0, -375.0, 375.0),
               (-375.0, -375.0, 375.0), (-375.0, 375.0, 375.0)]
        s_i = [(325.0, 325.0, 325.0), (-325.0, 325.0, 325.0),
               (-325.0, -325.0, 325.0), (325.0, -325.0, 325.0)]

        e_o = [(525.0, 525.0, 525.0), (525.0, -525.0, 525.0),
               (-525.0, -525.0, 525.0), (-525.0, 525.0, 525.0)]
        e_i = [(475.0, 475.0, 475.0), (-475.0, 475.0, 475.0),
               (-475.0, -475.0, 475.0), (475.0, -475.0, 475.0)]
        poly_s_o = CurvePoly(s_o, (0, 0, 0), (0, 0, 1), (1, 0, 0))
        poly_s_i = CurvePoly(s_i, (0, 0, 0), (0, 0, 1), (1, 0, 0))
        section_s = Section('MyStartCrossSection',
                            "poly",
                            outer_poly=poly_s_o,
                            inner_poly=poly_s_i,
                            units="mm")

        poly_e_o = CurvePoly(e_o, (0, 0, 0), (0, 0, 1), (1, 0, 0))
        poly_e_i = CurvePoly(e_i, (0, 0, 0), (0, 0, 1), (1, 0, 0))
        section_e = Section('MyEndCrossSection',
                            "poly",
                            outer_poly=poly_e_o,
                            inner_poly=poly_e_i,
                            units="mm")

        bm = Beam('MyCone', (2, 2, 2), (4, 4, 4), sec=section_s, tap=section_e)
        a = Assembly(
            'Level1', project='Project0', creator='krande',
            units='mm') / (Part('Level2') / bm)
        a.to_ifc(test_folder / 'cone_ex.ifc')
Пример #21
0
    def test_bm_eigenfrequency_shell(self):
        bm = test_bm()

        p = Part("MyPart")
        a = Assembly("MyAssembly") / [p / bm]
        create_beam_mesh(bm, p.fem, "shell")

        fix_set = p.fem.add_set(FemSet("bc_nodes", get_beam_end_nodes(bm), "nset"))
        a.fem.add_bc(Bc("Fixed", fix_set, [1, 2, 3, 4, 5, 6]))

        a.fem.add_step(Step("Eigen", "eigenfrequency"))

        a.to_fem("Cantilever_CA_EIG_sh", "abaqus", overwrite=True)
        a.to_fem("Cantilever_CA_EIG_sh", "sesam", overwrite=True)

        res = a.to_fem("Cantilever_CA_EIG_sh", "code_aster", overwrite=True, execute=True)

        f = h5py.File(res.results_file_path)
        modes = f.get("CHA/modes___DEPL")

        for mname, m in modes.items():
            mode = m.attrs["NDT"]
            freq = m.attrs["PDT"]

            print(mode, freq)
Пример #22
0
def test_export_basic(ifc_test_dir):
    bm = Beam(
        "MyBeam",
        (0, 0, 0),
        (2, 0, 0),
        Section("MySec", from_str="BG300x200x10x20"),
        metadata=dict(hidden=True),
    )
    bm1 = Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red")
    bm2 = Beam("bm2", n1=[0, 0, 0], n2=[0, 2, 0], sec="IPE220", colour="blue")
    bm3 = Beam("bm3", n1=[0, 0, 0], n2=[0, 0, 2], sec="IPE220", colour="green")
    bm4 = Beam("bm4", n1=[0, 0, 0], n2=[2, 0, 2], sec="IPE220", colour="black")
    bm5 = Beam("bm5", n1=[0, 0, 2], n2=[2, 0, 2], sec="IPE220", colour="white")

    user = User(user_id="krande", org_id="ADA", org_name="Assembly Test")
    pl1 = Plate(
        "pl1",
        [(0, 0, 0), (0, 0, 2), (0, 2, 2), (0, 2.0, 0.0)],
        0.01,
        use3dnodes=True,
    )

    a = Assembly("MyFirstIfcFile", user=user) / (
        Part("MyBldg", metadata=dict(ifctype="building")) / [bm, bm1, bm2, bm3, bm4, bm5, pl1]
    )

    a.to_ifc(ifc_test_dir / "my_test.ifc", return_file_obj=True)
Пример #23
0
    def test_ifc_groups(self):
        a = Assembly("MySiteName", project="MyTestProject")
        p = Part(
            "MyTopSpatialLevel",
            metadata=dict(ifctype="spatial", description="MyTopLevelSpace"),
        )
        p.add_beam(Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red"))
        a.add_part(p)

        newp = Part(
            "MySecondLevel",
            metadata=dict(ifctype="spatial", description="MySecondLevelSpace"),
        )
        newp.add_beam(Beam("bm2", n1=[0, 0, 0], n2=[0, 2, 0], sec="IPE220", colour="blue"))
        p.add_part(newp)

        newp2 = Part(
            "MyThirdLevel",
            metadata=dict(ifctype="spatial", description="MyThirdLevelSpace"),
        )
        newp2.add_beam(Beam("bm3", n1=[0, 0, 0], n2=[0, 0, 2], sec="IPE220", colour="green"))
        newp2.add_plate(
            Plate(
                "pl1",
                [(0, 0, 0), (0, 0, 2), (0, 2, 2), (0, 2.0, 0.0)],
                0.01,
                use3dnodes=True,
            )
        )
        newp.add_part(newp2)

        a.to_ifc(test_folder / "my_test_groups.ifc")
Пример #24
0
def build_test_beam():
    a = Assembly('MyAssembly')
    p = Part('MyPart')
    p.add_beam(Beam('Bm', (0, 0, 0), (1, 0, 0), 'IPE300'))
    p.gmsh.mesh(0.5)
    a.add_part(p)
    return a
Пример #25
0
def test_viz_to_binary_json(test_dir):
    components = [
        Beam("bm1", n1=[0, 0, 0], n2=[2, 0, 0], sec="IPE220", colour="red"),
        Beam("bm2", n1=[0, 0, 1], n2=[2, 0, 1], sec="HP220x10", colour="blue"),
        Beam("bm3",
             n1=[0, 0, 2],
             n2=[2, 0, 2],
             sec="BG800x400x20x40",
             colour="green"),
        Beam("bm4", n1=[0, 0, 3], n2=[2, 0, 3], sec="CIRC200", colour="green"),
        Beam("bm5",
             n1=[0, 0, 4],
             n2=[2, 0, 4],
             sec="TUB200x10",
             colour="green"),
        Plate(
            "pl1",
            [(0, 0, 0), (0, 0, 1), (0, 1, 1), (0, 1, 0)],
            0.01,
            use3dnodes=True,
        ),
    ]

    a = Assembly("my_test_assembly") / components

    res = a.to_vis_mesh()

    res.to_binary_and_json(test_dir / "viz/binjson/beams")
    res.to_custom_json(test_dir / "viz/binjson/beams.json")
Пример #26
0
 def test_read_R3D4(self):
     from ada import Assembly
     a = Assembly('my_assembly', 'temp')
     a.read_fem(
         os.path.join(this_dir,
                      example_files / 'fem_files/abaqus/box_rigid.inp'))
     assert len(a.fem.constraints) == 1
Пример #27
0
def build_test_beam():
    a = Assembly("MyAssembly")
    p = Part("MyPart")
    p.add_beam(Beam("Bm", (0, 0, 0), (1, 0, 0), "IPE300"))
    p.gmsh.mesh(0.5)
    a.add_part(p)
    return a
Пример #28
0
 def test_write_simple_stru(self):
     from ada.param_models.basic_module import SimpleStru
     a = Assembly('MyTest')
     p = SimpleStru('SimpleStru')
     a.add_part(p)
     p.gmsh.mesh()
     a.to_fem('MyTest', fem_format='sesam', overwrite=True)
Пример #29
0
 def test_read_write_code_aster_to_xdmf(self):
     a = Assembly("meshio_from_ca", "temp")
     a.read_fem(example_files / "fem_files/meshes/med/box.med",
                fem_converter="meshio")
     a.to_fem("box_analysis_xdmf",
              fem_format="xdmf",
              fem_converter="meshio")
Пример #30
0
    def test_mix_extrude(self):

        bm = Beam("MyBeam", (0, 0, 0), (1.5, 0, 0), Section("myIPE", from_str="IPE400"))
        a = Assembly("Test", creator="Kristoffer H. Andersen") / [Part("MyPart") / bm]

        h = 0.2
        r = 0.02

        # Polygon Extrusions
        origin = np.array([0.1, 0.1, -0.1])
        normal = np.array([0, -1, 0])
        xdir = np.array([1, 0, 0])
        points = [(0, 0), (0.05, 0.1), (0.1, 0)]
        bm.add_penetration(PrimExtrude("my_pen", points, h, normal, origin, xdir))

        origin = np.array([0.3, 0.1, -0.1])
        points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)]
        bm.add_penetration(PrimExtrude("my_pen3", points, h, normal, origin, xdir))

        origin = np.array([0.5, 0.1, -0.1])
        points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0.0, 0.2, r)]
        bm.add_penetration(PrimExtrude("my_pen4", points, h, normal, origin, xdir))

        # Cylinder Extrude
        x = 0.8
        bm.add_penetration(PrimCyl("my_pen5", (x, -0.1, 0), (x, 0.1, 0), 0.1))

        # Box Extrude
        x = 1.0
        bm.add_penetration(PrimBox("my_pen6", (x, -0.1, -0.1), (x + 0.2, 0.1, 0.1)))

        a.to_ifc(test_folder / "penetrations_mix.ifc")