예제 #1
0
파일: ada02b.py 프로젝트: LeoBelmont/ADA
 def solve(self):
     from anastruct import SystemElements
     ss = SystemElements()
     ss.solve()
     ss.show_structure()
     ss.show_reaction_force()
     ss.show_bending_moment()
예제 #2
0
 def __init__(self, main_window, main_window_functions):
     self.mw = main_window
     self.fn = main_window_functions
     self.ss = SystemElements()
     self.ss.color_scheme = "dark"
     self.was_solved = False
     self.states = []
예제 #3
0
def generate_truss_by_grid(grid, enabled):
    """
	enabled is a list of booleans indicating which members in the grid are enabled. Length must match the total possible members in the grid
	"""
    enabled = np.array(enabled)
    width = MIN_WIDTH / 2
    height = MAX_HEIGHT
    all_possible_members = grid
    # print(f"number of possible members: {len(all_possible_members)}")
    assert len(all_possible_members) == len(enabled)
    members = all_possible_members[enabled]
    print(f"members selected: {len(members)}")
    # mirror the members to the right side
    members_mirror = np.copy(members)
    for member in members_mirror:
        for point in member:
            point[0] *= -1
            point[0] += width * 2
    members = np.append(members, members_mirror, axis=0)
    truss = SystemElements(EA=MODULUS_OF_ELASTICITY * BRASS_CROSS_SECTION_AREA,
                           EI=MODULUS_OF_ELASTICITY * MOMENT_OF_INERTIA)
    for member in members:
        truss.add_truss_element(member)
    try:
        truss.add_support_hinged(node_id=truss.find_node_id(vertex=[0, 0]))
        truss.add_support_hinged(node_id=truss.find_node_id(
            vertex=[width * 2, 0]))
        return truss
    except:
        return None
예제 #4
0
 def reset_struct_elems(self):
     self.ss = SystemElements()
     self.ss.color_scheme = "dark"
     self.states.clear()
     self.mw.MplWidget.plot(has_grid=self.mw.gridBox.isChecked())
     self.mw.MplWidget.set_background_alpha()
     self.mw.MplWidget.set_subplot_alpha()
     self.fn.figurefix()
     self.was_solved = False
     self.fn.disable_buttons()
예제 #5
0
 def __init__(
     self,
     system_elements,
     node_order=None,
     assemble_order=None,
     target_dir="tmp",
 ):
     self.ss = system_elements
     self.branch_ss = SystemElements()
     self.assemble_order = assemble_order
     self.node_order = node_order
     self.target_dir = target_dir
예제 #6
0
def redraw():
    frame = FreeCAD.ActiveDocument.getObjectsByLabel(
        ui.comboBox.currentText())[0]
    print(frame.Label)
    sk = frame.Base
    print('\tBase: ' + sk.Label)
    A = frame.Profile.Shape.Area * 1e-6
    I = frame.Profile.Shape.MatrixOfInertia.multiply(X).dot(X) * 1e-12
    ss = SystemElements()
    for l in sk.Geometry:
        sp = [i * 1e-3 for i in list(l.StartPoint)[:2]]
        ep = [i * 1e-3 for i in list(l.EndPoint)[:2]]
        ss.add_element([sp, ep], EA=E * A, EI=E * I)
    print('\tNodes: %i\n\tElements: %i\n\n' %
          (ss.id_last_node, ss.id_last_element))
    ss.show_structure()
    ui.editE.setText(str(E))
    ui.editA.setText(str(A))
    ui.editI.setText(str(I))
    n = len(sk.Geometry)
    ui.table.setRowCount(n)
    for i in list(range(n)):
        item = QtGui.QTableWidgetItem('%.1f m' %
                                      (sk.Geometry[i].length() / 1000))
        ui.table.setItem(i, 0, item)
    ui.table.setItem(3, 1, QtGui.QTableWidgetItem('-2000'))  #for test
    ui.table.setItem(4, 1, QtGui.QTableWidgetItem('-1000'))  #for test
    ui.table_2.setRowCount(ss.id_last_node)
    for i in list(range(ss.id_last_node)):
        ui.table_2.setItem(
            i, 0,
            QtGui.QTableWidgetItem('%.2f, %.2f' % ss.nodes_range('both')[i]))
    ui.table_2.setItem(0, 1, QtGui.QTableWidgetItem('fix'))  #for test
    ui.table_2.setItem(3, 1, QtGui.QTableWidgetItem('roll'))  #for test
    ui.table_2.setItem(5, 1, QtGui.QTableWidgetItem('hinge'))  #for test
예제 #7
0
 def redraw(self):
     for l in self.labNodes + self.labEl:
         l.removeLabel()
     if self.form.comboBox.currentText():
         frame = FreeCAD.ActiveDocument.getObjectsByLabel(
             self.form.comboBox.currentText())[0]
         sk = frame.Base
         A = frame.Profile.Shape.Area
         I = frame.Profile.Shape.MatrixOfInertia.multiply(X).dot(X)
         ss = SystemElements()
         i = 1
         for l in sk.Geometry:
             sp = [i * 1e-3 for i in list(l.StartPoint)[:2]]
             ep = [i * 1e-3 for i in list(l.EndPoint)[:2]]
             ss.add_element([sp, ep], EA=E * A * 1e-3, EI=E * I * 1e-9)
             p2 = FreeCAD.Placement()
             p2.Base = sk.Placement.multVec((l.StartPoint + l.EndPoint) / 2)
             self.labNodes.append(
                 label3D(pl=p2, color=(0, 0.8, 0),
                         text='____beam' + str(i)))
             i += 1
         nodes = ss.nodes_range('both')
         coords = [
             FreeCAD.Vector(n[0] * 1000, n[1] * 1000, 0) for n in nodes
         ]
         globalCoords = [sk.Placement.multVec(c) for c in coords]
         i = 1
         for gc in globalCoords:
             self.labNodes.append(
                 label3D(pl=FreeCAD.Placement(gc, FreeCAD.Rotation()),
                         text='____node' + str(i)))
             i += 1
         self.form.editE.setText(str(E))
         self.form.editA.setText(str(A))
         self.form.editI.setText(str(I))
         n = len(sk.Geometry)
         self.form.tableDistrib.setRowCount(n)
         self.combotypes.clear()
         for i in list(range(n)):
             item = QTableWidgetItem('%.1f m' %
                                     (sk.Geometry[i].length() / 1000))
             self.form.tableDistrib.setItem(i, 0, item)
             self.combotypes.append(QComboBox())
             self.combotypes[-1].addItems(['beam', 'brace'])
             self.form.tableDistrib.setCellWidget(i, 1, self.combotypes[-1])
         #self.form. tableDistrib.setItem(0,1,QTableWidgetItem('1000')) #for test
         self.form.table_2.setRowCount(ss.id_last_node)
         self.form.tableConc.setRowCount(ss.id_last_node)
         self.combos.clear()
         for i in list(range(ss.id_last_node)):
             self.form.table_2.setItem(
                 i, 0,
                 QTableWidgetItem('%.2f, %.2f' % ss.nodes_range('both')[i]))
             self.combos.append(QComboBox())
             self.combos[-1].addItems(['-', 'fix', 'hinge', 'roll'])
             self.form.table_2.setCellWidget(i, 1, self.combos[-1])
             self.form.tableConc.setItem(
                 i, 0,
                 QTableWidgetItem('%.2f, %.2f' % ss.nodes_range('both')[i]))
예제 #8
0
파일: ada02b.py 프로젝트: LeoBelmont/ADA
 def element(self):
     x1 = float(self.x1value.text())
     x2 = float(self.x2value.text())
     y1 = float(self.y1value.text())
     y2 = float(self.y2value.text())
     from anastruct import SystemElements
     ss = SystemElements()
     ss.add_element(location=[[x1, y1], [x2, y2]])
     ss.show_structure()
예제 #9
0
def test_solve_modal_analysis():
    system = SystemElements()
    l = 10
    n = 50
    subd = l / n
    for i in range(n):
        system.add_element(location=[[subd * i, 0], [subd * (i + 1), 0]], EA=5e8, EI=800, linear_density=10)

    system.add_support_hinged(node_id=1)
    system.add_support_roll(node_id=n + 1)

    natural_frequencies = system.solve_modal_analysis()

    def analytical_natural_frequencies(linear_density, l, EI, n):
        # See Rao, Singiresu S. - Vibration of continuous Systems - John Wiley & Sons (2019) - Section 11.5.1
        return (n ** 2) * (np.pi ** 2) * np.sqrt(EI / (linear_density * l ** 4))

    # retrieve fist four eigenvalues, as error incr6eases for higher eigenvalues
    for i in range(4):
        assert np.isclose(natural_frequencies[i], analytical_natural_frequencies(10, 10, 800, i + 1), rtol=1e-2)
#!/usr/bin/env python3
from anastruct import SystemElements
import math

width = 15
height = 4

ss = SystemElements(EA=15000, EI=5000)
ss.add_truss_element(location=[[0, 0], [0, height]])
ss.add_truss_element(location=[[0, 0], [width, 0]])
ss.add_truss_element(location=[[0, 4], [width, height]])
ss.add_truss_element(location=[[width, height], [width, 0]])
ss.add_truss_element(location=[[0, height], [width/4, 0]])
ss.add_truss_element(location=[[width/4*2, height], [width/4, 0]])
ss.add_truss_element(location=[[width/4*2, height], [width/4*3, 0]])
ss.add_truss_element(location=[[width, height], [width/4*3, 0]])

ss.add_support_fixed(node_id=ss.find_node_id(vertex=[0, 0]))
ss.add_support_fixed(node_id=ss.find_node_id(vertex=[15, 0]))

ss.point_load(Fy=-300, node_id=ss.find_node_id(vertex=[width/2, height]))

ss.solve()

# Get visual results.
ss.show_structure()
# ss.show_reaction_force()
# ss.show_axial_force()
# ss.show_shear_force()
# ss.show_bending_moment()
# ss.show_displacement()
예제 #11
0
def test_timoshenko_continuous():
    system = SystemElements()
    system.add_element(location=[[0, 0], [1, 0]],
                       EA=1.4e8,
                       EI=1.167e5,
                       GA=0.8333 * 8.75e6)
    system.q_load(element_id=1, q=5000, direction="y")

    system.add_support_hinged(node_id=1)
    system.add_support_roll(node_id=2)

    system.solve()

    assert np.isclose(np.max(abs(system.element_map[1].deflection)),
                      6.44e-4,
                      rtol=1e-2)
예제 #12
0
파일: ada02b.py 프로젝트: LeoBelmont/ADA
 def support(self):
     apoio = str(self.apoiobox.currentText())
     pos = int(self.apoiopos.text())
     from anastruct import SystemElements
     ss = SystemElements()
     if apoio == 'Fixo':
         ss.add_support_hinged(node_id=pos)
     elif apoio == 'Móvel':
         ss.add_support_roll(node_id=pos)
     elif apoio == 'Engaste':
         ss.add_support_fixed(node_id=pos)
     elif apoio == 'Mola':
         ss.add_support_spring(node_id=pos)
     ss.show_structure()
예제 #13
0
def get_diagram():
    '''
    Recebe um parâmetro numerico que identifica o tipo de diagrama a ser retornado
        0 = Estrutural
        1 = Forças de reação
        2 = Axial
        3 = Cortante
        4 = Fletor
        5 = Displacement ?
    Requisita os parâmetros, via json:
        apoio1 e apoio2, que são os tipos dos apoios
        apoio1pos e apoio2pos, que são as posições dos dois apoios
        cargap, que é a posição da carga
        cargam, que é o módulo da carga
    Tipo dos apoios:
        0 = Primeiro gênerio (roll)
        1 = Segundo gênero (hinged)
        2 = Tercêiro Gênero (fixed)
    '''
    tipo = int(request.args.get('tipo'))

    r = requests.get('https://calculusapi.herokuapp.com/test')
    
    apoio1tipo, apoio2tipo  = r.json().get('apoio1'), r.json().get('apoio2')
    apoio1pos, apoio2pos = r.json().get('apoio1p'), r.json().get('apoio2p')

    cargapos  = r.json().get('cargap')
    cargamod = r.json().get('cargam')

  
    ss = SystemElements()

    #criação da barra
    ss.add_element(location=[[0, 0], [3, 0]])
    ss.add_element(location=[[3, 0], [8, 0]])
    
    #adição do primeiro apoio
    if apoio1tipo == 0:
        ss.add_support_roll(node_id=apoio1pos)
    elif apoio1tipo == 1:
        ss.add_support_hinged(node_id=apoio1pos)
    else:
        ss.add_support_fixed(node_id=apoio1pos)

    
    #adição do segundo apoio
    if apoio2tipo == 0:
        ss.add_support_roll(node_id=apoio2pos)
    elif apoio2tipo == 1:
        ss.add_support_hinged(node_id=apoio2pos)
    else:
        ss.add_support_fixed(node_id=apoio2pos)

    
    #adição da carga
    ss.q_load(element_id=cargapos, q=cargamod)
    
    #geração dos diagramas
    ss.solve()
    img = io.BytesIO()
    if tipo == 0:
        ss.show_structure(show=False).savefig(img)
    elif tipo == 1:
    	ss.show_reaction_force(show=False).savefig(img)
    elif tipo == 2:
    	ss.show_axial_force(show=False).savefig(img)
    elif tipo == 3:
    	ss.show_shear_force(show=False).savefig(img)
    elif tipo == 4:
    	ss.show_bending_moment(show=False).savefig(img)
    elif tipo == 5:
    	ss.show_displacement(show=False).savefig(img) 	
    img.seek(0)
    return send_file(img, mimetype='image/png')
예제 #14
0
def test_bernoulli():
    system = SystemElements()
    system.add_element(location=[[0, 0], [1, 0]], EA=1.4e8, EI=1.167e5)
    system.q_load(element_id=1, q=5000, direction="y")

    system.add_support_hinged(node_id=1)
    system.add_support_roll(node_id=2)

    system.solve()

    assert np.isclose(np.max(abs(system.element_map[1].deflection)),
                      5.58e-4,
                      rtol=1e-2)
예제 #15
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 14 11:50:42 2020

@author: leafuser
"""
import matplotlib as plt
#from matplotlib.widgets import Slider
import numpy as np
from anastruct import SystemElements

ss = SystemElements()
#axSlider1 = plt.axes([0.1, 0.2, 0.8, 0.05])
#slider1 = Slider(axSlider1, 'Slider1', valmin=0, valmax=5)

#1
ss.add_element(location=[[0, 0], [.5, 1]])

#2
ss.add_element(location=[[0, 0], [.8, .8]])
#3
ss.add_element(location=[[.8, .8], [.5, 1]])
#4
ss.add_element(location=[[.5, 1], [1.5, 2]])
#5
ss.add_element(location=[[.8, .8], [1.7, 1.6]])
#6
ss.add_element(location=[[.8, .8], [2, 1.3]])
#7
ss.add_element(location=[[2, 1.3], [1.7, 1.6]])
예제 #16
0
def test_timoshenko_discrete():
    system = SystemElements()
    system.add_element(location=[[0.25, 0]],
                       EA=1.4e8,
                       EI=1.167e5,
                       GA=0.8333 * 8.75e6)
    system.add_element(location=[[0.5, 0]],
                       EA=1.4e8,
                       EI=1.167e5,
                       GA=0.8333 * 8.75e6)
    system.add_element(location=[[0.75, 0]],
                       EA=1.4e8,
                       EI=1.167e5,
                       GA=0.8333 * 8.75e6)
    system.add_element(location=[[1, 0]],
                       EA=1.4e8,
                       EI=1.167e5,
                       GA=0.8333 * 8.75e6)
    system.q_load(element_id=1, q=5000, direction="y")
    system.q_load(element_id=2, q=5000, direction="y")
    system.q_load(element_id=3, q=5000, direction="y")
    system.q_load(element_id=4, q=5000, direction="y")

    system.add_support_hinged(node_id=1)
    system.add_support_roll(node_id=5)

    system.solve()

    assert np.isclose(abs(system.system_displacement_vector[7]),
                      6.44e-4,
                      rtol=1e-2)
예제 #17
0
def results():
    # add section data and loads of the dialog
    E = float(ui.editE.text())
    I = float(ui.editI.text())
    A = float(ui.editA.text())
    ss = SystemElements()
    frame = FreeCAD.ActiveDocument.getObjectsByLabel(
        ui.comboBox.currentText())[0]
    sk = frame.Base
    for l in sk.Geometry:
        sp = [i * 1e-3 for i in list(l.StartPoint)[:2]]
        ep = [i * 1e-3 for i in list(l.EndPoint)[:2]]
        ss.add_element([sp, ep], EA=E * A, EI=E * I)
    for i in list(range(len(sk.Geometry))):
        if ui.table.item(i, 1):
            item = ui.table.item(i, 1)
            try:
                load = float(item.text())
                ss.q_load(element_id=(i + 1), q=load)
            except:
                pass
    for i in list(range(ss.id_last_node)):
        if ui.table_2.item(i, 1):
            if ui.table_2.item(i, 1).text() == 'fix':
                ss.add_support_fixed(node_id=i + 1)
            elif ui.table_2.item(i, 1).text() == 'hinge':
                ss.add_support_hinged(node_id=i + 1)
            elif ui.table_2.item(i, 1).text() == 'roll':
                ss.add_support_roll(node_id=i + 1)
    ss.solve()
    ss.show_results()
예제 #18
0
def test_struct1():
    ss = SystemElements()
    ss.add_element([[-2, 2], [-1, 0]])
    ss.add_element([[-2, 3], [-2, 2]])
    ss.add_element([[-1, 4], [-2, 3]])
    # ss.add_element([[-1, 4], [0, 5]])
    # ss.add_element([[0, 5], [1, 5]])
    # ss.add_element([[1, 5], [2, 5]])
    # ss.add_element([[2, 5], [3, 5]])
    # ss.add_element([[3, 5], [5, 2]])
    ss.add_element([[-3, 4], [-2, 3]])
    ss.add_element([[-4, 4], [-3, 4]])
    ss.add_element([[-3, 5], [-3, 4]])
    ss.add_element([[-2, 0], [-1, 0]])
    ss.add_element([[-2, 1], [-2, 0]])
    ss.add_element([[-2, -1], [-2, 0]])
    ss.add_element([[-3, 0], [-2, 0]])
    ss.add_element([[-4, 1], [-3, 0]])
    ss.add_element([[-5, 2], [-4, 1]])
    ss.add_element([[-4, -1], [-3, 0]])
    ss.add_element([[-5, -2], [-4, -1]])
    ss.add_element([[-1, 0], [0, 0]])
    ss.add_element([[0, 0], [1, 0]])
    ss.add_element([[2, 0], [3, 0]])
    ss.add_element([[1, 0], [2, 0]])
    ss.add_element([[2, 0], [3, 1]])
    ss.point_load(10, 5)
    ss.moment_load(1, 15)
    # ss.add_element([[3, 1], [4, 1]])
    # ss.add_element([[3, 1], [3, 2]])
    # ss.add_element([[4, 1], [5, 2]])
    # ss.add_element([[4, 1], [6, 2]])
    ss.add_element([[1, 0], [-1, 1]])
    ss.show_structure()
    ass = Assembler(ss)
    ass.assemble_structure(main_path=(15, 20))
    # ass.assemble_structure(main_path=(7, 13))
    # ass.plot_solve_order(ass.plot_order, show=True, save_figure=False, plotting_start_node=15)
    [[print(f"section {index + 1}-{sub_index + 1}: {sympify(sub_string, evaluate=False)}") for sub_index, sub_string in
      enumerate(string)] for index, string in enumerate(ass.sections_strings)]
예제 #19
0
def test_struct():
    ss = SystemElements()
    ss.add_element([[0, 0], [1, 0]])
    ss.add_element([[1, 0], [1, 1]])
    ss.add_element([[1, 0], [2, 0]])
    ss.add_element([[2, 0], [3, 0]])
    ss.add_element([[3, 0], [4, 1]])
    ss.add_element([[4, 1], [5, 1]])
    ss.point_load(2, Fy=10)
    ss.point_load(3, Fy=-20, Fx=5)
    ss.point_load(4, Fy=-30)
    ss.point_load(5, Fx=-40)
    ss.moment_load(2, Ty=-9)
    ss.moment_load(1, 7)
    ss.moment_load(3, 3)
    ss.q_load(element_id=3, q=(-10, -20))
    ss.q_load(element_id=5, q=(-10, -20))
    ss.add_support_roll(4)
    ss.add_support_hinged(5)
    # ss.add_support_fixed(3)

    mn = Manager(ss)
    mn.generate_pdf(pdf_path=r"C:\testfolder")
예제 #20
0
def shear_design(Ast, B, D, Vu, fck, fy):
    FS = SystemElements()

    # Add beams to the system.
    FS.add_element(location=[0, 5], EA=15000, EI=5000)
    FS.add_element(location=[[0, 5], [5, 5]], EA=15000, EI=5000)
    FS.add_element(location=[[5, 5], [5, 0]], EA=15000, EI=5000)

    # Add a fixed support at node 1.
    FS.add_support_fixed(node_id=1)

    # Add a rotational spring support at node 4.
    FS.add_support_spring(node_id=4, translation=3, k=4000)

    # Add loads.
    FS.point_load(Fx=30, node_id=2)
    FS.q_load(q=-10, element_id=2)
    FS.q_load(q=-10, element_id=1)
    #ss.q_load(q=-10, element_id=4)
    #print(ss.node_ranges())

    # Solve
    FS.solve()

    FS.get_element_results(element_id=1)['length']
    FS.get_element_results(element_id=1)['Mmin']
    deno = FS.get_element_results(element_id=1)['shear']

    #breadth = randgen(300,600)
    #Asc = 0
    #Ast = 0
    #spacing = 150
    #beam = Beam(depth,breadth,Asc,Ast,15,415,415,3.14*10**2/4,spacing)
    #Asc = beam.p_min()
    #Ast = beam.p_min()
    #beam1 = Beam(depth,breadth,Asc,Ast,15,415,415,3.14*10**2/4,spacing)
    #beam1.moment_capcity()
    #beam1.min_spacing()
    #beam1.max_spacing()

    #print(beam1.moment_capcity()*10**(-3))
    #print(FS.get_element_results(element_id=1)['Mmax'])
    res = Beam_gene(depths)

    beam1 = Beam(depth, breadth, Asc, Ast, 15, 415, 415, 3.14 * 10**2 / 4,
                 spacing)
    beam1.moment_capcity()
    beam1.min_spacing()
    beam1.max_spacing()
    # Add a fixed support at node 1.
    FS.add_support_fixed(node_id=1)

    # Add a rotational spring support at node 4.
    FS.add_support_spring(node_id=4, translation=3, k=4000)

    # Add loads.
    FS.point_load(Fx=30, node_id=2)
    FS.q_load(q=-10, element_id=2)
    FS.q_load(q=-10, element_id=1)
    #ss.q_load(q=-10, element_id=4)
    #print(ss.node_ranges())

    # Solve
    FS.solve()

    FS.get_element_results(element_id=1)['length']
    FS.get_element_results(element_id=1)['Mmin']
    FS.get_element_results(element_id=1)['Mmax']
    FS.get_element_results(element_id=1)['shear']

    #print(beam1.moment_capcity()*10**(-3))
    #print(FS.get_element_results(element_id=1)['Mmax'])
    C_D = ((beam1.moment_capcity()) *
           10**(-3)) / (FS.get_element_results(element_id=1)['Mmax'])
    print(C_D)
예제 #21
0
def Beam_objective_funciton_BD(depths):
    #def fn(*args):
    #beam1 = Beam(depth,breadth,Asc,Ast,15,415,415,3.14*10**2/4,spacing);
    #beam1.moment_capcity()
    #beam1.min_spacing()
    #beam1.max_spacing()
    FS = SystemElements()

    # Add beams to the system.
    FS.add_element(location=[0, 5], EA=15000, EI=5000)
    FS.add_element(location=[[0, 5], [5, 5]], EA=15000, EI=5000)
    FS.add_element(location=[[5, 5], [5, 0]], EA=15000, EI=5000)

    # Add a fixed support at node 1.
    FS.add_support_fixed(node_id=1)

    # Add a rotational spring support at node 4.
    FS.add_support_spring(node_id=4, translation=3, k=4000)

    # Add loads.
    FS.point_load(Fx=30, node_id=2)
    FS.q_load(q=-10, element_id=2)
    FS.q_load(q=-10, element_id=1)
    #ss.q_load(q=-10, element_id=4)
    #print(ss.node_ranges())

    # Solve
    FS.solve()
    FS.get_element_results(element_id=1)['length']
    FS.get_element_results(element_id=1)['Mmin']
    deno = FS.get_element_results(element_id=1)['Mmax']

    #breadth = randgen(300,600)
    #Asc = 0
    #Ast = 0
    #spacing = 150
    #beam = Beam(depth,breadth,Asc,Ast,15,415,415,3.14*10**2/4,spacing)
    #Asc = beam.p_min()
    #Ast = beam.p_min()
    #beam1 = Beam(depth,breadth,Asc,Ast,15,415,415,3.14*10**2/4,spacing)
    #beam1.moment_capcity()
    #beam1.min_spacing()
    #beam1.max_spacing()

    #print(beam1.moment_capcity()*10**(-3))
    #print(FS.get_element_results(element_id=1)['Mmax'])
    res, depth_f = Beam_gene(depths, deno)
    C_D = res / deno
    #print()
    return C_D
예제 #22
0
class connections:
    def __init__(self, main_window, main_window_functions):
        self.mw = main_window
        self.fn = main_window_functions
        self.ss = SystemElements()
        self.ss.color_scheme = "dark"
        self.was_solved = False
        self.states = []

    def add_beam(self):
        try:
            self.workaround()
            e = self.mw.elementtype.currentIndex()

            if self.mw.utilizeinfo.isChecked():
                EI = float(self.fn.filter(self.mw.beam_E.text())) * float(
                    self.fn.filter(self.mw.beam_I.text()))
                EA = float(self.fn.filter(self.mw.beam_E.text())) * float(
                    self.fn.filter(self.mw.beam_A.text()))
                element_types = ["beam", "truss"]
                self.ss.add_element(location=[
                    [
                        float(self.fn.filter(self.mw.beam_x1.text())),
                        float(self.fn.filter(self.mw.beam_y1.text()))
                    ],
                    [
                        float(self.fn.filter(self.mw.beam_x2.text())),
                        float(self.fn.filter(self.mw.beam_y2.text()))
                    ]
                ],
                                    EI=EI,
                                    EA=EA,
                                    element_type=element_types[e])

            else:
                self.ss.add_element(
                    location=[[
                        float(self.fn.filter(self.mw.beam_x1.text())),
                        float(self.fn.filter(self.mw.beam_y1.text()))
                    ],
                              [
                                  float(self.fn.filter(
                                      self.mw.beam_x2.text())),
                                  float(self.fn.filter(self.mw.beam_y2.text()))
                              ]])

            self.visualize_structure()
            self.states.append(pickle.dumps(self.ss))
        except:
            self.fn.warning()

    def beam_info(self):
        if self.mw.utilizeinfo.isChecked():
            self.mw.frame_4.setHidden(False)
        else:
            self.mw.frame_4.setHidden(True)

    def element_type_list(self):
        if self.mw.elementtype.currentIndex() == 1:
            self.mw.beam_I.setEnabled(False)
        elif self.mw.elementtype.currentIndex() == 0:
            self.mw.beam_I.setEnabled(True)

    def add_node(self):
        try:
            if int(self.mw.node_id.text()) in self.ss.node_map.keys():
                self.workaround()
                self.ss.insert_node(element_id=int(self.mw.node_id.text()),
                                    location=[
                                        self.fn.filter(self.mw.node_x.text()),
                                        self.fn.filter(self.mw.node_y.text())
                                    ])
                self.mw.last_figure.click()
                self.states.append(pickle.dumps(self.ss))
            else:
                self.fn.invalid_id_warning()
        except:
            self.fn.warning()

    def add_support(self):
        try:
            if int(self.mw.support_pos.text()) in self.ss.node_map.keys():
                self.workaround()
                if self.mw.support_hinged.isChecked():
                    self.ss.add_support_hinged(
                        node_id=int(self.mw.support_pos.text()))
                elif self.mw.support_roll.isChecked():
                    self.ss.add_support_roll(
                        node_id=int(self.mw.support_pos.text()),
                        angle=float(
                            self.fn.filter(self.mw.support_angle.text())))
                elif self.mw.support_fixed.isChecked():
                    self.ss.add_support_fixed(
                        node_id=int(self.mw.support_pos.text()))
                elif self.mw.support_spring.isChecked():
                    self.ss.add_support_spring(
                        node_id=int(self.mw.support_pos.text()),
                        translation=self.mw.spring_translation.text(),
                        k=self.mw.spring_k.text())
                elif self.mw.support_internal_hinge.isChecked():
                    pass

                self.mw.last_figure.click()
                self.states.append(pickle.dumps(self.ss))
                self.fn.enable_buttons()
            else:
                self.fn.invalid_id_warning()

        except:
            self.fn.warning()

    def show_support_stuff(self):
        if self.mw.support_roll.isChecked():
            self.mw.support_angle.setHidden(
                True)  # Always true due to anaStruct bug
            self.mw.label_113.setHidden(
                True)  # Always true due to anaStruct bug
            self.mw.label_27.setHidden(
                True)  # Always true due to anaStruct bug
            self.mw.label_71.setHidden(True)
            self.mw.label_73.setHidden(True)
            self.mw.spring_k.setHidden(True)
            self.mw.spring_translation.setHidden(True)
        elif self.mw.support_spring.isChecked():
            self.mw.label_71.setHidden(False)
            self.mw.label_73.setHidden(False)
            self.mw.spring_k.setHidden(False)
            self.mw.spring_translation.setHidden(False)
            self.mw.support_angle.setHidden(
                True)  # Always true due to anaStruct bug
            self.mw.label_27.setHidden(True)
            self.mw.label_127.setHidden(False)
        else:
            self.mw.support_angle.setHidden(
                True)  # Always true due to anaStruct bug
            self.mw.label_27.setHidden(True)
            self.mw.label_71.setHidden(True)
            self.mw.label_73.setHidden(True)
            self.mw.spring_k.setHidden(True)
            self.mw.label_113.setHidden(True)
            self.mw.label_127.setHidden(True)
            self.mw.spring_translation.setHidden(True)

    def add_point_load(self):
        try:
            if int(self.mw.load_pos.text()) in self.ss.node_map.keys():
                self.workaround()
                if self.mw.load_moment.text() != '' and float(
                        self.mw.load_moment.text()) != 0:
                    self.ss.moment_load(
                        node_id=int(self.mw.load_pos.text()),
                        Ty=float(self.fn.filter(self.mw.load_moment.text())))

                if float(self.mw.load_y.text()) == 0 and float(
                        self.mw.load_x.text()) == 0 and float(
                            self.mw.load_angle.text()) == 0:
                    pass
                elif self.mw.load_y.text() != '' and self.mw.load_x.text(
                ) != '' and self.mw.load_angle.text() != '':
                    self.ss.point_load(
                        node_id=int(self.mw.load_pos.text()),
                        Fy=float(self.fn.filter(self.mw.load_y.text())),
                        Fx=float(self.fn.filter(self.mw.load_x.text())),
                        rotation=float(
                            self.fn.filter(self.mw.load_angle.text())))
                self.mw.last_figure.click()
                self.states.append(pickle.dumps(self.ss))
                self.fn.enable_buttons()
            else:
                self.fn.invalid_id_warning()
        except:
            self.fn.warning()

    def add_q_load(self):
        try:
            if int(self.mw.qload_pos.text()) in self.ss.node_map.keys():
                if float(self.mw.qload_initial.text()) >= 0 and float(self.mw.qload_final.text()) >= 0 or \
                        float(self.mw.qload_initial.text()) <= 0 and float(self.mw.qload_final.text()) <= 0:
                    self.workaround()
                    if self.mw.qload_initial.text() == '':
                        self.mw.qload_final.setText(
                            self.fn.filter(self.mw.qload_final.text()))
                    if self.mw.qload_final.text() == '':
                        self.mw.qload_final.setText(
                            self.fn.filter(self.mw.qload_initial.text()))
                    self.ss.q_load(
                        element_id=int(self.mw.qload_pos.text()),
                        q=(float(self.fn.filter(self.mw.qload_initial.text())),
                           float(self.fn.filter(self.mw.qload_final.text()))))
                    self.mw.last_figure.click()
                    self.states.append(pickle.dumps(self.ss))
                    self.fn.enable_buttons()
                else:
                    msg = QMessageBox()
                    msg.setWindowTitle(self.mw.warning_title)
                    msg.setText(self.mw.qload_warning)
                    msg.setIcon(QMessageBox.Warning)
                    x = msg.exec_()
            else:
                self.fn.invalid_id_warning()
        except:
            self.fn.warning()

    def visualize_structure(self):
        if self.ss.element_map:
            self.mw.MplWidget.canvas.figure.clear()
            ax = self.mw.MplWidget.canvas.figure.add_subplot(111)
            self.fn.visualize(
                self.ss.show_structure(show=False,
                                       figure=(self.mw.MplWidget.canvas.figure,
                                               ax)))
            ax.patch.set_alpha(0.2)
            self.mw.last_figure = self.mw.show_structure
        else:
            self.mw.MplWidget.plot(has_grid=self.mw.gridBox.isChecked())
            self.fn.figurefix()
            self.mw.last_figure = None

    def visualize_diagram(self):
        self.solve()
        self.mw.MplWidget.canvas.figure.clear()
        ax = self.mw.MplWidget.canvas.figure.add_subplot(111)
        ax.patch.set_alpha(0.2)
        self.fn.visualize(
            self.ss.show_structure(show=False,
                                   free_body_diagram=1,
                                   figure=(self.mw.MplWidget.canvas.figure,
                                           ax)))
        self.mw.last_figure = self.mw.show_diagram

    def visualize_supports(self):
        self.solve()
        self.mw.MplWidget.canvas.figure.clear()
        ax = self.mw.MplWidget.canvas.figure.add_subplot(111)
        ax.patch.set_alpha(0.2)
        self.fn.visualize(
            self.ss.show_reaction_force(
                show=False, figure=(self.mw.MplWidget.canvas.figure, ax)))
        self.mw.last_figure = self.mw.show_supports

    def visualize_normal(self):
        self.solve()
        self.mw.MplWidget.canvas.figure.clear()
        ax = self.mw.MplWidget.canvas.figure.add_subplot(111)
        ax.patch.set_alpha(0.2)
        self.fn.visualize(
            self.ss.show_axial_force(show=False,
                                     figure=(self.mw.MplWidget.canvas.figure,
                                             ax)))
        self.mw.last_figure = self.mw.show_normal

    def visualize_shear(self):
        self.solve()
        self.mw.MplWidget.canvas.figure.clear()
        ax = self.mw.MplWidget.canvas.figure.add_subplot(111)
        ax.patch.set_alpha(0.2)
        self.fn.visualize(
            self.ss.show_shear_force(show=False,
                                     figure=(self.mw.MplWidget.canvas.figure,
                                             ax)))
        self.mw.last_figure = self.mw.show_shear

    def visualize_moment(self):
        self.solve()
        self.mw.MplWidget.canvas.figure.clear()
        ax = self.mw.MplWidget.canvas.figure.add_subplot(111)
        ax.patch.set_alpha(0.2)
        self.fn.visualize(
            self.ss.show_bending_moment(
                show=False, figure=(self.mw.MplWidget.canvas.figure, ax)))
        self.mw.last_figure = self.mw.show_moment

    def visualize_displacement(self):
        self.solve()
        self.mw.MplWidget.canvas.figure.clear()
        ax = self.mw.MplWidget.canvas.figure.add_subplot(111)
        ax.patch.set_alpha(0.2)
        self.fn.visualize(
            self.ss.show_displacement(show=False,
                                      figure=(self.mw.MplWidget.canvas.figure,
                                              ax)))
        self.mw.last_figure = self.mw.show_displacement

    def solve(self):
        self.was_solved = True
        self.ss.solve()

    def static_solver(self, clean=True):
        if find_executable('latex'):
            if self.mw.show_moment.isEnabled():
                if (len(self.ss.supports_roll) == 1 and len(self.ss.supports_hinged) == 1) \
                        or (len(self.ss.supports_fixed) == 1):
                    dialog = QDialog()
                    prompt = PathPrompt(self.mw.language, dialog)
                    dialog.exec_()
                    if not prompt.userTerminated:
                        solve_path = prompt.path
                        file, ok = QFileDialog.getSaveFileName(
                            self.mw, self.mw.pdf_title, self.mw.pdf_text,
                            "PDF (*.pdf)")
                        if ok:
                            try:
                                self.mw.toolBox.setCurrentIndex(0)
                                pdf_dir, filename = split_dir_filename(file)
                                make_pdf_folders(pdf_dir)

                                self.ss.color_scheme = "bright"
                                plt.style.use('default')

                                mn = Manager(self.ss)

                                pdf_generator_thread = PDFGeneratorThread(
                                    mn.generate_pdf,
                                    self.mw.language,
                                    pdf_path=pdf_dir,
                                    filename=filename,
                                    solve_path=solve_path,
                                    path_warning=self.fn.path_warning,
                                )

                                self.fn.setupLoading(pdf_generator_thread)

                                pdf_generator_thread.finished.connect(
                                    self.on_finished)

                                pdf_generator_thread.start()
                                self.mw.loadingScreen.exec_()

                                if not self.mw.loadingUi.userTerminated:
                                    self.fn.pdf_generated_prompt()
                                if clean:
                                    delete_folder(pdf_dir)
                                self.ss.color_scheme = "dark"
                                plt.style.use('dark_background')

                            except:
                                self.fn.latex_packages_warning()
                else:
                    self.fn.static_warning()
            else:
                self.fn.warning()
        else:
            self.fn.latex_warning()

    def on_finished(self):
        self.mw.loadingScreen.close()

    def reset_struct_elems(self):
        self.ss = SystemElements()
        self.ss.color_scheme = "dark"
        self.states.clear()
        self.mw.MplWidget.plot(has_grid=self.mw.gridBox.isChecked())
        self.mw.MplWidget.set_background_alpha()
        self.mw.MplWidget.set_subplot_alpha()
        self.fn.figurefix()
        self.was_solved = False
        self.fn.disable_buttons()

    def load_structure_aux(self, file):
        with open(f'{file}', 'rb') as f:
            self.ss, _, _ = pickle.load(f)
        self.mw.struct_loaded = True

    def workaround(self):
        if self.was_solved:
            self.ss = pickle.loads(self.states[-1])
            self.was_solved = False

    def reset(self):
        self.workaround()
        self.ss.remove_loads()
        self.mw.MplWidget.canvas.figure.clear()
        ax = self.mw.MplWidget.canvas.figure.add_subplot(111)
        ax.patch.set_alpha(0.2)
        self.fn.visualize(
            self.ss.show_structure(show=False,
                                   figure=(self.mw.MplWidget.canvas.figure,
                                           ax)))
        self.states.append(pickle.dumps(self.ss))
        self.fn.disable_buttons()
예제 #23
0
 def pressed(self):
     x1 = int(self.x1value.text())
     x2 = int(self.x2value.text())
     y1 = int(self.y1value.text())
     y2 = int(self.y2value.text())
     movel = (int(self.movelvalue.text()))
     fixo = (int(self.fixovalue.text()))
     from anastruct import SystemElements
     ss = SystemElements()
     ss.add_element(location=[[x1, y1], [x2, y2]])
     ss.add_support_hinged(node_id=movel)
     ss.add_support_fixed(node_id=fixo)
     ss.q_load(element_id=1, q=-10)
     ss.solve()
     ss.show_structure()
     ss.show_reaction_force()
예제 #24
0
from anastruct import SystemElements

ss = SystemElements(EA=15000, EI=5000)

# Add beams to the system.
ss.add_element(location=[0, 5])
ss.add_element(location=[[0, 5], [5, 5]])
ss.add_element(location=[[5, 5], [5, 0]])
ss.add_element(location=[[0, 5], [0, 10]])
ss.add_element(location=[[0, 10], [5, 10]])
ss.add_element(location=[[5, 10], [5, 5]])
# Add a fixed support at node 1.
ss.add_support_fixed(node_id=1)
ss.add_support_fixed(node_id=4)
# Add loads.
ss.point_load(Fx=30, node_id=2)
ss.point_load(Fx=30, node_id=5)
ss.q_load(q=-10, element_id=2)
ss.q_load(q=-10, element_id=5)
# Solve
ss.solve()
# Get visual results.
ss.show_structure()
ss.show_reaction_force()
ss.show_axial_force()
ss.show_shear_force()
ss.show_bending_moment()
ss.show_displacement()
예제 #25
0
def initializeLatticeShell(startPoint,
                           latticeParam,
                           xHexagons,
                           yHexagons,
                           force=10,
                           theta=0,
                           elasticModulus=17000000000,
                           moment=5000000,
                           area=0.0005,
                           g=0,
                           invertHex=True,
                           saveDir=None):
    '''
    This function takes in initial parameters for a hexagon lattice, creates
    a mesh structure using the anaStruct library object SystemElements(). First, 
    the center points of hexagons in the lattice will be generated, the hexagon 
    vertices will be saved in a custom NumPy array to save the center points and 
    al 6 vertices. 

    The numpy array will hold 7 tuples( 1 tuple for the center-point, 6 tuples for
    coordinates of each hexagon vertex. )

    Args: 

        (startPoint): 
            (tuple): Tuple of dtype=np.float64 or dtype=np.float32 housing the 
            original start point (bottom left) of the hexagon lattice to be constructed.
        (latticeParam): 
            (float): The length of each 'sub triangle' length starting from the center
            of the hexagon to each vertex. 
        (xHexagons): 
            (int): Number of hexagons to be constructed in the x-direction in the lattice.
        (yHexagons): 
            (int): Number of hexagons to be constructed in the y-direction in the lattice.
    
    Returns: 

        (lattice): 
            (SystemElements() Object): The system elements object containing all trusses
            defined and fully constrained. 
        (lattice_coordinatews): 
            (numpy array): Custom numpy array of shape=( xHexagons, yHexagons, 7, 2 ). 
            Contains 7 coordinates per hexagon: Center coords, and vertex coordinates.
    '''
    # Initialize finite element material parameters
    EA = elasticModulus * area
    EI = elasticModulus * moment
    # Initialize timer
    start = timeit.default_timer()

    # Initialize anaStruct.py SystemElements() object...
    # ss = SystemElements(figsize=(12,8), EA=15000.0, EI=5e3)
    ss = SystemElements(EA=EA, EI=EI)
    '''
    EA - Standard axial stiffness of element 
    EI - Standard bending stiffness of elements 
    figsize - Matplotlibs standard figure size (inches) 
    '''

    # Initialize custom numpy array...
    lattice_coordinates = np.empty(shape=(xHexagons + 1, yHexagons, 7, 2))

    # Take not of all elements that are already saved so we don't repeat them
    # Save initialized system elements points as an array to be referenfced when
    # creating new system elements to the FEM mesh.
    old_ss = []

    # Initialize hexagon lattice centers:
    lattice_centers = getHexagonLatticeCenters(startPoint,
                                               latticeParam,
                                               xHexagons,
                                               yHexagons,
                                               invertHex=invertHex)
    print(lattice_centers)

    # Iterate through each hexagon center and fill lattice_coordinates numpy array
    for j in range(yHexagons):

        # Every odd numbered row (0 start counting) will have 1 extra hexagon to be drawn in.
        if j % 2 != 0:
            xHexagonCount = xHexagons + 1
        else:
            xHexagonCount = xHexagons

        for i in range(xHexagonCount):

            # Get hexagon points
            curr_hexPoints = hexagonPoints(lattice_centers[i, j],
                                           latticeParam,
                                           invertHex=invertHex)

            # Initialize start point
            lattice_coordinates[i, j, 0] = lattice_centers[i, j]
            lattice_coordinates[i, j, 1:] = curr_hexPoints

            # Iterating through first hexagon being drawn
            if i == 0:

                # For even values:
                if j % 2 != 0:
                    # Finds the point pair list of the right half of the hexagon
                    point_pair_list = [
                        (curr_hexPoints[1], curr_hexPoints[0]),
                        (curr_hexPoints[0], curr_hexPoints[5]),
                        (curr_hexPoints[5], curr_hexPoints[4]),
                    ]
                    for k in range(3):

                        # Check if current element is already added
                        is_added, index = checkSystemElement(
                            point_pair_list[k][0], point_pair_list[k][1],
                            old_ss)

                        # Check if element exists
                        if is_added == False:
                            ss.add_element(location=[
                                point_pair_list[k][0], point_pair_list[k][1]
                            ],
                                           EA=EA,
                                           EI=EI,
                                           g=g)
                            old_ss.append(
                                (point_pair_list[k][0], point_pair_list[k][1]))
                        else:
                            print(
                                "Point Pair {} has already been added at index {} of old_ss list."
                                .format(curr_point_pair, index))

                else:
                    # Iterate through all point pairs:

                    for k in range(6):

                        curr_point_pair = (curr_hexPoints[k - 1],
                                           curr_hexPoints[k])
                        is_added, index = checkSystemElement(
                            curr_point_pair[0], curr_point_pair[1], old_ss)

                        # If element doesn't already exist, add it to the mesh
                        if is_added == False:

                            ss.add_element(location=[
                                curr_hexPoints[k - 1], curr_hexPoints[k]
                            ],
                                           EA=EA,
                                           EI=EI,
                                           g=g)
                            old_ss.append(
                                (curr_hexPoints[k - 1], curr_hexPoints[k]))

                        else:

                            # save elements added
                            # old_ss.append( curr_hexPoints[k-1], curr_hexPoints[k] )

                            # testing line --------------------
                            print(
                                "Point Pair {} has already been added at index {} of old_ss list."
                                .format(curr_point_pair, index))
                            # end testing line ------------------

            elif j % 2 != 0 and i == xHexagons:

                # Uneven row numbers
                if j % 2 != 0:
                    # Finds the point pair list of the right half of the hexagon
                    point_pair_list = [
                        (curr_hexPoints[1], curr_hexPoints[2]),
                        (curr_hexPoints[2], curr_hexPoints[3]),
                        (curr_hexPoints[3], curr_hexPoints[4]),
                    ]
                    for k in range(3):

                        # Check if current element is already added
                        is_added, index = checkSystemElement(
                            point_pair_list[k][0], point_pair_list[k][1],
                            old_ss)

                        # Check if element exists
                        if is_added == False:
                            ss.add_element(location=[
                                point_pair_list[k][0], point_pair_list[k][1]
                            ],
                                           EA=EA,
                                           EI=EI,
                                           g=g)
                            old_ss.append(
                                (point_pair_list[k][0], point_pair_list[k][1]))
                        else:
                            print(
                                "Point Pair {} has already been added at index {} of old_ss list."
                                .format(curr_point_pair, index))

                # Even hexagon values:
                else:

                    for k in range(6):

                        # check if current element is already added...if not, add it!
                        curr_point_pair = (curr_hexPoints[k - 1],
                                           curr_hexPoints[k])
                        is_added, index = checkSystemElement(
                            curr_point_pair[0], curr_point_pair[1], old_ss)

                        # If element doesn't already exist, add it to the mesh
                        if is_added == False:

                            ss.add_element(location=[
                                curr_hexPoints[k - 1], curr_hexPoints[k]
                            ],
                                           EA=EA,
                                           EI=EI,
                                           g=g)
                            old_ss.append(
                                (curr_hexPoints[k - 1], curr_hexPoints[k]))

                        else:

                            # save elements added
                            # old_ss.append( curr_hexPoints[k-1], curr_hexPoints[k] )

                            # testing line --------------------
                            print(
                                "Point Pair {} has already been added at index {} of old_ss list."
                                .format(curr_point_pair, index))
                            # end testing line ------------------

            # add all system elements and save point pairs
            else:

                for k in range(6):

                    # check if current element is already added...if not, add it!
                    curr_point_pair = (curr_hexPoints[k - 1],
                                       curr_hexPoints[k])
                    is_added, index = checkSystemElement(
                        curr_point_pair[0], curr_point_pair[1], old_ss)

                    # If element doesn't already exist, add it to the mesh
                    if is_added == False:

                        ss.add_element(location=[
                            curr_hexPoints[k - 1], curr_hexPoints[k]
                        ],
                                       EA=EA,
                                       EI=EI,
                                       g=g)
                        old_ss.append(
                            (curr_hexPoints[k - 1], curr_hexPoints[k]))

                    else:

                        # save elements added
                        # old_ss.append( curr_hexPoints[k-1], curr_hexPoints[k] )

                        # testing line --------------------
                        print(
                            "Point Pair {} has already been added at index {} of old_ss list."
                            .format(curr_point_pair, index))
                        # end testing line ------------------

    end = timeit.default_timer()

    total_time = np.round((end - start), 2)

    print(
        "\n\nGenerating hexagon mesh of x-y dimensions, {}-{}, lattice parameter, {},  took {} seconds.\n\n"
        .format(xHexagons, yHexagons, latticeParam, total_time))

    lowest_nodes = findLowestNodes(ss, startPoint, latticeParam, xHexagons,
                                   yHexagons)
    highest_nodes = findHighestNodes(ss, startPoint, latticeParam, xHexagons,
                                     yHexagons)

    # add supports and flattening elements
    for i in range(len(lowest_nodes)):

        ss.add_element(location=[lowest_nodes[i - 1][1], lowest_nodes[i][1]])
        old_ss.append((lowest_nodes[i - 1], lowest_nodes[i]))

        # add fixed support on lowest nodes...
        ss.add_support_fixed(node_id=lowest_nodes[i][0])

    # add forces and node locations
    for i in range(len(highest_nodes)):

        ss.add_element(location=[highest_nodes[i - 1][1], highest_nodes[i][1]])
        old_ss.append((highest_nodes[i - 1], highest_nodes[i]))

        # add forces at highest nodes...
        # ss.q_load(q=-1, element_id=highest_nodes[i], direction='element')
        ss.point_load(node_id=highest_nodes[i][0],
                      Fx=0,
                      Fy=force,
                      rotation=theta)

    # Solve and time it
    solveTimeStart = np.round(timeit.default_timer(), 2)
    ss.solve()
    solveTimeEnd = np.round(timeit.default_timer(), 2)
    total_solve_time = solveTimeEnd - solveTimeStart

    print(
        "\n\nSolving beam element model of x-y dimensions, {}-{}, lattice parameter, {},  took {} seconds.\n\n"
        .format(xHexagons, yHexagons, latticeParam, total_solve_time))

    # Calculate average displacement of nodes
    totalDisplacement = 0
    displacements = ss.get_node_displacements(node_id=0)
    for i in range(len(displacements)):
        totalDisplacement += np.sqrt(displacements[i][1]**2 +
                                     displacements[i][2]**2)
    averageDisplacements = totalDisplacement / len(displacements)

    print("\n\nAverage Node Displacement: {}mm".format(averageDisplacements *
                                                       1000))

    if saveDir != None:
        diagnosticData = []
        diagnosticData.append(
            "Hexagon Lattice ({}-x-hexagons,{}-y-hexagons)\n".format(
                xHexagons, yHexagons))
        diagnosticData.append("Lattice Parameter: {}mm\n".format(latticeParam))
        diagnosticData.append("Force: {}N\n".format(force))
        diagnosticData.append("Elastic Modulus: {}MPa\n".format(
            elasticModulus / 1000))
        diagnosticData.append("Second Moment of Area: {}\n".format(moment))
        diagnosticData.append("Area: {}mm\n".format(area * 1000))
        diagnosticData.append("Bending Stiffness: {}\n".format(elasticModulus *
                                                               moment))
        diagnosticData.append(
            "Average Displacement: {}mm\n".format(averageDisplacements))
        diagnosticData.append("Mesh Generated in {}s\n".format(total_time))
        diagnosticData.append(
            "Beam Element Model Solved in {}s\n".format(total_solve_time))

        folderDir = snr.createFolder(
            saveDir,
            "a={}mm A={}mm f={}N E={}MPa".format(latticeParam, area, force,
                                                 elasticModulus / 1000))
        textFile = open("{}\\diagnostics.txt".format(folderDir), 'w')
        textFile.writelines(diagnosticData)
        textFile.close()

        # beam element model is solved in the call of this function.
        saveElementModel(
            ss, folderDir,
            "a={}mm A={}mm f={}N E={}MPa".format(latticeParam, area, force,
                                                 elasticModulus / 1000))

    return ss
예제 #26
0
def test_struct2():
    ss = SystemElements()
    ss.add_element([[0, 0], [1, 0]])
    ss.add_element([[1, 0], [1, 1]])
    ss.add_element([[1, 0], [2, 0]])
    ss.add_element([[2, 0], [3, 0]])
    ss.add_element([[3, 0], [4, 1]])
    ss.add_element([[4, 1], [5, 1]])
    ss.point_load(2, Fy=10)
    ss.point_load(3, Fy=-20)
    ss.point_load(4, Fy=-30)
    ss.point_load(5, Fx=-40)
    ss.moment_load(2, Ty=-9)
    ss.moment_load(1, 7)
    ss.moment_load(3, 3)
    ss.q_load(element_id=3, q=(-10, -20))
    ss.add_support_roll(4)
    ss.add_support_hinged(5)
    # ss.show_structure()
    ss.solve()
    ss.show_reaction_force(show=False)
    ass = Assembler(ss)
    ass.assemble_structure(main_path=Setting.longest)
    [print(element.id, values) for element, values in ass.internal_stresses_dict.items()]
예제 #27
0
def generate_truss(subdivide_mode=None, subdivides=None):
    """
	Randomly generate a valid truss
	"""
    ss = SystemElements(EA=MODULUS_OF_ELASTICITY * BRASS_CROSS_SECTION_AREA,
                        EI=MODULUS_OF_ELASTICITY * MOMENT_OF_INERTIA)
    width = MIN_WIDTH
    height = MAX_HEIGHT
    if not subdivide_mode:
        subdivide_mode = random.choice(
            ["triangle_subdivide", "radial_subdivide", "pillar_subdivide"])
    if subdivide_mode == "triangle_subdivide":
        if not subdivides:
            subdivides = random.randint(1, 2)
        triangles = [
            [
                [[0, 0], [width, 0]],
                [[width, 0], [width / 2, height]],
                [[width / 2, height], [0, 0]],
            ],
        ]
        for _ in range(subdivides):
            new_triangles = []
            for triangle in triangles:
                mids = [midpoint(*line) for line in triangle]
                new_triangles += [
                    [
                        [triangle[0][0], mids[0]],
                        [mids[0], mids[2]],
                        [mids[2], triangle[0][0]],
                    ],
                    [
                        [mids[2], mids[1]],
                        [mids[1], triangle[2][0]],
                        [triangle[2][0], mids[2]],
                    ],
                    [
                        [mids[0], triangle[1][0]],
                        [triangle[1][0], mids[1]],
                        [mids[1], mids[0]],
                    ],
                    [
                        [mids[2], mids[0]],
                        [mids[0], mids[1]],
                        [mids[1], mids[2]],
                    ],
                ]
            triangles = new_triangles
        raw_lines = np.reshape(triangles, (-1, 2, 2))
        # sort coordinates in each line
        raw_lines = [sorted(line, key=lambda p: p[0]) for line in raw_lines]
        # sort lines by first point's x value
        raw_lines = sorted(raw_lines, key=lambda l: l[0][0])
        # remove duplicate lines
        lines = []
        for line in raw_lines:
            is_duplicate = False
            for l in lines:
                if np.array_equal(line, l):
                    is_duplicate = True
            if not is_duplicate:
                lines.append(line)
        for line in lines:
            ss.add_truss_element(location=line)
    elif subdivide_mode == "radial_subdivide":
        if not subdivides:
            subdivides = random.randint(1, 4)
        step_size = width / 2 / subdivides
        bottom_midpoint = midpoint([0, 0], [width, 0])
        lines = []
        for x in np.arange(0, width + 0.1, step_size):
            lines += [
                [
                    bottom_midpoint,
                    [
                        x,
                        valmap(x, 0, width / 2, 0, height) if x <= width / 2
                        else valmap(x, width / 2, width, height, 0)
                    ]
                ],
            ]
        lines[-1][1][1] = 0  # HACK: set last y value to 0
        top_points = [p[1] for p in lines]
        top_lines = []
        for i in range(1, len(top_points)):
            top_lines += [[top_points[i - 1], top_points[i]]]
        lines += top_lines
        for line in lines:
            ss.add_truss_element(location=line)
    elif subdivide_mode == "pillar_subdivide":
        if not subdivides:
            subdivides = random.randint(1, 4)
        step_size = width / 2 / subdivides
        lines = []
        for x in np.arange(step_size, width, step_size):
            lines += [
                [[x, 0],
                 [
                     x,
                     valmap(x, 0, width / 2, 0, height) if x <= width / 2 else
                     valmap(x, width / 2, width, height, 0)
                 ]],
            ]
        top_points = [p[1] for p in lines]
        edge_lines = []
        for i in range(1, len(top_points)):
            edge_lines += [
                [top_points[i - 1], top_points[i]],
                [[top_points[i - 1][0], 0], [top_points[i][0], 0]],
            ]
            if i < len(top_points) / 2:
                edge_lines += [
                    [[top_points[i - 1][0], 0], top_points[i]],
                ]
            else:
                edge_lines += [
                    [top_points[i - 1], [top_points[i][0], 0]],
                ]
        lines += [
            [[0, 0], top_points[0]],
            [[0, 0], [top_points[0][0], 0]],
            [[width, 0], top_points[-1]],
            [[width, 0], [top_points[-1][0], 0]],
        ]
        lines += edge_lines
        for line in lines:
            ss.add_truss_element(location=line)

    ss.add_support_hinged(node_id=ss.find_node_id(vertex=[0, 0]))
    ss.add_support_hinged(node_id=ss.find_node_id(vertex=[width, 0]))
    return ss
예제 #28
0
from anastruct import SystemElements
import random


def randgen(lb, ub):
    return lb - float(float(random.randint(0, 100)) / 100) * (lb - ub)


ss = SystemElements()

# Add beams to the system.
ss.add_element(location=[0, 5], EA=15000, EI=5000)
ss.add_element(location=[[0, 5], [5, 5]], EA=15000, EI=5000)
ss.add_element(location=[[5, 5], [5, 0]], EA=15000, EI=5000)

# Add a fixed support at node 1.
ss.add_support_fixed(node_id=1)

# Add a rotational spring support at node 4.
ss.add_support_spring(node_id=4, translation=3, k=4000)

# Add loads.
ss.point_load(Fx=30, node_id=2)
ss.q_load(q=-10, element_id=2)
ss.q_load(q=-10, element_id=1)
#ss.q_load(q=-10, element_id=4)
#print(ss.node_ranges())

# Solve
ss.solve()
#print(ss.get_element_results(element_id=1))
예제 #29
0
파일: ada03.py 프로젝트: LeoBelmont/ADA
class Ui_MainWindow(object):

    ss = SystemElements()
    listax1 = []
    listax2 = []
    listay1 = []
    listay2 = []
    listappos = []
    listaprot = []
    listapint = []
    listafixo = []
    listamovel = []
    listamola = []
    listaeng = []
    listamint = []
    listampos = []
    listalint = []
    listaldir = []
    listalpos = []
    cont = contpont = contfixo = contmovel = conteng = contmola = contmom = contload = 0

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1107, 801)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            MainWindow.sizePolicy().hasHeightForWidth())
        MainWindow.setSizePolicy(sizePolicy)
        MainWindow.setMinimumSize(QtCore.QSize(1280, 1000))
        MainWindow.setTabShape(QtWidgets.QTabWidget.Rounded)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout_6 = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout_6.setObjectName("gridLayout_6")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.splitter = QtWidgets.QSplitter(self.centralwidget)
        self.splitter.setOrientation(QtCore.Qt.Vertical)
        self.splitter.setObjectName("splitter")
        self.label_2 = QtWidgets.QLabel(self.splitter)
        self.label_2.setFrameShape(QtWidgets.QFrame.Box)
        self.label_2.setFrameShadow(QtWidgets.QFrame.Raised)
        self.label_2.setObjectName("label_2")
        self.layoutWidget = QtWidgets.QWidget(self.splitter)
        self.layoutWidget.setObjectName("layoutWidget")
        self.gridLayout = QtWidgets.QGridLayout(self.layoutWidget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.x2label = QtWidgets.QLabel(self.layoutWidget)
        self.x2label.setObjectName("x2label")
        self.gridLayout.addWidget(self.x2label, 2, 0, 1, 1)
        self.y1label = QtWidgets.QLabel(self.layoutWidget)
        self.y1label.setObjectName("y1label")
        self.gridLayout.addWidget(self.y1label, 0, 1, 1, 1)
        self.x2value = QtWidgets.QLineEdit(self.layoutWidget)
        self.x2value.setObjectName("x2value")
        self.gridLayout.addWidget(self.x2value, 3, 0, 1, 1)
        self.y1value = QtWidgets.QLineEdit(self.layoutWidget)
        self.y1value.setObjectName("y1value")
        self.gridLayout.addWidget(self.y1value, 1, 1, 1, 1)
        self.x1value = QtWidgets.QLineEdit(self.layoutWidget)
        self.x1value.setObjectName("x1value")
        self.gridLayout.addWidget(self.x1value, 1, 0, 1, 1)
        self.y2label = QtWidgets.QLabel(self.layoutWidget)
        self.y2label.setObjectName("y2label")
        self.gridLayout.addWidget(self.y2label, 2, 1, 1, 1)
        self.y2value = QtWidgets.QLineEdit(self.layoutWidget)
        self.y2value.setObjectName("y2value")
        self.gridLayout.addWidget(self.y2value, 3, 1, 1, 1)
        self.x1label = QtWidgets.QLabel(self.layoutWidget)
        self.x1label.setObjectName("x1label")
        self.gridLayout.addWidget(self.x1label, 0, 0, 1, 1)
        self.eleadd = QtWidgets.QPushButton(self.splitter)
        self.eleadd.setObjectName("eleadd")
        self.label = QtWidgets.QLabel(self.splitter)
        self.label.setAutoFillBackground(False)
        self.label.setFrameShape(QtWidgets.QFrame.Box)
        self.label.setFrameShadow(QtWidgets.QFrame.Raised)
        self.label.setObjectName("label")
        self.layoutWidget1 = QtWidgets.QWidget(self.splitter)
        self.layoutWidget1.setObjectName("layoutWidget1")
        self.gridLayout_2 = QtWidgets.QGridLayout(self.layoutWidget1)
        self.gridLayout_2.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.apoiobox = QtWidgets.QComboBox(self.layoutWidget1)
        self.apoiobox.setObjectName("apoiobox")
        self.apoiobox.addItem("")
        self.apoiobox.addItem("")
        self.apoiobox.addItem("")
        self.apoiobox.addItem("")
        self.gridLayout_2.addWidget(self.apoiobox, 3, 0, 1, 2)
        self.label_3 = QtWidgets.QLabel(self.layoutWidget1)
        self.label_3.setObjectName("label_3")
        self.gridLayout_2.addWidget(self.label_3, 1, 0, 1, 2)
        self.apoiopos = QtWidgets.QLineEdit(self.layoutWidget1)
        self.apoiopos.setObjectName("apoiopos")
        self.gridLayout_2.addWidget(self.apoiopos, 2, 0, 1, 2)
        self.apoioadd = QtWidgets.QPushButton(self.splitter)
        self.apoioadd.setObjectName("apoioadd")
        self.label_5 = QtWidgets.QLabel(self.splitter)
        self.label_5.setFrameShape(QtWidgets.QFrame.Box)
        self.label_5.setFrameShadow(QtWidgets.QFrame.Raised)
        self.label_5.setObjectName("label_5")
        self.tabWidget = QtWidgets.QTabWidget(self.splitter)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.tabWidget.sizePolicy().hasHeightForWidth())
        self.tabWidget.setSizePolicy(sizePolicy)
        self.tabWidget.setMinimumSize(QtCore.QSize(300, 300))
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.pontualadd = QtWidgets.QPushButton(self.tab)
        self.pontualadd.setGeometry(QtCore.QRect(180, 170, 121, 31))
        self.pontualadd.setObjectName("pontualadd")
        self.layoutWidget2 = QtWidgets.QWidget(self.tab)
        self.layoutWidget2.setGeometry(QtCore.QRect(90, 90, 301, 51))
        self.layoutWidget2.setObjectName("layoutWidget2")
        self.gridLayout_3 = QtWidgets.QGridLayout(self.layoutWidget2)
        self.gridLayout_3.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.label_8 = QtWidgets.QLabel(self.layoutWidget2)
        self.label_8.setObjectName("label_8")
        self.gridLayout_3.addWidget(self.label_8, 0, 2, 1, 1)
        self.pontrot = QtWidgets.QLineEdit(self.layoutWidget2)
        self.pontrot.setObjectName("pontrot")
        self.gridLayout_3.addWidget(self.pontrot, 1, 2, 1, 1)
        self.label_6 = QtWidgets.QLabel(self.layoutWidget2)
        self.label_6.setObjectName("label_6")
        self.gridLayout_3.addWidget(self.label_6, 0, 0, 1, 1)
        self.pontpos = QtWidgets.QLineEdit(self.layoutWidget2)
        self.pontpos.setObjectName("pontpos")
        self.gridLayout_3.addWidget(self.pontpos, 1, 0, 1, 1)
        self.pontint = QtWidgets.QLineEdit(self.layoutWidget2)
        self.pontint.setObjectName("pontint")
        self.gridLayout_3.addWidget(self.pontint, 1, 1, 1, 1)
        self.label_7 = QtWidgets.QLabel(self.layoutWidget2)
        self.label_7.setObjectName("label_7")
        self.gridLayout_3.addWidget(self.label_7, 0, 1, 1, 1)
        self.tabWidget.addTab(self.tab, "")
        self.tab_2 = QtWidgets.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.distadd = QtWidgets.QPushButton(self.tab_2)
        self.distadd.setGeometry(QtCore.QRect(180, 170, 121, 31))
        self.distadd.setObjectName("distadd")
        self.layoutWidget3 = QtWidgets.QWidget(self.tab_2)
        self.layoutWidget3.setGeometry(QtCore.QRect(90, 90, 301, 51))
        self.layoutWidget3.setObjectName("layoutWidget3")
        self.gridLayout_5 = QtWidgets.QGridLayout(self.layoutWidget3)
        self.gridLayout_5.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_5.setObjectName("gridLayout_5")
        self.label_12 = QtWidgets.QLabel(self.layoutWidget3)
        self.label_12.setObjectName("label_12")
        self.gridLayout_5.addWidget(self.label_12, 0, 0, 1, 1)
        self.label_11 = QtWidgets.QLabel(self.layoutWidget3)
        self.label_11.setObjectName("label_11")
        self.gridLayout_5.addWidget(self.label_11, 0, 1, 1, 1)
        self.label_13 = QtWidgets.QLabel(self.layoutWidget3)
        self.label_13.setObjectName("label_13")
        self.gridLayout_5.addWidget(self.label_13, 0, 2, 1, 1)
        self.distpos = QtWidgets.QLineEdit(self.layoutWidget3)
        self.distpos.setObjectName("distpos")
        self.gridLayout_5.addWidget(self.distpos, 1, 0, 1, 1)
        self.distint = QtWidgets.QLineEdit(self.layoutWidget3)
        self.distint.setObjectName("distint")
        self.gridLayout_5.addWidget(self.distint, 1, 1, 1, 1)
        self.distdir = QtWidgets.QLineEdit(self.layoutWidget3)
        self.distdir.setObjectName("distdir")
        self.gridLayout_5.addWidget(self.distdir, 1, 2, 1, 1)
        self.tabWidget.addTab(self.tab_2, "")
        self.tab_3 = QtWidgets.QWidget()
        self.tab_3.setObjectName("tab_3")
        self.momadd = QtWidgets.QPushButton(self.tab_3)
        self.momadd.setGeometry(QtCore.QRect(180, 170, 121, 31))
        self.momadd.setObjectName("momadd")
        self.layoutWidget4 = QtWidgets.QWidget(self.tab_3)
        self.layoutWidget4.setGeometry(QtCore.QRect(110, 90, 271, 51))
        self.layoutWidget4.setObjectName("layoutWidget4")
        self.gridLayout_4 = QtWidgets.QGridLayout(self.layoutWidget4)
        self.gridLayout_4.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.label_9 = QtWidgets.QLabel(self.layoutWidget4)
        self.label_9.setObjectName("label_9")
        self.gridLayout_4.addWidget(self.label_9, 0, 0, 1, 1)
        self.label_10 = QtWidgets.QLabel(self.layoutWidget4)
        self.label_10.setObjectName("label_10")
        self.gridLayout_4.addWidget(self.label_10, 0, 1, 1, 1)
        self.mompos = QtWidgets.QLineEdit(self.layoutWidget4)
        self.mompos.setObjectName("mompos")
        self.gridLayout_4.addWidget(self.mompos, 1, 0, 1, 1)
        self.momint = QtWidgets.QLineEdit(self.layoutWidget4)
        self.momint.setObjectName("momint")
        self.gridLayout_4.addWidget(self.momint, 1, 1, 1, 1)
        self.tabWidget.addTab(self.tab_3, "")
        self.horizontalLayout.addWidget(self.splitter)
        self.calcular = QtWidgets.QPushButton(self.centralwidget)
        self.calcular.setObjectName("calcular")
        self.horizontalLayout.addWidget(self.calcular)
        self.gridLayout_6.addLayout(self.horizontalLayout, 0, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(2)
        self.eleadd.clicked.connect(self.element)
        self.apoioadd.clicked.connect(self.support)
        self.pontualadd.clicked.connect(self.pointload)
        self.momadd.clicked.connect(self.moment)
        self.distadd.clicked.connect(self.load)
        self.calcular.clicked.connect(self.solve)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Ada 0.3"))
        self.label_2.setText(_translate("MainWindow", "Adicionar elementos"))
        self.x2label.setText(_translate("MainWindow", "Coordenada X2"))
        self.y1label.setText(_translate("MainWindow", "Coordenada Y1"))
        self.y2label.setText(_translate("MainWindow", "Coordenada Y2"))
        self.x1label.setText(_translate("MainWindow", "Coordenada X1"))
        self.eleadd.setText(_translate("MainWindow", "Adicionar"))
        self.label.setText(_translate("MainWindow", "Adicionar apoios"))
        self.apoiobox.setItemText(0, _translate("MainWindow", "Fixo"))
        self.apoiobox.setItemText(1, _translate("MainWindow", "Móvel"))
        self.apoiobox.setItemText(2, _translate("MainWindow", "Engaste"))
        self.apoiobox.setItemText(3, _translate("MainWindow", "Mola"))
        self.label_3.setText(
            _translate("MainWindow", "Posição do apoio (nódulo)"))
        self.apoioadd.setText(_translate("MainWindow", "Adicionar"))
        self.label_5.setText(
            _translate("MainWindow", "Adicionar cargas e momentos"))
        self.pontualadd.setText(_translate("MainWindow", "Adicionar"))
        self.label_8.setText(_translate("MainWindow", "Rotação"))
        self.label_6.setText(_translate("MainWindow", "Posição"))
        self.label_7.setText(_translate("MainWindow", "Intensidade"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab),
                                  _translate("MainWindow", "Carga pontual"))
        self.distadd.setText(_translate("MainWindow", "Adicionar"))
        self.label_12.setText(_translate("MainWindow", "Posição"))
        self.label_11.setText(_translate("MainWindow", "Intensidade"))
        self.label_13.setText(_translate("MainWindow", "Direção"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2),
                                  _translate("MainWindow", "Carregamento"))
        self.momadd.setText(_translate("MainWindow", "Adicionar"))
        self.label_9.setText(_translate("MainWindow", "Posição"))
        self.label_10.setText(_translate("MainWindow", "Intensidade"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3),
                                  _translate("MainWindow", "Momento"))
        self.calcular.setText(_translate("MainWindow", "Calcular"))

    def element(self):
        self.listax1.append(float(self.x1value.text()))
        self.listax2.append(float(self.x2value.text()))
        self.listay1.append(float(self.y1value.text()))
        self.listay2.append(float(self.y2value.text()))
        self.x1value.clear()
        self.x2value.clear()
        self.y1value.clear()
        self.y2value.clear()

    def support(self):
        apoio = str(self.apoiobox.currentText())
        pos = int(self.apoiopos.text())
        if apoio == 'Fixo':
            self.listafixo.append(pos)
        elif apoio == 'Móvel':
            self.listamovel.append(pos)
        elif apoio == 'Engaste':
            self.listaeng.append(pos)
        elif apoio == 'Mola':
            self.listamola.append(pos)
        self.apoiopos.clear()

    def pointload(self):
        self.listappos.append(int(self.pontpos.text()))
        self.listapint.append(float(self.pontint.text()))
        self.listaprot.append(float(self.pontrot.text()))
        self.pontpos.clear()
        self.pontint.clear()
        self.pontrot.clear()

    def load(self):
        self.listalpos.append(int(self.distpos.text()))
        self.listalint.append(float(self.distint.text()))
        self.listaldir.append(str(self.distdir.text()))
        self.distpos.clear()
        self.distint.clear()
        self.distdir.clear()

    def moment(self):
        self.listamint.append(float(self.momint.text()))
        self.listampos.append(int(self.mompos.text()))
        self.momint.clear()
        self.mompos.clear()

    def solve(self):
        for c in range(len(self.listax1)):
            self.ss.add_element(
                location=[[self.listax1[self.cont], self.listay1[self.cont]],
                          [self.listax2[self.cont], self.listay2[self.cont]]])
            self.cont += 1

        for c in range(len(self.listafixo)):
            self.ss.add_support_hinged(node_id=self.listafixo[self.contfixo])
            self.contfixo += 1

        for c in range(len(self.listamovel)):
            self.ss.add_support_roll(node_id=self.listamovel[self.contmovel])
            self.contmovel += 1

        for c in range(len(self.listaeng)):
            self.ss.add_support_fixed(node_id=self.listafixo[self.conteng])
            self.conteng += 1

        for c in range(len(self.listamola)):
            self.ss.add_support_spring(node_id=self.listamola[self.contmola])
            self.contmola += 1

        for c in range(len(self.listapint)):
            self.ss.point_load(node_id=self.listappos[self.contpont],
                               Fy=self.listapint[self.contpont],
                               rotation=self.listaprot[self.contpont])
            self.contpont += 1

        for c in range(len(self.listamint)):
            self.ss.moment_load(node_id=self.listampos[self.contmom],
                                Ty=self.listamint[self.contmom])
            self.contmom += 1

        for c in range(len(self.listalint)):
            self.ss.q_load(element_id=self.listalpos[self.contload],
                           q=self.listalint[self.contload],
                           direction=self.listaldir[self.contload])
            self.contload += 1

        self.ss.solve()
        self.ss.show_structure()
        self.ss.show_axial_force()
        self.ss.show_reaction_force()
        self.ss.show_bending_moment()
    def __init__(self,
                 x,
                 y,
                 connections,
                 loads,
                 supports,
                 density=880,
                 unit='m',
                 width=0.95 / 100,
                 thick=1.8 / 1000,
                 pop_compressive_strength=18100,
                 pop_tensile_strength=70000):
        pop_cross_area = width * thick
        pop_mpl = pop_cross_area * density
        g = pop_mpl * 9.81 / 1000
        unit_conv = 1
        if (unit == 'cm'):
            unit_conv = (1 / 100)
        nodes = [[x[i] * unit_conv, y[i] * unit_conv] for i in range(len(x))]
        ss = SystemElements(EA=pop_cross_area * 8600000)
        for node1, node2 in connections:
            ss.add_element([nodes[node1], nodes[node2]],
                           element_type='truss',
                           g=g)

        for node in supports:
            id = ss.find_node_id(nodes[node])
            ss.add_support_fixed(id)
        for node, load in loads:
            id = ss.find_node_id(nodes[node])
            ss.point_load(id, Fy=-9.81 * load / 1000)
        ss.solve()
        self.ss = ss
        self.nodes = nodes
        self.connections = connections
        self.loads = loads
        self.supports = supports
        self.pop_mpl = pop_mpl
        self.cross_area = pop_cross_area
        self.compress = pop_compressive_strength
        self.tensile = pop_tensile_strength
예제 #31
0
class Ui_MainWindow(object):

    from anastruct import SystemElements
    ss = SystemElements()

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1113, 873)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.Calcular = QtWidgets.QPushButton(self.centralwidget)
        self.Calcular.setGeometry(QtCore.QRect(870, 380, 231, 111))
        self.Calcular.setObjectName("Calcular")
        self.widget = QtWidgets.QWidget(self.centralwidget)
        self.widget.setGeometry(QtCore.QRect(12, 12, 851, 821))
        self.widget.setObjectName("widget")
        self.gridLayout = QtWidgets.QGridLayout(self.widget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.x1label = QtWidgets.QLabel(self.widget)
        self.x1label.setObjectName("x1label")
        self.gridLayout.addWidget(self.x1label, 0, 0, 1, 1)
        self.y1label = QtWidgets.QLabel(self.widget)
        self.y1label.setObjectName("y1label")
        self.gridLayout.addWidget(self.y1label, 0, 1, 1, 1)
        self.x1value = QtWidgets.QLineEdit(self.widget)
        self.x1value.setObjectName("x1value")
        self.gridLayout.addWidget(self.x1value, 1, 0, 1, 1)
        self.y1value = QtWidgets.QLineEdit(self.widget)
        self.y1value.setObjectName("y1value")
        self.gridLayout.addWidget(self.y1value, 1, 1, 1, 1)
        self.x2label = QtWidgets.QLabel(self.widget)
        self.x2label.setObjectName("x2label")
        self.gridLayout.addWidget(self.x2label, 2, 0, 1, 1)
        self.y2label = QtWidgets.QLabel(self.widget)
        self.y2label.setObjectName("y2label")
        self.gridLayout.addWidget(self.y2label, 2, 1, 1, 1)
        self.x2value = QtWidgets.QLineEdit(self.widget)
        self.x2value.setObjectName("x2value")
        self.gridLayout.addWidget(self.x2value, 3, 0, 1, 1)
        self.y2value = QtWidgets.QLineEdit(self.widget)
        self.y2value.setObjectName("y2value")
        self.gridLayout.addWidget(self.y2value, 3, 1, 1, 1)
        self.fixolabel = QtWidgets.QLabel(self.widget)
        self.fixolabel.setObjectName("fixolabel")
        self.gridLayout.addWidget(self.fixolabel, 4, 0, 1, 1)
        self.movellabel = QtWidgets.QLabel(self.widget)
        self.movellabel.setObjectName("movellabel")
        self.gridLayout.addWidget(self.movellabel, 4, 1, 1, 1)
        self.fixovalue = QtWidgets.QLineEdit(self.widget)
        self.fixovalue.setObjectName("fixovalue")
        self.gridLayout.addWidget(self.fixovalue, 5, 0, 1, 1)
        self.movelvalue = QtWidgets.QLineEdit(self.widget)
        self.movelvalue.setObjectName("movelvalue")
        self.gridLayout.addWidget(self.movelvalue, 5, 1, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.Calcular.clicked.connect(self.pressed)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Ada 0.1"))
        self.Calcular.setText(_translate("MainWindow", "Calcular"))
        self.x1label.setText(_translate("MainWindow", "x1"))
        self.y1label.setText(_translate("MainWindow", "y1"))
        self.x2label.setText(_translate("MainWindow", "x2"))
        self.y2label.setText(_translate("MainWindow", "y2"))
        self.fixolabel.setText(_translate("MainWindow", "Apoio fixo"))
        self.movellabel.setText(_translate("MainWindow", "Apoio móvel"))

    def pressed(self):
        x1 = int(self.x1value.text())
        x2 = int(self.x2value.text())
        y1 = int(self.y1value.text())
        y2 = int(self.y2value.text())
        movel = (int(self.movelvalue.text()))
        fixo = (int(self.fixovalue.text()))
        from anastruct import SystemElements
        ss = SystemElements()
        ss.add_element(location=[[x1, y1], [x2, y2]])
        ss.add_support_hinged(node_id=movel)
        ss.add_support_fixed(node_id=fixo)
        ss.q_load(element_id=1, q=-10)
        ss.solve()
        ss.show_structure()
        ss.show_reaction_force()