Skip to content

Latest commit

 

History

History
127 lines (94 loc) · 7.87 KB

README.md

File metadata and controls

127 lines (94 loc) · 7.87 KB

microFE

TUoS INSIGNEO CompBioMed

License

Installation (ShARC)

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 m_files/main_win.m file.

Usage

The entire pipeline is run by

$ python microFE.py -c config.ini

where 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.

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

By specifying only the Young's modulus E, the analysis will be linear elastic, whereas including also yield_stress and Et (the tangent Young's modulus) the analysis will be elastic-perfectly-plastic.

Matlab mesher

In m_files\ there is the code for generating FE models with cartesian mesh and homogeneous material properties. The original mesher code is in /m_files/mesher.m.

The following inputs are required:

  • greyscale images (.tiff format);
  • voxel size (Image_Resolution);
  • threshold for defining bone tissue;

The 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.

Outputs

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

Citation

The Matlab code was developed by Y. Chen as part of his PhD project: