← Back to team overview

yade-users team mailing list archive

Re: [Question #703734]: Get force on Facet

 

Question #703734 on Yade changed:
https://answers.launchpad.net/yade/+question/703734

    Status: Answered => Open

GINNA TORRES is still having a problem:
Thanku Karol,

1. When I place O.force.f(Barrera1.id) I get an error:

AttributeError                            Traceback (most recent call last)
/usr/bin/yade in <module>

/usr/bin/yade in addPlotData()
    234             # each item is given a names, by which it can be the unsed in plot.plots
    235             # the **O.energy converts dictionary-like O.energy to plot.addData arguments
--> 236         Fz= sum(O.forces.f(Barrera1.id))
    237         plot.addData(Fz=Fz,i=O.iter, unbalanced=unbalancedForce(), **O.energy)
    238 

AttributeError: 'int' object has no attribute 'id'

2. When leaving only the code without id, it works, however I am trying
to graph this force and it does not work.

My code:

#BARRERA MÒVIL
Barrera1 = O.bodies.append(facet([(412,706,-100),(412,706,200),(412,635,0)],material='pFacetMat',color=[255,0,0]))
[10:41 a. m., 6/11/2022] G: #Definición de los motores de calculo
  
O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
    InteractionLoop(
        # handle sphere+sphere and facet+sphere collisions
        [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
        [Ip2_FrictMat_FrictMat_FrictPhys()],
        [Law2_ScGeom_FrictPhys_CundallStrack()]
    ),
    NewtonIntegrator(gravity=(0,-9.81,0),damping=0.4),
[10:41 a. m., 6/11/2022] G: # call the checkUnbalanced function (defined below) every 2 seconds
    PyRunner(command='checkUnbalanced()',realPeriod=2), 
    # call the addPlotData function every 200 steps
    PyRunner(command='addPlotData()', iterPeriod=100)

]


 # set timestep to a fraction of the critical timestep
# the fraction is very small, so that the simulation is not too fast
# and the motion can be observed
O.dt = .9e-1 * PWaveTimeStep()

O.trackEnergy = True

# if the unbalanced forces goes below .1, the packing
# is considered stabilized, therefore we stop collected
# data history and stop
def checkUnbalanced():
    if O.iter < 5000 :
        return

    #cuando las fuerzas se desbalanceen
    if unbalancedForce() < 0.1:
        O.bodies.erase(Barrera1)
        O.bodies.erase(Barrera2)
        O.bodies.erase(Barrera3)
        O.bodies.erase(Barrera4)
        O.pause()
        plot.saveDataTxt('tesis')
        plot.saveDataTxt('Fuerzab', vars= ('i','Fz'))

def addPlotData():
	    # each item is given a names, by which it can be the unsed in plot.plots
	    # the **O.energy converts dictionary-like O.energy to plot.addData arguments
        Fz= sum(O.forces.f(Barrera1.id))
        plot.addData(Fz=Fz,i=O.iter, unbalanced=unbalancedForce(), **O.energy)


plot.plots = {'i': ('unbalanced', None, O.energy.keys), 'w': ('Fz',)}
plot.plot()

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.