What's the most efficient way to get the average stress at each cycle?

Asked by behzad

Hi,

I have a simulation in which a sinusoidal strain is applied to a cylindrical sample of spheres by a box. I'd like to get the imposed stress history which is supposed to be a sinusoidal curve with a time lag.
The history of stress on the box with bodyStressTensors()[box_1][2][2] has some noise.
I decided to get the average stress of the spheres in the sample in z direction as the imposed stress.

This can be done via calling the following function at certain cycles by Pyrunner:

def get2():
 stress=0.0
 sums=0.0
 global a
 num=len(a)
 for i in a:
  sums+=bodyStressTensors()[i][2][2]
 stress=sums/num
 return stress

However, this is not efficient at all (as you can tell, with such a loop in the function).
So, what's the most efficient way to get the stress in z direction from spherical bodies of a model with iterPeriod of e.g.100.

Shall I use VTKRecorder?

I wonder if others are using VTKRecorder, that much or not? But, I'm not used to it yet. I appreciate if you can share your ideas or experience in dealing with such a case.

Regards,
Behzad

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#1

Hi

This:
"for i in a: sums+=bodyStressTensors()[i][2][2]"

is computing the stress for all bodies for all bodies (yes: nested "for all").

This would make more sense:
stress=bodyStressTensors()
for i in a: sums+=stress[i][2][2]

However, I don't see how this is supposed to solve your noise problem.
I would simply record the total force on the box (not bodyStress of the box, it is probably a junk value).
If it is also noisy then you will have to understand why.

Bruno

Revision history for this message
Jan Stránský (honzik) said :
#2

Hi Behzad,

bodyStressTensors() computes stress tensors for each body, so to make it
more efficient, just do not call it for each body again :-)

def get2():
        stress=0.0
        sums=0.0
        global a
        num=len(a)
        stressTensors = bodyStressTensors()
        for i in a:
                sums+=stressTensors[i][2][2]
        stress=sums/num
        return stress

cheers
Jan

2015-04-20 17:41 GMT+02:00 behzad <email address hidden>:

> New question #265521 on Yade:
> https://answers.launchpad.net/yade/+question/265521
>
> Hi,
>
> I have a simulation in which a sinusoidal strain is applied to a
> cylindrical sample of spheres by a box. I'd like to get the imposed stress
> history which is supposed to be a sinusoidal curve with a time lag.
> The history of stress on the box with bodyStressTensors()[box_1][2][2] has
> some noise.
> I decided to get the average stress of the spheres in the sample in z
> direction as the imposed stress.
>
> This can be done via calling the following function at certain cycles by
> Pyrunner:
>
> def get2():
> stress=0.0
> sums=0.0
> global a
> num=len(a)
> for i in a:
> sums+=bodyStressTensors()[i][2][2]
> stress=sums/num
> return stress
>
> However, this is not efficient at all (as you can tell, with such a loop
> in the function).
> So, what's the most efficient way to get the stress in z direction from
> spherical bodies of a model with iterPeriod of e.g.100.
>
> Shall I use VTKRecorder?
>
> I wonder if others are using VTKRecorder, that much or not? But, I'm not
> used to it yet. I appreciate if you can share your ideas or experience in
> dealing with such a case.
>
> Regards,
> Behzad
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
behzad (behzad-majidi) said :
#3

Hi,

So, both comments are almost the same. alright, I 'll avoid calling bodyStressTensors() for each single body.

@Bruno: I'm getting the average stress of all spheres in the sample by this function, hoping it can solve the noise problem.

I'll give a try to the force on the box to see how it looks like.

is O.forces.f(box_1)[2] a right way to do that or getting the force from individual contacts of O.bodies[box_1].intrs() is more precise?
Theoretically, there should not be a difference!

Thanks.

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#4

You are right, there should be no difference and there will be no difference.

Can you help with this problem?

Provide an answer of your own, or ask behzad for more information if necessary.

To post a message you must log in.