Beispiel #1
0
def simply_released_beam_test():
    #FEModel Test
    model=FEModel()

    E=1.999e11
    mu=0.3
    A=4.265e-3
    J=9.651e-8
    I3=6.572e-5
    I2=3.301e-6
    rho=7849.0474
    
    model.add_node(0,0,0)
    model.add_node(0.5,1,0.5)
    model.add_node(1,2,1)
    
    model.add_beam(0,1,E,mu,A,I2,I3,J,rho)
    model.add_beam(1,2,E,mu,A,I2,I3,J,rho)

    model.set_node_force(1,(0,0,-1e6,0,0,0))
    model.set_node_restraint(2,[True]*6)
    model.set_node_restraint(0,[True]*6)
    
    model.set_beam_releases(0,[True]*6,[False]*6)
    model.set_beam_releases(1,[False]*6,[True]*6)
    
    model.assemble_KM()
    model.assemble_f()
    model.assemble_boundary()
    solve_linear(model)
    print(np.round(model.d_,6))
    print("The result of node 1 should be about [0.00445,0.00890,-0.02296,-0.01930,-0.03860,-0.01930]")
Beispiel #2
0
def shear_test4():
    model=FEModel()
    n1=Node(0,0,0)
    n2=Node(0,0,5)
    n3=Node(5,0,5)
    n4=Node(10,0,5)
    n5=Node(10,0,0)
    n6=Node(5,0,0)
    
    a1=Membrane4(n1,n2,n3,n6,0.25,2e11,0.3,7849)
    a2=Membrane4(n3,n4,n5,n6,0.25,2e11,0.3,7849)
    
    model.add_node(n1)
    model.add_node(n2)
    model.add_node(n3)
    model.add_node(n4)
    model.add_node(n5)
    model.add_node(n6)

    model.add_membrane4(a1)
    model.add_membrane4(a2)

    n3.fn=(0,0,-100000,0,0,0)
    n1.dn=n2.dn=n4.dn=n5.dn=[0]*6
    n3.dn=n6.dn=[0,0,None,0,0,0]
    
    model.assemble_KM()
    model.assemble_f()
    model.assemble_boundary()
    res=solve_linear(model)

    np.set_printoptions(precision=6,suppress=True)
    print(res)
    print(r"correct answer should be ???")
Beispiel #3
0
def planar_frame_test():
    #FEModel Test
    model=FEModel()
    n1=Node(0,0,0)
    n2=Node(0,0,5)
    n3=Node(5,0,5)
    n4=Node(10,0,5)
    n5=Node(10,0,0)
    b1=Beam(n1,n2,2e11,0.3,0.013,2.675e-5,3.435e-4,1.321e-6,7849)
    b2=Beam(n2,n3,2e11,0.3,0.013,2.675e-5,3.435e-4,1.321e-6,7849)
    b3=Beam(n3,n4,2e11,0.3,0.013,2.675e-5,3.435e-4,1.321e-6,7849)
    b4=Beam(n4,n5,2e11,0.3,0.013,2.675e-5,3.435e-4,1.321e-6,7849)
    
    model.add_node(n1)
    model.add_node(n2)
    model.add_node(n3)
    model.add_node(n4)
    model.add_node(n5)

    model.add_beam(b1)
    model.add_beam(b2)
    model.add_beam(b3)
    model.add_beam(b4)

    n2.fn=(100000,0,0,0,0,0)
    n3.fn=(0,0,-100000,0,0,0)
    n1.dn=[0,0,0,0,0,0]
    n5.dn=[0,0,0,0,0,0]

    model.assemble_KM()
    model.assemble_f()
    model.assemble_boundary()
    res=solve_linear(model)
    
    print(res)
Beispiel #4
0
def cantilever_beam_test():
    #FEModel Test
    model=FEModel()
    model.add_node(0,0,0)
    model.add_node(2,1,1)
    E=1.999e11
    mu=0.3
    A=4.265e-3
    J=9.651e-8
    I3=6.572e-5
    I2=3.301e-6
    rho=7849.0474
    
    model.add_beam(0,1,E,mu,A,I2,I3,J,rho)
    model.set_node_force(1,(0,0,-1e6,0,0,0))
    model.set_node_restraint(0,[True]*6)
    model.assemble_KM()
    model.assemble_f()
    model.assemble_boundary()
    solve_linear(model)
    print(np.round(model.d_,6))
    print("The result of node 1 should be about [0.12879,0.06440,-0.32485,-0.09320,0.18639,0]")
Beispiel #5
0
def pseudo_cantilever_test(l=25,h=5):
    """
    This is a cantilever beam with 50x10
    l,h: division on l and h direction
    """
    model=FEModel()
    nodes=[]
    for i in range(h+1):
        for j in range(l+1):
            nodes.append(Node(j*50/l,0,i*10/h))
            model.add_node(nodes[-1])
            
    for i in range(h):
        for j in range(l):
            area1=Membrane3(nodes[i*(l+1)+j],
                           nodes[i*(l+1)+j+1],
                           nodes[(i+1)*(l+1)+j+1],
                           0.25,2e11,0.3,7849)
            area2=Membrane3(nodes[i*(l+1)+j],
                           nodes[(i+1)*(l+1)+j+1],
                           nodes[(i+1)*(l+1)+j],
                           0.25,2e11,0.3,7849)
            if j==0:
                nodes[i*(l+1)+j].dn=[0]*6
                nodes[(i+1)*(l+1)+j].dn=[0]*6

            model.add_membrane3(area1)
            model.add_membrane3(area2)

    nodes[(l+1)*(h+1)-1].fn=(0,0,-100000,0,0,0)
    
    model.assemble_KM()
    model.assemble_f()
    model.assemble_boundary()
    res=solve_linear(model)

    np.set_printoptions(precision=6,suppress=True)
    print(res[(l+1)*(h+1)*6-6:])
    print(r"correct answer should be ???")
Beispiel #6
0
    def run(self, lcs):
        """
        Run the model with loadcases
        params:
            lcs: list of str, specify load cases to run.
        return:
            None.
        """
        if not self.fe_model.is_assembled:
            logger.info('Mesh model...')
            self.mesh()
            self.fe_model.assemble_KM()
            self.fe_model.assemble_boundary(mode='KM')
        try:
            for lc in lcs:
                loadcase = self.session.query(LoadCase).filter_by(
                    name=lc).first()
                if loadcase is None:
                    raise Exception("Loadcase doen't exist!")
                if loadcase.case_type == 'static-linear':
                    logger.info('Solving static linear case %s...' % lc)
                    self.apply_load(lc)
                    self.fe_model.assemble_f()
                    self.fe_model.assemble_boundary(mode='f')
                    solve_linear(self.fe_model)
                    #write disp
                    for pt in self.session.query(Point).all():
                        hid = self.pn_map[pt.name]
                        rst = ResultPointDisplacement()
                        rst.point_name = pt.name
                        rst.loadcase_name = lc
                        disp = self.fe_model.resolve_node_disp(hid)
                        (rst.u1, rst.u2, rst.u3, rst.r1, rst.r2,
                         rst.r3) = tuple(disp)
                        self.session.add(rst)
                    #write reaction
                    for res in self.session.query(PointRestraint).all():
                        hid = self.pn_map[res.point_name]
                        rst = ResultPointReaction()
                        rst.point_name = res.point_name
                        rst.loadcase_name = lc
                        reac = self.fe_model.resolve_node_reaction(hid)
                        (rst.p1, rst.p2, rst.p3, rst.m1, rst.m2,
                         rst.m3) = tuple(reac)
                        self.session.add(rst)
                    #write beam force
                    for frm in self.session.query(Frame).all():
                        hids = self.fb_map[frm.name]
                        for i in range(len(hids)):
                            hid = hids[i]
                            rst = ResultFrameForce()
                            rst.frame_name = frm.name
                            rst.loadcase_name = lc
                            rst.segment = i
                            f = self.fe_model.resolve_beam_force(hid)
                            (rst.p01, rst.p02, rst.p03, rst.m01, rst.m02,
                             rst.m03) = tuple(f[:6])
                            (rst.p11, rst.p12, rst.p13, rst.m11, rst.m12,
                             rst.m13) = tuple(f[6:])
                            self.session.add(rst)
                    self.session.commit()
                    logger.info('Finished case %s.' % lc)
                elif loadcase.case_type == 'modal':
                    logger.info('Solving modal case %s...' % lc)
                    solve_modal(self.fe_model,
                                k=loadcase.loadcase_modal_setting.modal_num)
                    #write period
                    _order = 1
                    for omega in self.fe_model.omega_:
                        rst = ResultModalPeriod()
                        rst.order = _order
                        rst.loadcase_name = lc
                        rst.omega = omega
                        rst.period = 2 * 3.1415926535897932384626 / omega
                        rst.frequency = 1 / (2 * 3.1415926535897932384626 /
                                             omega)
                        self.session.add(rst)
                        _order += 1

                    #write disp
                    for pt in self.session.query(Point).all():
                        for od in range(1, _order):
                            hid = self.pn_map[pt.name]
                            rst = ResultModalDisplacement()
                            rst.point_name = pt.name
                            rst.loadcase_name = lc
                            rst.order = od
                            disp = self.fe_model.resolve_modal_displacement(
                                hid, od)
                            (rst.u1, rst.u2, rst.u3, rst.r1, rst.r2,
                             rst.r3) = tuple(disp)
                            self.session.add(rst)

                    self.session.commit()
                    logger.info('Finished case %s.' % lc)
                else:
                    pass
        except Exception as e:
            logger.info(str(e))
            self.session.rollback()
            self.session.close()