Introduction

Corrosion of metals is a long-standing economic and engineering problem. The total annual direct cost of corrosion was estimated to be over $2.5 trillion in 2013.[1] It also limits rapid development of new metallic materials due to a long time scale over which the degradation occurs. For example, Mg alloys are lightweight and have excellent strength-to-weight ratio and exhibit versatile processability via rolling, extrusion, and casting when alloyed with Al.[2] However, such alloys suffer from localized corrosion triggered by the microgalvanic coupling between the Mg17Al12 intermetallic particles and the Mg matrix.[3] While different forms of corrosion may take place on Mg alloys,[4] galvanic corrosion, either through contact with a dissimilar metal or by alloying, is a common occurrence because of the electronegativity of Mg.[2] Second-phase precipitates also lead to microgalvanic or local coupling effects.[5,6,7] In addition, localized corrosion is often observed.[8] The conditions associated with each form of corrosion have not been fully determined, and how different alloy chemistries and precipitate/grain microstructures lead to such a range of corrosion behavior is yet to be quantitatively understood. Thus, it is clear that we must further develop the science behind their corrosion behavior before Mg alloys can be widely used as a structural material in a corrosive environment.[2] Only when we have a better mechanistic understanding underlying the corrosion process, we will be able to conduct science-driven alloy design and optimization of Mg alloys for a range of applications. However, due to the long lifetime of structural materials and slow progression of corrosion under non-accelerated conditions, experiments can take many months or sometimes years to produce data and resulting insights. Therefore, it is critical that modeling and simulation of corrosion are integrated into the material design cycle for Mg alloy development.

Recent advances in the modeling of corrosion employing the phase-field,[9,10,11,12,13,14] level set,[15] and sharp interface[16,17] methods allow us to predict how corrosion proceeds in different materials and conditions, taking into account the different electrochemical properties of phases and grain boundaries present in the system. However, in order to bring such capability to the broader community and to advance the science of corrosion, it is important to establish an open-source software that is flexible, easy to use, and highly efficient. Existing computational tools that are publicly available freely or for a fee to simulate the evolution of the corrosion front include the COMSOL Corrosion module[18] and the HOGNOSE[19] application based on the MOOSE[20] framework. In COMSOL Multiphysics®, which is a commercial software, the moving corrosion interface is tracked by using either the Arbitrary Lagrangian–Eulerian method or the level set method. The evolution of this interface is governed by electrochemical reaction kinetics and ionic transport within the electrolyte, which includes diffusion and migration. However, because it is a commercial software with a high license fee, COMSOL Multiphysics® is not available to all researchers and engineers in the material science and engineering community. Furthermore, for the same reason, it is frequently unavailable on many high-performance-computing clusters, which limits its application to large 3D problems. Additionally, meshing of complex microstructures within COMSOL Multiphysics® requires the users to have advanced knowledge of meshing packages.[21,22] In contrast to COMSOL Multiphysics®, the HOGNOSE application is developed based on the open-source MOOSE framework, a finite element parallel computational framework targeted at the solution of coupled, nonlinear partial differential equations. The MOOSE framework is highly modular and features a plug-in infrastructure that simplifies definitions of physics, material properties, multiphysics coupling, and postprocessing. The HOGNOSE application simulates early-stage irradiation-enhanced corrosion of Zircaloy-4 in pressurized water reactors using the phase-field method. The implemented model describes the evolution of the metal-oxide interface in fuel cladding, where corrosion is enhanced by the release of iron from secondary phase particles. However, galvanic or microgalvanic effects are not considered to be contributing factors to corrosion in this scenario. Therefore, to our knowledge, there is not yet a publicly available application or software tool to simulate galvanic or microgalvanic corrosion with MOOSE or any other open-source frameworks.

To enable the wider materials science community to easily and efficiently simulate galvanic or microgalvanic corrosion and to integrate the Materials Genome Initiative[23] (MGI) approach into their research, we offer a new corrosion application within PRISMS-PF titled corrosion_microgalvanic.[24] Below, we discuss the model equations implemented in the application, the corresponding implementation details in PRISMS-PF, and the application’s features such as parallel performance and 2D and 3D capabilities. PRISMS-PF is an open-source high-performance framework for phase-field simulation of microstructure evolution.[25,26] This framework has been developed within the Predictive Integrated Structural Materials Science (PRISMS) Center.[26] The code is built on the deal.II finite element library[27] and exhibits excellent computational performance, which is enabled by the use of a matrix-free variant of the finite element method (FEM). This method allows for an efficient time integration, in addition to mesh refinement capabilities and multi-level parallelism (distributed memory parallelization, task-based threading, and vectorization). The framework is designed with a modular, application-centric code structure for ease of use and contains 28 built-in applications. Performance for a solidification benchmark problem[28] has been shown to meet or exceed that of other phase-field frameworks (including MOOSE).[25] Some functionalities of the framework include built-in methods for nucleation, order-parameter remapping for grain growth simulations, and an iterative solver for nonlinear partial differential equations. Recent applications of the PRISMS-PF framework include simulations of precipitate morphology and composition,[29] pitting corrosion of microstructures from additive manufacturing,[30] and dendritic solidification in Mg alloys.[31]

Model equations

The model utilized in this application considers migration of ions in the electrolyte, electrochemical reaction at the metal/electrolyte interface, and the motion of the interface due to the reaction. Below, we discuss the equations used to describe these phenomena, which are based on the corrosion model described by Chadwick et al.[9] with an addition of an order parameter to represent the cathodic phase. Additional details of the model can be found in Ref. 9. All the variables and symbols used in the model equations below are listed in Table 3.

Phase-field equations

In this application, we employ the phase-field method as a tool to track the moving metal–electrolyte interface as well as the interfaces between various phases of the metal. Field variables known as order parameters are used to describe the geometry of all phases. Each order parameter has a value of \(1\) within the corresponding phase and \(0\) outside that phase. At the interface between the phase and another phase, the order parameter smoothly transitions between 0 and 1. In this formulation, we use \(\psi\) and \({\varphi }_{j}\) to represent the order parameter for the electrolyte phase and the jth metal phase, respectively. Furthermore, the free energy functional, \(\widetilde{\mathcal{F}}\), of the system can be written in terms of the order parameters and their gradients as[32]

$$\widetilde{\mathcal{F}}={\int }_{\Omega }\left({f}_{0}\left(\{{\varphi }_{j}\},\psi \right)+\frac{{\widetilde{\epsilon }}^{2}}{2}\left(\sum\limits_{j=1}^{N}{\left|\nabla {\varphi }_{j}\right|}^{2} + {\left|\nabla \psi \right|}^{2}\right)\right){\text{d}}\Omega ,$$
(1)

where \(\widetilde{\epsilon }\) is the gradient energy coefficient and \(\Omega\) represents the system volume. Note that the quantities \(\widetilde{\mathcal{F}}\) and \({\widetilde{\epsilon }}^{2}\) are normalized by the height of the double well, \(W\), which has units of J/m3. The bulk free energy \({f}_{0}\) is given by[32]

$${f}_{0}\left(\{{\varphi }_{j}\},\psi \right)=\sum\limits_{j=1}^{N}\left(\frac{{\varphi }_{j}^{4}}{4}-\frac{{\varphi }_{j}^{2}}{2}\right)+\left(\frac{{\psi }^{4}}{4}-\frac{{\psi }^{2}}{2}\right)+\frac{3}{2}\sum\limits_{j=1}^{N}\sum\limits_{k>j}^{N}{\varphi }_{j}^{2}{\varphi }_{k}^{2}+\frac{3}{2}\sum\limits_{j=1}^{N}{\varphi }_{j}^{2}{\psi }^{2}.$$
(2)

We note that we only consider two phases in the metal for this application: \({\varphi }_{1}\) indicates the anodic phase and \({\varphi }_{2}\) indicates the cathodic phase. Nonetheless, Eqs. 1 and 2 are kept in their general form to allow the consideration of more phases. The evolution of the anodic metal/electrolyte interface is governed by Cahn–Hilliard equations with a source term,[33,34]

$$\frac{\partial {\varphi }_{1}}{\partial t}=\nabla \cdot \left({M}_{{\varphi }_{1}}\nabla \frac{\delta \widetilde{\mathcal{F}}}{\delta {\varphi }_{1}}\right)+v\left|\nabla \psi \right|,$$
(3)
$$\frac{\partial \psi }{\partial t}=\nabla \cdot \left({M}_{\psi }\nabla \frac{\delta \widetilde{\mathcal{F}}}{\delta \psi }\right)-v\left|\nabla \psi \right|,$$
(4)

where \({M}_{{\varphi }_{1}}\) and \({M}_{\psi }\) are the mobilities for phases \({\varphi }_{1}\) and \(\psi\), respectively, and \(v\) is the normal component of the velocity of the anodic metal/electrolyte interface, which is related to the anodic reaction current density (RCD), \({i}_{rxn, 1}\), and an interpolation function for the anodic phase, \({\xi }_{1}\) (that is equal to 0 in the cathodic phase and 1 in the anodic phase) via

$$v=-\frac{{V}_{m}{\xi }_{1}{i}_{rxn, 1}}{{z}_{m}F},$$
(5)

where \({V}_{m}\) is the molar volume of the corroding metal, \({z}_{m}\) is the charge number of the corresponding metallic cation in the electrolyte, and \(F\) is Faraday’s constant. We note that Eq. 5 is a slightly modified version of the expressions provided by Refs. 9, 15, and 35 for the interface velocity. The equations used to calculate \({i}_{rxn, 1}\) and \({\xi }_{1}\) are described in the next subsection. It is important to note that the terms proportional to \(v\) on the right-hand side of Eqs. 3 and 4 are not due to the bulk motion. Rather, these terms are added as source terms to model the motion of the electrolyte/anodic phase interface due to the corrosion reaction at the interface. Note that multiplication by the magnitude of the gradient of \(\psi\) confines the region where these terms are nonzero. In Eq. 3, the Cahn–Hilliard dynamics, rather than the Allen–Cahn dynamics, was chosen to describe the evolution of \({\varphi }_{1}\) to ensure that the change in mass of anodic phase is due only to the corrosion reaction. Following Ref. 9, we use the same approach for the electrolyte phase (Eq. 4) but with the opposite sign of the source term to ensure the direction of the interfacial displacement is correct. We do not consider any deposition on the cathodic phase, and thus the evolution of \({\varphi }_{2}\) is given by the Cahn–Hilliard equation,[33]

$$\frac{\partial {\varphi }_{2}}{\partial t}=\nabla \cdot \left({M}_{{\varphi }_{2}}\nabla \frac{\delta \widetilde{\mathcal{F}}}{\delta {\varphi }_{2}}\right),$$
(6)

where \({M}_{{\varphi }_{2}}\) is the mobility for the phase \({\varphi }_{2}\). While corrosion does not affect the cathodic phase, it is important to evolve this equation so that the order parameters adjust accordingly to the free energy functional in Eq. 1 as other order parameters evolve; without doing so can lead to undesired numerical artifacts and instability. In this work, we do not consider the deposition of the corrosion product, although it is a potential valuable extension, as discussed later. Finally, all the mobilities are set to be equal and are dependent on \({i}_{rxn,1}\) and \({\xi }_{1}\). These mobilities are given by an expression similar to that provided by Chadwick et al.[9]:

$${M}_{{\varphi }_{1}}={M}_{{\varphi }_{2}}={M}_{\psi }=M=2\delta \frac{{V}_{m}\left|{\xi }_{1}{i}_{rxn, 1}\right|\psi }{{z}_{m}F},$$
(7)

where \(2\delta =2\sqrt{2{\widetilde{\epsilon }}^{2}}\) is the equilibrium interfacial thickness. The mobility coefficients in Eq. 7 are defined in such way that the dimensionless Peclet number, \(2\delta v/M\), is unity to ensure that the moving interface can maintain the profile required by the free energy functional.[9]

Electrochemical equations

The ionic transport in the electrolyte is caused by migration, diffusion, and convection. We assume that there is continuous replenishment of the ions in the electrolyte through sufficiently large fluid flow, i.e., the well-stirred limit. Under these assumptions, no ionic-concentration gradients exist in the electrolyte, due to which the diffusion of ions in the electrolyte does not need to be considered. Additionally, fluid flow does not need to be explicitly considered for in this limit. Such a setup is consistent with other studies reported in the literature[13,36,37] and is valid for systems in contact with flowing electrolyte like structural components operating in rivers and seas. Consequently, the current density in the electrolyte, \({i}_{e}\), is given by[38]

$${{\varvec{i}}}_{e}=-{\kappa }_{e}\nabla {\Phi }_{e},$$
(8)

where \({\kappa }_{e}\) is the ionic conductivity of the electrolyte and \({\Phi }_{e}\) is the electrostatic potential in the electrolyte. Current continuity requires that

$$\nabla \cdot {{\varvec{i}}}_{e}=0$$
(9)

in the electrolyte. Furthermore, at the metal/electrolyte interface, the normal component of \({{\varvec{i}}}_{e}\) must be equal to the reaction current density, \({i}_{rxn}\):

$${{\varvec{i}}}_{e}\cdot {\widehat{n}}_{m/e}={i}_{rxn},$$
(10)

where \({\widehat{n}}_{m/e}\) is the unit normal vector of the metal/electrolyte interface pointing out of the metal. Natural (zero-normal-derivative) boundary conditions are imposed at all the other boundaries in the system. Equations 810 are combined using the Smoothed Boundary Method (SBM)[9,39,40,41] to obtain an expression for \({\Phi }_{e}\) within the electrolyte. The SBM applies mathematical identities in calculus to transform a partial differential equation to an alternative form that implicitly includes the boundary conditions. Here, since these equations are only valid within the electrolyte or its boundary, the SBM is applied with \(\psi\) as the domain parameter. The resulting equation for \({\Phi }_{e}\) is given by

$$\nabla \cdot \left(\psi {\kappa }_{e}\nabla {\Phi }_{e}\right)=-\left|\nabla \psi \right|{i}_{rxn}.$$
(11)

Note that even though \({i}_{rxn}\) is calculated throughout the system, its value is only meaningful in the interfacial regions and affects the electrolyte potential only where \(\left|\nabla \psi \right|\) is nonzero, i.e., at the metal/electrolyte interface.

To calculate \({i}_{rxn}\) in Eqs. 10 and 11, we must first obtain the cathodic and anodic RCDs independently. In general, RCD is given by the product of the corrosion current and an exponential function containing the overpotential (which includes the corrosion potential). The anodic RCD is obtained by a modified Tafel relation as[38]

$${i}_{rxn, 1}=\frac{{i}_{{\text{corr}},1}{\text{e}}^{{\eta }_{1}/{A}_{1}}}{1 + \frac{{i}_{{\text{corr}},1}{\text{e}}^{{\eta }_{1}/{A}_{1}}}{{i}_{\text{max}}}},$$
(12)

where \({i}_{{\text{corr}},1}\) is the corrosion current density for the anodic phase, \({\eta }_{1}\) is the anodic overpotential given by \({\Phi }_{m}-{\Phi }_{e}-{E}_{{\text{corr}},1}\); \({\Phi }_{m}\) and \({E}_{{\text{corr}},1}\) represent the applied electrostatic potential of the metal and the corrosion potential of the anodic phase, respectively; and \({A}_{1}\) is the corresponding Tafel slope. Figure 1 shows a typical Tafel plot and how the corrosion parameters (\({i}_{\text{corr}}, {E}_{\text{corr}}\), and \(A\)) are obtained. In Eq. 12, the current density smoothly approaches \({i}_{\text{max}}\) as \({i}_{\mathrm{0,1}}{e}^{{\eta }_{1}/{A}_{1}}\) becomes large, and thus \({i}_{\text{max}}\) sets the maximum current density. This constraint is added to account for any kinetic limitations such as limiting ionic transport in the electrolyte or charge transfer current density that may exist in the system due to surface passivation or the deposition of the corrosion product.[42] We assume no such limitation on the cathode, and thus, the cathodic RCD is simply given by the standard Tafel relation[38]

Figure 1
figure 1

A schematic of a typical Tafel plot. The magenta dashed lines represent the linear approximations to the anodic and cathodic polarization curves. \({E}_{\text{corr}}\) and \({i}_{\text{corr}}\) are obtained from the intersection of these lines and the Tafel slopes are obtained as the slopes of these lines.[43]

$${i}_{rxn, 2}=-{i}_{{\text{corr}},2}{\text{e}}^{{\eta }_{2}/{A}_{2}},$$
(13)

where \({\eta }_{2}={\Phi }_{m}-{\Phi }_{e}-{E}_{{\text{corr}},2}\), and the cathodic corrosion current density, the corrosion potential, and the Tafel slope for the cathodic phase are denoted by \({i}_{{\text{corr}},2}\), \({E}_{{\text{corr}},2}\), and \({A}_{2}\), respectively. Note that we assume that the metallic conductivity is large enough to ensure that \({\Phi }_{m}\) is nearly constant throughout the metal. Additionally, we assume corrosion to advance under an unbiased condition, i.e., free immersion, and thus we set \({\Phi }_{m}=0\). Furthermore, the use of natural (zero-normal-derivative) boundary conditions for \({\Phi }_{e}\) on all the borders of the system in contact with the electrolyte ensures that the net current along the metal/electrolyte interfaces is zero. This can be shown by applying the divergence theorem on the volume (area in 2D) occupied by the electrolyte along with Eq. 8. Finally, the reaction current density in Eqs. 10 and 11 is then calculated from the cathodic and anodic RCD as a linear combination of the two:

$${i}_{rxn}=\sum_{j=1}^{2}{\xi }_{j}{i}_{rxn, j},$$
(14)

where \({\xi }_{j}\) is an interpolation function that varies from \(0\) to \(1\), which indicates the region of the corresponding phase. In this work, we defined the interpolation function as

$${\xi }_{2} =\frac{{\varphi }_{2}}{\mathrm{max}\left({\varphi }_{1} + {\varphi }_{2}, \zeta \right)},$$
(15)
$${\xi }_{1} =1- {\xi }_{2},$$
(16)

where \(\zeta\) is a small number added to the denominator to avoid division by zero. Extensive testing indicates that \(\zeta\) must be small enough but not too small, \(\approx {10}^{-3},\) in order to ensure smooth behavior near the interfacial region (see Fig. 7 in the appendix).

PRISMS-PF implementation

The governing equations of the model are implemented into the PRISMS-PF framework,[24] which employs a matrix-free variant of FEM. We provide a list of variables/parameters names used in the model equations and the corresponding names used in the code in Table I. An explicit forward Euler scheme with constant step size is used for time integration. Natural (zero-normal-derivative) boundary conditions are applied for all fields at all the boundaries of the computational domain, but these conditions can be modified to periodic or Dirichlet boundary conditions. The equations are discretized in space with a rectangular adaptive mesh with first-order elements in two or three dimensions. The minimum linear element size is chosen such that the interfaces are well resolved, i.e., an interface contains at least four nodes across the region. The highest level of mesh refinement is selected dynamically for all regions where either of \({\varphi }_{1}\), \({\varphi }_{2}\), or \(\psi\) lie between the values \({10}^{-4}\) and \({1-10}^{-4}\). The smallest and largest element size are set to ~\(3\times {10}^{-8}\) m and ~\(1.23\times {10}^{-7}\) m, respectively. The time step is set as 0.01 s, and the mesh adaption is carried out every 2000 time steps (i.e., 20 s). The order and domain parameters are bounded to the range [0,1] at the start of every time step to avoid negative values of the order/domain parameters near the interfaces. Moreover, all the interfaces are equilibrated for 100 s without corrosion to ensure that \({\varphi }_{1}\), \({\varphi }_{2}\), and \(\psi\) are consistent with the governing equation in the static condition based on the initial condition. The equilibrium electrostatic potential field, \({\Phi }_{e}\), is computed at every time step using the integrated nonlinear solver functionality. These default settings can be modified by appropriately changing the following files in a manner described in Ref. 25 and the PRISMS-PF user manual[44]:

Table I A list of variables and parameters names used in the model equations and the corresponding names used in the PRISMS-PF Microgalvanic Corrosion code (corrosion_microgalvanic).[24]

parameters.prm: This is a parsed text file that contains information about the material parameters such as \({i}_{{\text{corr}},j}\), \({E}_{{\text{corr}},j}\), \({A}_{j}\), \({\kappa }_{e}\), \({V}_{m}\), and \({z}_{m}\); geometry-related parameters like dimension and size; mesh-related parameters such as element order, adaptivity criteria and frequency, and level; solver parameters like tolerance criterion and value, time step, number of solver iterations, initial guess for \({\Phi }_{e}\); and boundary conditions. All these parameters can be modified by the user according to their requirement. We recommend a combination of literature survey and experimental measurements, which include polarization measurements, to determine the material parameters for different systems. The rescaled gradient energy coefficient, \({\widetilde{\epsilon }}^{2}\), which controls the interfacial thickness, is also set in this file. The value of this parameter should be chosen so that the interfacial thickness is much smaller (~ 10%) than the length scale of the smallest feature of interest in the problem. Accordingly, the size of the mesh at the highest refinement level should be set to ensure that there are \(3\sim 5\) elements across each of the interfaces and the time step should be small enough to ensure the stability of the time stepping algorithm. We also note that the solver parameters and miscellaneous parameters such as \(\zeta\) may need to be tuned if model parameters are modified. As with all PRISMS-PF applications, the microgalvanic corrosion application does not need to be re-compiled if only parameters.prm is modified.

ICs_and_BCs.cc: This is a code file that has the information about the initial state of the system. Users can modify the initial geometry of the system by appropriately setting the fields \({\varphi }_{1}\), \({\varphi }_{2}\), and \(\psi\). We note that the PRISMS-PF also supports a file input for setting the initial conditions of the system.

Other files: The governing equations of the model are set in equations.cc, and the main class of the application and its member functions and variables (including model constants) are declared in customPDE.h.

The application outputs data in the Visualization Toolkit Unstructured Points Data (VTU) format. We recommend using a tool such as VisIt or Paraview to visualize and analyze the output files. Both these software packages support Python scripting, which enables automation of visualizations and post-simulation analysis.

Parallel performance

The parallel performance of the application was tested for a 3D system with ~ 4.8 × 107 degrees of freedom, and for 500 time steps. The system consisted of a cylindrical cathodic phase (\(\beta\)) (~ 21% volume fraction in the metal) surrounded by the anodic phase (\(\alpha\)), and both phases are in contact with an electrolyte, as shown in Fig. 2(a). The symmetry of the setup allows one to perform the simulations in only one quarter of the system. The result from the strong scaling test, performed on the “ICX-normal” queue (Intel Xeon Platinum 8380, 2.3 GHz, 80 cores, 256 GB DDR4 RAM) of the TACC Stampede2 cluster, is shown in Fig. 2(b). As can be seen, the application exhibits super-linear parallel performance even up to 3200 cores, which is enabled by an increase in the available cache as the number of cores is increased. Thus, we conclude that the application is well suited for investigating scientifically and technologically relevant large systems with an excellent parallel efficiency. In the next section, we demonstrate the utility of the application in investigating microgalvanic corrosion in Mg alloys.

Figure 2
figure 2

(a) A schematic of the 3D system used for the scaling study. (b) The strong scaling performance of the application.

Demonstration examples

To demonstrate the utility of the application, we simulated the microgalvanic corrosion effect in an Mg alloy. We employed the properties of AM30 alloy (Mg-3wt%Al-0.4wt%Mn) for the \(\alpha\) phase and of Mg17Al12 for the \(\beta\) phase, as in Refs. 36 and 37. The value of \({i}_{\text{max}}\) for the AM30 alloy is obtained from the polarization curves provided in Ref. 45. It should be noted that these \({i}_{\text{max}}\) values vary between 30 and 1000 A/m2. The authors of Ref. 45 attributed this wide range to the difference in the grain size of the alloy samples and the immersion time in the electrolyte. Due to the wide range in the literature values, we chose an intermediate value of 100 A/m2 for \({i}_{\text{max}}\). We note that the parameter values used here are intended to demonstrate the capability of the application and are not calibrated to match any experimental measurement of corrosion rates in Mg alloys. Such a study is left for future work.

We first present results for a 2D system, where the anodic (\(\alpha\)) and cathodic (\(\beta\)) phases are present in alternating lamellae. By employing natural boundary conditions, we can represent this configuration with a simulation domain that includes only half of the \(\alpha\) phase and half of the \(\beta\) phase of one full period, as shown in Fig. 3. We demonstrate that the application captures the evolution of the corroding interface and the electrolyte potential and use it to illustrate the effect of the area fraction of \(\beta\) phase on the corrosion rate. Finally, we demonstrate the ability of the application to simulate the evolution of the corroding interface in 3D by using the 3D system shown in Fig. 2(a).

Figure 3
figure 3

Evolution of the interfaces (\(\alpha\) (anodic metal)/electrolyte, \(\beta\) (cathodic metal)/electrolyte, and \(\alpha /\beta )\) and the electrolyte potential, \({\Phi }_{e}\), during microgalvanic corrosion are shown at \(t=0\) s, 1250 s, and 2480 s. The color bar shows the value of the potential in V.

2D simulations

Figure 3 shows the evolution of the anodic metal/electrolyte interface along with the evolution of the electrolyte potential, \({\Phi }_{e}\) for a system with 20% area fraction of \(\beta\) (defined as a fraction of the entire domain width). All other model parameters are provided in Table II. For the corrosion parameters, we adopt the values determined by Beura et al.,[37] which were based on the polarization curve measured by Deshpande.[36] As can be seen, the anodic region corrodes at a faster rate near the anodic metal/cathodic metal interface than away from the cathodic region. The nonuniformity of the corrosion rate occurs due to the spatial variation of the reaction current density (RCD), which is higher near the anodic metal/cathodic metal interface throughout the duration of the corrosion simulation, as shown in Fig. 4. (Note that the shape of the \(\alpha\)-phase interface near the junction with the \(\beta\)-phase interface is slightly rounded due to the diffuse interface effect. This rounding can be reduced by employing numerical parameters that provide a thinner interface.) There appear to be two distinct regions, one near the anodic metal/cathodic metal interface, which is dominated by the accelerated corrosion, and the other characterized by almost constant corrosion rate, leading to nearly uniform corrosion. This indicates that there are at least two length scales associated with the corrosion process even when only migration is considered: a short length scale over which the corrosion current decays quickly, and another length scale (which is greater than the simulation domain size for the simulation shown in Fig. 3) over which the corrosion current persists.

Table II Parameter values used in the simulations along with their sources.
Figure 4
figure 4

The distribution of the reaction current density at the three times shown in Fig. 3.

Next, we investigated the effect of the initial area fraction of \(\beta\) on the corrosion rate by selecting 5 values of the \(\beta\) fraction: 5%, 10%, 15%, 20%, and 25%. Figure 5(a) shows the comparison of the evolution of the corrosion RCD integrated along the anodic metal/electrolyte interface (hereafter, integrated current density, or ICD) for all the cases, and the location of the corroding interface is compared at t = 2480 s in Fig. 5(b). Two trends can be observed in these results. First, the ICD increases with the initial \(\beta\) fraction for a fixed time, including at \(t=0\). The fact that increasing the \(\beta\) region exposed to the electrolyte increases the ICD indicates that the corrosion process here is limited by the cathodic reaction. This was confirmed by conducting additional simulations and analysis covering a larger range of volume fractions to identify regimes that are limited by the cathodic reaction and the anodic reaction, as well as the crossover regime. Second, the ICD increases with time for a given initial \(\beta\) fraction. This occurs because the corrosion of the \(\alpha\) phase exposes more \(\beta\) phase to the electrolyte, leading to a greater \(\beta\)/electrolyte interfacial length (equivalent to area in 3D). This increase in \(\beta\)/electrolyte interfacial length also reduces the cathodic-reaction limitation and thus accelerates corrosion. This result illustrates the importance of microstructure; specifically, when the cathodic phase is elongated (e.g., in eutectic microstructure), the increase in the exposed surface of the cathodic phase will lead to an increase in corrosion rate; thus, any corrosion will accelerate the subsequent corrosion in this limit.

Figure 5
figure 5

Comparison of (a) the integrated current density (ICD) vs. time and (b) the position of the anodic metal/electrolyte interface at t = 2480 s for all \(\beta\) fraction considered in this study.

3D simulation

The 3D capability of the application is demonstrated in Fig. 6, where the evolution of the metal/electrolyte interface and the ICD are shown for the 3D system from Fig. 2. The morphological evolution of the corroding surface is similar to that of the 2D simulations, i.e., a fastest corrosion is observed close to the \(\alpha /\beta\) interface, leading to a circular trench near the \(\beta\) (cathodic) phase. However more uniform corrosion proceeds away from the interface, again suggesting an existence of two lengths scales discussed above. Furthermore, the overall corrosion rate increases with time (as shown in Fig. 6(b)), again suggesting that growth in the exposed surface area of \(\beta\), as well as that of \(\alpha\) due to its nonplanar evolution, leads to further acceleration of corrosion. Since such evolution is strongly dependent on the microstructure, the design of alloys for improved corrosion resistance should consider not only the alloy composition but also the processing and the resulting microstructure. We note that small fluctuations in Fig. 6(b) result from the limited mesh resolution used for the simulation to reduce the computational cost. They can be eliminated by increasing the mesh resolution and reducing the time step size; however, based on the 2D studies, the overall evolution is not affected by the fluctuations.

Figure 6
figure 6

(a) Evolution of the metal/electrolyte interface in the 3D system shown in Fig. 1(a) at two stages during microgalvanic corrosion. (b) Evolution of the integrated corrosion current density.

Conclusions

One of the critical foundations required in realizing the visions outlined in the Material Genome Initiative[23] is the software infrastructure. There is a growing number of open-source software, as well as commercial software, but for any given application, the choices are still limited. In this prospective article, we focused on simulation of corrosion. We first provided an overview of the existing tools for simulating corrosion. We then summarized the features and capabilities of the open-source corrosion_microgalvanic[24] application developed within the PRISMS-PF framework. The application is capable of simulating both 2D and 3D systems and exhibits super-linear parallel performance for sufficiently large simulations. To show the utility of this application, we employed it to investigate the effect of the \(\beta\) (cathodic) phase fraction on the corrosion rate, where the microstructure was assumed to be of lamellae (in 2D) or a cylinder embedded in the \(\alpha\) matrix (in 3D). It was found that the corrosion rate in the systems examined was limited by the cathodic reaction, and thus increasing the \(\beta\)/electrolyte interfacial length in 2D or area in 3D led to an increase in the corrosion rate. Similarly, an increase in the corrosion rate with time was observed for a given simulation as the \(\alpha\) phase corrodes and exposes more of the \(\beta\) phase to the electrolyte. The distribution of the corrosion current, as well as the morphology of the corroded surface, suggests the existence of two length scales, one that is small and is associated with a larger corrosion current near the \(\alpha /\beta\) interface, and the other on a larger scale, greater than the simulation domain size we examined. Furthermore, it was found that both the 2D and 3D systems exhibit similar corrosion behavior. Detailed analyses of these results, as well as an expanded parametric study to develop a quantitative understanding of the effect of microstructure on microgalvanic corrosion in Mg alloys, are beyond the scope of this paper and will be left for a future publication. While corrosion_microgalvanic application currently does not account for diffusion of ions in the electrolyte phase, it is trivial to add it in the same manner as the original corrosion application. Moreover, new features can be added to enhance the applicability of the corrosion-related problems. For example, deposition of corrosion products from cathodic reactions, which has an important role in self-limitation of corrosion, could be implemented by the same scheme used to evolve an interface during corrosion. These additional developments are also left for future work.