Bio-tissue is often in a certain state of pre-stress in the human body, for example, the cornea is under intraocular pressure, the blood vessel is under blood pressure and et al. So whatever method we use to measure the configuration of the tissue, we can not get the load-free configuration(or be called initial configuration), which is needed in abaqus modeling.
In this project, we use the direct method to obtain the initial configuration. Assume that we have a target configuration
- Start with our only known target configuration
$A$ as initial configuration$A_0$ - Apply load
$F$ to$A_0$ , and get the result configuration$A^*$ - Calculate the difference between
$A^{*}$ and the target configuration$A$ , to get the difference field$U=A^{*}-A$ - Check if the difference field
$U$ is small enough, if yes, then stop the iteration and$A_0$ is the result of initial configuration; if not, then update the initial configuration$A_0$ by$A_0 = A_0 - U$ and go back to step 2.
In this project, we use a internal pressure loaded cylinder as an example of the direct method. You can simply replace the example job file to your own one, the code still works. You should refer to different folders regarding to the dimension of your model, 2D or 3D.
main_program.py is the main program, IdentifyInitialConfiguration.py is a module for defined functions, Step-1.inp, Step-2.inp and GenerateStep-3.py are files you should prepare based on your job file. The code interpretation for the program is as follows:
main_program.pyopens a powershell to submitStep-1.inpto abaqus- After the calculation is complete, read the initial coordinates and displacement field of the node set
allnodes, save asinitial_X0anddis_datarespectively. - Implement
-dis_datatoStep-2.inpand submit to abaqus. - After the calculation is done,
main_program.pycallsGenerateStep3.pyto generateStep-3.inpbased on the deformed shape ofStep-2, and submit to abaqus. - After
Step-3is complete, read the initial coordinates and displacement field of the nodesetallnodes. Check if the deformed shape meet the requirements of the tolerance. - If not, recalculate the displacement that should be implement to
Step-2and go to3.. - If so, the procedure is done and
Step-3.inpis the model with pre-stress that we wanted.
Here we introduce how to prepare the needed files based on your job.
-
Prepare
Step-1.inp- First, after you have complete your own abaqus job file, you need to select all the nodes that are not fixed(all nodes in the model except the nodes of the fixed boundary) and create a nodeset named
allnodes. - Then you can write the
.inpfile of your job, and save it asStep-1.inpin your abaqus working directory. - You need to add the following code to the end of your
.inpfile before the line of*End Step:
*node print, nset=allnodes U - First, after you have complete your own abaqus job file, you need to select all the nodes that are not fixed(all nodes in the model except the nodes of the fixed boundary) and create a nodeset named
-
Prepare
Step-2.inp- Everything is the same as your own job file, except the load section. You should remove your force load
$F$ , and add a displacement load toallnodes, which is based on a user subroutine DISP (remember to tick the boxes beforeU1,U2,U3, which means they would be passed to the user subroutine; you don't need to write a DISP by yourself, the DISP file will be automatically generated by the program). - Write
.inpfile for the job and save it asStep-2.inp
- Everything is the same as your own job file, except the load section. You should remove your force load
-
Prepare
GenerateStep3.py- Submit
Step-1and wait for completion. - Open a new model database in abaqus, open
PythonReader.exeto record your python code of modeling process. - Click
File > Import > Partto import deformed shape fromStep-1.odbas a new meshed part. - Set material parameters, boundary conditions and stuff same as what you have done when creating
Step-1.inp. - After you have writen imput file, copy all the code in the window of
PythonReader.exetoGenerateStep3.py. Here you've got a python file which can reproduce your job file. - At the beginning of the
.pyfile, add the following code:
import os import time with open('Step3_loop.txt','r') as f: status_code = int(f.read()) new_Step3_filename = 'Step-3-' + str(status_code) f.close() main_folder = r"D:\abaqus2022\temp\righteye\Search-Initial-Configuration" # set your own working directory Step2_name = 'Step-2-' + str(status_code) + '.odb' os.chdir(main_folder)
- Change the odb name in
openOdb[]as follows:
session.openOdb(os.path.join(main_folder,Step2_name)) odb = session.odbs[Step2_name]
- Change the job name as follows:
mdb.Job(name=new_Step3_filename, model='Model-1', description='', type=ANALYSIS, atTime=None, waitMinutes=0, waitHours=0, queue=None, memory=90, memoryUnits=PERCENTAGE, getMemoryFromAnalysis=True, explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE, echoPrint=OFF, modelPrint=OFF, contactPrint=OFF, historyPrint=OFF, userSubroutine='', scratch='', resultsFormat=ODB, numThreadsPerMpiProcess=1, multiprocessingMode=DEFAULT, numCpus=8, numDomains=8, numGPUs=0) mdb.jobs[new_Step3_filename].writeInput(consistencyChecking=OFF)
- At the end of the python file, add the following code:
# flag for .py file completion step3_status = 1 step3_status_filename = 'step3.txt' with open(step3_status_filename,'w') as step3_status_file: step3_status_file.writelines(str(step3_status)) step3_status_file.close()
- Submit
These are all the files you need to prepare based on your own model.
- In the code file
IdentifyInitialConfiguration.py, you need to change the*Part, name=cylinderin line 157 to your own part name. - In the code file
main_program.pyandGenerateStep3_2.py, you need to change the variablemain_folderto your own working directory.
After these changes are made, you can move all the five files to your working directory and run main_program.py in any python compiler and wait for success!
The figure above is an example of 2D model. The left and the right represent the loaded configuration before and after the modification procedure, respectively.
- When the main program encounters an error, before you fix the bugs and restart the program, remember to delete all the result files of abaqus in your working directory. If you don't do that, the powershell called by the main program would halt, because it would ask
Old job files exist. Overwrite? (y/n):and you have no way to answer.