Esempio n. 1
0
    def test_OnePart1(self):
        numD = 2  # number of dimensions
        enum = 2  # number of elements in each dof
        nodes = nodeList(1, 1, 1, enum, enum)
        ien = get_ien(enum, enum)
        cc = [1.0, 0.0]

        wall = nsel('x', 'n', 0, 0.01, nodes)  # select the wall
        edge = nsel('x', 'n', 1, 0.01, nodes)  # select free edge

        ida, ncons, cons0, loads = constrain(nodes, wall, ien, 'x', 0)
        ida, ncons, cons1, loads = constrain(nodes, wall, ien, 'y', 0.0, cons0)
        ida, ncons, cons2, loads = constrain(nodes, edge, ien, 'x', 1.0, cons1)

        deform, i = solver(numD, loads, nodes, ien, ida, ncons, cons2, cc)

        correct = [0, 0, 0.5, 0, 1, 0, 0, 0, 0.5, 0, 1, 0, 0, 0, 0.5, 0, 1, 0]
        for i in range(len(deform)):  # for every item in the solution...
            self.assertAlmostEqual((correct[i] + 1) / (correct[i] + 1), 1)

        c = contourPlot(deform, ien, nodes, 'sigma_x', 'z', cc)
        c = contourPlot(deform, ien, nodes, 'sigma_y', 'z', cc)
        c = contourPlot(deform, ien, nodes, 'tau_xy', 'z', cc)
        c = contourPlot(deform, ien, nodes, 'd_x', 'z', cc)
        c = contourPlot(deform, ien, nodes, 'd_y', 'z', cc)
Esempio n. 2
0
    def setUp(self):
        # Here, we generate the mesh
        thetaDomain = pi / 2.0  # quarter circle of the pipe
        self.ri = 1.2  # the inner radius of the pipe
        self.ro = 1.8  # the outer radius of the pipe
        self.nr = 8  # the number of elements in the radial direction
        self.nt = 16  # the number of elements in the circumfrential direction
        self.nodes = []  # stores the nodes in the cylindrical mesh
        self.p = -2.0e6  # the pressure (Pa) (against the surface normal)

        for i in range(self.nr + 1):  # for every node in the r-direction...
            for j in range(self.nt +
                           1):  # for every node in the theta-direction...
                radius = i * (self.ro - self.ri) / self.nr + self.ri
                theta = j * thetaDomain / self.nt
                self.nodes.append(
                    [radius * sin(theta), radius * cos(theta), 0])

        self.ien = get_ien(self.nt, self.nr)

        # now the fun begins. We solve this problem using roller constraints on
        # the straight faces and pressure loads on the inner face.
        s0 = nsel('y', 'n', 0, 0.01, self.nodes)
        s1 = nsel('x', 'n', 0, 0.01, self.nodes)

        ida, ncons, cons0, loads = constrain(self.nodes, s0, self.ien, 'y', 0)
        ida, ncons, cons, loads = constrain(self.nodes, s1, self.ien, 'x', 0,
                                            cons0)
        for i in range(self.nt):  # for every inner element...
            loads[3][i] = self.p

        self.deform, i = solver(2, loads, self.nodes, self.ien, ida, ncons,
                                cons)
        self.ps0 = nsel('y', 'n', 0, 0.01, self.nodes)
Esempio n. 3
0
 def setUp(self):
     self.nodes = [[1.0, 2.0, 0.0], [2.0, 1.0, 0.0], [2.0, 3.0, 0.0],
                   [3.0, 2.0, 0.0]]
     p = 2.0e6  # pressure load
     self.ien = get_ien(1, 1)
     selset = [2, 3]  # selected node numbers
     ida, ncons, cons0, loads = constrain(self.nodes, selset, self.ien, 'x',
                                          0)
     ida, ncons, cons, loads = constrain(self.nodes, selset, self.ien, 'y',
                                         0, cons0)
     loads[3][0] = p
     self.deform, i = solver(2, loads, self.nodes, self.ien, ida, ncons,
                             cons)
Esempio n. 4
0
 def test_1Elem1DPlot(self):
     s0 = nsel('x', 'n', 0, 0.01, self.nodes1)
     ida, ncons, cons, loads = constrain(self.nodes1, s0, self.ien1, 'x', 0)
     loads[2][0] = 1.0e8  #Pa
     deform, i = solver(1, loads, self.nodes1, self.ien1, ida, ncons, cons)
     #c = plotResults(deform, self.nodes1, self.nnums1, [1, 0, 0], 'x')
     self.assertEqual(0, 0)
Esempio n. 5
0
    def setUp(self):
        self.nodes = nodeList(1, 1, 1, 1, 1, 1)
        self.ien = get_ien(1, 1, 1)
        self.nnums = np.linspace(0, len(self.nodes) - 1, len(self.nodes))

        self.s0 = nsel('x', 'n', 1, 0.01, self.nodes)

        self.ida, self.ncons, self.cons, loads = constrain(
            self.nodes, self.s0, self.ien, 'y', 0)
Esempio n. 6
0
    def test_1Elem3DPlot(self):
        s0 = nsel('x', 'n', 0, 0.01, self.nodes)
        ida, ncons, cons, loads = constrain(self.nodes, s0, self.ien, 'x', 0)
        s1 = nsel('z', 's', 0, 0.01, self.nodes, s0)
        ida, ncons, cons, loads = constrain(self.nodes, s1, self.ien, 'z', 0,
                                            cons)
        s2 = nsel('y', 's', 0, 0.01, self.nodes, s1)
        ida, ncons, cons, loads = constrain(self.nodes, s2, self.ien, 'y', 0,
                                            cons)
        loads[2][1] = 1.0e8  #Pa
        loads[2][3] = 1.0e8
        loads[2][5] = 1.0e8
        loads[2][7] = 1.0e8

        deform, i = solver(3, loads, self.nodes, self.ien, ida, ncons, cons)
        ps0 = nsel('y', 'n', 0, 0.01, self.nodes)
        ps1 = nsel('z', 's', 0, 0.01, self.nodes, ps0)
        #c = plotResults(deform, self.nodes, ps1, [1, 0, 0], 'x')

        self.assertEqual(0, 0)
Esempio n. 7
0
    def test_CylinderPlot(self):
        # Here, we generate the mesh
        thetaDomain = pi / 2.0  # quarter circle of the pipe
        self.ri = 1.2  # the inner radius of the pipe
        self.ro = 1.8  # the outer radius of the pipe
        self.nr = 16  # the number of elements in the radial direction
        self.nt = 32  # the number of elements in the circumfrential direction
        self.nodes = []  # stores the nodes in the cylindrical mesh
        self.p = -2.0e6  # the pressure (Pa)
        cc = [2.0e11, 0.3]  # [Young's Modulus, Poisson's Ratio]

        for i in range(self.nr + 1):  # for every node in the r-direction...
            for j in range(self.nt +
                           1):  # for every node in the theta-direction...
                radius = i * (self.ro - self.ri) / self.nr + self.ri
                theta = j * thetaDomain / self.nt
                self.nodes.append(
                    [radius * sin(theta), radius * cos(theta), 0])

        self.ien = get_ien(self.nt, self.nr)
        self.nnums = np.linspace(0, len(self.nodes) - 1, len(self.nodes))

        # now the fun begins. We solve this problem using roller constraints on
        # the straight faces and pressure loads on the inner face.
        s0 = nsel('y', 'n', 0, 0.01, self.nodes)
        s1 = nsel('x', 'n', 0, 0.01, self.nodes)

        ida, ncons, cons0, loads = constrain(self.nodes, s0, self.ien, 'y', 0)
        ida, ncons, cons, loads = constrain(self.nodes, s1, self.ien, 'x', 0,
                                            cons0)
        for i in range(self.nt):  # for every inner element...
            loads[3][i] = self.p

        self.deform, i = solver(2, loads, self.nodes, self.ien, ida, ncons,
                                cons)
        ps0 = nsel('y', 'n', 0, 0.01, self.nodes)
        #c = plotResults(deform, self.nodes, ps0, [1, 0, 0], 'x')
        c = contourPlot(self.deform, self.ien, self.nodes, 'sigma_t', 'z', cc)
Esempio n. 8
0
    def test_OnePart2(self):
        numD = 2  # number of dimensions
        enum = 10  # number of elements in each dof
        nodes = nodeList(1, 1, 1, enum, enum)
        ien = get_ien(enum, enum)
        cc = [1.0e7, 0.3]

        wall = nsel('x', 'n', 0, 0.01, nodes)  # select the wall

        ida, ncons, cons0, loads = constrain(nodes, wall, ien, 'x', 0)
        ida, ncons, cons1, loads = constrain(nodes, wall, ien, 'y', 0.0, cons0)
        for i in range(enum):  # for every element on a side...
            loads[2][enum * (i + 1) - 1] = 1000.0  # traction on the right

        deform, i = solver(numD, loads, nodes, ien, ida, ncons, cons1, cc)

        c = contourPlot(deform, ien, nodes, 'd_abs', 'z', cc)
        c = contourPlot(deform, ien, nodes, 'd_x', 'z', cc)
        c = contourPlot(deform, ien, nodes, 'd_y', 'z', cc)
        c = contourPlot(deform, ien, nodes, 'sigma_x', 'z', cc)
        c = contourPlot(deform, ien, nodes, 'sigma_y', 'z', cc)
        c = contourPlot(deform, ien, nodes, 'tau_xy', 'z', cc)

        self.assertEqual(c, 0)