AMME4981 Applied Biomedical Engineering AMME9981 Computational Biomedical Engineering Tutorial Week 10 Internal bone remodelling Introduction This tutorial will introduce the necessary steps to simulate internal bone remodelling of an implanted femur using ANSYS. You will learn to: • Setup and export mesh data from Workbench • Generate an APDL input file for use with ANSYS Classic • Call a pre-compiled Fortran subroutine during solution Step 1: Prepare geometries for the femur and implant The preparation of a realistic implanted femur geometry was detailed in week 4’s tutorial. This involved the removal of the head and neck of the segmented femur in ScanIP using the 3D editing tools. After completing the steps detailed in week 4’s tutorial, you should end up with the following femur bone geometry. Export this geometry from ScanIP as an IGS file. The femoral component of the hip implant is available for download on the course website (FemoralImplant.IGS), under the tutorial content for week 4, shown below. AMME4981 Applied Biomedical Engineering AMME9981 Computational Biomedical Engineering Once you have both IGS geometries, they can be imported into Workbench. While it is possible to import geometries directly into ANSYS Classic, the CAD interfaces in Workbench are significantly more modern and work much better with external geometry files. Start a new Mechanical Model module in the Workbench project window. Double-click on geometry to open Design Modeler. Import both the femur and implant geometries. They should look something like this: The process of aligning these two geometries is provided in the week 4 tutorial. This involves a simple body translation to move the implant into the correct position as shown. Once correctly aligned, a cavity for the implant in the femur is required. Use the Boolean subtraction function provided in Design Modeler (Create > Boolean) to AMME4981 Applied Biomedical Engineering AMME9981 Computational Biomedical Engineering create this cavity. Remember to select the femur as the target body and the implant as the tool body, and ensure Preserve tool bodies is enabled (Yes). Pay attention! At this point, the instructions deviate from week 4’s tutorial. For this model, we are going to assume that the bone and implant are glued together. We could allow Workbench to apply the default bonded condition to the contact surfaces between these two geometries, but the simplest way to define this relationship is to form a single part. Do this by selecting both geometries in the tree outline, right-clicking and choosing Form New Part. For the mesh-savvy amongst you, forming a new part enforces a contiguous mesh between the implant and the bone. This means that the implant and bone will share the same nodes along their interface, effectively gluing the two bodies together, and negating the need for special contact conditions. The result will be a single part containing two individual bodies. Don’t worry, separate material properties may still be assigned to these two bodies. Close the Design Modeler window, and it’s probably a good idea to save your project file at this point. Step 2: Generating the mesh in Workbench Now the material properties can be set up in the Mechanical Model module. Open Engineering Data and make two isotropic elastic materials: Bone and Implant. It doesn’t matter what Young’s modulus and Poisson’s ratio you specify in this section; they will just act as placeholders for the bone and implant mesh objects. A Young’s modulus of 1 for the bone and Young’s modulus of 2 for the implant will suffice. Close Engineering Data and open the Model component. This will launch the Mechanical application window. First, assign the bone and implant materials to their respective bodies. The next thing to do is generate a mesh for the model. For this AMME4981 Applied Biomedical Engineering AMME9981 Computational Biomedical Engineering tutorial, it’s sufficient to just keep most of the default mesh settings. However, you should keep element mid-side nodes to generate quadratic (second-order) elements. Do this in the Advanced section of Mesh details, as shown below. Although we should technically do a mesh convergence study to verify the accuracy of our finite element model, we’re going to skip this for the sake of brevity. The last thing we need to do in the Mechanical application is to define a named selection for face on the neck of the femoral implant. Select the face and add it as a named selection as below. This will make it easier to apply forces using APDL. AMME4981 Applied Biomedical Engineering AMME9981 Computational Biomedical Engineering Step 3: Using FE Modeler to export the mesh Once the mesh and named selection have been generated, close the Mechanical application window. Insert an Finite Element Modeler module into the Workbench project window, and link the model component of the Mechanical Model module to it. The FE Modeler module enables the export of mesh objects created in Workbench to a variety of formats, including to ANSYS Classic by creating an APDL input file. It will also translate the materials specified in Engineering Data and the Named Selections defined in the Mechanical application to their APDL analogues. Before opening FE Modeler, ensure that the unit used for the model are in metres, not millimetres. You can do this by checking the Properties of the Assembly Mesh in the Outline pane. If you don’t see Outline and Properties panes, go to View > Outline and View > Properties in the project window. Open FE Modeler by double-clicking the Model component. Ensure that the Target System is Mechanical APDL. You can check out the features of your mesh in the outline tree. If all the instructions have been followed correctly, all you need to do is click on Write Solver File. This writes all the mesh data to an APDL input file. You can preview the contents of this file under Generate Data. Name your input file “A3_mesh.inp” so it can be identified later. AMME4981 Applied Biomedical Engineering AMME9981 Computational Biomedical Engineering Step 4: Editing the generated APDL input file After saving the APDL input file from FE Modeler, close and save your Workbench project file. The remainder of this project will take you through the steps needed to create a solvable APDL input file. APDL input files are just text files. You can open them in any text editor. The input file generated from FE Modeler contains the locations of all the nodes, and the definitions of all the elements from those nodes, and is therefore quite large for a text file. Use Notepad++, which is available on the PCLAB computers, to open this input file. Your input file will probably start off like this: /PREP7 SHPP,OFF /NOPR ! ! COORDINATE SYSTEMS ! ! ! MATERIAL PROPERTIES ! /com, Materials <SECTION=MATERIALS> ! Origin Material Property ID - 23 MP,EX,1,1, ! Pa MP,NUXY,1,0.3, ! Origin Material Property ID - 25 MP,EX,2,2, ! Pa MP,NUXY,2,0.3, ! ! PHYSICAL PROPERTIES ! ! ! ELEMENT TYPES ! /com, Element Types <SECTION=ELEMENTTYPES> et,1,MESH200 keyopt,1,1,9 Some of these commands will be explained later in this tutorial when you work with the template input file. The ! character denotes a comment, as does the /com command. Briefly, the above set of commands opens the pre-processing module (PREP7), sets up two materials (MP), with Young’s modulus (EX) and Poisson’s ratio (NUXY), and then specifies a type of element to use (ET), which is called MESH200. The Young’s modulus and Poisson’s ratio of the materials you specified in Engineering Data previously should be reflected in the MP commands. All we want in this input file is the definition of the nodes, elements, and the named selection, which is called a component in APDL. So either delete, or comment out the above selection of commands. You should end up with the nodal listing (list of node numbers and their co-ordinates): nblock,3 (1i8,3e20.9e3) <nodes> AMME4981 Applied Biomedical Engineering AMME9981 Computational Biomedical Engineering and the element listing (list of element numbers, the material number, element type, and the nodes that are used to construct them): eblock,19,solid,12307 (19i8) <elements> and the component listing (component from the Named Selection, and the associated node numbers): CMBLOCK,NECK ,NODE, 37 (8i10) <nodes> Note that the CMBLOCK command, which is used to define the component, specifies 37 nodes. This is important later, when we apply forces on these nodes. Then go to the very end of the input file (Ctrl+End), and delete the following unnecessary commands. ! ! BOUNDARY CONDITIONS ! ! ! LOADS ! ! ! Solution ! ! ! Turn output back on ! /GOPR ! FINI /GOPR You can now save this input file. Step 5: Generating a solvable APDL input file Download the template APDL file from the course website, under the week 10 tutorial content, and open this in Notepad++. Most of the input file has been commented in-line, however some important commands will be detailed here. Full descriptions of each command and the associated options are detailed in ANSYS Help (under Mechanical APDL > Command Reference). To enable the set-up of model, /PREP7 command is issued to activate the pre- processing modules in ANSYS. After this, we can define the materials, mesh, and loads. AMME4981 Applied Biomedical Engineering AMME9981 Computational Biomedical Engineering et,1,SOLID187 defines element type number 1 as a SOLID187, which is a 10- node tetrahedral element (10 nodes means it has mid-side nodes and therefore has quadratic shape functions). This matches the type of mesh we defined in Step 2. Next we need to define the material properties of the femur bone (material number 1). As the Young’s modulus of the femur bone is going to change in response to a mechanical stimulus, TB,ELASTIC,1 is used to make a material table that can be used to define changing elastic material properties (i.e. Young’s modulus and Poisson’s ratio). In addition, we need a specify a user-defined field variable (UF01) that can be changed in this manner using a subroutine. In this example, UF01 is going to be the Young’s modulus, so the relationship between UF01 and the Young’s modulus in the material table is going to be perfectly linear (with a gradient of 1). We can make this happen by using the TBFIELD and TBDATA commands to define two points that will define a straight line. See the table below to see what this means. UF01 Young’s modulus (Pa) 1 1 1000000000000 1000000000000 This work-around allows us to directly change the Young’s modulus of the bone by changing UF01 using a Fortran subroutine. Note that the Poisson’s ratio will stay the same here. TB,STATE,,1 is another work-around in the APDL input that allows us to store custom data in the results. This defines a single state variable that we will use to store bone density, which will then be plotted after the model is solved. The implant is then given regular material properties using the MP command. You can change the numbers to give the implant a Young’s modulus (EX) and Poisson’s ratio (NUXY) of your own choosing. Next, it’s time to import the mesh you defined in the “A3_mesh.inp” APDL file. You can insert it using: /INPUT,A3_MESH,inp. This type of command can be used to input any APDL code into the file without having to copy and paste it over. Following this are commands that give an initial value to the UF01 field variable that was defined earlier. The femur bone elements need this for the first time-step (before any bone remodelling has occurred). In this example, we’ve assumed that the bone is completely homogeneous, and has a Young’s modulus of approximately 10.5 GPa. To fix the base of the femur, the nodes on the bottom face of the femur need to be selected. The following commands select these nodes, set their displacements in the AMME4981 Applied Biomedical Engineering AMME9981 Computational Biomedical Engineering X, Y, and Z directions to 0, and then re-select everything to prevent confusion with the following commands. NSEL,S,LOC,Z,-445.9e-3 D,ALL,UX,0 D,ALL,UY,0 D,ALL,UZ,0 ALLSEL Forces in the Z direction (FZ) can be applied onto the component/named selection that was defined from Workbench. Specify the name of the component (NECK) when issuing the F command. Forces can also be applied in the X (FX) and Y (FY) directions as well by issuing multiple commands. Note that the force is applied to each node, so we divide the total force by the number of nodes noted earlier in the component definition (37 nodes for the example given in Step 4). The final part of the APDL input file specifies the solution settings. antype,transient time,24 deltim,1 outres,all,all outres,svar,all solve finish save These commands specify a transient analysis type (ANTYPE), which will terminate at time = 24 (TIME), in increments of 1 (DELTIM), and export all the results for all the time-steps (OUTRES), including the state variable (SVAR) which will contain the bone density data. SOLVE executes the solution. SAVE creates a .DB file that can be used to reopen the model in the ANSYS Classic GUI. You may add your own post-processing commands to save the bone density plots automatically after it finishes solving (see Appendix). Once you have completed creating the APDL input file, save it with a different filename (e.g. A3_solve.inp) Step 6: Solving using the pre-compiled USERFLD subroutine As described in the lecture, the APDL input is a high-level scripting language, which is interpreted line-by-line by the ANSYS program. In this tutorial, APDL input has been used to define the nodes and elements of the model, and set up the various boundary conditions and material properties. To simulate the internal remodelling in the femur bone, a USERFLD subroutine needs to be run at the end of every time-step to update the bone density, and therefore, the Young’s modulus (which corresponded to the user-defined field, UF01 in the APDL file). These changes in Young’s modulus affect the mechanical stimulus experienced by the femur bone in the next time-step. The subroutine is written in AMME4981 Applied Biomedical Engineering AMME9981 Computational Biomedical Engineering Fortran, which is a lower-level programming language that needs to be compiled to an executable object before ANSYS can execute it. Luckily in this tutorial, we can use a pre-compiled subroutine, which saves a lot of trouble. The commented source code and pre-compiled objects necessary to solve the model are downloadable from the course website. Please download this and examine the source code (USERFLD.F) to identify the steps and relationships used to translate the mechanical stimulus to a change in bone density and Young’s modulus. All the files should be placed in your working directory. It is ideal to make the working directory as a new folder on the Desktop if you are in the PCLAB. The most efficient way of running ANSYS is using the batch interface. From the Windows Start Menu, open cmd.exe. Use the cd command to navigate to your working directory. An example navigating to the folder “assignment” on the Desktop is provided below. cd C:\Users\your_unikey\Desktop\assignment Before we run our APDL input file (A3_solve.inp), ANSYS needs to know if there is a subroutine we would like to use, and where it is located. Let’s assume you followed the instructions above and put all the pre-compiled files into the working directory (e.g. “assignment”). Use the following commands to set a temporary ANSYS environmental variable, and check that it has been set properly. set ANS_USER_PATH=C:\Users\your_unikey\Desktop\assignment echo %ANS_USER_PATH% Finally, it is time to run ANSYS. “C:\Program Files\ANSYS Inc\v161\ansys\bin\winx64\ansys161.exe” –b –j A3 –i A3_solve.inp –o A3.out -b means batch mode -j specifies the job name (and the name of the files that get dumped in your working directory) -i specifies the name of the APDL input file -o specifies the name of an output file, from which you can monitor the status of your job and any errors or warnings that occur. On UNIX systems, there is a tool called tail, but on Windows, you can download a program called baretail.exe to watch the output file as new events get added to it. Once the job has completed successfully, you can open the generated .db file by double-clicking on it, which will open the ANSYS Classic GUI.
Description: