示例#1
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")
示例#2
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")
示例#3
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)
示例#4
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')
示例#5
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)
示例#6
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
示例#7
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")
示例#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 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
示例#10
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
示例#11
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)
示例#12
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)
示例#13
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
示例#14
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
示例#15
0
def test_cone_beam():
    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",
                 units="mm") / (Part("Level2") / bm)
    _ = a.to_ifc(test_dir / "cone_ex.ifc", return_file_obj=True)
示例#16
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")
示例#17
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]))
示例#18
0
def test_ifc_groups(ifc_test_dir):
    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(ifc_test_dir / "my_test_groups.ifc", return_file_obj=True)
示例#19
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)
示例#20
0
def test_sweep_shape(shape_ifc_test_dir):
    sweep_curve = [(0, 0, 0), (5, 5.0, 0.0, 1), (10, 0, 0)]
    ot = [(-0.1, -0.1), (0.1, -0.1), (0.1, 0.1), (-0.1, 0.1)]
    shape = PrimSweep("MyShape", sweep_curve, (0, 1, 0), (1, 0, 0), ot)

    a = Assembly("SweptShapes", units="m") / [Part("MyPart") / [shape]]
    _ = a.to_ifc(shape_ifc_test_dir / "my_swept_shape_m.ifc", return_file_obj=True)
示例#21
0
def beam_ex1(p1=(0, 0, 0), p2=(1.5, 0, 0), profile="IPE400"):
    """

    :return:
    :rtype: ada.Assembly
    """
    bm = Beam("MyBeam", p1, p2, profile, Material("S355"))
    a = Assembly("Test", user=User("krande")) / [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
    p = a.get_part("MyPart")
    create_beam_mesh(bm, p.fem, "shell")

    # Add a set containing ALL elements (necessary for Calculix loads).
    fs = p.fem.add_set(FemSet("Eall", [el for el in p.fem.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 * 800, fem_set=fs))

    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]))
    return a
示例#22
0
    def test_fem(self):
        a = Assembly("MyAssembly") / (Part("MyPart") /
                                      Beam("Bm", (0, 0, 0),
                                           (1, 0, 0), "IPE300"))
        a.gmsh.mesh()

        a._repr_html_()
        a._renderer.toggle_mesh_visibility()
示例#23
0
    def test_import_arcboundary(self):

        url = url_root + "master/IFC%204.0/NURBS/Bentley%20Building%20Designer/SolidsAndSheets/WithArcBoundary.ifc"
        dest = "c:/temp/ifc_files/WithArcBoundary.ifc"
        download_to(dest, url)

        a = Assembly("MyAssembly")
        a.read_ifc(dest)
示例#24
0
def build_test_model():
    param_model = SimpleStru("ParametricModel")
    a = Assembly("ParametricSite")
    a.add_part(param_model)
    param_model.gmsh.mesh(max_dim=2, interactive=False)
    param_model.add_bcs()

    return a
示例#25
0
 def test_read_C3D20(self):
     from ada import Assembly
     a = Assembly('my_assembly', 'temp')
     a.read_fem(
         os.path.join(this_dir,
                      example_files / 'fem_files/calculix/contact2e.inp'))
     beams = list(a.parts.values())[0]
     vol = beams.fem.nodes.vol_cog
     assert vol == (0.49999999627471, 1.2499999925494, 3.9999999701977)
示例#26
0
    def test_sweep_shape(self):
        sweep_curve = [(0, 0, 0), (5, 5.0, 0.0, 1), (10, 0, 0)]
        ot = [(-0.1, -0.1), (0.1, -0.1), (0.1, 0.1), (-0.1, 0.1)]
        shape = PrimSweep("MyShape", sweep_curve, (0, 1, 0), (1, 0, 0), ot)

        a = Assembly("SweptShapes", units="m") / [
            Part("MyPart") / [shape, PrimBox("VolBox", p1, p2)]
        ]
        a.to_ifc(test_folder / "my_swept_shape_m.ifc")
示例#27
0
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
示例#28
0
def test_material_ifc_roundtrip(materials_test_dir):
    ifc_path = materials_test_dir / "my_material.ifc"

    p = Part("MyPart")
    p.add_material(Material("my_mat"))
    a = Assembly("MyAssembly") / p
    fp = a.to_ifc(ifc_path, return_file_obj=True)

    b = ada.from_ifc(fp)
    assert len(b.materials) == 1
示例#29
0
def test_profiles_to_ifc(ifc_test_dir):
    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(ifc_test_dir / "my_beam_profiles.ifc", return_file_obj=True)
示例#30
0
    def test_export_basic(self):
        bm = Beam(
            "MyBeam",
            (0, 0, 0),
            (2, 0, 0),
            Section("MySec", from_str="BG300x200x10x20"),
            metadata=dict(hidden=True),
        )

        a = Assembly("MyFirstIfcFile") / (Part("MyBldg", metadata=dict(ifctype="building")) / bm)
        a.to_ifc(test_folder / "MyTest.ifc")