예제 #1
0
def test_bbox_viz():

    blist = []
    ypos = 0

    for sec in ["IPE300", "HP200x10", "TUB300x30", "TUB300/200x20"]:
        bm = Beam(sec, (0, ypos, 0), (0, ypos, 1), sec)
        blist += [
            Part(sec + "_Z") / [
                bm,
                PrimBox("Bbox_Z_" + sec,
                        *bm.bbox.minmax,
                        colour="red",
                        opacity=0.5)
            ]
        ]
        bm = Beam(sec, (0, ypos, 2), (1, ypos, 2), sec)
        blist += [
            Part(sec + "_X") / [
                bm,
                PrimBox("Bbox_X_" + sec,
                        *bm.bbox.minmax,
                        colour="red",
                        opacity=0.5)
            ]
        ]
        bm = Beam("bm_" + sec + "_Y", (ypos, 0, 3), (ypos, 1, 3), sec)
        blist += [
            Part(sec + "_Y") / [
                bm,
                PrimBox("Bbox_Y_" + sec,
                        *bm.bbox.minmax,
                        colour="red",
                        opacity=0.5)
            ]
        ]
        bm = Beam("bm_" + sec + "_XYZ", (ypos, ypos, 4),
                  (ypos + 1, ypos + 1, 5), sec)
        blist += [
            Part(sec + "_XYZ") / [
                bm,
                PrimBox("Bbox_XYZ_" + sec,
                        *bm.bbox.minmax,
                        colour="red",
                        opacity=0.5)
            ]
        ]
        ypos += 1
    a = Assembly() / blist
    _ = a.to_ifc(test_dir / "beam_bounding_box.ifc", return_file_obj=True)
예제 #2
0
파일: fem_models.py 프로젝트: Krande/adapy
def add_random_cutouts(bm: Beam):
    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)))
예제 #3
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)
예제 #4
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")
예제 #5
0
파일: fem_models.py 프로젝트: haavahk/adapy
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
예제 #6
0
def assembly() -> Assembly:
    bm1 = Beam("bm1", (0, 0, 1), (1, 0, 1), "IPE300")
    bm2 = Beam("bm2", (1.1, 0, 1), (2, 0, 1), "IPE300")
    bm3 = Beam("bm3", (2.1, 0, 1), (3, 0, 1), "IPE300")

    placement = Placement(origin=(1, 1, 1), xdir=(1, 0, 0), zdir=(0, 0, 1))
    pl_points = [(0, 0), (1, 0), (1, 1), (0, 1)]
    pl1 = Plate("pl1", pl_points, 10e-3, placement=placement)

    pipe = Pipe("pipe", [(0, 0.5, 0), (1, 0.5, 0), (1.2, 0.7, 0.2),
                         (1.5, 0.7, 0.2)], "OD120x6")

    p1, p2 = (1, -2, 0), (2, -1, 1)
    shp1 = PrimBox("MyBox", p1, p2)
    shp1.add_penetration(PrimSphere("MyCutout", p1, 0.5))

    return Assembly() / (Part("MyFemObjects") /
                         [bm1, bm2, bm3, pl1, shp1, pipe])
예제 #7
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")
예제 #8
0
    def test_bbox_viz(self):
        from ada import PrimBox

        blist = []
        ypos = 0

        for sec in ["IPE300", "HP200x10", "TUB300x30", "TUB300/200x20"]:
            bm = Beam(sec, (0, ypos, 0), (0, ypos, 1), sec)
            blist += [Part(sec + "_Z") / [bm, PrimBox("Bbox_Z_" + sec, *bm.bbox, colour="red", opacity=0.5)]]
            bm = Beam(sec, (0, ypos, 2), (1, ypos, 2), sec)
            blist += [Part(sec + "_X") / [bm, PrimBox("Bbox_X_" + sec, *bm.bbox, colour="red", opacity=0.5)]]
            bm = Beam("bm_" + sec + "_Y", (ypos, 0, 3), (ypos, 1, 3), sec)
            blist += [Part(sec + "_Y") / [bm, PrimBox("Bbox_Y_" + sec, *bm.bbox, colour="red", opacity=0.5)]]
            bm = Beam("bm_" + sec + "_XYZ", (ypos, ypos, 4), (ypos + 1, ypos + 1, 5), sec)
            blist += [Part(sec + "_XYZ") / [bm, PrimBox("Bbox_XYZ_" + sec, *bm.bbox, colour="red", opacity=0.5)]]
            ypos += 1
        a = Assembly() / blist
        a.to_ifc(test_folder / "beam_bounding_box.ifc")
예제 #9
0
    def test_bbox_viz(self):
        from ada import PrimBox

        blist = []
        ypos = 0

        for sec in ['IPE300', 'HP200x10', 'TUB300x30', 'TUB300/200x20']:
            bm = Beam(sec, (0, ypos, 0), (0, ypos, 1), sec)
            blist += [
                Part(sec + '_Z') / [
                    bm,
                    PrimBox(
                        'Bbox_Z_' + sec, *bm.bbox, colour='red', opacity=0.5)
                ]
            ]
            bm = Beam(sec, (0, ypos, 2), (1, ypos, 2), sec)
            blist += [
                Part(sec + '_X') / [
                    bm,
                    PrimBox(
                        'Bbox_X_' + sec, *bm.bbox, colour='red', opacity=0.5)
                ]
            ]
            bm = Beam('bm_' + sec + '_Y', (ypos, 0, 3), (ypos, 1, 3), sec)
            blist += [
                Part(sec + '_Y') / [
                    bm,
                    PrimBox(
                        'Bbox_Y_' + sec, *bm.bbox, colour='red', opacity=0.5)
                ]
            ]
            bm = Beam('bm_' + sec + '_XYZ', (ypos, ypos, 4),
                      (ypos + 1, ypos + 1, 5), sec)
            blist += [
                Part(sec + '_XYZ') / [
                    bm,
                    PrimBox(
                        'Bbox_XYZ_' + sec, *bm.bbox, colour='red', opacity=0.5)
                ]
            ]
            ypos += 1
        a = Assembly() / blist
        a.to_ifc(test_folder / 'beam_bounding_box.ifc')
예제 #10
0
def test_export_primitives(shape_ifc_test_dir):
    a = Assembly("Site") / [
        PrimBox("VolBox", (0.2, 0.2, 2), (1.2, 1.2, 4)),
        PrimCyl("VolCyl", (2, 2, 2), (4, 4, 4), 0.2),
        PrimExtrude("VolExtrude", [(0, 0), (1, 0), (0.5, 1)], 2, (0, 0, 1), (2, 2, 2), (1, 0, 0)),
        PrimRevolve(
            "VolRevolve",
            points2d=[(0, 0), (1, 0), (0.5, 1)],
            origin=(2, 2, 3),
            xdir=(0, 0, 1),
            normal=(1, 0, 0),
            rev_angle=275,
        ),
    ]
    fp = a.to_ifc(shape_ifc_test_dir / "world_of_shapes.ifc", return_file_obj=True)

    b = ada.from_ifc(fp)
    assert len(b.shapes) == 4
    print(b)
예제 #11
0
    def _cut_intersecting_member(self, mem_base: Beam, mem_incoming: Beam):
        from ada import PrimBox

        p1, p2 = mem_base.bbox.minmax
        mem_incoming.add_penetration(PrimBox(f"{self.name}_neg", p1, p2))
예제 #12
0
    def test_export_primbox(self):
        a = Assembly("Site") / SimpleStru("SimpleStru")

        a.add_shape(PrimBox("VolBox", p1, p2))
        a.to_ifc(test_folder / "world_shape_box.ifc")