Force sensor

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Force sensor

Clément
Hey it's me again :)

I'm trying to create a force sensor but of nearly all particles, or of every particle in contact with a body.
However, I can't access to each particle force, and write it in a file.
I don't know how to get the id of a particle based on its position (for example in contact with a body), and how to set a sensor for every element that share this property.

Here is one of the code I tried :
Best Regards CD

import pygranoo as granoo

class InitSensor(granoo.plugin):

    def __init__(self):
        granoo.plugin.__init__(self, "InitSensor")
        self.Global = granoo.discrete_element_set.glob()
        self.d = {}
       

    def run(self):
        granoo.sensor.add(granoo.time.get().get_it, "Iteration")
        for k in range(10):
            granoo.sensor.add(self.Global.get(k).force(), 'e'.format(k))
       
#        granoo.sensor.add(self.Global.force, "ForceGlobale")
Reply | Threaded
Open this post in threaded view
|

Re: Force sensor

Damien André
Administrator
Hello, I am not sure to understand what you want to do... ^^

If you want to capture the force exerted on a given a body, you can "ask" to this body the force

You can take a look on the  "Example/Tool/BrazilianTest".
It shows how to capture the force exerted on the loading plate (this is in C++, not in Python).

Kind regards, Damien.
Reply | Threaded
Open this post in threaded view
|

Re: Force sensor

Clément
I want to know the pressure under a body and see a graph of the pressure applied under the body(Pression-Distance To the edge of a body).
To do that I wanted to know all the time the force applied to particle close to the body. Or at least know the force applied to every particle in the Global Set all the time.
And yes, the other problem is that I'm coding in python sry :)

Best Regards, CD
Reply | Threaded
Open this post in threaded view
|

Re: Force sensor

Damien André
Administrator
Hello, you must identify the bodies into a SetOf.

After that you can collect the force on them with :
my_set = granoo.discrete_element_set.get("The ID of your SetOf")
granoo.sensor.add(my_set.force, "Your label Name in the sensors file")

Please take a look in PlugIn_InitSensor.py file in the 2.0/Example/Continuous/TensileTest/ directory

Kind regards, Damien.
Reply | Threaded
Open this post in threaded view
|

Re: Force sensor

Clément
Hey,
I collect only the force applied on the whole set, is it possible to get the force on each and every particle at all times?
And yes I already had a look to all the file in Example :)

Best Regards CD
Reply | Threaded
Open this post in threaded view
|

Re: Force sensor

Damien André
Administrator
This post was updated on .
Hello,

please find below a short python code snippet that :
- read a series of gdd files
- extract forces and position for each discrete elements

import pygranoo as gr
import glob

dom = gr.domain.get()

files = glob.glob('*.gdd') # read all gdd files in the current dir
for f in files:
    print('reading {}...'.format(f))
    dom.clear()
    dom.load(f)
    print('')
    el_set = gr.element_set.get('Global')
    for i, el in enumerate(el_set):
        force = el.force
        pos   = el.pos
        print('Parsing the {}th element...'.format(i))
        print(' - pos   = ({},{},{}) m'.format(pos.x  , pos.y  , pos.z  ))
        print(' - force = ({},{},{}) N'.format(force.x, force.y, force.z))

Hope this help, good luck, Damien.