Log in and create conda environment
$ qrshx $ module load apps/python/conda $ cd <path to>/microFE/ $ conda env create -f environment.yml
Compile matlab code as
$ cd m_files/ $ module load apps/matlab/R2016a $ ./compile.sh
In case you want to run the workflow in Windows, compile
The entire pipeline is run by
$ python microFE.py -c config.ini
config.ini is a generic configuration file. Meshing and FE solver are run by submitting a batch job. See
microFE.sh for an example file which you can run as
qsub microFE.sh in ShARC. All the parameters are specified in the
.ini configuration file.
The meshing process requires the definition of a number of paths and variables. These are defined in a
.ini configuration file
[directories] CT_IMAGE_FOLDER = <CT image location> OUTPUT_DIR = <output folder path> MESHER_SRC = <folder containing the compiled matlab code> LD_LIB_PATH = <matlab executable path, $LD_LIBRARY_PATH on ShARC> [images] img_name = <microCT DICOM image name> [mesher] threshold = <bone tissue threshold in uCT images, e.g., 18500> resolution = <voxel size in uCT images in micron, e.g., 19.96> [fem] boundary_condition = <`displacement` or `load`> units = <`mm` or `percent` for `displacement`, `N` for `load`> direction = <`x`, `y`, or `z`> sign = <`positive` or `negative`> amount = <diplacement or load amount; float> constrain = <`full` or `free`> E = <Young's modulus in Pa; float> yield_stress = <yield stress value in Pa - only for plastic-elastic model; float> Et = <tangent Young's modulus in Pa - only for plastic-elastic model; float> [job] name = <job name> np = <number of processes>
The element used in ANSYS APDL is the 8-nodes SOLID185
m_files\ there is the code for generating FE models with cartesian mesh and homogeneous material properties. The original mesher code is in
The following inputs are required:
- greyscale images (
- voxel size (
- threshold for defining bone tissue;
m_files/main.m file executes the mesher.
The script in
m_files/compile.sh compiles the matlab scripts with the matlab compiler. Compiled files can be run with the matlab runtime environment.
After executing microFE.py, the results will be saved in
OUTPUT_DIR/ folder as specified in the
.ini configuration file. The folder structure will be
<OUTPUT_DIR>/ |- elementdata.txt (mesh elements list) |- nodedata.txt (mesh nodes list) |- fe_model.txt (Ansys model script) |- microFE.py.log (log file) |- Binary/ (Binary slices from microCT image) | |- binary0001.tif | |- binary0002.tif | |- ... |- tiff/ (microCT slices converted to tiff from DICOM) | |- <img_name>_0001.tif | |- <img_name>_0002.tif | |- ... |- NodalDisplacements.txt (nodal displacement from FEM solution as: node, x, y, z) |- <job_name>.db (Ansys output files) |- <job_name>.err |- <job_name>.esav |- <job_name>.log |- <job_name>.mntr |- <job_name>.PCS |- <job_name>.rst |- <job_name>.stat
The Matlab code was developed by Y. Chen as part of his PhD project:
Chen Y, Pani M, Taddei F, Mazzà C, Li X, Viceconti M. Large-scale finite element analysis of human cancellous bone tissue micro computer tomography data: a convergence study. Journal of biomechanical engineering. 2014 Oct 1;136(10):101013.
Chen Y, Dall'Ara E, Sales E, Manda K, Wallace R, Pankaj P, Viceconti M. Micro-CT based finite element models of cancellous bone predict accurately displacement once the boundary condition is well replicated: A validation study. Journal of the mechanical behavior of biomedical materials. 2017 Jan 31;65:644-51.