chfem.compute_properties module

chfem.compute_properties.compute_property(property, array, mat_props=None, voxel_size=1e-06, solver=None, solver_tolerance=1e-06, solver_maxiter=10000, precondition=True, type_of_rhs=0, refinement=1, xreduce='full', direction='all', output_fields=None, nf_filepath=None)[source]

Computes the effective property of a material using chfem.

This function calculates the effective thermal conductivity, linear elasticity, or permeability of a material sample characterized by a 3D domain. The domain is discretized into voxels, each assigned a material phase with specific properties. It interfaces with the chfem cuda/c library to perform image-based finite element analysis.

Parameters:
  • property (str) – The physical property to be computed (‘conductivity’, ‘elasticity’, ‘permeability’).

  • array (np.ndarray) – 3D numpy array representing the material domain, where each voxel’s value is the material phase.

  • mat_props (dict) – Material properties corresponding to each phase in the domain, provided as {phase_id: cond} for conductivity and {phase_id: (young, poisson)} or {phase_id: (young, poisson, alpha)} for elasticity, None for permeability

  • voxel_size (float, optional) – The edge length of each voxel in the domain, defaults to 1e-6 meters.

  • solver (str, optional) – The type of solver to use (‘cg’ for Conjugate Gradient, ‘minres’ for MINimal RESidual). Defaults to ‘cg’ for conductivity and elasticity, and ‘minres’ for permeability. Options: ‘cg’, ‘minres’ (5 vectors implementations, faster but more memory), ‘cg3’, ‘minres3’ (3 vectors, slower but less memory), ‘cg2’, ‘minres2’ (2 vectors, less memory but not fields output).

  • solver_tolerance (float, optional) – The tolerance for the solver convergence criterion, defaults to 1e-6.

  • solver_maxiter (int, optional) – The maximum number of iterations for the solver, defaults to 10000.

  • precondition (bool, optional) – Flag to use preconditioning in the solver, defaults to True.

  • type_of_rhs (int, optional) – Type of the right-hand side in the system of equations, defaults to 0.

  • refinement (int, optional) – Refinement level for the domain discretization, defaults to 1.

  • xreduce (str or float, optional) – Reduction strategy for 2-vector solvers (‘full’, ‘diag’, float: stablization factor ), defaults to ‘full’.

  • direction (str, optional) – Direction for calculating the property (‘x’, ‘y’, ‘z’, ‘yz’, ‘xz’, ‘xy’, ‘all’), defaults to ‘all’.

  • output_fields (str, optional) – File path to output the fields (e.g., displacement, temperature), defaults to None.

  • nf_filepath (str, optional) – Provide the path to a Neutral File (.nf) to specify the simulation settings.

Returns:

The effective property coefficient.

Return type:

list

Example:

>>> import chfem
>>> array = np.zeros((80, 90, 100), dtype=np.uint8)
>>> array[20:60, 30:70, 30:70] = 255
>>> keff = chfem.compute_property('conductivity', array, mat_props={255: 1, 0: 0.1}, direction='x', output_fields="cubes")
>>> Ceff = chfem.compute_property('elasticity', array, mat_props={255: (200, 0.2), 0: (100, 0.3)}, direction='x', output_fields="cubes") 
>>> Keff = chfem.compute_property('permeability', array, direction='x', output_fields="cubes")