#!/usr/bin/python # -*- coding: utf-8 -*- from yade import utils from yade import ymport sphereRadius = 0.05 ## Import wall's geometry walls = O.bodies.append(ymport.stl('ring.stl')) def fill_cylinder_with_spheres(sphereRadius, cylinderRadius, cylinderHeight, cylinderOrigin, cylinderSlope): spheresCount = 0 for h in xrange(0, int(cylinderHeight / sphereRadius / 2)): for r in xrange(1, int(cylinderRadius / sphereRadius / 2)): dfi = asin(0.5 / r) * 2 for a in xrange(0, int(6.28 / dfi)): x = cylinderOrigin[0] + 2 * r * sphereRadius * cos(dfi * a) y = cylinderOrigin[1] + 2 * r * sphereRadius * sin(dfi * a) z = cylinderOrigin[2] + h * 2 * sphereRadius s = utils.sphere([ x, y * cos(cylinderSlope) + z * sin(cylinderSlope), z * cos(cylinderSlope) - y * sin(cylinderSlope) ], sphereRadius) O.bodies.append(s) spheresCount += 1 return spheresCount
## PhysicalParameters Density = 2400 frictionAngle = radians(35) tc = 0.001 en = 0.3 es = 0.3 ## Import wall's geometry params = getViscoelasticFromSpheresInteraction(tc, en, es) facetMat = O.materials.append(ViscElMat( frictionAngle=frictionAngle, **params)) # **params sets kn, cn, ks, cs sphereMat = O.materials.append( ViscElMat(density=Density, frictionAngle=frictionAngle, **params)) from yade import ymport fctIds = O.bodies.append( ymport.stl('baraban.stl', color=(1, 0, 0), material=facetMat)) ## Spheres sphereRadius = 0.2 nbSpheres = (10, 10, 10) #nbSpheres = (50,50,50) for i in xrange(nbSpheres[0]): for j in xrange(nbSpheres[1]): for k in xrange(nbSpheres[2]): x = (i * 2 - nbSpheres[0]) * sphereRadius * 1.1 y = (j * 2 - nbSpheres[1]) * sphereRadius * 1.1 z = (k * 2 - nbSpheres[2]) * sphereRadius * 1.1 s = sphere([x, y, z], sphereRadius, material=sphereMat) O.bodies.append(s) ## Timestep O.dt = .2 * tc
numSpheres=0. for o in O.bodies: if isinstance(o.shape,Sphere): o.shape.color=(0,0,1) numSpheres+=1 R+=o.shape.radius if o.shape.radius>Rmax: Rmax=o.shape.radius else : o.shape.color=(0,0,0) Rmean=R/numSpheres print('number of spheres=', numSpheres, ' | Rmean=', Rmean, ' | dim=', dim) ############################ import stl file O.bodies.append(ymport.stl(DFN+'.stl',color=(0.9,0.9,0.9),wire=False,material=facetMat)) ############################ engines definition interactionRadius=1.; O.engines=[ ForceResetter(), InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=interactionRadius,label='is2aabb'),Bo1_Facet_Aabb()]), InteractionLoop( [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=interactionRadius,label='ss2d3dg'),Ig2_Facet_Sphere_ScGeom()], [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys(cohesiveTresholdIteration=1,label='interactionPhys')], [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(smoothJoint=True,label='interactionLaw')] ), NewtonIntegrator(damping=1) ]
ysup - 0.1 * Rmean, zsup - 0.1 * Rmean) walls = utils.aabbWalls(oversizeFactor=1.5, extrema=(mn, mx), thickness=0.1 * min(X, Y, Z), material=wallMat) wallIds = O.bodies.append(walls) ### packing O.bodies.append(ymport.text(PACK + '.spheres', material=sphereMat)) ### DFN O.bodies.append( ymport.stl(DFN + '.stl', color=(0.9, 0.9, 0.9), wire=False, material=wallMat)) execfile('identifyInitialFractures.py') ### to reduce initial crack extent: penny crack in the (Y,Z) plane, centre at Yc=0.5 and Zc=0.5, radius 0.1 for o in O.bodies: if isinstance(o.shape, Sphere): if ((o.state.pos[2] - 0.5)**2 + (o.state.pos[1] - 0.5)**2) > (0.05 + Rmean)**2: o.state.onJoint = False #### engines ### Triaxial Engine triax = TriaxialStressController(internalCompaction=False, stressMask=7, goal1=Sxx,
from operator import itemgetter indices, zValues_sorted = zip(*sorted(enumerate(zValues), key=itemgetter(1))) list(zValues) list(indices) sp_new = [] for i in range(0, len(sp)): sp_new.append(sp[indices[i]]) Nspheres = 122000 sp_new = sp_new[0:Nspheres] from yade import ymport facets = ymport.stl(fileName + '.stl', color=(0, 1, 0), material=Steel) fctIds = range(len(facets)) NSTEPS = 1000 if numMPIThreads > 1: mp.mprint("appending bodies, rank", mp.rank) if mp.rank == 0: O.bodies.append(facets) mp.mprint("master has", len(O.bodies), "facets") else: import numpy as np layers = np.array_split(sp_new, numMPIThreads - 1) mp.mprint("layers", [len(l) for l in layers]) layerNo = mp.rank - 1 #rank zero is for facets
## Omega o=Omega() ## PhysicalParameters Density=2400 frictionAngle=radians(35) sphereRadius=0.05 tc = 0.001 en = 0.3 es = 0.3 ## Import wall's geometry facetMat=O.materials.append(ViscElMat(frictionAngle=frictionAngle,tc=tc,en=en,et=es)) sphereMat=O.materials.append(ViscElMat(density=Density,frictionAngle=frictionAngle,tc=tc,en=en,et=es)) walls = O.bodies.append(ymport.stl('ring.stl',material=facetMat)) def fill_cylinder_with_spheres(sphereRadius,cylinderRadius,cylinderHeight,cylinderOrigin,cylinderSlope): spheresCount=0 for h in xrange(0,int(cylinderHeight/sphereRadius/2)): for r in xrange(1,int(cylinderRadius/sphereRadius/2)): dfi = asin(0.5/r)*2 for a in xrange(0,int(6.28/dfi)): x = cylinderOrigin[0]+2*r*sphereRadius*cos(dfi*a) y = cylinderOrigin[1]+2*r*sphereRadius*sin(dfi*a) z = cylinderOrigin[2]+h*2*sphereRadius s=sphere([x,y*cos(cylinderSlope)+z*sin(cylinderSlope),z*cos(cylinderSlope)-y*sin(cylinderSlope)],sphereRadius,material=sphereMat) o.bodies.append(s) spheresCount+=1 return spheresCount
numSpheres=0. for o in O.bodies: if isinstance(o.shape,Sphere): o.shape.color=(0,0,1) numSpheres+=1 R+=o.shape.radius if o.shape.radius>Rmax: Rmax=o.shape.radius else : o.shape.color=(0,0,0) Rmean=R/numSpheres print 'number of spheres=', numSpheres, ' | Rmean=', Rmean, ' | dim=', dim ############################ import stl file O.bodies.append(ymport.stl(DFN+'.stl',color=(0.9,0.9,0.9),wire=False,material=facetMat)) ############################ engines definition interactionRadius=1.; O.engines=[ ForceResetter(), InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=interactionRadius,label='is2aabb'),Bo1_Facet_Aabb()]), InteractionLoop( [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=interactionRadius,label='ss2d3dg'),Ig2_Facet_Sphere_ScGeom()], [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys(cohesiveTresholdIteration=1,label='interactionPhys')], [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(smoothJoint=True,label='interactionLaw')] ), NewtonIntegrator(damping=1) ]
from builtins import range import time ## PhysicalParameters Density=2400 frictionAngle=radians(35) tc = 0.001 en = 0.3 es = 0.3 ## Import wall's geometry facetMat=O.materials.append(ViscElMat(frictionAngle=frictionAngle,tc=tc,en=en,et=es)) # **params sets kn, cn, ks, cs sphereMat=O.materials.append(ViscElMat(density=Density,frictionAngle=frictionAngle,tc=tc,en=en,et=es)) from yade import ymport fctIds=O.bodies.append(ymport.stl('baraban.stl',color=(1,0,0),material=facetMat)) ## Spheres sphereRadius = 0.2 nbSpheres = (10,10,10) #nbSpheres = (50,50,50) for i in range(nbSpheres[0]): for j in range(nbSpheres[1]): for k in range(nbSpheres[2]): x = (i*2 - nbSpheres[0])*sphereRadius*1.1 y = (j*2 - nbSpheres[1])*sphereRadius*1.1 z = (k*2 - nbSpheres[2])*sphereRadius*1.1 s=sphere([x,y,z],sphereRadius,material=sphereMat) O.bodies.append(s) ## Timestep O.dt=.2*tc
# -*- coding: utf-8 -*- from __future__ import print_function from builtins import range import random from yade import ymport ## PhysicalParameters ## Variant of mesh mesh = 'coarse' #mesh = 'fine' #mesh = 'tiny' ## Import geometry rod = O.bodies.append(ymport.stl('rod-'+mesh+'.stl',wire=True)) # Spheres sphereRadius = 0.01 nbSpheres = (32,11,32) print("Creating %d spheres..."%(nbSpheres[0]*nbSpheres[1]*nbSpheres[2]), end=' ') for i in range(nbSpheres[0]): for j in range(nbSpheres[1]): for k in range(nbSpheres[2]): x = (i*2 - nbSpheres[0])*sphereRadius*1.1+sphereRadius*random.uniform(-0.1,0.1) y = -j*sphereRadius*2.2-0.01 z = (k*2 - nbSpheres[2])*sphereRadius*1.1+sphereRadius*random.uniform(-0.1,0.1) r = random.uniform(sphereRadius,sphereRadius*0.9) fixed = False color=[0.51,0.52,0.4] if (i==0 or i==nbSpheres[0]-1 or j==nbSpheres[1]-1 or k==0 or k==nbSpheres[2]-1):
#!/usr/bin/python # -*- coding: utf-8 -*- from yade import utils import random from yade import ymport ## PhysicalParameters ## Variant of mesh mesh = 'coarse' #mesh = 'fine' #mesh = 'tiny' ## Import geometry rod = O.bodies.append(ymport.stl('rod-' + mesh + '.stl', wire=True)) # Spheres sphereRadius = 0.01 nbSpheres = (32, 11, 32) print "Creating %d spheres..." % (nbSpheres[0] * nbSpheres[1] * nbSpheres[2]), for i in xrange(nbSpheres[0]): for j in xrange(nbSpheres[1]): for k in xrange(nbSpheres[2]): x = (i * 2 - nbSpheres[0] ) * sphereRadius * 1.1 + sphereRadius * random.uniform( -0.1, 0.1) y = -j * sphereRadius * 2.2 - 0.01 z = (k * 2 - nbSpheres[2] ) * sphereRadius * 1.1 + sphereRadius * random.uniform( -0.1, 0.1)
#!/usr/bin/python # -*- coding: utf-8 -*- from yade import ymport sphereRadius=0.05 ## Import wall's geometry walls = O.bodies.append(ymport.stl('ring.stl')) def fill_cylinder_with_spheres(sphereRadius,cylinderRadius,cylinderHeight,cylinderOrigin,cylinderSlope): spheresCount=0 for h in xrange(0,int(cylinderHeight/sphereRadius/2)): for r in xrange(1,int(cylinderRadius/sphereRadius/2)): dfi = asin(0.5/r)*2 for a in xrange(0,int(6.28/dfi)): x = cylinderOrigin[0]+2*r*sphereRadius*cos(dfi*a) y = cylinderOrigin[1]+2*r*sphereRadius*sin(dfi*a) z = cylinderOrigin[2]+h*2*sphereRadius s=sphere([x,y*cos(cylinderSlope)+z*sin(cylinderSlope),z*cos(cylinderSlope)-y*sin(cylinderSlope)],sphereRadius) O.bodies.append(s) spheresCount+=1 return spheresCount ## Spheres spheresCount=0 spheresCount+=fill_cylinder_with_spheres(sphereRadius,0.5,0.10,[0,0,0],radians(0)) print "Number of spheres: %d" % spheresCount ## Engines O.engines=[
o=Omega() ## PhysicalParameters Density=2400 frictionAngle=radians(35) sphereRadius=0.05 tc = 0.001 en = 0.3 es = 0.3 ## Import wall's geometry params=utils.getViscoelasticFromSpheresInteraction(tc,en,es) facetMat=O.materials.append(ViscElMat(frictionAngle=frictionAngle,**params)) # **params sets kn, cn, ks, cs sphereMat=O.materials.append(ViscElMat(density=Density,frictionAngle=frictionAngle,**params)) walls = O.bodies.append(ymport.stl('ring.stl',material=facetMat)) def fill_cylinder_with_spheres(sphereRadius,cylinderRadius,cylinderHeight,cylinderOrigin,cylinderSlope): spheresCount=0 for h in xrange(0,int(cylinderHeight/sphereRadius/2)): for r in xrange(1,int(cylinderRadius/sphereRadius/2)): dfi = asin(0.5/r)*2 for a in xrange(0,int(6.28/dfi)): x = cylinderOrigin[0]+2*r*sphereRadius*cos(dfi*a) y = cylinderOrigin[1]+2*r*sphereRadius*sin(dfi*a) z = cylinderOrigin[2]+h*2*sphereRadius s=utils.sphere([x,y*cos(cylinderSlope)+z*sin(cylinderSlope),z*cos(cylinderSlope)-y*sin(cylinderSlope)],sphereRadius,material=sphereMat) o.bodies.append(s) spheresCount+=1 return spheresCount