yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #29448
[Question #706709]: Segmentation error
New question #706709 on Yade:
https://answers.launchpad.net/yade/+question/706709
My code runs perfectly fine until i add the VTK exporter, it then runs a few steps and then shows a segmentation error.
Can you please help with the error?
Here is my code:
from __future__ import print_function
from yade import plot, polyhedra_utils
import numpy as np
wire = False
######################################################################
# Need to define polyhedral material for Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys() to work
m = PolyhedraMat() #defines polyhedral properties
m.density = 0.0000026 #kg/mm^3
m.Ks = 130E6
m.Kn = 160E6#Pa
m.frictionAngle = 0.6 #rad
O.materials.append(m) #adds material to yade
######################################################################
# Defining polyhedra shapes in terms of their vertices so technically defining vertices, dimaters are 1 cm
t1_coords = ((0.33091155911506355, -0.3242136881048748, -0.33985697995026614),
(0.33091155911506355, 0.38088860029783984, -0.33985697995026614),
(-0.3662726180924643, -0.3242136881048748, -0.33985697995026614),
(-0.08498849969921465, -0.3242136881048748, 0.3440300800075135),
(0.33091155911506355, 0.0956749508999913, 0.3055457315613278),
(0.33091155911506355, 0.38088860029783984, 0.25920106521738856),
(-0.3662726180924643, 0.38088860029783984, 0.20493952283110147),
(-0.3662726180924643, -0.3242136881048748, 0.32033663438746235))
t2_coords = ((-0.14309681589806823, -0.2272260744496193, 0.38401015387691325),
(0.358010967088001, -0.2272260744496193, 0.38401015387691325),
(0.6643612513710932, -0.2272260744496193, -0.11312310165154156),
(0.09399535164170355, -0.2272260744496193, -0.4453308199780648),
(0.28983044257111084, 0.06624457321674196, -0.2657890485909965),
(-0.3263752923764808, 0.09806342306798776, -0.21177708099387714),
(-0.14309681589806823, 0.5961347452425924, 0.05063802822300939),
(-0.27303541351821494, 0.2667732486219123, 0.18065628098092602),
(0.37721690590733186, -0.0964985942102914, 0.3057083518969001),
(-0.47649283929694435, -0.2272260744496193, -0.11312310165154156))
t3_coords = ((0.2600238357760947, 0.2851848128988758, -0.24701557197894438),
(0.16012830358156934, 0.3484895606572876, -0.18513953373961826),
(-0.16008801057746095, 0.3484895606572876, -0.18513953373961826),
(-0.26000224348968266, 0.2851848128988758, -0.24701557197894438),
(-0.38471948905778405, 0.2025288577517229, -0.0915820081211398),
(-0.38471948905778405, -0.20256899286437123, -0.0915820081211398),
(-0.23030565260400093, -0.40365230950484085, 0.2613542406089658),
(-0.16008801057746095, -0.500774842940389, 0.18311089846328836),
(0.16012830358156934, -0.500774842940389, 0.18311089846328836),
(0.23034594560810932, -0.40365230950484085, 0.2613542406089658),
(0.38475978206189245, -0.20256899286437123, -0.0915820081211398),
(0.38475978206189245, 0.2025288577517229, -0.0915820081211398),
(0.23034594560810932, 0.40361217439219253, 0.2613542406089658),
(0.16012830358156934, 0.500734707827741, 0.18311089846328836),
(-0.16008801057746095, 0.500734707827741, 0.18311089846328836),
(-0.23030565260400093, 0.40361217439219253, 0.2613542406089658),
(-0.16008801057746095, 0.2025288577517229, 0.4286664300572351),
(-0.16008801057746095, -0.20256899286437123, 0.4286664300572351),
(0.16012830358156934, -0.20256899286437123, 0.4286664300572351),
(0.16012830358156934, 0.2025288577517229, 0.4286664300572351),
(0.16012830358156934, 0.2025288577517229, -0.4030812475869826),
(-0.16008801057746095, 0.2025288577517229, -0.4030812475869826),
(-0.16008801057746095, -0.20256899286437123, -0.4030812475869826),
(0.16012830358156934, -0.20256899286437123, -0.4030812475869826),
(0.2600238357760947, -0.2852249480115241, -0.24701557197894438),
(0.16012830358156934, -0.348529695769936, -0.18513953373961826),
(-0.16008801057746095, -0.348529695769936, -0.18513953373961826),
(-0.26000224348968266, -0.2852249480115241, -0.24701557197894438))
t4_coords = ((0.4254514979111890, 0.4106636864106340 ,0.4149508885978020),
(0.5684762836292130, 0.3280882876319440, 0.3323754918191100),
(0.5684762836292130, -0.3283734251788300, 0.3323754918191100),
(0.4254514979111890, -0.4109488219575220, 0.4149508885978020),
(-0.0000362362424167, -0.6566042805842190, -0.0105368442558058),
(-0.4069085993778770, -0.4216964118784300, -0.4174092086912640),
(-0.5685487555140470, -0.3283734231788330, -0.3240862209916650),
(-0.5685487555140470, 0.3280882876319440, -0.3240862209916650),
(-0.4069085993778770, 0.4214112753315430, -0.4174092086912640),
(-0.0000362362424167, 0.6563191440373320, -0.0105368442558058),
(0.5684762836292130, 0.3280882876319440, -0.3240862209916650),
(0.5684762836292130, -0.3283734231788330, -0.3240862209916650),
(0.4068361274930420, -0.4216964118784300, -0.4174092086912640),
(0.1268671643942450, -0.3283734231788330, -0.5790493638274360),
(-0.1269396372790780, -0.3283734231788330, -0.5790493638274360),
(-0.0000362362424167, 0.0371246810048347, -0.6523170763970530),
(-0.1269396372790780, 0.3280882876319440, -0.5790493638274360),
(0.1268671643942450 ,0.3280882876319440, -0.5790493638274360),
(0.4068361274930420, 0.4214112753315430, -0.4174092086912640),
(0.1777253035751180, 0.3280882876319440, 0.5579756743158260),
(-0.0000362362424167, 0.0371246810048347, 0.6606063472244980),
(0.1777253035751180, -0.3283734231788330, 0.5579756743158260),
(-0.1777977764599510, -0.3283734231788330, 0.5579756743158260),
(-0.4255239707960220, -0.4109488219575220, 0.4149508885978020),
(-0.5685487555140470, -0.3283734231788330, 0.3323754918191100),
(-0.5685487555140470, 0.3280882876319440, 0.3323754918191100),
(-0.4255239707960220, 0.4106636864106340, 0.4149508885978020),
(-0.1777977764599510, 0.3280882876319440, 0.5579756743158260))
shapes = [t1_coords, t2_coords, t3_coords, t4_coords]
bottom = polyhedron(((-5,-0.2,15),(50,-0.2,15),(50,0,15),(-5,0,15),(-5,-0.2,-5),(50,-0.2,-5),(50,0,-5),(-5,0,-5)),fixed=True,color=(0.1,0.2,0.5),wire=True)
leftside = polyhedron(((-0.2,0,10),(0,0,10),(0,8,10),(-0.2,8,10),(-0.2,0,0),(0,0,0),(0,8,0),(-0.2,8,0)),fixed=True,color=(0.1,0.2,0.5),wire=True)
rightside = polyhedron(((10,0,10),(10.2,0,10),(10.2,8,10),(10,8,10),(10,0,0),(10.2,0,0),(10.2,8,0),(10,8,0)),fixed=True,color=(0.1,0.2,0.5),wire=True) #side that will be removed
back = polyhedron(((0,0,10.2),(10,0,10.2),(10,8,10.2),(0,8,10.2),(0,0,10),(10,0,10),(10,8,10),(0,8,10)),fixed=True,color=(0.1,0.2,0.5),wire=True)
front = polyhedron(((0,0,0),(10,0,0),(10,8,0),(0,8,0),(0,0,-0.2),(10,0,-0.2),(10,8,-0.2),(0,8,-0.2)),fixed=True,color=(0.1,0.2,0.5),wire=True)
######################################################################
# Setting polyhedra positions in terms of their centers of mass
part_list = [] # Creates an empty list
i = 0 # counter
for x in np.linspace(1.5, 8.5, num=6): # (min coordinate, max coordinate, number of points) box width is 10 mm
for y in np.linspace(2,20, num=14): # box height is 8 mm and we are dropping into the box so drop from a heigher height
for z in np.linspace(1.5, 8.5, num=6): # width is 10 mm
shape_id = np.random.randint(0,4) # chooses a number between zero and 3
shape = shapes[shape_id] # uses the random number to pick one of the 4 shapes
part_list += [polyhedron(shape,color=(1,1,1),wire=wire)] # adds a new particle to the particle list
part_list[i].state.pos = (x,y,z)
i = i + 1
# centroid location
bottom.state.pos = (22.5,-0.1,5)
leftside.state.pos = (-0.1,4.1,5)
rightside.state.pos = (10.1,4.1,5)
back.state.pos = (5,4.1,10.2)
front.state.pos = (5,4.1,-0.2)
part_list = part_list + [bottom] + [leftside] + [back] + [front]
######################################################################
# Adding the bodies to the simulation, to see how to assign material properties to different polyhedra check O.bodies.append used in free-fall.py
O.bodies.append(part_list)
ThisID = O.bodies.append(rightside)
######################################################################
# Simulation loop
O.engines=[
# Reset forces
ForceResetter(),
# Appropriate collision detection, create interactions
InsertionSortCollider([Bo1_Polyhedra_Aabb(),Bo1_Wall_Aabb(),Bo1_Facet_Aabb()]),
# Handle interaction
InteractionLoop(
[Ig2_Wall_Polyhedra_PolyhedraGeom(), Ig2_Polyhedra_Polyhedra_PolyhedraGeom(), Ig2_Facet_Polyhedra_PolyhedraGeom()],
[Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys()], # collision "physics"
[Law2_PolyhedraGeom_PolyhedraPhys_Volumetric()] # contact law -- apply forces
),
# GravityEngine(gravity=(0,0,-9.81)), and Newton Integrator which updates position using Newton's equation
NewtonIntegrator(damping=0.10,gravity=(0,-9810,0)),
#VTKRecorder(fileName='./vtk/Trial', recorders= ['all'], iterPeriod=10000) # disabled for the time being because takes too much space
]
######################################################################
# Time step
O.dt = 4.03E-7
######################################################################
# remove Box Side
escapeNo=0
def myAddPlotData():
global escapeNo
uf=utils.unbalancedForce()
if isnan(uf):
uf = 1.0
KE = utils.kineticEnergy()
if O.iter>180000:
removeThisID()
from yade import plot
plot.plots={'timeStep1':('unbalancedForce'),'timeStep2':('kineticEn'),'time':('outsideNo')}
#plot.plot() #Uncomment to view plots
O.engines=O.engines+[PyRunner(iterPeriod=10000,command='myAddPlotData()')]
def removeThisID():
global ThisID
if (O.bodies[ThisID]):
O.bodies.erase(ThisID)
##Control the rendering quality
#Gl1_PotentialParticle.aabbEnlargeFactor=1.1
#Gl1_PotentialParticle.sizeX=30
#Gl1_PotentialParticle.sizeY=30
#Gl1_PotentialParticle.sizeZ=30
from yade import qt
qt.Controller()
v=qt.View()
O.saveTmp()
Thanks
--
You received this question notification because your team yade-users is
an answer contact for Yade.