Beispiel #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")
def test_main_properties():
    matS355 = Material("MatS355", mat_model=CarbonSteel("S355"))
    matS420 = Material("MatS420", mat_model=CarbonSteel("S420"))
    for model in [matS355.model, matS420.model]:
        assert model.E == 2.1e11
        assert model.rho == 7850
        assert model.v == 0.3

    assert matS355.model.sig_y == 355e6
    assert matS420.model.sig_y == 420e6
Beispiel #3
0
def test_bm():
    bm = Beam("MyBeam", (0, 0.5, 0.5), (5, 0.5, 0.5), "IPE400", Material("S420", CarbonSteel("S420")))
    f1 = fundamental_eigenfrequency(bm)
    f2 = 6.268 * f1
    f3 = 17.456 * f1
    print(f"Fundamental Eigenfrequencies\n\n1: {f1}\n2: {f2}\n3: {f3}")
    return bm
Beispiel #4
0
def read_material(ifc_mat, ifc_ref: "IfcRef",
                  assembly: "Assembly") -> Material:
    from ada.materials.metals import CarbonSteel, Metal

    mat_psets = ifc_mat.HasProperties if hasattr(ifc_mat,
                                                 "HasProperties") else None

    if mat_psets is None or len(mat_psets) == 0:
        logging.info(f'No material properties found for "{ifc_mat}"')
        return Material(ifc_mat.Name)

    props = {}
    for entity in mat_psets[0].Properties:
        if entity.is_a("IfcPropertySingleValue"):
            props[entity.Name] = entity.NominalValue[0]

    mat_props = dict(
        E=props.get("YoungModulus", 210000e6),
        sig_y=props.get("YieldStress", 355e6),
        rho=props.get("MassDensity", 7850),
        v=props.get("PoissonRatio", 0.3),
        alpha=props.get("ThermalExpansionCoefficient", 1.2e-5),
        zeta=props.get("SpecificHeatCapacity", 1.15),
        units=assembly.units,
    )

    if "StrengthGrade" in props:
        mat_model = CarbonSteel(grade=props["StrengthGrade"], **mat_props)
    else:
        mat_model = Metal(sig_u=None, **mat_props)

    return Material(name=ifc_mat.Name,
                    mat_model=mat_model,
                    ifc_ref=ifc_ref,
                    units=assembly.units)
Beispiel #5
0
    def get_morsmel(m):
        """
        MORSMEL

        Anisotropy, Linear Elastic Structural Analysis, 2-D Membrane Elements and 2-D Thin Shell Elements

        :param m:
        :return:
        """

        d = m.groupdict()
        matno = str_to_int(d["matno"])
        return Material(
            name=mat_names[matno],
            mat_id=matno,
            mat_model=CarbonSteel(
                rho=roundoff(d["rho"]),
                E=roundoff(d["d11"]),
                v=roundoff(d["ps1"]),
                alpha=roundoff(d["alpha1"]),
                zeta=roundoff(d["damp1"]),
                sig_p=[],
                eps_p=[],
                sig_y=5e6,
            ),
            metadata=d,
            parent=part,
        )
Beispiel #6
0
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"))),
    )
Beispiel #7
0
 def mat_from_list(mat_int, mat_str):
     guid, name, units = str_fix(mat_str)
     E, rho, sigy = mat_int
     return Material(name=name,
                     guid=guid,
                     units=units,
                     mat_model=CarbonSteel(E=E, rho=rho, sig_y=sigy),
                     parent=parent)
Beispiel #8
0
def mat_str_to_mat_obj(mat_str):
    """
    Converts a Abaqus materials str into a ADA Materials object

    :param mat_str:
    :return:
    """
    from ada import Material

    rd = roundoff

    # Name
    name = re.search(r"name=(.*?)\n", mat_str, _re_in).group(1).split("=")[-1].strip()

    # Density
    density_ = re.search(r"\*Density\n(.*?)(?:,|$)", mat_str, _re_in)
    if density_ is not None:
        density = rd(density_.group(1).strip().split(",")[0].strip(), 10)
    else:
        print('No density flag found for material "{}"'.format(name))
        density = None

    # Elastic
    re_elastic_ = re.search(r"\*Elastic(?:,\s*type=(.*?)|)\n(.*?)(?:\*|$)", mat_str, _re_in)
    if re_elastic_ is not None:
        re_elastic = re_elastic_.group(2).strip().split(",")
        young, poisson = rd(re_elastic[0]), rd(re_elastic[1])
    else:
        print('No Elastic properties found for material "{name}"'.format(name=name))
        young, poisson = None, None

    # Plastic
    re_plastic_ = re.search(r"\*Plastic\n(.*?)(?:\*|\Z)", mat_str, _re_in)
    if re_plastic_ is not None:
        re_plastic = [tuple(x.split(",")) for x in re_plastic_.group(1).strip().splitlines()]
        sig_p = [rd(x[0]) for x in re_plastic]
        eps_p = [rd(x[1]) for x in re_plastic]
    else:
        eps_p, sig_p = None, None

    # Expansion
    re_zeta = re.search(r"\*Expansion(?:,\s*type=(.*?)|)\n(.*?)(?:\*|$)", mat_str, _re_in)
    if re_zeta is not None:
        zeta = float(re_zeta.group(2).split(",")[0].strip())
    else:
        zeta = 0.0

    # Return material object
    model = CarbonSteel(
        rho=density,
        E=young,
        v=poisson,
        eps_p=eps_p,
        zeta=zeta,
        sig_p=sig_p,
        plasticity_model=None,
    )
    return Material(name=name, mat_model=model)
Beispiel #9
0
    def test_negative_mat_contained(self):
        # A minor change in material property (S420 instead of S355)
        sec = Section("myBG", from_str="BG800x400x30x40")

        mat = Material("my_mat", CarbonSteel("S420"))

        bm = Beam("my_beam", (0, 0, 0), (1, 0, 0), sec, mat)
        elem = Elem(1, [bm.n1, bm.n2], "B31")
        fem_set = FemSet("my_set", [elem], "elset")
        fem_sec = FemSection("my_sec", "beam", fem_set, mat, sec)
        p = get_fsec_bm_collection()

        self.assertFalse(fem_sec in p.fem.sections)
Beispiel #10
0
    def test_negative_mat_contained(self):
        # A minor change in material property (S420 instead of S355)
        sec = Section('myBG', from_str='BG800x400x30x40')

        mat = Material('my_mat', CarbonSteel('S420'))

        bm = Beam('my_beam', (0, 0, 0), (1, 0, 0), sec, mat)
        elem = Elem(1, [bm.n1, bm.n2], 'B31')
        fem_set = FemSet('my_set', [elem], 'elset')
        fem_sec = FemSection('my_sec', 'beam', fem_set, mat, sec)
        p = get_fsec_bm_collection()

        self.assertFalse(fem_sec in p.fem.sections)
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
Beispiel #12
0
def get_mat(match, mat_names, part) -> Material:
    d = match.groupdict()
    matno = str_to_int(d["matno"])
    mat_model = CarbonSteel(
        rho=roundoff(d["rho"]),
        E=roundoff(d["young"]),
        v=roundoff(d["poiss"]),
        alpha=roundoff(d["damp"]),
        zeta=roundoff(d["alpha"]),
        sig_y=roundoff(d["yield"]),
    )
    return Material(name=mat_names[matno],
                    mat_id=matno,
                    mat_model=mat_model,
                    parent=part)
Beispiel #13
0
 def create_ifc(name, up=(0, 0, 1)):
     a = Assembly("MyAssembly")
     p = Part(name)
     p.add_beam(
         Beam(
             "bm_up",
             n1=[0, 0, 0],
             n2=[2, 0, 0],
             sec="HP200x10",
             mat=Material("SteelMat", CarbonSteel("S420")),
             colour="red",
             up=up,
         ))
     a.add_part(p)
     a.to_ifc(test_folder / name)
Beispiel #14
0
def test_negative_mat_contained(part_with_beam):
    # A minor change in material property (S420 instead of S355)
    sec = Section("myBG", from_str="BG800x400x30x40")

    mat = Material("my_mat", CarbonSteel("S420"))

    bm = Beam("my_beam", (0, 0, 0), (1, 0, 0), sec, mat)
    elem = Elem(1, [bm.n1, bm.n2], "line")
    fem_set = FemSet("my_set", [elem], "elset")
    fem_sec = FemSection("my_sec",
                         "line",
                         fem_set,
                         mat,
                         sec,
                         local_z=(0, 0, 1))

    assert fem_sec not in part_with_beam.fem.sections
Beispiel #15
0
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
Beispiel #16
0
def test_beam_to_from_ifc():
    bm = Beam(
        "bm1",
        n1=[0, 0, 0],
        n2=[2, 0, 0],
        sec="IPE220",
        mat=Material("SteelMat", CarbonSteel("S420")),
        colour="red",
    )

    a = Assembly("MyAssembly") / [Part("MyPart") / bm]
    fp = a.to_ifc(test_dir / "my_beam_profile.ifc", return_file_obj=True)

    a2 = Assembly("MyNewAssembly")
    a2.read_ifc(fp)

    # This would require more work put into __eq__ and __neq__. Not a priority (visual check in Blender for now)
    # bm2 = a2.get_by_name(bm.name)
    # assert bm2 == bm
    _ = a2.to_ifc(test_dir / "my_beam_profile_re_exported.ifc", return_file_obj=True)
Beispiel #17
0
    def __init__(
        self,
        name,
        nodes,
        t,
        mat="S420",
        use3dnodes=False,
        placement=Placement(),
        pl_id=None,
        offset=None,
        colour=None,
        parent=None,
        ifc_geom=None,
        opacity=1.0,
        metadata=None,
        tol=None,
        units="m",
        ifc_elem=None,
        guid=None,
        ifc_ref: "IfcRef" = None,
    ):
        super().__init__(
            name,
            guid=guid,
            metadata=metadata,
            units=units,
            ifc_elem=ifc_elem,
            placement=placement,
            ifc_ref=ifc_ref,
            colour=colour,
            opacity=opacity,
        )

        points2d = None
        points3d = None

        if use3dnodes is True:
            points3d = nodes
        else:
            points2d = nodes

        self._pl_id = pl_id
        self._material = mat if isinstance(mat, Material) else Material(
            mat, mat_model=CarbonSteel(mat), parent=parent)
        self._material.refs.append(self)
        self._t = t

        if tol is None:
            if units == "mm":
                tol = Settings.mmtol
            elif units == "m":
                tol = Settings.mtol
            else:
                raise ValueError(f'Unknown unit "{units}"')

        self._poly = CurvePoly(
            points3d=points3d,
            points2d=points2d,
            normal=self.placement.zdir,
            origin=self.placement.origin,
            xdir=self.placement.xdir,
            tol=tol,
            parent=self,
        )

        self._offset = offset
        self._parent = parent
        self._ifc_geom = ifc_geom
        self._bbox = None
def mat1():
    return Material("Mat1", mat_model=CarbonSteel())
Beispiel #19
0
    def __init__(
            self,
            name,
            mass: float,
            cog: Tuple[float, float, float],
            legs=4,
            height=2,
            width=3,
            length=3,
            sec_str="BG200x200x30x30",
            eq_mat=Material("EqMatSoft", CarbonSteel("S355", E=2.1e9)),
    ):
        """

        :param name:
        :param mass:
        :param cog:
        :param legs: can be either 3 or 4 legs
        :param height:
        :param width:
        :param length: Length is along the Y-axis
        """
        super(EquipmentTent, self).__init__(name=name)

        eq_bm = Counter(1, f"{name}_bm")
        cognp = np.array(cog)
        corner_index = [(-1, -1), (-1, 1), (1, 1), (1, -1)]
        if legs == 3:
            corner_index = [(-1, -1), (1, -1), (0.5, 1)]

        mid_points = []
        btn_points = []

        for sX, sY in corner_index:
            p = cognp + sX * np.array(X) * width + sY * np.array(
                Y) * length - np.array(Z) * height / 2
            mid_points.append(p)
            p = cognp + sX * np.array(X) * width + sY * np.array(
                Y) * length - np.array(Z) * height
            btn_points.append(p)

        vertical_legs = []
        for btnp, midp in zip(btn_points, mid_points):
            bm = Beam(next(eq_bm), btnp, midp, sec_str, eq_mat)
            vertical_legs.append(bm)
            self.add_beam(bm)

        horizontal_members = []
        for bs, be in zip(mid_points[:-1], mid_points[1:]):
            bm = Beam(next(eq_bm), bs, be, sec_str, eq_mat)
            horizontal_members.append(bm)
            self.add_beam(bm)

        bm = Beam(next(eq_bm), mid_points[-1], mid_points[0], sec_str, eq_mat)
        horizontal_members.append(bm)
        self.add_beam(bm)

        eq_braces = []
        for midp in mid_points:
            bm = Beam(next(eq_bm), midp, cog, sec_str, eq_mat)
            eq_braces.append(bm)
            self.add_beam(bm)

        self.add_set("vertical_members", vertical_legs)
        self.add_set("horizontal_members", horizontal_members)
        self.add_set("braces", eq_braces)

        self.add_shape(
            PrimSphere(f"{name}_cog",
                       cog,
                       radius=(width + length) / 6,
                       mass=mass))
        self._centre_of_gravity = cog
        self._mass = mass