Skip to main content

A geometric generation tool for prismatic cellular solids

Project description

RingsPy

Python 3 PyPI version Anaconda-Server Badge License: GPL v3 Tests codecov status

RingsPy is a Voronoi diagrams-based geometric generation tool that generates 3D meshes and models of prismatic cellular solids with radial growth rules.

Dependencies and Installation

RingsPy depends on mainstream Python libraries numpy and scipy, and optionally depends on library hexalattice, if the regular hexagonal lattice (e.g. honeycomb) is wanted; also vtk, if the 3D STL files are also wanted.

1. pip install

To install RingsPy, one may use pip:

pip install ringspy

or use:

pip install git+https://github.com/kingyin3613/ringspy.git

to get updates beyond the latest release.

2. conda install

If you are on Linux or Mac, you can also use conda-forge channel:

conda install -c conda-forge ringspy

3. Installation Check

There are some unit tests in tests. One can use pytest to check whether the installation is successful by running this command:

pytest .

Getting Started

Once all required components are installed and one is ready to begin, a path forward should be established for generating the mesh. The basic steps for running/viewing a cellular mesh are listed as the following:

1. Edit geometry and algorithm parameters
2. Generate mesh using Mesh Generation Tools
3. Visualize 2D view using Matplotlib or 3D model in `ParaView`
4. (Optional) Export 3D STL model for 3D editing and/or printing
5. (Optional) Export input file for numerical simulations with software `Abaqus`

1. Geometry and Parameters

The first step to generate a cellular geometry is selecting geometry and appropriate parameters.

1.1. Geometry

A template file, for example, test_wood_cube.py located in the tests directory acts as both the parameter input file, and main executable for the generation of a cubic wood specimen.

Note: The Mesh Generation Tool by now only accepts many of pre-defined boundary geometries (for v0.3.x, the following 3 shapes are supported: triangle, square, hexagon), importing of CAD and/or other 3D model files will be implemented in subsequent versions.

Note: for greatest compatibility create the geometry using all millimeters.

1.2. Parameters

By opening a input file, e.g., tests/test_wood_cube.py in any text editor, a file format similar to what is shown below will be displayed:

geoName = 'wood_cube'
path = 'meshes'

radial_growth_rule = 'wood_binary'
iter_max = 100
print_interval = 500

# Radial cell growth parameters
# length unit: mm
r_min = 0   # inner radius of wood log
r_max = 4   # outer radius of wood log
nrings = 4 # number of rings
width_heart = 0.3*(r_max-r_min)/nrings # heart wood ring width
width_early = 0.7*(r_max-r_min)/nrings # early wood ring width
width_late = 0.3*(r_max-r_min)/nrings # late wood ring width
log_center = (0,0) # coordinates of log center in the global system of reference

cellsize_early = 0.02
cellsize_late = 0.01
cellwallthickness_early = 0.010
cellwallthickness_late = 0.006
    
# clipping box parameters
boundaryFlag = 'on'
box_shape = 'square'
box_center = (1.25,0) # coordinates of box center in the global system of reference
box_size = 1.0 # side length
   
# longitudinal direction parameters
fiberlength = 0.5*box_size
theta_min = 0 # radian
theta_max = 0.05 # radian
z_min = 0
z_max = box_size
long_connector_ratio = 0.02 # longitudinal joint size
    
merge_operation = 'on'
merge_tol = 0.01
    
precrackFlag = 'off'
precrack_widths = 0.1
    
stlFlag = 'on'
    
inpFlag = 'on'
inpType = 'Abaqus'
  • geoName is the geometry name, path is the folder where the mesh files will be generated.
  • radial_growth_rule is the radial growth rule for cell placement. When a file name with extension.npy is specified, a saved cell data file will be loaded (for v0.3.x, choose one of these rules: wood_binary, regular_hexagonal, or a file name with extension .npy).
  • iter_max is the max number of iteration for randomly placing new non-overlapping cell particles in the 2D toroidal cell placement region. Noticing that, larger iter_max leads to more centroidal Voronoi cells, for more reference, see Wiki Centroidal Voronoi Tessellation.
  • print_interval is the print interval when every n cell particles are placed in the placement region.
  • r_min and r_max are the upper and lower bounds of radii of toroidal cell placement region, nrings is the number of rings.
  • width_heart, width_early, and width_late, are ring widths for heartwood, earlywood, and latewood, respectively, which all together determine the morphology of the cellular structure.
  • log_center is the location of the placement region.
  • cellsize_early,cellsize_late, cellwallthickness_early, and cellwallthickness_late are parameters for the earlywood and latewood cells.
  • boundaryFlag flag can be turned on/off for generating neat boundaries consisting of grains.
  • box_shape is the shape of cutting box (for v0.3.x, choose one of following shapes: triangle, square, or hexagon).
  • box_center, and box_size are for locating the cutting box.
  • fiberlength is the length of fibers consisting the prismatic cells during the z- (longitudinal) extrusion.
  • theta_min and theta_max determine the twisting angles (unit: radian) of the 2D mesh around the log_center during the extrusion.
  • z_min and z_max determine the range of prismatic cells in z- (longitudinal) direction.
  • long_connector_ratio is the length of longitudinal joints, with joint length = long_connector_ratio * fiberlength.
  • merge_operation flag can be turned on/off for the merging operation, when flag is on, cell ridges that are shorter than the threshold merge_tol in the 2D mesh will be deleted, and their vertices will be merged respectively, the mesh will be reconstructed. This is designed for eliminating small cell ridges/walls which fall out of the resolution range of the 3D printing and for avoiding having elements with too small stable time increments in numerical simulations.
  • precrackFlag flag is for inserting a pre-crack, for the notched specimens. So far, only a single line pre-crack with the length of precrack_widths is supported.
  • stlFlag flag can be turned on/off for generating 3D STL files.
  • inpFlag flag can be turned on/off for generating input files for numerical simulations.
  • inpType indicates the software(s) that the mesh generation should generate input files for.

MeshGenerator

2.1. Run Mesh Generation

Open a Command Prompt or Terminal window and set the current directory to tests or any other directory, then run the command:

    python test_wood_cube.py

Functions in MeshGenTools library will be called to create the initial mesh, wood cell particles following certain cell size distribution will be placed, then Scipy.voronoi function will be called to form the initial 2D Voronoi tessellation, additional code reforms the tesselation and generates the desired files. A successful generation will end with the line "Files generated ..." in the Terminal window.

A new folder should have been created in the .\meshes directory with the same name as the geoName in test_wood_cube.py.

2.2. Check Mesh and 3D Model Files

The following files should be generated in the .\meshes\geoName directory with a successful run:

  • Mesh files
    • Non-Uniform Rational B-Splines (NURBS) beam file: wood_cubeIGA.txt
    • connector data file: wood_cube-mesh.txt
    • Grain-ridge data file: wood_cube-vertex.mesh
    • Ridge data file: wood_cube-ridge.mesh
  • Visualization files
    • Cross-sectional image file for initial 2D configuration: wood_cube.png
    • Paraview vtk file for initial vertex configuration: wood_cube_vertices.vtu
    • Paraview vtk file for initial grain solid configuration: wood_cube_beams.vtu
    • Paraview vtk file of initial cell ridge configuration: wood_cube_conns.vtu
    • Paraview vtk file of initial connector (volume) configuration: wood_cube_conns_vol.vtu
  • (Optional) 3D model files
    • STL file of initial cellular solid configuration: wood_cube.stl
  • (Optional) Abaqus input files
    • INP file of simulation input of initial cellular solid configuration in Abaqus: wood_cube.inp

3. Visualization

A scientific visualization application ParaView can directly visualize the generated vtk files; It can also visualize generated 3D model STL files if the STL flag is on. Paraview is a free software, it can be downloaded from its official website: https://www.paraview.org/download/, latest version is recommeded.

3.1. Visualize Components of the 3D Model in ParaView

1. Open ParaView
2. Recommeded to temporarily turn off ray tracing
    - Uncheck "Enable Ray Tracing" (bottom left)
3. Open File Sets in `.\meshes\geoName`
    - File > Open...
4. Select the visualization files containing: `_vertices.vtu`, `_beams.vtu`, `_conns.vtu`
5. Apply to visualize
    - Press Apply (left side, center)
6. Turn on color plotting
    - Left click `_conns.vtu`, then select coloring (mid/lower left) > Connector_width
7. Scale and position the image as desired
8. Turn back on Ray Tracing
9. Adjust Ray Tracing lighting and settings as desired
10. Export Image
    - File > Save Screenshot
    - Enter a file name > OK
    - Leave new window as-is or increase resolution > OK

3.2. Visualize Volumes of the 3D Model in ParaView

1. Open Paraview
2. Recommeded to temporarily turn off ray tracing
    - Uncheck "Enable Ray Tracing" (bottom left)
3. Open File Sets in `.\meshes\geoName`
    - File > Open...
4. Select the newly created visualization files containing: `_conns_vol.vtu`
5. Apply to visualize
    - Press Apply (left side, center)
6. Turn on color plotting
    - Left click `_conns_vol.vtu`, then select coloring (mid/lower left) > Connector_width
7. Scale and position the image as desired
8. Turn back on Ray Tracing
9. Adjust Ray Tracing lighting and settings as desired
10. Export Image
    - File > Save Screenshot
    - Enter a file name > OK
    - Leave new window as-is or increase resolution > OK

ModelVisualization

4. (Optional) Numerical Simulation

The mesh generation tool can also prepare the input files for the numerical simulations of the cellular solid in other softwares. By now (version 0.3.0), the input file format, .inp, that is used in a finite element method (FEM) software Abaqus is supported, if the INP flag is on. Abaqus is a commerical software suite for integrated computer-aided engineering (CAE) and finite element analysis, own by Dassault Systèmes. One may refer to its Wiki for more about Abaqus, and to Introduction for the introduction of Abaqus input files.

All steps for the model setup can be accomplished through manually coding the Abaqus input file in a text editor. The method used in the example procedure shown below requires access to the Abaqus GUI.

4.1 Create New Model

1. Open Abaqus CAE
2. Create a new model
    -	File > New Model Database > With Standard/Explicit Model

4.2 Import Meshed Part

1. Import the meshed part
    - File > Import > Part
    - Select the newly created file which ends in `.inp` (note: you may need to change the File Filter to see this file)
    - Click OK
2. Rename part
    - Under the model tree (left) expand `Parts`
    - Right click on the part > Rename...
    - Enter a new name less than 14 characters, no special symbols, and easily recognizable (i.e. "WoodCube")

Note: if FEM parts will be added to the model, this RingsPy generated part must come first alphabetically. Also recommended not to include numbers in the name.

Contributing

Contributions are always welcome!

If you wish to contribute code/algorithms to this project, or to propose a collaboration study, please send an email to haoyin2022 [at] u.northwestern.edu .

License

License: GPL v3

Distributed under the GPL v3 license. Copyright 2022 Hao Yin.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ringspy-0.3.5.tar.gz (54.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ringspy-0.3.5-py3-none-any.whl (49.9 kB view details)

Uploaded Python 3

File details

Details for the file ringspy-0.3.5.tar.gz.

File metadata

  • Download URL: ringspy-0.3.5.tar.gz
  • Upload date:
  • Size: 54.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.8

File hashes

Hashes for ringspy-0.3.5.tar.gz
Algorithm Hash digest
SHA256 21e09f5375091cd18ff15b5fb6c3f771c05d36e565183e9ee760f1ce8211c7d0
MD5 5487e4ebfa38e0d7bd34bf8883b9e7e7
BLAKE2b-256 d2268732fe94d3bd45b198b9a5c82b820a275f036204563b78df0183b7a9e265

See more details on using hashes here.

File details

Details for the file ringspy-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: ringspy-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 49.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.8

File hashes

Hashes for ringspy-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1bbc297f07f8461a33302901e8cb032f84c83afdf4af3f0537fd585e2a39af9b
MD5 38473f707743c4a7d0193e2c15c8496b
BLAKE2b-256 faef6faff36729d5243d9990547fcf355d93631d5fe0361227a749976da1f759

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page