1 Introduction

Polyurethane foam is used to demonstrate and evaluate the predictive capability of a multi-scale framework, namely MoDeNa. MoDeNa enables coupling of modeling tools that works on different scales. Modeling and simulation of PU provide apriori information about the final product, and how it can be modified by chemical recipes and operational conditions [17, 23, 30]. Thus, it is necessary to develop a comprehensive, yet feasible modeling platform in which different physical phenomena described on multiple scales, from molecular to macro-scale, can be integrated.

Reviewing the literature reveals that currently there is no multi-scale platform for modeling PU foams. The available models concentrate on one aspect of PU simulation. For example, Baser and Khakhar focused on the macro-scale behavior of PU foams, and solved a set of ordinary differential equations (ODEs) to describe foam density and temperature [1, 2]. Computational fluid dynamics (CFD) has also been an attractive alternative because it allows the spatial and temporal variations of different foam properties to be locally investigated. The typical method is to add extra partial differential equations (PDEs) for macroscopic phenomena, e.g., the progress of the polymerization is modeled by adding two PDEs [3, 10, 25,26,27, 29]. Considering the lower scale tools, the growth of a single bubble has been studied by different groups. Harikrishnan et al. [11] used a simple mass transfer model for the bubble growth in PU foam. A similar approach (bubble-shell model) was also adopted in which the mass and momentum balance were solved for a spherical bubble in a liquid foam to evaluate the radius of the bubble [6, 16].

Recently, Karimi et al. [14] presented a macro-scale model based on coupling VOF with a population balance equation (PBE). This enables the modeling approach to go one step further and predict the cell or bubble size distribution (BSD). However, they applied simplified models for the bubble growth based on diffusion. This has been addressed by Ferkl et al. [7] using a multi-scale modeling prototype coupling the macro- and bubble-scale models. The objective of this work is to follow up the previous attempt and develop a three-dimensional multi-scale platform for simulation of PU foams. This includes a macro-scale OpenFOAM\(^{\textregistered }\) solver in which the interconnectivity of scales is realized through MoDeNa. The solver is coupled with a detailed bubble-scale model providing the growth rate due to the presence of different gases. As the CFD code is supplemented by the solution of a PBE, the growth rate is needed to simulate the growth of bubbles via PBE. The growth rate itself depends on the dynamic characteristics of the foam during the foaming process and is too expensive to calculate on a cell-by-cell basis. Therefore, the MoDeNa is used to encapsulate the growth rate in a surrogate model with parameters that are dynamically fitted to detailed simulations. The information is then applied in the MODENAFoam solver to realistically simulate the state of gas bubbles within the foam at a much lower computational cost.

2 Governing Equations

2.1 Reaction Kinetics

PU foams are produced using a process called reaction foaming, during which polymerization occurs simultaneously with the expansion. The complex polymerization scheme can be simplified as two global reactions [1, 2]. The reaction source terms can be written in terms of polyol and water conversions as shown below.

$$\begin{aligned} S_\text {OH}&= A_\text {OH} \exp \left( -\dfrac{E_\text {OH}}{R_\text {g} T}\right) (1-X_\text {OH}) (c_{\text {NCO},0} - 2c_{\text {W},0}X_\text {W} - c_{\text {OH},0}X_\text {OH}), \end{aligned}$$
(1)
$$\begin{aligned} S_\text {W}&= A_\text {W} \exp \left( -\dfrac{E_\text {W}}{R_\text {g} T}\right) (1-X_\text {W}), \end{aligned}$$
(2)

where \(A_\text {OH}\) and \(A_\text {W}\) are the pre-exponential factors, \(E_\text {OH}\) and \(E_\text {W}\) are the activation energies, \(R_\text {g}\) is the gas constant, T is the temperature and \(c_{\text {NCO},0}\), \(c_{\text {OH},0}\), and \(c_{\text {W},0}\) are the initial concentrations of isocyanate, polyol, and water, respectively.

The temperature source terms associated with these reactions can be written as

$$\begin{aligned} S_T = \dfrac{\left( -\Delta H_\text {OH} \right) c_{\text {OH},0}}{\rho _\text {PU} c_{p,\text {f}}} \dfrac{\text {D} X_\text {OH}}{\text {D} t} + \dfrac{\left( - \Delta H_\text {W} \right) c_{\text {W},0}}{\rho _\text {PU} c_{p,\text {f}}} \dfrac{\text {D} X_\text {W}}{\text {D} t} + \sum _{i}^N \dfrac{\left( - \Delta H_{\text {v},i} \right) }{c_{p,\text {f}}} \dfrac{\text {D} w_i}{\text {D} t}, \end{aligned}$$
(3)

where t is the time, \(\Delta H_\text {OH}\) and \(\Delta H_\text {W}\) are the reaction enthalpies of the gelling and blowing reactions, \(\rho _\text {PU}\) is the density of the liquid mixture undergoing polymerization, \(c_{\text {p,f}}\) is the thermal capacity of the foam, N is the number of blowing agents, \(\Delta H_{\text {v},i}\) is the heat of evaporation for the ith blowing agent, and \(w_i\) is the mass fraction for the i-th blowing agent in the gas phase with respect to the foam.

2.2 Bubble-Scale Model

In PU foaming, a large number of air bubbles is entrained into the reaction mixture during the mixing of reactants. Thus, the system never reaches sufficient supersaturation, which would lead to nucleation. Instead, when the blowing agent is supersaturated in the reaction mixture, it diffuses into the bubbles.

The mathematical description of this process is based on idealized geometry. The bubbles are assumed to be spherical and surrounded by an effective shell of the reaction mixture, which accounts for the fact that there is a limited amount of blowing agent available for each bubble. In this case, the growth of a bubble will result in a purely radial velocity field, and thus the momentum balance can be simplified as in [6]:

$$\begin{aligned} \sum _{i=1}^N p_i + p_\text {air} - p_\text {PU} = \rho _\text {PU} \left[ R \frac{\mathrm {d}^2 R}{\mathrm {d}t^2} + \frac{3}{2}\left( \frac{\mathrm {d}R}{\mathrm {d}t} \right) ^2 \right] + \frac{2 \gamma }{R} + \frac{4 \mu _\text {PU}}{R} \frac{\mathrm {d}R}{\mathrm {d}t}, \end{aligned}$$
(4)

where \(p_i\) is the partial pressure of the ith blowing agent in the bubble, \(p_\text {PU}\) is the pressure in the reaction mixture, R is the actual bubble radius, \(\gamma \) is the surface tension and \(\mu _\text {PU}\) is the viscosity of the reaction mixture. The terms on the right-hand side represent inertial, surface tension and viscous forces, respectively.

The mass balance for the ith blowing agent in the bubble can be written as

$$\begin{aligned} \dfrac{\mathrm {d}}{\mathrm {d}t}\left( \dfrac{p_i R^3}{R_\text {g} T}\right) = 3 D_i R^2 \left. \dfrac{\partial c_i}{\partial r}\right| _{r=R}, \end{aligned}$$
(5)

where \(D_i\) is the diffusion coefficient of the blowing agent in the reaction mixture, \(c_i\) is the molar concentration of the blowing agent in the reaction mixture and r is the spatial coordinate. It is assumed that the resistance to mass transfer is entirely on the side of the reaction mixture.

Finally, the mass balance for the ith blowing agent in the reaction mixture can be written as

$$\begin{aligned} \dfrac{\partial c_i}{\partial t} + \dfrac{R^2}{r^2}\dfrac{\mathrm {d}R}{\mathrm {d}t}\dfrac{\partial c_i}{\partial r} = \dfrac{D_i}{r^2} \dfrac{\partial }{\partial r}\left( r^2 \dfrac{\partial c_i}{\partial r}\right) + r_i, \end{aligned}$$
(6)

where \(r_i\) is the reaction source term, which can be expressed as

$$\begin{aligned} r_i = {\left\{ \begin{array}{ll} c_{\text {W},0} S_W &{} \text {if } i=\text {CO}_2\\ 0 &{} \text {if } i \ne \text {CO}_2, \end{array}\right. } \end{aligned}$$
(7)

We assume that the concentration at the bubble–shell interface is given by the Henry’s law and that the blowing agent is not transported across the outer shell boundary. Thus, the boundary conditions for Eq. (6) are set according to

$$\begin{aligned} \left. c_i\right| _{r=R}&= H_i p_i, \end{aligned}$$
(8)
$$\begin{aligned} \left. \dfrac{\partial c_i}{\partial r}\right| _{r=S}&= 0, \end{aligned}$$
(9)

where \(H_i\) is the Henry constant and S is the outer radius of the shell. The size of the shell S is a function of time, but it can be directly calculated from the bubble radius and initial bubble and shell sizes assuming that the density of the reaction mixture is constant [7].

The system of differential Eqs. (46) is solved together with the reaction kinetics (see Sect. 2.1) under the assumption that the system is adiabatic. We are most interested in the continuous bubble growth rate as the quantity, which can be used in the macro-scale model. In this work, we quantify the contributions to the bubble growth rate due to each blowing agent as the molar flow rate of the blowing agent into the bubble:

$$\begin{aligned} \dot{n}_i = 4 \pi D_i R^2 \left. \dfrac{\partial c_i}{\partial r}\right| _{r=R}. \end{aligned}$$
(10)

2.3 Modeling the Macroscopic Scale

The macro-scale MODENAFoam is based on a VOF solver for two immiscible fluids, which is modified to address modeling concerns for polyurethane foam. One of the main features of the code is the implementation of a PBE. The general form of this equation considers that bubbles can grow and coalesce during foam expansion:

$$\begin{aligned} \dfrac{\partial n(\text {v})}{ \partial t} +&\nabla \cdot ( \mathbf U _f n(v))+ \dfrac{\partial }{\partial \text {v}}[G(\text {v})n(\text {v})] = \nonumber \\&\qquad \dfrac{1}{2}\int \limits _0^\text {v}\beta (\text {v}', \text {v-v}')n(\text {v}')n(\text {v-v}')\; \mathrm {d}\text {v}' - \int \limits _0^\infty \beta (\text {v},\text {v}')n(\text {v})n(\text {v}') \; \mathrm {d}\text {v}' . \end{aligned}$$
(11)

Where U\(_f\) is the foam velocity and the internal coordinate is the volume of bubble, v. The term \(n(\text {v})\) is the bubble size distribution indicating the number of bubbles per unit volume of the liquid mixture. Furthermore, the frequency of coalescence between two bubbles of volume v and v\('\) is defined with the coalescence kernel \(\beta (\text {v},\text {v}')\) and \(G(\text {v}) = \mathrm {d}\text {v} / \mathrm {d}t\) is the overall growth rate. The population balance equation [i.e., Eq. (11)] is solved by transforming it into a set of partial differential equations for the moments of BSD using the generic definition of moments:

$$\begin{aligned} m_k(t) = \int \limits _0^\infty n(\text {v})\text {v}^k \; \mathrm {d}\text {v} \; . \end{aligned}$$
(12)

This definition assigns physical meaning to each moment. For example, \(m_1(t)\) is the total volume of bubbles per unit volume of the liquid mixture. Another benefit of using the definition of generic moments is the efficiency of the computation, as it allows to follow the moments of the BSD using only 4–6 moments [19]. The evolution of the mean bubble diameter can be monitored knowing the first two moments as follows:

$$\begin{aligned} d_\text {b}(t) = \left( \frac{m_1(t)}{m_0(t)} \frac{6}{\pi } \right) ^{1/3} . \end{aligned}$$
(13)

The transport of moments within the PU foam phase is evaluated as follows:

$$\begin{aligned} {\partial m_k\over \partial t} + \left( \mathbf U _f - \alpha _\text {a}{} \mathbf U _r\right) \cdot \nabla m_k = k \sum _{\mathrm {i}=1}^N \overline{G}_k^i + \overline{S}_k . \end{aligned}$$
(14)

In this work, \(k \in [0, 3]\), and N represents the number of blowing agents. The volume fraction of surrounding air is represented as \(\alpha _\text {a}\). The source term due to different blowing agents is indicated by \(\overline{G}_k^i\), whereas \(\overline{S}_k\) is the source term for the coalescence of bubbles. More details on how to treat the source terms are reported elsewhere [14, 18].

As the solution of the PBE provides the total bubble volume per unit volume of the liquid of mixture, i.e., \(m_1(t)\), the evolution of the foam density can be expressed as

$$\begin{aligned} \rho _\text {f} = \rho _{b}\frac{m_1(t)}{1+m_1(t)} + \rho _{PU}\frac{1}{1+m_1(t)}. \end{aligned}$$
(15)

In Eq. (15), \(\rho _\text {b}\) and \(\rho _\text {PU}\) are the densities of the gas within the bubbles and of the liquid mixture, respectively.

The evolution of the temperature of the foam phase is calculated as follows:

$$\begin{aligned} {\partial T\over \partial \text {t}} + \nabla \cdot \left( \mathbf U T\right) + \left( \mathbf U - \mathbf U _r \right) \cdot \nabla T - \nabla ^2 \left( \bar{\alpha }T\right) = \alpha _\text {f} S_T, \end{aligned}$$
(16)

where \(\bar{\alpha }\) is the thermal diffusivity of the PU foam, and \(S_T\) is defined in Eq. (3). The conversions of water (\(X_\text {W}\)) and polyol (\(X_\text {OH}\)) are accounted for by adding two extra PDEs:

$$\begin{aligned} {\partial {X_\text {W}}\over \partial t} + \left( \mathbf U - \alpha _\text {a} \mathbf U _\text {r} \right) \cdot \nabla X_\text {W}&= S_\text {W} , \end{aligned}$$
(17)
$$\begin{aligned} {\partial {X_\text {OH}}\over \partial t} + \left( \mathbf U - \alpha _\text {a} \mathbf U _\text {r} \right) \cdot \nabla X_\text {OH}&= S_\text {OH} , \end{aligned}$$
(18)

Additionally, accounting for the blowing agents within the liquid mixture the mass balance for the ith blowing agent in the mixture is written as

$$\begin{aligned} {\partial w_\text {i}\over \partial \text {t} } + \left( \mathbf U - \alpha _\text {a} \mathbf U _r \right) \cdot \nabla w_\text {i} = r_{\text {i}}\frac{M_\text {i}}{\rho _{\text {PU}}} + \overline{G}_ 1 ^i \frac{P}{RT}\frac{M_\text {i}}{\rho _{\text {PU}}}, \end{aligned}$$
(19)

where \(w_\text {i}\) is the mass fraction of the ith blowing agent and \(r_\text {i}\) is defined as

$$\begin{aligned} r_\text {i}= {\left\{ \begin{array}{ll} C_{W}^{0} \frac{\text {DX}_\text {W} }{\text {D}\text {t} }, &{} \text {if}\ \text {i}=\text {CO}_2, \\ 0, &{} \text {if}\ \text {i}\ne \text {CO}_2 . \end{array}\right. } \end{aligned}$$
(20)

The molecular mass of the ith blowing agent is \(M_\text {i}\), and the symbol \(\overline{G}_ 1 ^i\) represents the moment of order one of the growth rate due to the ith blowing agent.

3 The MoDeNa Software Framework

Several strategies have been developed for building bridges across the scale-separation, thus coupling the scale-specific models, such as the heterogeneous multi-scale method (HMM) described in [28] and the equation-free approach by Kevrekidis et al. [15]. These approaches are opposite techniques for scale-bridging because HMM is a top-down approach and the equation-free method is bottom-up. The design of the MoDeNa software framework is a top-down and it aims at eliminating approximations, typically represented as constants or constitutive relationships, with surrogate models approximating the detailed models.

3.1 Design Philosophy

The philosophy underpinning the MoDeNa software framework is to ensure loose coupling between applications representing detailed models. The coupling and communication across scales is handled through recipes and adapters. Recipes perform simulations by executing applications (in-house codes or external software packages such as OpenFOAM\(^{\textregistered }\), Materials Studio, PC-Saft or in-house software) for a given set of inputs. Adapters handle the communication with the MoDeNa software framework. Both recipes and adapters are application-specific. Adapters exist as outgoing and incoming adapters. Outgoing adapters are relatively straightforward in that they perform a mapping operation (such as averaging) and communicate the results. The averaging process may have to be started and performed within the application (e.g., for time averaging). However, the results can usually be submitted in a separate process after the simulation is finished. Incoming adapters usually require that the surrogate model us embedded within the application and is, therefore, more complex.

3.2 Scale Coupling

When considering multi-scale modeling from the top-down perspective the scale coupling happens in the set of parameters (\(\mathbb {D}\)) of the individual scale-specific models (\(\mathcal {M}\)). Traditionally, it is assumed that the parameters are valid for the entire range of model inputs, \(\mathbf {u}\in \mathbf {U}_{max}\), resulting in the generic representation in Eq. (21).

$$\begin{aligned} \mathbf {y}_i = \mathcal {M}\left( \mathbf {u}_i\ ;\ \mathbb {D}\right)&;\; \mathbf {u}_i \in \mathbf {U}_{max}\;. \end{aligned}$$
(21)

The accuracy of models such as the Navier–Stokes equations has proven to be sufficient for an astonishing diversity of engineering applications. However, when the assumption no longer holds it may be necessary to replace the parameters with a set of models, \(\left\{ \mathcal {M}_{j}^{i-1} \right\} \), which provides the quantity using a model that describes the physics from first principles, as represented in Eq. (22).

$$\begin{aligned} \mathcal {M}:= \mathcal {M}\left( \mathbf {u}_{i}\ ;\ \left\{ \mathcal {M}_{j}^{i-1} \right\} \right)&; \mathbf {u}_{i} \in \mathbf {U}_{max} \end{aligned}$$
(22)

When coupling a large number of models using this strategy the practical issue of computational cost becomes important. The approach taken in the MoDeNa project was to employ surrogate models, a simplified model whose purpose is to approximate the input–output behavior of a more detailed model, in-place of scale-specific first-principle models. The parameters (\(\varvec{\theta }\)) of the surrogate model are validated in a domain (\(\mathbf {U}\)) using simulation results of the detailed model it approximates.

$$\begin{aligned} \hat{\mathbf {y}}_{i} = \hat{\mathcal {M}}\left( \mathbf {u}_{i}\ ;\ \varvec{\theta }\right) \approx \mathbf {y}_i&; \mathbf {u}_i \subset \mathbf {U}\in \mathbf {U}_{max} . \end{aligned}$$
(23)

Using the surrogate model in Eq. (22) the multi-scale detailed model becomes

$$\begin{aligned} \mathcal {M}:= \mathcal {M}\left( \mathbf {u}_{i}\ ;\ \left\{ \hat{\mathcal {M}}_{j}^{i-1} \right\} \right)&; \mathbf {u}_{i} \subset \mathbf {U}\in \mathbf {U}_{max} . \end{aligned}$$
(24)

The parameter fitting and validation of the individual surrogate models used in a scale-specific model in the form shown in Eq. (24) is done automatically by MoDeNa using the model-based design of experiments framework illustrated in Fig. 1 and outlined in [8]. The execution time of the surrogate is usually negligible compared to that of the detailed model.

3.3 Software Components

The role of the software framework in the multi-scale application is to orchestrate the overall simulation and facilitate scale coupling. It consists of an orchestrator, a database and interface library. The orchestrator is based on FireWorks [12, 13] and constitutes the backbone of the software in that it schedules simulations as well as design of experiments as well as parameter estimation operations which make up the workflow of the overall simulation. It is very much like a dynamic workflow engine, in which the different applications are “orchestrated” to obtain information, analyse and pass it to the other operations. The NoSQL database MongoDB [21] is used to store the state of the workflow as well as the surrogate models together with associated data such as model parameters, data used for parameter estimation, and meta-data.

Fig. 1
figure 1

Workflow of the model-based design of experiments procedure. The design of experiments (DoE) procedure generates a set of inputs \(\left\{ \mathbf {u}_{i} \right\} _{i=1}^{n}\), and a detailed simulation is performed using the detailed model \(\mathcal {M}\), producing a set of outputs \(\left\{ \mathbf {y}_{i} \right\} _{i=1}^{n}\). Because the inputs are generated based on the input space of the surrogate model, the framework includes scale interface models for homogenization \(\mathrm {I}\) and its inverse, lifting \(\mathrm {I}^{-1}\), respectively, transforming between the inputs and outputs of the detailed model and the surrogate model. The parameters of the surrogate model \(\varvec{\theta }\) are obtained and validated using a metric (g) against a criteria (\(\epsilon \))

The interface library consists of two parts. A high-level Python module providing database access and capabilities for performing design of experiments and regression analysis by building on MongoEngine [22] and R [9, 24], respectively. The second part is a low-level library providing unified access to the surrogate models. This component is written in C to ensure interoperability across platforms and target applications while providing the computationally efficient model execution required by the applications. The library is loaded as a shared library by the macroscopic-scale applications or as a native Python extension by the high-level Python module ensuring that all components instantiate identical model implementations. Complex operations such as database access are referred back to the high-level Python module using call-back mechanisms.

3.4 Coupling of Macro- and Bubble-Scale Models

The MoDeNa framework handles the communication between the MODENAFoam solver and embedded models. As an example, the design, implementation and embedding of the bubble growth model through the use of a surrogate model is explained in detail. Other models follow the same principles. A suitable surrogate model for bubble growth is based on the concentration difference of blowing agent between liquid and gas phase:

$$\begin{aligned} \dot{n}_i = 4 \pi R^2 \alpha R^\beta \left( \frac{w_i \rho _\text {PU}}{M_i} - H_i(T) p_i, \right) , \end{aligned}$$
(25)

where \(\alpha \) and \(\beta \) are the fitting parameters. The surrogate model provides bubble growth rate in terms of state variables R, \(w_i\), \(p_i\) and T (solubility is generally a function of temperature).

Since the bubble growth model itself is a transient simulation, it cannot be directly used to determine bubble growth rate for desired state conditions. Instead, the detailed model is used to simulate the foaming from the same initial conditions as the macro-scale tool and both the state variables and the growth rate are saved at fixed intervals. These values are then used to determine the fitting parameters \(\alpha \) and \(\beta \). Afterward, the surrogate model can be called from the macro-scale tool.

4 MoDeNa as a Functional Piece in Applications

In order to understand the interaction between the MoDeNa software framework and the OpenFOAM\(^{\textregistered }\) application it is necessary to consider the definition of surrogate models and how they are embedded into applications, as well as the role of the MoDeNa framework in the overall simulation.

4.1 Defining Surrogate Models

A core design-principle in the MoDeNa software framework is that the surrogate models are self-contained. Consequently, the definition must provide sufficient information to represent the generic function representation shown in Eq. (23), as well as identifying the model it approximates. However, the MoDeNa framework also demands that the author of the surrogate model provides recipes for how to read/write input files for the detailed model application as well as specifying the strategies that MoDeNa should invoke in order to resolve run-time exceptions related to the model. The figure below illustrates the information that is provided in order to define the model interface and properties of the surrogate model. The definition of the models are implemented in the Python programming language using predefined templates and software infrastructure provided by the high-level application program interface. Consequently, every scale-specific detailed model in the multi-scale application becomes a Python module; thus aiding in providing structure to the overall project which may involve a large number of models.

Fig. 2
figure 2

Illustration of the data that is provided in the definition of a MoDeNa surrogate model. All information is provided as Python dictionaries and the model properties are implemented using templates provided by the framework. This means that objects can be de-serialized directly from a database of a flat file

The purpose of the model-definition is to facilitate the development of models in relative isolation, such that authors of scale-specific models only need to be concerned with the information that should be passed between the models when MoDeNa couples them together. The benefit of this approach becomes apparent when considering how to embed the MoDeNa models inside an OpenFOAM\(^{\textregistered }\) application.

4.2 Embedding Surrogate Models into OpenFOAM\(^{\textregistered }\)

The footprint of the MoDeNa framework inside the OpenFOAM\(^{\textregistered }\) applications is low, and the self-sufficiency of the surrogate models eliminates the need to link the OpenFOAM\(^{\textregistered }\) application with libraries other than MoDeNa. However, in order to use surrogate models defined as modules in the MoDeNa software framework it is necessary to implement adaptors, i.e., code fragments calling the MoDeNa low-level library, inside the OpenFOAM\(^{\textregistered }\) application.

The major difference between the MoDeNa coupling and a traditional “exhaustive” approach, where OpenFOAM\(^{\textregistered }\) writes input files, executes the external application and reads the output is illustrates in Fig. 2. The low-level MoDeNa library is developed in C, but the surrogate models are still implemented as abstract data types that hide unnecessary implementation details from the user. However, since Fig. 2 clearly illustrates that the workflow for using the surrogate models is an excellent candidate for object-orientation the MoDeNa framework also provides a C++ class for easy integration into OpenFOAM\(^{\textregistered }\) (Fig. 3).

Fig. 3
figure 3

Illustration of a “exhaustive” (left) and MoDeNa-style (right) coupling between two applications, or detailed models. The MoDeNa approach can be thought of as a combination between a library API and the “exhaustive” input/output file approach. The benefit is that the API will look the same for all models, and there is no intrusion of code specific to other applications

4.3 Overall Simulation Workflow

The role of the MoDeNa software framework in the OpenFOAM\(^{\textregistered }\) application is to ensure that the surrogate models are ready to be used. This is largely handled by the Python layer of the software, which is where the computational workflow and database management take place.

The software framework does not communicate with the database during the OpenFOAM\(^{\textregistered }\) simulation assuming the execution of the surrogate model produces no exceptions. In this case, the database will only be used to instantiate the models at the beginning of the simulation. The ideal illustration is not accurate when the workflow is changed dynamically to accommodate the parameter-estimation procedure from Fig. 1. However, the software framework updates the state of the model in the database after each parameter-estimation run, which means that subsequent OpenFOAM\(^{\textregistered }\) simulations will not be interrupted (Fig. 4).

Fig. 4
figure 4

Illustration of the workflow of an OpenFOAM\(^{\textregistered }\) application (blue) in which calls to the MoDeNa software framework have been embedded (solid black lines). The workflow is ideal in the sense that error checks and exceptions related to the MoDeNa surrogate model have been omitted. The low-level C-layer of the MoDeNa framework (white) encapsulates the surrogate model, which is instantiated from the database by the high-level Python interface (gray)

5 Physical Properties and Operating Conditions

The viscosity of the liquid reaction mixture is modeled by Castro–Macosko model:

$$\begin{aligned} \mu _\text {PU} = A \exp \left( \dfrac{E}{R_\text {g} T}\right) \left( \dfrac{X_\text {OH,g}}{X_\text {OH,g}-X_\text {OH}}\right) ^{B+C X_\text {OH}}, \end{aligned}$$
(26)

where \(A=4.1 \times 10^{-8}\,{\text {Pas}}\), \(E=38.3 \times 10^{3}\,{\text {J}} {\text {mol}} ^{-1}\), \(B=4.0\), \(C=-2.0\) are constants determined from experiments [5]. \(X_\text {OH,g} = 0.5\) is the conversion of polyols at the gel point.

A non-Newtonian model is instead applied for the calculation of foam apparent viscocity based on the Bird–Carreau theory [4]:

$$\begin{aligned} \mu _f\left( T, X_{\text {OH}}, \dot{\gamma }\right) = A_{\text {OH}}\exp \left( \frac{E_{\text {OH}}}{R_gT}\right) \times \left( \mu _\infty + \left( \mu _0 - \mu _\infty \right) \left( 1 + (\dot{\gamma }\bar{\Lambda })^{\zeta }\right) ^{\frac{n-1}{\zeta }} \right) \end{aligned}$$
(27)

In Eq. 27, \(\mu _0\) and \(\mu _\infty \) are the values of foam viscosity under the minimum and maximum shear rates. The constants utilized in this work are: \(\bar{\Lambda } = 11.35\), \(\zeta = 2.0\), and \(n = 0.2\). The rest of the physical properties and operating conditions are summarized in Table 1.

Table 1 Kinetic parameters, operating conditions and material properties
Fig. 5
figure 5

The bubble growth rate as calculated by the detailed model (see Sect. 2.2) and the surrogate model Eq. 25

Fig. 6
figure 6

MODENAFoam predictions of foam density (top-left), conversion of components (top-right), temperature profile (bottom-left), and bubble radius (bottom-right) as a function of time

6 Results and Discussion

In this section, two cases are used to illustrate the efficiency of the coupling strategy in the MoDeNa framework. We first present the comparison between the detailed and surrogate model for the bubble growth (see Fig. 5). This is important in the coupling, as the purpose of the surrogate model is to provide a fast and viable mean value for estimating the growth rate of the bubbles. It can be seen that the growth rates computed by the surrogate model are reasonably accurate when compared to the detailed model. Second, the numerical predictions of the foam properties are validated with experimental measurements. This is to confirm how close the framework outputs are to the reality. Additional validation studies were reported in [7]. The foam properties predicted by MODENAFoam are shown in Fig. 6. The recipe, and by extension the simulation case, uses a chemical blowing agent, water, without any physical blowing agent. The measurements are done for a classical “beaker test”, which was simulated as a two-dimensional geometry with 10% liquid mixture filling at the beginning. Generally, the agreement between the experimental data and the numerical predictions of the foam density and temperature is reasonably good. However, the density predictions show better agreement compared to the temperature. The inconsistency between the predicted and measured temperatures can mainly be attributed to two factors: (1) that the heat capacity for the liquid mixture was assumed to be constant and (2) the lack of data for the enthalpies of the chemical reactions.

The conversion of reactants as well as the evolution of the bubble radius is also shown in order to demonstrate that detailed information can be extracted from the results. It is interesting to notice that the concentration of blowing agent within the liquid mixture requires a few seconds at the commence of foaming to reach to the equilibrium value. This physical phenomenon can be seen as the flat lines on the plots. This implies that during the first 20 s of the foaming process the concentration of CO\(_2\) in the liquid mixture increases to the equilibrium value before diffusing into the bubbles; thereby growing the bubbles and decreasing the density of the foam. The evolution of bubble size also confirms this phenomenon.

7 Conclusions

The MoDeNa software framework is introduced in this work as an open-source library for multi-scale modeling. The benefit of utilizing MoDeNa is demonstrated when it is applied for the simulation of PU foams. As an example, a bubble-scale model for the growth of gas bubbles is linked to a macro-scale CFD tool. The lower scale model provides growth rates due to the presence of different blowing agents for the macro-scale tool. The CFD code is augmented with a population balance equation that uses the results from the bubble growth model. Furthermore, the multi-scale model is validated for the prediction of PU foam properties and the numerical results are compared with experimental data. The observed agreement assures that the framework handles the transfer of information between different models and that each scale-specific model is accurate in their predictions of meso- and macro-scale properties of the PU foam. This work will continue to incorporate more modeling tools (e.g., a detailed kinetic model) for the simulation of PU foams.