## 4 MATLAB Script: Inserting Cohesive Elements at the Matrix/Precipitate Interface  
A MATLAB algorithm has been developed to insert cohesive elements between the matrix and precipitate elements. Figure 9 displays the included cohesive elements (depicted in red). The algorithm starts by reading the ABAQUS input file that is generated by the OOF2 software. Afterwards, it proceeds to generate nodes and elements in a sequential manner. The RVE is generated once more, and then the algorithm examines each element individually to identify the locations that require cohesive elements (the interface between the matrix and precipitate) where the material sets are different. Afterwards, it disconnects the matrix and precipitates elements by adding additional nodes and forms a unified element. An additional node is inserted in such a manner that it forms a cohesive element with zero thickness. In order to add the cohesive elements, the algorithm ensures that nodes and elements do not overlap. Placing cohesive elements at various locations is entirely distinct. The algorithm should initially check whether the cohesive element is meant to be inserted at the left, right, top, or bottom sides of a particle. Each case has its own scenario for disconnecting the matrix and precipitate elements and inserting the cohesive elements, including a cohesive element at each corner (specifically, at the top-left, bottom-left, top-right, or bottom-right corners), which also possess their own specific scenarios.  
To provide a clear explanation of how cohesive elements are inserted within an RVE, a flow chart is presented in Figure 10. Figure 10 presents a thorough depiction of the algorithm's procedure.  
Figure 8: Procedure of creating the RVE in OOF2.  
Figure 10: Procedure of inserting cohesive elements at the matrix/precipitate interfaces.  
Figure 9: Inserted cohesive elements between matrix and precipitate; the cohesive elements are in red.  
To insert 2D and three-dimensional (3D) elements (COH2D4 and COH3D8, respectively) in 2D RVEs in ABAQUS, two algorithms were implemented. Two-dimensional plane strain and stress elements such as CPE4 and CPS4, as well as a 3D element, namely C3D8, are considered. There is only one element in the thickness direction for the RVE when the 3D elements are used. These two algorithms are available through the following repositories [1; 2]. Figure 11 demonstrates how an interface separates between two elements that possess different material properties, achieved by introducing additional nodes. Furthermore, Figure 12 displays a schematic representation of the separation of elements in both 2D and 3D.  
As explained by [PERSON] et al. [42], plane strain and plain stress conditions occur in the necking region, where fracture initiates. Therefore, it is necessary to create the 2D RVE. However, in some cases, users may only be able to create a 2D model using a 3D element and only one element in the thickness direction due to limited available tools. Thus, we have provided an algorithm for inserting cohesive elements for the 3D cases as well. It is important to note that the number of elements in the thickness is only one, and for instance, the case of plane strain can be considered when the element is thick.  
Figure 11: An interface between two elements is separated through adding extra nodes [43].  
Figure 12: Schematic view of cohesive and bulk elements for (**a**) 2D and (**b**) 3D geometries [44]. Numbers belong to the nodes of every element.