pumapy.generation

pumapy.generation.generate_2d_square_array

class pumapy.generation.generate_2d_square_array.GeneratorSquareArray(size, porosity)[source]

Bases: object

error_check()[source]
generate()[source]
log_input()[source]
log_output()[source]
pumapy.generation.generate_2d_square_array.generate_2d_square_array(size, porosity)[source]

Generate a 2D periodic array of circles

Parameters
  • size (int) – size of the output domain

  • porosity (float) – porosity of the output domain

Returns

array of circles

Return type

Workspace

pumapy.generation.generate_sphere

class pumapy.generation.generate_sphere.GeneratorSphere(size, center, diameter)[source]

Bases: object

error_check()[source]
generate()[source]
log_input()[source]
log_output()[source]
pumapy.generation.generate_sphere.generate_sphere(size, center, diameter)[source]

Generation of a sphere at a given point and diameter

Parameters
  • size (tuple(int, int, int)) – size of 3D domain (x,y,z)

  • center (tuple(int, int, int)) – centerpoint of sphere (x,y,z)

  • diameter – diameter of the random spheres in voxels

Return type

float

pumapy.generation.random_fibers

The following function was copied and modified from the porespy project (distributed under the MIT License). See https://github.com/PMEAL/porespy/blob/dev/porespy/generators/_imgen.py for more information. See https://github.com/PMEAL/porespy/blob/dev/LICENSE for the license.

pumapy.generation.random_fibers.generate_random_fibers(shape, radius, nfibers=None, porosity=None, phi=90, theta=90, length=None, max_iter=3, allow_intersect=True)[source]

Generates random fibers from number of fibers or porosity

Parameters
  • shape (tuple(int, int, int)) – the size of the workspace to generate in (Nx, Ny, Nz) where N is the number of voxels.

  • radius (int) – the radius of the fibers in voxels

  • nfibers (int, optional) – the number of fibers to add to the domain. Adjust this value to control the final porosity, which is not easily specified since cylinders overlap and intersect different fractions of the domain

  • porosity (float, optional) – the target value for the porosity of the generated mat. The function uses an algorithm for predicting the number of required number of cylinder, and refines this over a certain number of fractional insertions (according to the ‘iterations’ input)

  • phi (float, optional) – a value between 0 and 90 that controls the amount that the fibers lie out of the XY plane, with 0 meaning all fibers lie in the XY plane, and 90 meaning that cylinders are randomly oriented out of the plane by as much as +/- 90 degrees

  • theta (float, optional) – a value between 0 and 90 that controls the amount of rotation in the XY plane, with 0 meaning all fibers point in the X-direction, and 90 meaning they are randomly rotated about the Z axis by as much as +/- 90 degrees

  • length (float, optional) – the length of the cylinders to add. If None (default) then the cylinders will extend beyond the domain in both directions so no ends will exist. If a scalar value is given it will be interpreted as the Euclidean distance between the two ends of the cylinder. Note that one or both of the ends may still lie outside the domain, depending on the randomly chosen center point of the cylinder

  • max_iter (int, optional) – the number of fractional fiber insertions used to target the requested porosity. By default a value of 3 is used (and this is typically effective in getting very close to the targeted porosity), but a greater number can be input to improve the achieved porosity

  • allow_intersect (bool, optional) – allow intersection betweem the fibers

Returns

random fibers domain

Return type

Workspace

Example

>>> import pumapy as puma
>>> # specify porosity
>>> ws_fibers = puma.generate_random_fibers(shape=(100, 100, 100), radius=4, porosity=0.8, phi=90, theta=90, length=200)
>>> puma.render_contour(ws_fibers, cutoff=(1, 1))
>>> puma.render_orientation(ws_fibers)
>>> # specify number of fibers
>>> ws_fibers = puma.generate_random_fibers(shape=(100, 100, 100), radius=4, nfibers=100, phi=90, theta=90, length=200)
>>> puma.render_contour(ws_fibers, cutoff=(1, 1))
>>> puma.render_orientation(ws_fibers)
>>> # don't allow intersection between fibers
>>> ws_fibers = puma.generate_random_fibers(shape=(100, 100, 100), radius=4, porosity=0.8, phi=90, theta=90, length=200, allow_intersect=False)
>>> puma.render_contour(ws_fibers, cutoff=(1, 1))
>>> puma.render_orientation(ws_fibers)

pumapy.generation.random_spheres

class pumapy.generation.random_spheres.GeneratorSpheres(size, diameter, porosity, allow_intersect)[source]

Bases: object

error_check()[source]
generate()[source]
log_input()[source]
log_output()[source]
pumapy.generation.random_spheres.generate_random_spheres(size, diameter, porosity, allow_intersect=True)[source]

Generation of triply periodic minimal surface material

Parameters
  • size (tuple(int, int, int)) – size of 3D domain (x,y,z)

  • diameter (float) – diameter of the random spheres in voxels

  • porosity (float) – target porosity of the generated structure

  • allow_intersect (bool) – allow the spheres to intersect or not

Returns

domain with random spheres with input diameter

Return type

Workspace

Example

>>> import pumapy as puma
>>> ws_generated = puma.generate_random_spheres(size=(200,200,200), diameter=20, porosity=0.7) # Generating a workspace of randomly placed, intersecting spheres
>>> puma.render_contour(ws_generated, cutoff=(128, 255))

pumapy.generation.sphere

pumapy.generation.sphere.get_circle(diameter)[source]
pumapy.generation.sphere.get_circle_even(diameter)[source]
pumapy.generation.sphere.get_circle_odd(diameter)[source]
pumapy.generation.sphere.get_sphere(diameter)[source]

pumapy.generation.tpms

class pumapy.generation.tpms.GeneratorTPMS(size, w, q, equation=0)[source]

Bases: object

error_check()[source]
generate()[source]
log_input()[source]
log_output()[source]
pumapy.generation.tpms.generate_tpms(size, w, q, equation=0)[source]

Generation of triply periodic minimal surface material

Parameters
  • size (tuple(int, int, int)) – size of 3D domain (x,y,z)

  • w (float or tuple(float, float)) – w parameter for tpms

  • q (float or tuple(float, float)) – q parameter for tpms (float or tuple)

  • equation (int) – equation 0, 1, or 2 for tpms

Returns

TPMS domain

Return type

Workspace

Example

>>> import pumapy as puma
>>> size = (200, 200, 200)  # size of the domain, in voxels.
>>> w = 0.08  # value of w in the equations above
>>> q = 0.2  # value of q in the equations above
>>> ws_eq0 = puma.generate_tpms(size, w, q, equation=0)
>>> ws_eq1 = puma.generate_tpms(size, w, q, equation=1)
>>> ws_eq2 = puma.generate_tpms(size, w, q, equation=2)
>>> puma.render_contour(ws_eq0, cutoff=(128, 255)) #visualize the workspace
>>> puma.render_contour(ws_eq1, cutoff=(128, 255))
>>> puma.render_contour(ws_eq2, cutoff=(128, 255))

pumapy.generation.tpms_utils

pumapy.generation.tpms_utils.generate()

pumapy.generation.tpms_utils

pumapy.generation.tpms_utils.generate()