コード例 #1
0
def display_truss_design(x):
    """
    find the displacements in the specified truss as well as the weight of the truss
    :param x: the defining parameters of the truss.  a list of values, in the order on/off, beam number
    :return:
    """
    ss = SystemElements()

    beam_locations = []
    side_length = 120
    beam_locations.append([[0, 0], [0, side_length]])
    beam_locations.append([[0, side_length], [side_length, side_length]])
    beam_locations.append([[side_length, side_length], [side_length, 0]])
    beam_locations.append([[side_length, 0], [0, side_length]])
    beam_locations.append([[0, 0], [side_length, side_length]])

    for i, beam in enumerate(beam_locations):
        if x[i * 2]:
            area = a[x[i * 2 + 1]]
            ss.add_element(location=beam, EA=e * area, EI=e * ix[x[i * 2 + 1]])

    ss.add_support_fixed(node_id=1)

    ss.add_support_roll(node_id=4)

    ss.point_load(Fx=50, node_id=2)
    ss.point_load(Fz=-50, node_id=3)
    ss.solve()

    # ss.show_structure()
    ss.show_displacement()
    return
コード例 #2
0
ファイル: Truss2.py プロジェクト: landonbw/575HW
def plot_truss(x):
    ss = SystemElements()
    p1 = Vertex(0, 0)
    p2 = Vertex(x[30], 0)
    p3 = Vertex(240, 0)
    p4 = Vertex(x[31], 0)
    p5 = Vertex(480, 0)
    p6 = Vertex(x[32], x[33])
    p7 = Vertex(x[34], x[35])
    p8 = Vertex(x[36], x[37])
    verticies = [p1, p2, p3, p4, p5, p6, p7, p8]
    members = [(0, 1), (1, 2), (2, 3), (3, 4), (0, 5), (1, 5), (2, 5), (5, 6),
               (1, 6), (2, 6), (3, 6), (6, 7), (2, 7), (3, 7), (4, 7)]
    weight = 0
    for i in range(0, 30, 2):
        if x[i]:
            start = verticies[members[int(i / 2)][0]]
            end = verticies[members[int(i / 2)][1]]
            length = calc_length(start, end)
            area = a[x[i + 1]]
            Ix = ix[x[i + 1]]
            weight += length * area * dens
            EI = e * Ix
            EA = e * area
            ss.add_element(location=[start, end], EA=EA, EI=EI)
    ss.add_support_hinged(1)
    ss.add_support_roll(3)
    ss.add_support_roll(5)
    # ss.q_load(element_id=[1, 2, 3, 4], q=-0.1)
    ss.point_load(node_id=[2, 4], Fz=[-100000, -100000])
    ss.solve()
    # ss.show_structure()
    ss.show_displacement()
コード例 #3
0
ファイル: Truss2.py プロジェクト: landonbw/575HW
def solve_truss(x):
    ss = SystemElements()
    p1 = Vertex(0, 0)
    p2 = Vertex(x[30], 0)
    p3 = Vertex(240, 0)
    p4 = Vertex(x[31], 0)
    p5 = Vertex(480, 0)
    p6 = Vertex(x[32], x[33])
    p7 = Vertex(x[34], x[35])
    p8 = Vertex(x[36], x[37])
    verticies = [p1, p2, p3, p4, p5, p6, p7, p8]
    members = [(0, 1), (1, 2), (2, 3), (3, 4), (0, 5), (1, 5), (2, 5), (5, 6),
               (1, 6), (2, 6), (3, 6), (6, 7), (2, 7), (3, 7), (4, 7)]
    weight = 0
    for i in range(0, 30, 2):
        if x[i]:
            start = verticies[members[int(i / 2)][0]]
            end = verticies[members[int(i / 2)][1]]
            length = calc_length(start, end)
            area = a[x[i + 1]]
            Ix = ix[x[i + 1]]
            weight += length * area * dens
            EI = e * Ix
            EA = e * area
            ss.add_element(location=[start, end], EA=EA, EI=EI)
    ss.add_support_hinged(1)
    ss.add_support_roll(3)
    ss.add_support_roll(5)
    # ss.q_load(element_id=[1, 2, 3, 4], q=-0.1)
    ss.point_load(node_id=[2, 4], Fz=[-10000, -10000])
    try:
        ss.solve()
        # ss.show_structure()
        # ss.show_reaction_force()
        # ss.show_displacement()
        displ = ss.get_node_displacements()
        phi_1 = np.abs(displ[0][3])
        d2x = np.abs(displ[1][1])
        d2y = np.abs(displ[1][2])
        d3x = np.abs(displ[2][1])
        d4x = np.abs(displ[3][1])
        d4y = np.abs(displ[3][2])
        d5x = np.abs(displ[4][1])
        avg = np.average(np.array([d2x, d2y, d3x, d4x, d4y, d5x]))
        fitness = [avg, weight]
    except:
        fitness = [999, 99999999]
    # print(weight)
    # print(ss.get_node_displacements())
    return fitness
コード例 #4
0
def truss_constraints(x):
    """
    find the displacements in the specified truss as well as the weight of the truss
    :param x: the defining parameters of the truss.  a list of values, in the order on/off, beam number
    :return:
    """
    ss = SystemElements()
    weight = 0

    max_displ = 0.5
    max_weight = 500

    beam_locations = []
    side_length = 120
    beam_locations.append([[0, 0], [0, side_length]])
    beam_locations.append([[0, side_length], [side_length, side_length]])
    beam_locations.append([[side_length, side_length], [side_length, 0]])
    beam_locations.append([[side_length, 0], [0, side_length]])
    beam_locations.append([[0, 0], [side_length, side_length]])

    for i, beam in enumerate(beam_locations):
        if x[i * 2]:
            length = calc_length(beam)
            area = a[x[i * 2 + 1]]
            weight += area * dens * length
            ss.add_element(location=beam, EA=e * area, EI=e * ix[x[i * 2 + 1]])

    ss.add_support_fixed(node_id=1)

    ss.add_support_roll(node_id=4)

    ss.point_load(Fx=50, node_id=2)
    ss.point_load(Fz=-50, node_id=3)
    ss.solve()

    # ss.show_structure()
    # ss.show_displacement()
    node_disp = []
    displacements = ss.get_node_displacements()
    for (node, ux, uy, phi) in displacements:
        displ = np.sqrt(ux**2 + uy**2)
        displ = (displ - max_displ) / max_displ
        node_disp.append(displ)
    weight = (weight - max_weight) / max_weight
    node_disp.append(weight)
    return node_disp
コード例 #5
0
from anastruct.fem.system import SystemElements

ss = SystemElements(EI=5e3, EA=1e5)

ss.add_multiple_elements([[0, 0], [0, 10]], 10)

top_node = ss.nearest_node('y', 10) + 1
ss.add_support_roll(top_node, 1)
ss.add_support_hinged(1)

ss.point_load(top_node, Fz=-1)

if __name__ == "__main__":
    print(ss.solve(geometrical_non_linear=True))
    ss.show_displacement()
コード例 #6
0
from anastruct.fem.system import SystemElements

"""
Test dead loads on the structure. TO DO! Distributed axial force
"""

ss = SystemElements()
ss.add_element([[0, 0], [10, 5]], g=1)
ss.add_support_hinged(1)
ss.add_support_roll(2, 2)

if __name__ == '__main__':
    ss.solve()
    ss.show_reaction_force()
    ss.show_axial_force()
    ss.show_bending_moment()
コード例 #7
0
def build_single_bridge(dna,
                        comb,
                        loc,
                        height,
                        get_ss=False,
                        unit="deflection",
                        EI=15e3,
                        roll=True,
                        support_btm=False,
                        es=False):
    """
    Build a single bridge structure.

    :param dna: (array) DNA from population.
    :param comb: (array) All possible combinations.
    :param loc: (array) All possible locations.
    :param height: (int) Maximum height of the bridge.
    :param unit: (str) Make this important in the fitness score evaluation. {deflection, axial compression,
                                                                         tension, moment)
    :param EI: (flt) Bending stiffness of the structure.
    :param roll: (bool) Add a support that is free in x.
    :param support_btm: (bool) Place the support at the bottom of the grid.
    :param es: (bool) Special code for Evolution Strategies.
    :return: (unit, length, number of elements)
    """
    ss = SystemElements(EI=EI, mesh=3)
    on = np.argwhere(dna == 1).flatten()

    # Add the elements based on the dna
    mirror_line = 0
    for j in on:
        n1, n2 = comb[j]
        l1 = loc[n1]
        l2 = loc[n2]
        ss.add_element([l1, l2])
        mirror_line = max(mirror_line, l1[0], l2[0])

    # add mirrored element
    for j in on:
        n1, n2 = comb[j]
        l1 = loc[n1]
        l2 = loc[n2]
        ss.add_element([mirror(l1, mirror_line), mirror(l2, mirror_line)])

    # Placing the supports on the outer nodes, and the point load on the middle node.
    x_range = ss.nodes_range('x')

    # A bridge of one element is no bridge, it's a beam.
    if len(x_range) <= 2:
        return None
    else:
        length = max(x_range)
        start = min(x_range)
        ids = list(ss.node_map.keys())

        # Find the ids of the middle node for the force application,
        # and the most right node for the support of the bridge
        max_node_id = ids[np.argmax(x_range)]

        for j in range(height):
            middle_node_id = ss.nearest_node(
                "both", np.array([(length + start) / 2, height - j]))
            if middle_node_id:
                break

        if middle_node_id is None:
            middle_node_id = ids[np.argmin(
                np.abs(np.array(x_range) - (length + start) / 2))]

        # Find the support ids in case the supports should be place in the middle.
        if support_btm:
            left_node_id = 1
            right_node_id = max_node_id
        else:
            idx = np.argsort(np.abs(np.arange(height) - height // 2))

            for j in idx:
                left_node_id = ss.nearest_node("both", np.array([start, j]))
                if left_node_id:
                    break
            for j in idx:
                right_node_id = ss.nearest_node("both",
                                                np.array([start + length, j]))
                if right_node_id:
                    break

        # Add support conditions
        ss.add_support_hinged(left_node_id)
        if roll and right_node_id is not None:
            ss.add_support_roll(right_node_id)
        elif right_node_id is not None:
            ss.add_support_hinged(right_node_id)
        ss.point_load(middle_node_id, Fz=-100)

        if ss.validate():
            if get_ss:
                return ss

            ss.solve()

            if unit == "deflection":
                val = np.abs(ss.get_node_displacements(middle_node_id)["uy"])
            elif unit == "axial compression":
                val = -np.min(ss.get_element_result_range("axial"))
            elif unit == "tension":
                val = np.max(ss.get_element_result_range("axial"))
            elif unit == "moment":
                val = np.abs((ss.get_element_result_range("moment")))
            else:
                raise LookupError("Unit is not defined")

            if es:
                return val, length - start, on.size, max(ss.nodes_range('y'))

            return val, length - start, on.size
コード例 #8
0
from anastruct.fem.system import SystemElements

ss = SystemElements(EI=5e3, EA=1e5)

ss.add_element([0, 10])

ss.add_support_hinged(1)
ss.add_support_roll(2, 1)

ss.point_load(2, Fz=-1)

if __name__ == "__main__":
    ss.solve(geometrical_non_linear=True, discretize_kwargs=dict(n=15))
    print(ss.buckling_factor)
    ss.show_displacement()
コード例 #9
0
from anastruct.fem.system import SystemElements
"""
Test dead loads on the structure. TO DO! Distributed axial force
"""

ss = SystemElements()
ss.add_element([[0, 0], [10, 5]], g=1)
ss.add_support_hinged(1)
ss.add_support_roll(2, 2)

if __name__ == '__main__':
    ss.solve()
    ss.show_reaction_force()
    ss.show_axial_force()
    ss.show_bending_moment()
コード例 #10
0
from anastruct.fem.system import SystemElements

ss = SystemElements(EI=5e3, EA=1e5)

ss.add_element([0, 10])

ss.add_support_hinged(1)
ss.add_support_roll(2, 1)

ss.point_load(2, Fy=-1)

if __name__ == "__main__":
    ss.solve(geometrical_non_linear=True, discretize_kwargs=dict(n=15))
    print(ss.buckling_factor)
    ss.show_displacement()
    afstand_puntlast = overspanning * round(random.uniform(0.1, 0.9), 1)
    puntlast = round(random.uniform(-2, -100), 1)
    qlast = round(random.uniform(-10, -40), 1)

    # De constructie bestaat uit 1 element, dus het traagheidsmoment en het oppervlakte van het profiel hebben geen
    # invloed op de oplegreacties ed. Vandaar dat de stijfehedn ed voor het gemak zo worden verklaard.
    ss = SystemElements(EA=EA, EI=EI)

    # Construeren van het element. het element wordt in twee delen opgedeeld omdat Anastruct geen puntlast op afstanden
    # tot knopen toe laat, maar alleen op knopen zelf.
    ss.add_element(location=[[0, 0], [afstand_puntlast, 0]])
    ss.add_element(location=[[afstand_puntlast, 0], [overspanning, 0]])

    # Toevoegen van opleggingen. Een vast scharnier en een rolscharnier. het systeem is statisch bepaald.
    ss.add_support_hinged(node_id=1)
    ss.add_support_roll(node_id=3)

    # Toevoegen van de lasten. De puntlast grijpt aan op de middelste knoop, een willekeurige afstand dus.
    ss.point_load(node_id=2, Fz=puntlast)
    ss.q_load(q=qlast, element_id=1)

    # Uitrekenen van de constructie. De resultaten worden opgeslagen onder resultaten.
    ss.solve()
    resultaat = ss.get_element_results()

    # Lijst om de maximale momenten in op te slaan. Daarna itereren over de elementen en de maximale momenten opslaan.
    momenten = []
    for element in resultaat:
        momenten.append(element['Mmin'])

    # Ittereren over alle HEA balken.