예제 #1
0
파일: parser.py 프로젝트: Kleissl/feapy
        def applyBoundary(selection, start, stop=None, value=None):
            if isInt(selection):
                selection = (int(selection), )
            else:
                selection = self.nset[selection.upper()]

            start = self.parse_int(start, minimum=1, maximum=6)

            if stop is None:
                stop = start + 1
            else:
                stop = self.parse_int(stop, minimum=1, maximum=6) + 1

            if value is None:
                if self.step != 0:
                    raise FEError('Homogeneous conditions inside *STEP')
                value = 0.
            else:
                value = self.parse_float(value)

            for nid in selection:
                node = nodes[nid]

                if node.boundCon is None:
                    node.boundCon = BoundCon()

                for dof in range(start, stop):
                    node.boundCon[dof - 1] = 0.
예제 #2
0
 def test_boundcon_dof(self):
     fixed = BoundCon(Dx=0.,Dy=0.,Dz=0.,Rx=0.,Ry=0.,Rz=0.)
     self.assertTrue(fixed[Dx] == 0.)
     self.assertTrue(fixed[Dz] == 0.)
     self.assertTrue(fixed[Dy] == 0.)
     self.assertTrue(fixed[Rx] == 0.)
     self.assertTrue(fixed[Ry] == 0.)
     self.assertTrue(fixed[Rz] == 0.)
     
     active = fixed.activeDofSet()
     self.assertTrue(active.count() == 0)
     
     del fixed[Dz]
     active = fixed.activeDofSet()
     self.assertTrue(active.count() == 1)
     
     fixed[Dz] = 0.
     active = fixed.activeDofSet()
     self.assertTrue(active.count() == 0)
     
     fixed[Dz] = 0.01
     active = fixed.activeDofSet()
     self.assertTrue(active.count() == 1)
     
     pinned = BoundCon(Dx=0.,Dy=0.,Dz=0.)
     self.assertTrue(pinned[Dx] == 0.)
     self.assertTrue(pinned[Dz] == 0.)
     self.assertTrue(pinned[Dy] == 0.)
     
     active = pinned.activeDofSet()
     self.assertTrue(active.count() == 3)
     
     del pinned[Dz]
     active = pinned.activeDofSet()
     self.assertTrue(active.count() == 4)
     
     pinned[Dz] = 0.
     active = pinned.activeDofSet()
     self.assertTrue(active.count() == 3)
     
     pinned[Dz] = 0.01
     active = pinned.activeDofSet()
     self.assertTrue(active.count() == 4)
예제 #3
0
 def test_boundcon_loads(self):
     load = BoundCon(Dx=0.01, Fz = 1000.)
     self.assertTrue(load[Dx] == 0.01)
     self.assertTrue(load[Fz] == 1000.)
     
     active = load.activeLoads([None,]*12)
     self.almostEqual(active,(0.01,0.,0.,
                               0.,0.,0.,
                               0.,0.,1000.,
                               0.,0.,0.))
     del load[Dx]
     active = load.activeLoads([None,]*12)
     self.almostEqual(active,(0.,0.,0.,
                               0.,0.,0.,
                               0.,0.,1000.,
                               0.,0.,0.))
     load[Dx] = 0.001
     active = load.activeLoads([None,]*12)
     self.almostEqual(active,(0.001,0.,0.,
                               0.,0.,0.,
                               0.,0.,1000.,
                               0.,0.,0.))
예제 #4
0
파일: test_base.py 프로젝트: Kleissl/feapy
    def test_boundcon_loads(self):
        load = BoundCon(Dx=0.01, Fz=1000.)
        self.assertTrue(load[Dx] == 0.01)
        self.assertTrue(load[Fz] == 1000.)

        active = load.activeLoads([
            None,
        ] * 12)
        self.almostEqual(active,
                         (0.01, 0., 0., 0., 0., 0., 0., 0., 1000., 0., 0., 0.))
        del load[Dx]
        active = load.activeLoads([
            None,
        ] * 12)
        self.almostEqual(active,
                         (0., 0., 0., 0., 0., 0., 0., 0., 1000., 0., 0., 0.))
        load[Dx] = 0.001
        active = load.activeLoads([
            None,
        ] * 12)
        self.almostEqual(
            active, (0.001, 0., 0., 0., 0., 0., 0., 0., 1000., 0., 0., 0.))
예제 #5
0
파일: parser.py 프로젝트: Kleissl/feapy
    def handleCLOAD(self, fh, line):
        for part in line.parts:
            part = part.upper()
            if part.startswith("OP="):
                _, op = part.split("=")
                # remove all previous defined boundaries
                if op == 'NEW':
                    if self.step == 1:
                        nodes = self.nodemap.itervalues()
                    else:
                        nodes = self.nodes

                    for node in nodes:
                        if not node.boundCon is None:
                            node.boundCon.deleteLoads()
            else:
                raise ParserError(line, '*CLOAD definition malformed!')

        # fetch next line
        line = self.nextline(fh)
        if line.keyword or line is EmptyLine:
            raise ParserError(line, 'Expected *CLOAD definitions!')

        while not line.keyword and not line is EmptyLine:
            if len(line.parts) != 3:
                raise ParserError(line, '*CLOAD definition malformed!')

            selection, dof, value = line.parts

            if isInt(selection):
                selection = (int(selection), )
            else:
                selection = self.nset[selection.upper()]

            dof = self.parse_int(dof, minimum=1, maximum=6)
            value = self.parse_float(value)

            for nid in selection:
                node = self.nodemap[nid]

                if node.boundCon is None:
                    node.boundCon = BoundCon()

                node.boundCon[dof + 5] = value

            line = self.nextline(fh)

        return line
예제 #6
0
파일: test_base.py 프로젝트: Kleissl/feapy
    def test_boundcon_dof(self):
        fixed = BoundCon(Dx=0., Dy=0., Dz=0., Rx=0., Ry=0., Rz=0.)
        self.assertTrue(fixed[Dx] == 0.)
        self.assertTrue(fixed[Dz] == 0.)
        self.assertTrue(fixed[Dy] == 0.)
        self.assertTrue(fixed[Rx] == 0.)
        self.assertTrue(fixed[Ry] == 0.)
        self.assertTrue(fixed[Rz] == 0.)

        active = fixed.activeDofSet()
        self.assertTrue(active.count() == 0)

        del fixed[Dz]
        active = fixed.activeDofSet()
        self.assertTrue(active.count() == 1)

        fixed[Dz] = 0.
        active = fixed.activeDofSet()
        self.assertTrue(active.count() == 0)

        fixed[Dz] = 0.01
        active = fixed.activeDofSet()
        self.assertTrue(active.count() == 1)

        pinned = BoundCon(Dx=0., Dy=0., Dz=0.)
        self.assertTrue(pinned[Dx] == 0.)
        self.assertTrue(pinned[Dz] == 0.)
        self.assertTrue(pinned[Dy] == 0.)

        active = pinned.activeDofSet()
        self.assertTrue(active.count() == 3)

        del pinned[Dz]
        active = pinned.activeDofSet()
        self.assertTrue(active.count() == 4)

        pinned[Dz] = 0.
        active = pinned.activeDofSet()
        self.assertTrue(active.count() == 3)

        pinned[Dz] = 0.01
        active = pinned.activeDofSet()
        self.assertTrue(active.count() == 4)
예제 #7
0
                # correct last step if needed
                if (i + 1) * _dx > L:
                    _dx = L - i * _dx

        return res


if __name__ == '__main__':
    import math
    from base import FE, Node, Transform, BoundCon, LineLoad, localX
    from postprocess import PostProcess

    class BeamFE(FE, PostProcess):
        pass

    fixed = BoundCon(Dx=0., Dy=0., Dz=0., Rx=0., Ry=0., Rz=0.)
    pinned = BoundCon(Dx=0., Dy=0., Dz=0.)
    free = BoundCon()

    prof = Properties(Area=10., Ixx=100., Iyy=200., Izz=300.)
    mat = Material(E=30E6, G=12E6, nu=0.4, Density=7850.)

    n1 = Node(0., 0., 0., boundCon=fixed)
    n4 = Node(0., 0., 100., boundCon=free)
    n3 = Node(100., 0., 100., boundCon=free)
    n2 = Node(100., 0., 0., boundCon=fixed)

    b1 = Beam(n1, n4, mat, prof)
    b2 = Beam(n2, n3, mat, prof)
    b3 = Beam(n3, n2, mat, prof)