Skip to content

kludda/TPMS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TPMS

Generates a mesh representing a Schoen gyroid, which is is an infinitely connected triply periodic minimal surface discovered by Alan Schoen in 1970.

The exiting thing with the gyroid is the high surface area and turbulent flow which makes it suitable for heat exchanger applications.

Currently, parametric CAD softwares aren't suitable to draw these kind of surfaces so they need to be created as mesh.

This is, as far as I know, the only open source gyroid generator that:

  • can generate alternating lids, creating a heat exchanger core with separated hot/cold volumes, while also
  • does not rely on any other software than Python and Python packages.

Buy me a coffee :)

Config for the left:
metadata:
  filename: gyroid_s150-60-100_r300_he1_p15_s0
mesh:
  size: [150, 60, 100]
  resolution: 300
  cuboid heat exchanger: 1
gyroid:
  periodicity: 15
  strut param: 0

Config for the right:

metadata:
  filename: gyroid_s60-60-150_r300_cylhe1_p15_s0
mesh:
  size: [60, 60, 150]
  resolution: 300
  cylinder heat exchanger: 1
gyroid:
  periodicity: 15
  strut param: 0

Inital setup

You need python installed. (Python doc on Windows)

Clone repo (or download and unzip https://github.com/kludda/TPMS):

git clone https://github.com/kludda/TPMS.git

Enter TPMS folder using a shell e.g. Windows Powershell.

Not necessary but highly recommended: set up a virtual environment for python and activate (commands are for Windows, if you're on *nix you probably know how to find out):

python -m venv .\.venv 
.\.venv\Scripts\activate

Install required packages:

python -m pip install -r requirements.txt

You can edit requirements.txt and remove matplotlib if you don't want to use --png or --show.

CLI

usage: generate.py [-h] [--log LOG] --conf CONF [--stl] [--txt] [--png] [--show]

options:
  -h, --help   show this help message and exit
  --log LOG    DEBUG, INFO, WARNING
  --stl        Save mesh to STL. Will overwrite if exist.
  --txt        Save conf and extra data to a text file as prettyfied json. Will overwrite if exist.
  --png        Save a PNG. Will overwrite if exist.
  --show       Show generated mesh in a window.

required:
  --conf CONF  Your configuration file.
  • --conf CONF Your YAML configuration file containing the parameters of the mesh to generate.

  • --stl Save the generated mesh to an STL. Will overwrite existing file.

  • --txt Save configuration and some extra data to a text file as prettyfied json. Useful if you generate multiple meshes and want to know what parameters you used. Will overwrite existing file.

  • --png Save a image ISO view of the PNG. Useful if you have multiple mesh files and quickly want to find the one to import. Will overwrite existing file. The tool currently use Matplotlib to create this image. Matplotlib performance for this is low, generating images for high resolution will be very slow.

  • --show Show generated mesh in an interactive view. The tool currently use Matplotlib to create interactive view. Matplotlib performance for this is low, viewing high resolution mesh will be very slow.

  • --log LOGLEVEL DEBUG, INFO, WARNING (default). The tool is quiet unless setting loglevel.

Example usage:

python generate.py --log INFO --conf gyroid.yaml --txt --stl

Configuration file

metadata:
  description: Gyroid example
  filename: gyroid_example

mesh:
  size: 40
  size: [40, 20, 40]
  resolution: 40
  thicken: 1
  cap extremes:
  heat exchanger: 1
  
gyroid:
  periodicity: 2
  strut param: 0
  • metadata:

    • filename: Required. The filename, without ending, to use for the generated files.
    • You can add any tag, like description, anywhere, as long as they don't confilict with existing tags, and they will be saved in the text file.
  • mesh:

    • size: Required. Size of geometry.
      If size is an int or a float; the tool will generate a cube.
      If size is an array; the tool will generate a rectangular cuboid with sides of length [x, y, z].

      Note: size is the size of the gyroid surface or solid. Any "caps" or "lids" are outside size (special case cylinder heat exchanger). Origin of gyroid surface or solid is however always at (0, 0, 0) in output file.

    • resolution: Required. The resolution of the largest size. If too coarse the mesh will not generate properly. If too fine the mesh will be unnecessarily large and difficult to post process.

      Tip: Mesh resolution starting point for gyroid: periodicity × 20. If e.g. thickening with small thickness; resolutions needs to be higher. If there are artefacts in the geometry; try increasing the resolution.

    • thicken: Optional. Thickness in size units. Offset the surface (thicken / 2) to each side.

    • cap extremes: Optional. Puts a "cap" on the surface at the bounding box extremes. This makes an infinitely connected surface a "solid". The "caps" are convex.
      Use with thicken to make a shell.
      Use without thicken to make a skeletal.

    • cuboid heat exchanger: Optional. Generates a rectangular cuboid heat exchanger core by creating alternating lids on volumes in X and Y. Caps the entire face in Z. Value is the thickness in size units. The lids will have a thickness of round(cuboid heat exchanger / (max(size) / resolution)). Use with cylinder heat exchanger, thicken or cap extremes is an error.

    • cylinder heat exchanger: Optional. Generates a cylindrical heat exchanger core by creating lids on lateral surface (X,Y) and end surfaces (Z). Value is the thickness in size units. Radius of cylinder is min(size X, size Y)/2). Height is Z. The lids will have a thickness of round(cylinder heat exchanger / (max(size) / resolution)). The lids on the lateral surface is created inside size. Use with cuboid heat exchanger, thicken or cap extremes is an error.

  • gyroid:

    • periodicity: Required. The number of periods within max(size).

    • strut param: Required. 0 ➝ a gyroid, <0< ➝ gyroid-like. In practice strut param ≠ 0 makes the volumes in the gyroid asymmetrical. (The surfaces overlap somewhere around +/- 0.95.)

Post process

Mesh cleaning and simplification

Ideas for post process in MeshLab:

  • There will be duplicate vertices in the output file. Remove them:
    Filters ➝ Cleaning and Repairing ➝ Remove Duplicate Vertices

  • If you want to reduce the mesh, here's a starting point:
    Filters ➝ Remeshing, Simplification and Reconstruction ➝ Quadratic Collapse Edge Decimation
    Target number of faces: blank
    Percentage reduction: 0.3
    Preserve Normal: check
    Preserve Topology: check
    Optimal position of simplified vertices: check
    Planar Simplification: check
    Planar Simp. Weight: 0.00001
    Post-simplification cleaning: check

Parametric CAD

Working with a large mesh in parametric CAD is an absolute pain.

I suggest you merge the geometries in a mesh software, e.g. MeshLab, instead. Since an additive manufacturing method is required to make the heat exchanger, I think it is an acceptable approach.

Ideas on work flow:

  1. Generate a heat exchanger core using this tool.
  2. a. Design the heat exchanger shell as printed with inlets, outlets etc. in your parametric CAD software. Ensure your heat exchanger core can be inserted at origin (0, 0, 0). Mind the orientation.
    b. Export the as printed heat exchanger shell to mesh.
    c. Optional as needed: import your as printed design to a separate design and add your post processing steps (e.g. machinging, surface finnish, ...).
  3. a. Import as printed heat exchanger shell and heat exchanger core to a mesh software, e.g. MeshLab. In case of MeshLab, at least, the mesh will imported to (0, 0, 0) and is ready to be merged.
    b. Merge mesh.
    c. Export mesh.

Examples

Rectangular cuboid gyroid heat exchanger

mesh:
  size: [80, 60, 80]
  resolution: 80
  cuboid heat exchanger: 1
gyroid:
  periodicity: 4
  strut param: 0

Cylindrical gyroid heat exchanger

mesh:
  size: [60, 60, 80]
  resolution: 120
  cylinder heat exchanger: 1
gyroid:
  periodicity: 10
  strut param: 0

Gyroid surface

mesh:
  size: 40
  resolution: 40
gyroid:
  periodicity: 2
  strut param: 0

Offset gyroid surface

mesh:
  size: 40
  resolution: 40
  thicken: 1.2
gyroid:
  periodicity: 2
  strut param: 0

Thickened gyroid surface

mesh:
  size: 40
  resolution: 40
  thicken: 2
  cap extremes:
gyroid:
  periodicity: 2
  strut param: 0

Skeletal gyroid-like surface

mesh:
  size: 40
  resolution: 40
  cap extremes:
gyroid:
  periodicity: 2
  strut param: -0.7

About

Gyroid mesh generator written in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors

Languages