コード例 #1
0
 def showAnimatedDeformation():
     """Show animated deformation"""
     nframes = 10
     res = askItems([
         _I('scale',optimscale),
         _I('nframes',nframes),
         _I('form','revert',choices=['up','updown','revert']),
         _I('duration',5./nframes),
         _I('ncycles',2),
         ],caption='Animation Parameters')
     if res:
         scale = res['scale']
         nframes = res['nframes']
         form = res['form']
         duration = res['duration']
         ncycles = res['ncycles']
         amp = scale * frameScale(nframes,form)
         animate_deformed_plot(amp,duration,ncycles)
コード例 #2
0
    def showAnimatedDeformation():

        # Show animated deformation
        scale = optimscale
        nframes = 10
        form = "revert"
        duration = 5.0 / nframes
        ncycles = 2
        items = [["scale", scale], ["nframes", nframes], ["form", form], ["duration", duration], ["ncycles", ncycles]]
        res = askItems(items, "Animation Parameters")
        if res:
            scale = float(res["scale"])
            nframes = int(res["nframes"])
            duration = float(res["duration"])
            ncycles = int(res["ncycles"])
            form = res["form"]
            if form in ["up", "updown", "revert"]:
                amp = scale * frameScale(nframes, form)
                animate_deformed_plot(amp, duration, ncycles)
コード例 #3
0
    def showAnimatedDeformation():

        # Show animated deformation
        scale = optimscale
        nframes = 10
        form = 'revert'
        duration = 5./nframes
        ncycles = 2
        items = [ ['scale',scale], ['nframes',nframes],
                  ['form',form],
                  ['duration',duration], ['ncycles',ncycles] ]
        res = askItems(items,'Animation Parameters')
        if res:
            scale = float(res['scale'])
            nframes = int(res['nframes'])
            duration = float(res['duration'])
            ncycles = int(res['ncycles'])
            form = res['form']
            if form in [ 'up', 'updown', 'revert' ]:
                amp = scale * frameScale(nframes,form)
                animate_deformed_plot(amp,duration,ncycles)
コード例 #4
0
def postCalpy():
    """Show results from the Calpy analysis."""
    from plugins.postproc import niceNumber,frameScale
    from plugins.postproc_menu import showResults
    try:
        FE = named('fe_model')
        displ,frc = named('calpy_results')
    except:
        warning("I could not find the finite element model and/or the calpy results. Maybe you should try to first create them?")
        raise
        return
    
    # The frc array returns element forces and has shape
    #  (nelems,nforcevalues,nloadcases)
    # nforcevalues = 8 (Nx,Vy,Vz,Mx,My1,Mz1,My2,Mz2)
    # Describe the nforcevalues element results in frc.
    # For each result we give a short and a long description:
    frc_contents = [('Nx','Normal force'),
                    ('Vy','Shear force in local y-direction'),
                    ('Vz','Shear force in local z-direction'),
                    ('Mx','Torsional moment'),
                    ('My','Bending moment around local y-axis'),
                    ('Mz','Bending moment around local z-axis'),
                    ('None','No results'),
                    ]
    # split in two lists
    frc_keys = [ c[0] for c in frc_contents ]
    frc_desc = [ c[1] for c in frc_contents ]

    # Ask the user which results he wants
    res = askItems([('Type of result',None,'select',frc_desc),
                    ('Load case',0),
                    ('Autocalculate deformation scale',True),
                    ('Deformation scale',100.),
                    ('Show undeformed configuration',False),
                    ('Animate results',False),
                    ('Amplitude shape','linear','select',['linear','sine']),
                    ('Animation cycle','updown','select',['up','updown','revert']),
                    ('Number of cycles',5),
                    ('Number of frames',10),
                    ('Animation sleeptime',0.1),
                    ])
    if res:
        frcindex = frc_desc.index(res['Type of result'])
        loadcase = res['Load case']
        autoscale = res['Autocalculate deformation scale']
        dscale = res['Deformation scale']
        showref = res['Show undeformed configuration']
        animate = res['Animate results']
        shape = res['Amplitude shape']
        cycle = res['Animation cycle']
        count = res['Number of cycles']
        nframes = res['Number of frames']
        sleeptime = res['Animation sleeptime']

        dis = displ[:,0:3,loadcase]
        if autoscale:
            siz0 = Coords(FE.nodes).sizes()
            siz1 = Coords(dis).sizes()
            print siz0
            print siz1
            dscale = niceNumber(1./(siz1/siz0).max())

        if animate:
            dscale = dscale * frameScale(nframes,cycle=cycle,shape=shape) 
        
        # Get the scalar element result values from the frc array.
        val = val1 = txt = None
        if frcindex <= 5:
            val = frc[:,frcindex,loadcase]
            txt = frc_desc[frcindex]
            if frcindex > 3:
                # bending moment values at second node
                val1 = frc[:,frcindex+2,loadcase]

        showResults(FE.nodes,FE.elems,dis,txt,val,showref,dscale,count,sleeptime)
コード例 #5
0
                sleep(sleeptime)


    # Show a deformed plot
    linewidth(2)
    #print optimscale
    deformed_plot(optimscale)
    view('__last__',True)

    # Show animated deformation
    scale = optimscale
    nframes = 10
    form = 'revert'
    duration = 5./nframes
    ncycles = 2
    while ack('Show an animated deformation plot?'):
        items = [ ['scale',scale], ['nframes',nframes],
                  ['form',form],
                  ['duration',duration], ['ncycles',ncycles] ]
        res = askItems(items,'Animation Parameters')
        scale = float(res['scale'])
        nframes = int(res['nframes'])
        duration = float(res['duration'])
        ncycles = int(res['ncycles'])
        form = res['form']
        if form in [ 'up', 'updown', 'revert' ]:
            amp = scale * frameScale(nframes,form)
            animate_deformed_plot(amp,duration,ncycles)
            
# End
コード例 #6
0
ファイル: Hesperia.py プロジェクト: gunnups/pyFormex
def postCalpy():
    """Show results from the Calpy analysis."""
    from plugins.postproc import niceNumber, frameScale
    from plugins.postproc_menu import showResults
    try:
        FE = named('fe_model')
        displ, frc = named('calpy_results')
    except:
        warning(
            "I could not find the finite element model and/or the calpy results. Maybe you should try to first create them?"
        )
        raise
        return

    # The frc array returns element forces and has shape
    #  (nelems,nforcevalues,nloadcases)
    # nforcevalues = 8 (Nx,Vy,Vz,Mx,My1,Mz1,My2,Mz2)
    # Describe the nforcevalues element results in frc.
    # For each result we give a short and a long description:
    frc_contents = [
        ('Nx', 'Normal force'),
        ('Vy', 'Shear force in local y-direction'),
        ('Vz', 'Shear force in local z-direction'),
        ('Mx', 'Torsional moment'),
        ('My', 'Bending moment around local y-axis'),
        ('Mz', 'Bending moment around local z-axis'),
        ('None', 'No results'),
    ]
    # split in two lists
    frc_keys = [c[0] for c in frc_contents]
    frc_desc = [c[1] for c in frc_contents]

    # Ask the user which results he wants
    res = askItems([
        ('Type of result', None, 'select', frc_desc),
        ('Load case', 0),
        ('Autocalculate deformation scale', True),
        ('Deformation scale', 100.),
        ('Show undeformed configuration', False),
        ('Animate results', False),
        ('Amplitude shape', 'linear', 'select', ['linear', 'sine']),
        ('Animation cycle', 'updown', 'select', ['up', 'updown', 'revert']),
        ('Number of cycles', 5),
        ('Number of frames', 10),
        ('Animation sleeptime', 0.1),
    ])
    if res:
        frcindex = frc_desc.index(res['Type of result'])
        loadcase = res['Load case']
        autoscale = res['Autocalculate deformation scale']
        dscale = res['Deformation scale']
        showref = res['Show undeformed configuration']
        animate = res['Animate results']
        shape = res['Amplitude shape']
        cycle = res['Animation cycle']
        count = res['Number of cycles']
        nframes = res['Number of frames']
        sleeptime = res['Animation sleeptime']

        dis = displ[:, 0:3, loadcase]
        if autoscale:
            siz0 = Coords(FE.nodes).sizes()
            siz1 = Coords(dis).sizes()
            print(siz0)
            print(siz1)
            dscale = niceNumber(1. / (siz1 / siz0).max())

        if animate:
            dscale = dscale * frameScale(nframes, cycle=cycle, shape=shape)

        # Get the scalar element result values from the frc array.
        val = val1 = txt = None
        if frcindex <= 5:
            val = frc[:, frcindex, loadcase]
            txt = frc_desc[frcindex]
            if frcindex > 3:
                # bending moment values at second node
                val1 = frc[:, frcindex + 2, loadcase]

        showResults(FE.nodes, FE.elems, dis, txt, val, showref, dscale, count,
                    sleeptime)