yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #08566
Re: [Question #239133]: IndexError
Question #239133 on Yade changed:
https://answers.launchpad.net/yade/+question/239133
pingyang.1019@xxxxxxx gave more information on the question:
Hi
this is the modified script, can you help me find where the error has? I want to run only "uniax-compression" and save '/tmp/uniax-compression.yade.gz'
from __future__ import division
from yade import utils,plot,pack,timing,eudoxos
import time, sys, os, copy
#import matplotlib
#matplotlib.rc('text',usetex=True)
#matplotlib.rc('text.latex',preamble=r'\usepackage{concrete}\usepackage{euler}')
# default parameters or from table
utils.readParamsFromTable(noTableOk=True, # unknownOk=True,
young=24e9,
poisson=.2,
sigmaT=3.5e6,
frictionAngle=atan(0.8),
epsCrackOnset=1e-4,
crackOpening=1e-6,
intRadius=1.5,
dtSafety=.8,
damping=0.4,
strainRateTension=.05,
strainRateCompression=.5,
setSpeeds=True,
# 1=tension, 2=compression (ANDed; 3=both)
doModes=2,
specimenLength=.1,
sphereRadius=2e-3,
# isotropic confinement (should be negative)
isoPrestress=0,
# use the ScGeom variant
scGeom=False
)
from yade.params.table import *
if 'description' in O.tags.keys():
O.tags['id']=O.tags['id']+O.tags['description']
# make geom; the dimensions are hard-coded here; could be in param table if desired
# z-oriented hyperboloid, length 20cm, diameter 10cm, skirt 8cm
# using spheres 7mm of diameter
concreteId=O.materials.append(CpmMat(young=young,frictionAngle=frictionAngle,poisson=poisson,density=4800,sigmaT=sigmaT,crackOpening=crackOpening,epsCrackOnset=epsCrackOnset,isoPrestress=isoPrestress))
spheres=pack.randomDensePack(pack.inHyperboloid((0,0,-.5*specimenLength),(0,0,.5*specimenLength),.25*specimenLength,.25*specimenLength),spheresInCell=2800,radius=sphereRadius,memoizeDb='/tmp/triaxPackCache.sqlite',material=concreteId)
#spheres=pack.randomDensePack(pack.inAlignedBox((-.25*specimenLength,-.25*specimenLength,-.5*specimenLength),(.25*specimenLength,.25*specimenLength,.5*specimenLength)),spheresInCell=2000,radius=sphereRadius,memoizeDb='/tmp/triaxPackCache.sqlite')
O.bodies.append(spheres)
bb=utils.uniaxialTestFeatures()
negIds,posIds,axis,crossSectionArea=bb['negIds'],bb['posIds'],bb['axis'],bb['area']
O.dt=dtSafety*utils.PWaveTimeStep()
print 'Timestep',O.dt
mm,mx=[pt[axis] for pt in utils.aabbExtrema()]
coord_25,coord_50,coord_75=mm+.25*(mx-mm),mm+.5*(mx-mm),mm+.75*(mx-mm)
area_25,area_50,area_75=utils.approxSectionArea(coord_25,axis),utils.approxSectionArea(coord_50,axis),utils.approxSectionArea(coord_75,axis)
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=intRadius,label='is2aabb'),],verletDist=.05*sphereRadius),
InteractionLoop(
[Ig2_Sphere_Sphere_Dem3DofGeom(distFactor=intRadius,label='ss2d3dg') if not scGeom else Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=intRadius,label='ss2sc')],
[Ip2_CpmMat_CpmMat_CpmPhys()],
[Law2_Dem3DofGeom_CpmPhys_Cpm(epsSoft=0) if not scGeom else Law2_ScGeom_CpmPhys_Cpm()],
),
NewtonIntegrator(damping=damping,label='damper'),
CpmStateUpdater(realPeriod=1),
UniaxialStrainer(strainRate=strainRateTension,axis=axis,asymmetry=0,posIds=posIds,negIds=negIds,crossSectionArea=crossSectionArea,blockDisplacements=False,blockRotations=False,setSpeeds=setSpeeds,label='strainer'),
PyRunner(virtPeriod=1e-6/strainRateTension,realPeriod=1,command='addPlotData()',label='plotDataCollector',initRun=True),
PyRunner(realPeriod=4,command='stopIfDamaged()',label='damageChecker'),
]
#O.miscParams=[Gl1_CpmPhys(dmgLabel=False,colorStrain=False,epsNLabel=False,epsT=False,epsTAxes=False,normal=False,contactLine=True)]
# plot stresses in ¼, ½ and ¾ if desired as well; too crowded in the graph that includes confinement, though
plot.plots={'eps':('sigma',)} #,'sigma.50')},'t':('eps')} #'sigma.25','sigma.50','sigma.75')}
O.saveTmp('initial');
xmin=-0.025
xmax=0.025
ymin=-0.0015
ymax=0.0015
zmin=-0.025
zmax=0.03
for b in O.bodies:
if ((xmin<b.state.pos[0]<xmax)&(ymin<b.state.pos[1]<ymax)&(zmin<b.state.pos[2]<zmax)):
print 'Inside sphere ID:', b.id, b.state.pos, '\n'
O.bodies.erase(b.id)
O.timingEnabled=False
global mode
mode='tension' if doModes & 1 else 'compression'
def initTest():
global mode
print "init"
if O.iter>0:
O.wait();
O.loadTmp('initial')
print "Reversing plot data"; plot.reverseData()
else: plot.plot(subPlots=False)
strainer.strainRate=abs(strainRateTension) if mode=='tension' else -abs(strainRateCompression)
try:
from yade import qt
renderer=qt.Renderer()
renderer.dispScale=(1000,1000,1000) if mode=='tension' else (100,100,100)
except ImportError: pass
print "init done, will now run."
O.step(); # to create initial contacts
# now reset the interaction radius and go ahead
if not scGeom: ss2d3dg.distFactor=-1.
else: ss2sc.interactionDetectionFactor=1.
is2aabb.aabbEnlargeFactor=-1.
O.run()
def stopIfDamaged():
global mode
if O.iter<2 or not plot.data.has_key('sigma'): return # do nothing at the very beginning
sigma,eps=plot.data['sigma'],plot.data['eps']
extremum=max(sigma) if (strainer.strainRate>0) else min(sigma)
minMaxRatio=0.5 if mode=='tension' else 0.5
if extremum==0: return
# uncomment to get graph for the very first time stopIfDamaged() is called
#eudoxos.estimatePoissonYoung(principalAxis=axis,stress=strainer.avgStress,plot=True,cutoff=0.3)
print O.tags['id'],mode,strainer.strain,sigma[-1]
import sys; sys.stdout.flush()
if abs(sigma[-1]/extremum)<minMaxRatio or abs(strainer.strain)>(5e-3 if isoPrestress==0 else 5e-2):
if mode=='compression' and doModes & 2: # only if compression is enabled
mode='tension'
O.save('/tmp/uniax-compression.yade.gz')
print "Saved /tmp/uniax-compression.yade.gz (for use with interaction-histogram.py and uniax-post.py)"
print "Damaged, switching to compression... "; O.pause()
# important! initTest must be launched in a separate thread;
# otherwise O.load would wait for the iteration to finish,
# but it would wait for initTest to return and deadlock would result
import thread; thread.start_new_thread(initTest,())
return
else:
print "Damaged, stopping."
ft,fc=max(sigma),min(sigma)
print 'Strengths fc=%g, ft=%g, |fc/ft|=%g'%(fc,ft,abs(fc/ft))
title=O.tags['description'] if 'description' in O.tags.keys() else O.tags['params']
print 'gnuplot',plot.saveGnuplot(O.tags['id'],title=title)
print 'Bye.'
#O.pause()
sys.exit(0)
def addPlotData():
yade.plot.addData({'t':O.time,'i':O.iter,'eps':strainer.strain,'sigma':strainer.avgStress+isoPrestress,
'sigma.25':utils.forcesOnCoordPlane(coord_25,axis)[axis]/area_25+isoPrestress,
'sigma.50':utils.forcesOnCoordPlane(coord_50,axis)[axis]/area_50+isoPrestress,
'sigma.75':utils.forcesOnCoordPlane(coord_75,axis)[axis]/area_75+isoPrestress,
})
plot.plot(subPlots=False)
#O.run()
initTest()
utils.waitIfBatch()
At 2013-11-13 15:26:20,"Jan Stránský" <question239133@xxxxxxxxxxxxxxxxxxxxx> wrote:
>Your question #239133 on Yade changed:
>https://answers.launchpad.net/yade/+question/239133
>
> Status: Open => Answered
>
>Jan Stránský proposed the following answer:
>Hello,
>I have just found, that the script examples/concrete/uniax.py itself is not
>working. Is this also your case?
>cheers
>Jan
>
>
>2013/11/13 pingyang.1019@xxxxxxx <question239133@xxxxxxxxxxxxxxxxxxxxx>
>
>> New question #239133 on Yade:
>> https://answers.launchpad.net/yade/+question/239133
>>
>> Hi teachers
>> I run uniax-post.py , but there is a error. I do not know how to
>> modify .
>>
>> Running script /home/py/test/tunnel/uniax-post.py
>> Traceback (most recent call last):
>> File "bins/yade-pingyang", line 162, in runScript
>> execfile(script,globals())
>> File "/home/py/test/tunnel/uniax-post.py", line 28, in <module>
>> pylab.figure();
>> ax,map=post2d.plot(post2d.data(extractDmg,flattener,stDev=2e-3))
>> File "/home/py/yade/lib/yade-pingyang/py/yade/post2d.py", line 277, in
>> plot
>>
>> ct=axes.contour(data['x'],data['y'],data['val'],colors='k',origin='lower',extend='both')
>> File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 7381, in
>> contour
>> return mcontour.QuadContourSet(self, *args, **kwargs)
>> File "/usr/lib/pymodules/python2.7/matplotlib/contour.py", line 1112, in
>> __init__
>> ContourSet.__init__(self, ax, *args, **kwargs)
>> File "/usr/lib/pymodules/python2.7/matplotlib/contour.py", line 704, in
>> __init__
>> self._process_levels()
>> File "/usr/lib/pymodules/python2.7/matplotlib/contour.py", line 911, in
>> _process_levels
>> self._levels.insert(0, min(self.levels[0],self.zmin) - 1)
>> IndexError: index out of bounds
>>
>>
>> --
>> 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
>>
>
>--
>If this answers your question, please go to the following page to let us
>know that it is solved:
>https://answers.launchpad.net/yade/+question/239133/+confirm?answer_id=0
>
>If you still need help, you can reply to this email or go to the
>following page to enter your feedback:
>https://answers.launchpad.net/yade/+question/239133
>
>You received this question notification because you asked the question.
--
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.