Skip to content

3D foam example #68

Answered by kip-hart
Kresa96 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Kresa96,

You could avoid the voronoi step by creating a list of void spheres, then test whether each voxel is inside a sphere or not.

For example, the following code would create the voids:

import microstructpy as msp
import numpy as np
import scipy.stats

# Create Voids
material_1 = {
    'name': 'Voids',
    'material_type': 'void',
    'fraction': 1,
    'shape': 'sphere',
    'size': scipy.stats.uniform(loc=0, scale=1.5)
}
# Create Domain
domain = msp.geometry.Cube(side_length=15, corner=(0, 0))

# Create List of Un-Positioned Seeds
porosity = 0.12;
seed_volume = porosity * domain.volume
rng_seeds = {'size': 1}
seeds = msp.seeding.SeedList.from_info([material_1],
                 …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kip-hart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants