← Back to team overview

yade-users team mailing list archive

Re: [Question #246936]: using snapshot engine at certain stresses not at iterperiods

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Sina,

the problem is in

 if abs(stress) > self.nextStress:
                        self.nextStress += self.dStress

if it is true for the call of the first method (avgcoord), self.nextStress
+= self.dStress is executed, therefore it is false in other calls.

One solution is to delete this condition from all the methods and define
one overall output method:

class StressChecker:
  ...
  def output(self):
    if abs(stress) > self.nextStress:
      self.nextStress += self.dStress
      snapshoter()
      self.avgcoord()
      self.numitem()

cheers
Jan



2014-04-22 18:41 GMT+02:00 Sina Jafari <question246936@xxxxxxxxxxxxxxxxxxxxx
>:

> Question #246936 on Yade changed:
> https://answers.launchpad.net/yade/+question/246936
>
>     Status: Answered => Open
>
> Sina Jafari is still having a problem:
> Thanks Jan it was helpful, going back to the previous discussion I tried
> to add another method to the class created above but the problem is when I
> try to put the method as command in pyrunner,only the first method
> mentioned in pyrunner is taken into account and the others give no output
> which is weird! why is this happening?
> here is the end of my script concerning the output of simulations:
>
> class StressChecker():  #To check whether we've reached specific stress
> levels
>  dStress=nextStress=20
>  def check(self):
>
> stress=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
>                 if abs(stress) > self.nextStress:
>                         self.nextStress += self.dStress
>                         snapshoter()
>  def avgcoord(self):
>
> stress=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
>                 if abs(stress) > self.nextStress:
>                         self.nextStress += self.dStress
>                         plot.addData(ACN=utils.avgNumInteractions(),
>
> P=stress,e=utils.voxelPorosityTriaxial(triax)/(1-utils.voxelPorosityTriaxial(triax)))
>                         plot.saveDataTxt('results C-MAO')
>
>
>  def numint(self):
>                 f= open('%s.txt'%"interactions of each body",'w')
>
> stress=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
>                 if abs(stress) > self.nextStress:
>                         self.nextStress += self.dStress
>                         i=O.iter
>                         f.write('%s\n'%' ')
>                         f.write('%s\n'%' ')
>                         f.write('%s\n'%' ')
>                         f.write('%s\n'%int(i))
>                         f.write('%s\n'%float(triax.meanStress))
>                         f.write('%s\t'%str('bodyid'))
>                         f.write('%s\t'%str("     "))
>                         f.write('%s\t'%str('Radius'))
>                         f.write('%s\t'%str("     "))
>                         f.write('%s\n'%str('NumInteractions'))
>                         for m in O.bodies:
>                                 intrs=m.intrs()
>                                 nintrs=len(intrs)
>                                 bodyid=m.id
>                                 if isinstance(m.shape,Sphere):
>                                         radii=m.shape.radius
>                                 else:
>                                         radii="NaN"
>                                 f.write('%s\t'%int(bodyid))
>                                 f.write('%s\t'%str("     "))
>                                 f.write('%s\t'%float(radii))
>                                 f.write('%s\t'%str("     "))
>                                 f.write('%s\n'%int(nintrs))
>                 f.close()
> checker=StressChecker()
> # include a periodic engine calling that function in the simulation loop
>
> O.engines=O.engines[0:5]+[PyRunner(iterPeriod=25000,command='cntctforce()')]+[PyRunner(iterPeriod=50000,command='Sintrhisto()')]+[PyRunner(iterPeriod=50000,command='Intrhisto()')]+[PyRunner(iterPeriod=50,command='checker.avgcoord()')]+[PyRunner(iterPeriod=50,command='checker.check()')]+[PyRunner(iterPeriod=50,command='checker.numint()')]+O.engines[5:13]
>
> and here is my O.engines container:
>
> O.engines=[
>         ForceResetter(),
>         InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
>         InteractionLoop(
>                 [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
>                 [Ip2_FrictMat_FrictMat_MindlinPhys()],
>                 [Law2_ScGeom_MindlinPhys_Mindlin()]
>         ),
>
> GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=10,timestepSafetyCoefficient=0.8),
>         triax,
>         TriaxialStateRecorder(iterPeriod=100,file='WallStresses.dat'),
>         newton,
>         qt.SnapshotEngine(fileBase='Force
> Network-',counter=1,iterPeriod=0,label='snapshoter'),
>
> ]
>
> for example in the script above, only checker.avgcoord() works and the
> other two methods give no out put. what is wrong here? Thank you so much
> for your cooperation.
>
> --
> 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     : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp
>

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.