RitioL / PolyFatigueCrackSim

This repository contains scripts for the batch generation of polycrystalline RVE models and finite element analysis operations. These scripts are used to simulate the generation of fatigue cracks in polycrystalline materials. The involved software includes Neper, Gmsh, and Abaqus 2022.
MIT License
9 stars 2 forks source link
crack fatigue udmgini umat xfem

PolycrystalFatigueCrackSim

1. simulation_utils

预处理:

  1. 设置 config.json
    • 设置工作区的路径,或者使用我的默认工作区。把 monitor.ps1, startup.batsubroutines3_revised.for 添加到你的工作区,之后我会介绍这些文件的作用。
    • 决定晶界类型(平滑或不平滑)。其中平滑晶界模型的网格划分用到了 Gmsh 和相应的脚本,大概原理是先划分三角网格,然后将三角重新组合为四边形;非平滑模型的网格类似于EBSD的栅格化数据形式。不过此处并没有提供将EBSD转化为多晶模型的脚本,但是可以试着先将其转化为 .tser 文件类型(推荐逛逛 Neper 的 GitHub 讨论区,那里有挺多宝贵的建模经验)。
    • 平滑与不平滑晶界
  2. 运行 scriptGenerator.py
    • 该脚本可创建多晶模型批量生成脚本 neper.sh,这个批处理脚本通过改变 Neper-T 命令中的 -id 参数生成了晶粒分布不同的模型,并划分好网格。另外,在工作目录中还会生成多个名称为 wpXXX 的子工作目录。但是 scriptGenerator.py 目前不生成 Abaqus 运算的启动脚本 startup.bat,该脚本位于 workplace 文件夹中。
  3. 在 Ubuntu 终端命令行中切换到 neper.sh 所在目录,然后输入以下命令:
    ./neper.sh
    • 注意:不同系统的换行符不同,可能会导致脚本执行错误。scriptGenerator.py 已解决此问题。如有需要,可以在 Ubuntu 终端命令行中转换:
      sed -i 's/\r$//' neper.sh
  4. 运行 editInp1.py
    • 此脚本向 inp 文件中添加材料信息。同时可以设置第二个随机数种子,即晶体取向随机数种子。
  5. 运行 preprocessor.py
    • 此脚本设置各种模拟参数,如分析步和边界条件。
    • 注意:若运行时提示“输入行太长 命令语法不正确”,可将 abq2022.bat 中的调用编译器命令注释掉,运行完毕再启用。如下图使用 rem 注释掉了两条调用 VS 和 Fortran 的命令。 注释两条命令
  6. 运行 editInp2.py
    • 此脚本批量修改某些参数,具体可打开脚本查看。

执行运算:

  1. 运行 startup.bat
    • 该批处理脚本位于 workplace,用于向 Abaqus 提交任务。脚本中默认运行 wp001wp100 的运算,另外,为了节省存储空间会将 Abaqus 生成的 .dat.stt 文件删除。你可以按需修改 startup.bat。另外,当前启动批处理可以监控命令窗口(见 workplace 中的 monitor.ps1),并解决因奇异矩阵(singular matrix)问题导致的计算停滞。

后处理:

  1. 运行 postprocessor1.py
    • 此脚本用于筛选不符合长度标准的裂纹。该脚本从 Odb 文件的最后一帧提取 philsm 信息,分析裂纹长度是否符合指定标准,并删除不符合标准的文件夹。 后处理流程图
  2. 运行 postprocessor2.py
    • 最终帧的裂纹图像可能会出现往回拐的路径,这往往不符合我们的要求。因此,此脚本设计用于识别裂纹回拐之前的关键帧并生成图像。该脚本从 Odb 文件的选定帧中提取 philsm 信息,并生成 EBSD 和裂纹图像。 后处理流程图
  3. 运行 postprocessor3.py
    • 此脚本用于手动识别裂纹回拐之前的关键帧。前两个脚本通常能产生符合长度标准且不含弯曲部分的裂纹,但仍有少数情况需要手动干预。

2. UMAT 和 UDMGINI 说明:

3. Neper 案例:

4. 参考文献:


Introduction

This repository contains scripts for the batch generation of 2D polycrystalline RVE models and finite element analysis operations. These scripts are used to simulate the growth of fatigue cracks in polycrystalline materials. The involved software includes Neper 4.9.0, Gmsh 4.13.1, and Abaqus 2022. Neper and Gmsh are run on Ubuntu installed via WSL, and the related installation instructions can be found in the References section. This script is still not fully developed, and the setting of many parameters as well as the selection of mechanisms require further refinement. I only hope this provides you with some inspiration or reference.

1.simulation_utils:

Preprocessing:

  1. Set config.json
    • Set your workplace path, or use the default workplace path. Add monitor.ps1, startup.bat, and subroutines3_revised.for to your workplace, and I will explain the functions of these files shortly.
    • Decide the type of grain boundary (smooth or non-smooth). For smooth grain boundary models, the meshing uses Gmsh and the corresponding scripts, where the basic principle is to first generate triangular meshes and then recombine them into quadrilaterals. For non-smooth models, the mesh resembles the gridded data format of EBSD. However, the script for converting EBSD data into polycrystalline models is not provided here. You can try converting it to the .tser file format first (it's recommended to check out Neper's GitHub discussion forum, where you'll find plenty of valuable modeling experiences). Smooth vs. Non-smooth Grain Boundaries
  2. Run scriptGenerator.py
    • This script generates the batch polycrystal model generation script neper.sh. This batch script generates models with different grain distributions by changing the -id parameter in the -T command of Neper and also performs the meshing. However, scriptGenerator.py does not currently generate the Abaqus operation startup script, startup.bat, which is now located in the workplace folder.
  3. Change the directory to where neper.sh is located in the Ubuntu command line, then enter the following command:
    ./neper.sh
    • Note: Different systems have different line break characters, which may cause script execution errors. scriptGenerator.py has resolved this issue. If needed, you can convert it in the Ubuntu command line with:
      sed -i 's/\r$//' neper.sh
  4. Run editInp1.py
    • This script adds material information to the inp file. You can also set a second random seed, which is the random seed for the crystal orientation.
  5. Run preprocessor.py
    • This script sets various simulation parameters such as analysis steps and boundary conditions.
    • Note: If you receive the message "The input line is too long. The syntax of the command is incorrect" during execution, you can comment out the compiler calls in abq2022.bat, run it, and then enable them again. As shown in the image, use rem to comment out the two commands that call Visual Studio and Fortran. Comment out two commands
  6. Run editInp2.py
    • This script batch modifies certain parameters.

Execution:

  1. Run startup.bat
    • This script batch is located in the workplace and is used to submit the jobs to Abaqus. By default, the script runs computations from wp001 to wp100, and it deletes the .dat and .stt files generated by Abaqus to save storage space. You can modify startup.bat according to your need. Additionally, the current startup batch is capable of monitoring the command window (see monitor.ps1 in workplace) and resolving stalls caused by Singular Matrix issues.

Post-processing:

  1. Run postprocessor1.py
    • This script is used to filter out cracks that do not meet the length standard. This script extracts the philsm information from the last frame of the Odb file, analyzes whether the crack length meets the specified standard, and deletes any folders that do not meet the standard. The workflow of postprocessor1
  2. Run postprocessor2.py
    • The crack image in the final frame may have a path that turns back, which does not meet our requirements. Therefore, this script is designed to identify key frames before the crack turns back and to generate plots. This script extracts the philsm information from selected frames of the Odb file and generates EBSD and crack images. The workflow of postprocessor2
  3. Run postprocessor3.py
    • This script is used to manually identify key frames before the crack turns back. While the first two scripts generally produce cracks that meet the length standard and do not contain curved sections, there are still a few cases that require manual intervention.

2.UMAT and UDMGINI Instructions:

3.Neper Cases: