from mesh2d import rectangular_triangles
 from mesh2d import draw_vtk
 from assembly2d import assembly_triangles_stress_strain
 from stress_strain_matrix import plane_strain_isotropic
 from numpy import zeros
 from scipy.sparse.linalg import spsolve
 l = 10.0  # beam half-length
 c = 2.0  # beam half-height
 e = 203200.0  # Young's modulus
 nu = 0.27  # Poison's modulus
 q = 100.0  # uniformly distributed load
 n = 51  # nodes in the first direction of computational domain
 m = 21  # nodes in the second direction of computational domain
 d = plane_strain_isotropic(e, nu)
 print(d)
 (nodes, elements) = rectangular_triangles(x_count=n, y_count=m, x_origin=0.0, y_origin=-c, width=l, height=2.0 * c)
 stiffness = assembly_triangles_stress_strain(nodes, elements, d)
 dimension = stiffness.shape[0]
 force = zeros(dimension)
 for i in range(len(nodes)):
     if abs(nodes[i, 0]) < 0.0000001:
         force[2 * i + 1] = -q / m
 for i in range(len(nodes)):
     if abs(l - nodes[i, 0]) < 0.0000001:
         for j in range(dimension):
             if stiffness[2 * i, j] != 0.0:
                 stiffness[2 * i, j] = 0.0
             if stiffness[j, 2 * i] != 0.0:
                 stiffness[j, 2 * i] = 0.0
             if stiffness[2 * i + 1, j] != 0.0:
                 stiffness[2 * i + 1, j] = 0.0
Exemplo n.º 2
0
if __name__ == "__main__":
    from mesh2d import rectangular_quads
    from mesh2d import rectangular_triangles
    from plot_coo_matrix import plot_coo_matrix
    d = array([[1., 1., 0.], [1., 1., 0.], [0., 0., 1.]])
    (nodes, elements) = rectangular_quads(x_count=51,
                                          y_count=11,
                                          x_origin=-10.0,
                                          y_origin=-2.0,
                                          width=20.0,
                                          height=4.0)
    global_matrix = assembly_quads_stress_strain(nodes, elements, d)
    plot_coo_matrix(global_matrix)
    (nodes, elements) = rectangular_triangles(x_count=51,
                                              y_count=11,
                                              x_origin=-10.0,
                                              y_origin=-2.0,
                                              width=20.0,
                                              height=4.0)
    global_matrix = assembly_triangles_stress_strain(nodes, elements, d)
    plot_coo_matrix(global_matrix)
    (nodes, elements) = rectangular_quads(x_count=31,
                                          y_count=31,
                                          x_origin=0.0,
                                          y_origin=0,
                                          width=1,
                                          height=1)
    global_matrix = assembly_quads_mindlin_plate(nodes, elements, 0.1, 10920,
                                                 0.3)
    plot_coo_matrix(global_matrix)
Exemplo n.º 3
0
    from scipy.sparse.linalg import spsolve
    from numpy import array

    l = 10.0  # beam half-length
    c = 2.0  # beam half-height
    e = 203200.0  # Young's modulus
    nu = 0.27  # Poison's modulus
    q = 100.0  # uniformly distributed load
    n = 51  # nodes in the first direction of computational domain
    m = 21  # nodes in the second direction of computational domain
    d = plane_strain_isotropic(e, nu)
    print(d)

    (nodes, elements) = rectangular_triangles(x_count=n,
                                              y_count=m,
                                              x_origin=0.0,
                                              y_origin=-c,
                                              width=l,
                                              height=2.0 * c)
    stiffness = assembly_triangles_stress_strain(nodes=nodes,
                                                 elements=elements,
                                                 elasticity_matrix=d)
    stiffness = stiffness.tocsr()

    print("Evaluating force...")

    def force_func(node):
        if abs(node[0]) < 0.0000001:
            return array([0.0, -q / m])
        else:
            return array([0.0, 0.0])
Exemplo n.º 4
0
            ])
            bt = b.conj().transpose()
            local = local + bt.dot(strain_stress_matrix).dot(b) * jacobian * w[i]
        for i in range(element_dimension):
            ii = elements[element_index, i / freedom] * freedom + i % freedom
            for j in range(i, element_dimension):
                jj = elements[element_index, j / freedom] * freedom + j % freedom
                global_matrix[ii, jj] += local[i, j]
                if i != j:
                    global_matrix[jj, ii] = global_matrix[ii, jj]
        print_progress(element_index, elements_count - 1)
    print "\nAssembly is completed"
    return global_matrix


if __name__ == "__main__":
    from numpy import array
    from mesh2d import rectangular_quads
    from mesh2d import rectangular_triangles
    from plot_coo_matrix import plot_coo_matrix
    d = array([
        [1., 1., 0.],
        [1., 1., 0.],
        [0., 0., 1.]
    ])
    (nodes, elements) = rectangular_quads(x_count=51, y_count=11, x_origin=-10.0, y_origin=-2.0, width=20.0, height=4.0)
    global_matrix = assembly_quads_stress_strain(nodes, elements, d)
    plot_coo_matrix(global_matrix)
    (nodes, elements) = rectangular_triangles(x_count=51, y_count=11, x_origin=-10.0, y_origin=-2.0, width=20.0, height=4.0)
    global_matrix = assembly_triangles_stress_strain(nodes, elements, d)
    plot_coo_matrix(global_matrix)