Exemplo n.º 1
0
h = 0.01
smoothingKernelFunc = 2
speedsound = 1
density = 1
shearmodulus = 1
bulkmodulus = 1
# Create a packer, see packers directory for options
cubic = pyck.CubicPacker([10.0, 10.0, 10.0], h)
# pack = pyck.Pack(cubic); # do not create the cubic packer in this
# function call as it will be destroyed, blame SWIG developers
pack = pyck.StructuredPack(cubic)

# Create some shapes, see shapes directory for options and reference
# First argument is always a tag for these particles
# Mapping operations are applied sequentially
cube = pyck.Cuboid(1, [2, 2, 2], [6, 6, 6])
sphere = pyck.Sphere(2, [2, 2, 2], 5)

# Map the shapes and generate the pack
# As with creating the cubic packer, do not create the shapes within the
# function call here
pack.AddShape(cube)
pack.AddShape(sphere)
pack.Process()

# Create a new model from the pack
model = pyck.Model(pack)

# Create a new field of n-dimensional integers
# Arguments are CreateIntField(label,dimensions)
# label - label for this field in the vtp file
Exemplo n.º 2
0
import pyck

L = [1, 1, 0]
r = 0.002
dim = 2
smoothingKernelFunc = 1

cubic = pyck.Hcp2dPacker(L, r)
# do not create the cubic packer in this function call as it will be
# destroyed, blame SWIG developers
pack = pyck.StructuredPack(cubic)

cube = pyck.Cuboid(1, [0, 0, 0], [1, 1, 0])
convexh = pyck.ConvexHull2D(2, [[0.1, 0.2, 0], [0.8, 0.2, 0], [0.3, 0.8, 0]])

pack.AddShape(cube)
pack.AddShape(convexh)

# Map the shapes and generate the pack
pack.Process()

# Create a new model from the pack
model = pyck.Model(pack)

# Create a new field of n-dimensional integers
# Arguments are CreateIntField(label,dimensions)
# label - label for this field in the vtp file
# dimensions - dimensionality of this field, doesnt have to correspond to model dimensions
# Create field of doubles in the same way with CreateDoubleField
stateField = model.CreateIntField("State", 1)
# for i in range(1, 17):
Exemplo n.º 3
0
import pyck

L = [10.0, 10.0, 0.0]
r = 0.1

# Create a packer, see packers directory for options
cubic = pyck.Hcp2dPacker(L, r)

# Get the periodic extent of the pack
periodicExtent = cubic.GetPeriodicExtent()

# Create a structured pack
pack = pyck.StructuredPack(cubic)

# Create a cube which will pack every particle specified by the packer
cube = pyck.Cuboid(1, [-1, -1, -1], [11, 11, 11])

# Add and process
pack.AddShape(cube)
pack.Process()

# Create a new model from the pack
model = pyck.Model(pack)

# (Over)write the domain size
model.SetParameter("Lx", "%e" % periodicExtent[0])
model.SetParameter("Ly", "%e" % periodicExtent[1])
model.SetParameter("Lz", "%e" % periodicExtent[2])
model.SetParameter("GridSizeX", "%d" % math.floor(periodicExtent[0] / r))
model.SetParameter("GridSizeY", "%d" % math.floor(periodicExtent[1] / r))
model.SetParameter("GridSizeZ", "%d" % math.floor(periodicExtent[2] / r))
Exemplo n.º 4
0
pack = pyck.StructuredPack(Hcp)


def pythonShape(x, y, z):
    dx = x - 1.0
    dy = y - 1.0
    dz = z - 1.0
    r = 0.3
    if (dx * dx + dy * dy + dz * dz < r * r):
        return True
    return False


pyShape = pyck.PyShape(1, [0.7, 0.7, 0.7], [1.0, 1.0, 1.0], pythonShape)

cube = pyck.Cuboid(2, [0.2, 0.2, 0.2], [0.6, 0.6, 0.6])

# Map the shapes and generate the pack
pack.AddShape(pyShape)
pack.AddShape(cube)
pack.Process()

# Create a new model from the pack
model = pyck.Model(pack)

# Create a new field of n-dimensional integers
# Arguments are CreateIntField(label,dimensions)
# label - label for this field in the vtp file
# dimensions - dimensionality of this field, doesnt have to correspond to model dimensions
# Create field of doubles in the same way with CreateDoubleField
stateField = model.CreateIntField("State", 1)
Exemplo n.º 5
0
import pyck

L = [10.0, 10.0, 0.0]
r = 0.1

cubic = pyck.CubicPacker(L, r)
pack = pyck.StructuredPack(cubic)

cube = pyck.Cuboid(1, [2, 2, -1], [6, 6, 1])
sphere = pyck.Sphere(2, [2, 2, 2], 5)

pack.AddShape(cube)
pack.AddShape(sphere)
pack.Process()

model = pyck.Model(pack)

# Create an IntField
stateField = model.CreateIntField("State", 1)

# The IntField may be set in the traditional way:
model.SetIntField(stateField, 1, 10)

# Or we can use a callback to determine the value of the
# field as a function of position
# Note that the callback must always take arguments for X Y and Z
# regardless of the dimensionality of the pack


def fieldCallback(x, y, z):
    return x
Exemplo n.º 6
0
import pyck

L = [10.0, 10.0, 0.0]
offset = [100.0, 50.0, 0.0]
r = 0.1

# Create a packer, see packers directory for options
cubic = pyck.CubicPacker(L, r, offset)
# do not create the cubic packer in this function call as it will be
# destroyed, blame SWIG developers
pack = pyck.StructuredPack(cubic)

# Create some shapes, see shapes directory for options and reference
# First argument is always a tag for these particles
# Mapping operations are applied sequentially
cube = pyck.Cuboid(1, [102, 52, -1], [106, 56, 1])
sphere = pyck.Sphere(2, [102, 52, 2], 5)

# Map the shapes and generate the pack
# As with creating the cubic packer, do not create the shapes within the
# function call here
pack.AddShape(cube)
pack.AddShape(sphere)
pack.Process()

# Create a new model from the pack
model = pyck.Model(pack)

# Create a new field of n-dimensional integers
# Arguments are CreateIntField(label,dimensions)
# label - label for this field in the vtp file