Sebastian Knolla,
Klara Silber
bc,
Jason D. Williams
bc,
Peter Sagmeister
bc,
Christopher A. Hone
*bc,
C. Oliver Kappe
bc,
Martin Steinbergera and
Martin Horn*a
aInstitute of Automation and Control, Graz University of Technology, Inffeldgasse 21b, 8010 Graz, Austria. E-mail: martin.horn@tugraz.at
bCenter for Continuous Synthesis and Processing (CCFLOW), Research Center Pharmaceutical Engineering GmbH (RCPE), Inffeldgasse 13, 8010 Graz, Austria. E-mail: christopher.hone@rcpe.at
cInstitute of Chemistry, University of Graz, NAWI Graz, Heinrichstrasse 28, 8010 Graz, Austria
First published on 12th September 2025
This paper introduces a versatile, open-source MATLAB/Simulink toolbox for modeling and optimizing flow reactors. The toolbox features a modular architecture and an intuitive drag-and-drop interface, supporting a range of different modeling approaches, including physics-based, data-driven, and hybrid models such as physics-informed neural networks. We detail the toolbox's implementation and demonstrate its capabilities through real-world applications, including the simulation of flow reactors, identification of reaction parameters using experimental data (e.g., transient data), and optimization of reactor operating points and configurations. Experimental validations illustrate the practical applicability and effectiveness of the toolbox, making it a valuable resource for researchers and engineers in the field with the potential of reducing the cost and time required for parameter determination and reactor optimization.
The increased interest in the usage of transient measurements in flow reactors can also be seen in literature. Moore et al. presented a method using inline IR spectroscopy and an automated microreactor system to generate time-series reaction data from flow reactors, providing a continuous and efficient alternative to traditional batch experiments for studying reaction kinetics.6 Schrecker et al. used transient flow methodology to study the Knorr pyrazole synthesis under pH-neutral conditions, uncovering a new intermediate and revising the reaction mechanism, with insights into autocatalysis.7 Williams et al. reviewed the use of dynamic flow experiments in optimizing chemical processes, emphasizing their role in generating data for accurate kinetic models and identifying optimal conditions for more efficient, sustainable manufacturing.8 Aroh et al. presented an improved method for reaction kinetics studies using continuous flow microreactors, where simultaneous variation of temperature and flow rate enables rapid concentration profile generation and efficient kinetic analysis.9
Moreover, the integration of continuous flow and automation technologies has been shown to significantly enhance efficiency and safety in organic synthesis.10 State-of-the-art automation technologies, such as machine learning-driven optimization11,12 and robotic platforms,13 have enabled precise reaction monitoring and real-time adjustments.14 This advance is minimizing human intervention while maximizing efficiency.15 Furthermore, recent efforts in autonomous model-based experimental design underscore the potential of combining automation with predictive modeling to accelerate reaction development and significantly reduce the time required for process optimization.16
In parallel, modeling approaches have significantly advanced to support the design and optimization of flow systems. Traditional empirical models are now augmented by computational tools that integrate both physics-based models (PBMs) and data-driven models (DDMs).17,18 PBMs, such as the tanks-in-series model, and the axial-dispersion model, provide valuable insights into complex phenomena like mixing, heat transfer, and reaction kinetics. The tanks-in-series and axial-dispersion models are widely used to model fluid mixing and dispersion in flow reactors, offering critical insights into residence time distribution and reaction efficiency.19–21 Moreover, transfer functions are employed to analyze and predict the dynamic response of flow systems to various input changes, such as variations in flow rate or temperature, enabling precise control and optimization of reactor performance.22 In addition, DDM, such as machine learning algorithms, are increasingly utilized to predict system behavior by identifying patterns and relationships within large datasets, allowing for rapid and accurate predictions and optimizations even in complex systems.23 These models excel in areas where traditional PBM may struggle, such as handling non-linearities or high-dimensional parameter spaces. Furthermore, emerging hybrid models, such as physics-informed neural networks, combine the strengths of PBM and DDM, leveraging physical laws to guide learning processes and ensuring predictions adhere to known system constraints while benefiting from the flexibility of data-driven approaches.24,25
Despite these advances, automation and advanced modeling of flow chemistry remain a challenge.26 Specifically, the integration of automation and modeling into flow chemistry continues to face difficulties, particularly in areas such as process control, reaction optimization, process monitoring, scale-up, and data integration.27 Efforts are being made to develop user-friendly toolboxes that integrate data acquisition, analysis, and modeling into a single platform for greater convenience. Existing software such as CHEMCAD,28 Aspen Plus,29 gPROMS,30 and Python-based libraries such as OpenFOAM31 or Cantera32 provide valuable resources for simulation and optimization. While they are powerful for simulation and optimization, they often can be complex and require significant expertise to operate effectively, limiting their accessibility for non-expert users. Furthermore, while Python-based libraries including OpenFOAM and Cantera are flexible and open-source, they can be challenging to configure and may require substantial computational resources for large-scale simulations. Additionally, some of the commercial solutions, such as CHEMCAD, Aspen Plus, and gProms, are costly, making them less accessible for smaller organizations or academic researchers.
Thus, we present a lightweight MATLAB/Simulink toolbox for modeling flow reactors in a modular way. We intentionally chose MATLAB due to its widespread use in academia and industry, especially in pharmaceutical and chemical engineering. Many users are already familiar with MATLAB, enabling faster adoption, easy integration into workflows, and connection to lab equipment. Our toolbox targets small-scale continuous flow applications with user-friendly, transparent modeling including physics-informed neural networks which are not commonly supported by commercial tools. Importantly, it offers the opportunity for users to deepen their understanding and skills through transparent model structures and detailed documentation. Our toolbox supports various approaches like PBM, DDM, and combinations. It includes models such as transfer functions, tanks-in-series models, axial-dispersion models, and neural network-based methods, such as physics-informed neural networks. The toolbox requires minimal input data but allows for detailed model parameter specifications. Users can combine approaches to simulate real experiments, rebuild real-world reactor setups and optimize for reaction parameters. Moreover, it is possible to apply transient experimental data to identify reaction parameters which can reduce time and cost. Additionally, the toolbox aids in optimizing reactor operations and setups and can be used to find the pareto front for a defined setting. In the toolbox, we combine all common modeling approaches into one lightweight solution, allowing users to focus on the analysis and research rather than the implementation of models or optimizations. An overview of the concept of the developed toolbox can be found in Fig. 1.
The paper is organized as follows. First, we cover the necessary theoretical background and notations of the modeling approaches. Next, we introduce the toolbox, detailing the implementation for each modeling approach and demonstrating how it can be used to simulate real-world reactor setups. In the subsequent section, we describe how reaction parameters can be identified using our toolbox, including details on training a physics-informed neural network to obtain these parameters, and we validate the found parameters using additional experiments. Finally, we show how the toolbox can be used to optimize operating points and the reactor setup itself.
The dead-time element accounts for the nominal delay experienced by species as they flow through the pipe. This delay is given by τ(L,q) = L/q where L denotes the length of the tube, t the time, and q(t) the flow rate of the species. For ideal plug flow, where the species experiences only a delay without any change in the shape of the inflowing concentration, a dead-time element alone would suffice. However, in most cases, the flow through the reactor is not ideal, and additional effects such as dispersion alter the shape of the inflowing concentration. To account for these changes, a low-pass filter of n-th order is introduced. The parameters of this low-pass filter can be tuned to accurately describe the observed behavior, including dispersion-induced modifications to the concentration profile of the species.
A corresponding transfer function HL,q(s) for describing the delay and dispersion effects of an inflowing species with concentration (in)(s) into a tube of length L and a constant flow rate q(t) = q can thus be stated as
![]() | (1) |
In the equation, s denotes the Laplace variable, (out)(s) the outflowing concentration, and the term PTL,qn(s) represents the low-pass filter of n-th order. The superscript in HL,q(s) and PTL,qn(s) specifies the used tube length L and flow rate q. As the transfer function HL,q(s), especially the low-pass filter PTL,qn(s), can change for different tube lengths L and flow rates q it might be necessary, to have separate transfer functions for the individual combinations.
For changing parameters, it is also possible to form the resulting parameters of the transfer function by interpolating the parameters of the transfer function within two (or more) given anchor points. An anchor point, in this context, defines the parameters of the transfer function corresponding to a specific flow rate q and length L.
In Fig. 2, a schematic representation of a tanks-in-series model is shown. The figure illustrates a sequence of N interconnected tanks. Species flow sequentially from the first tank to the second, and continuing through the series. The concentration of the i-th species in the j-th tank is represented by Cij(t).
![]() | ||
Fig. 2 A schematic overview of a tanks-in-series model where the reactor is split into N tanks which are perfectly mixed and species are flowing from one tank to the next. (Reproduced from ref. 18 with permission from the Royal Society of Chemistry.) |
The change of the i-th concentration within the j-th tank is given by
![]() | (2) |
In the equation, ΔVj denotes the volume of the j-th tank, while (t) represents the volumetric flow rate of the fluid passing through the system. In general, each tank of the tanks-in-series model will be of the same size and thus all tanks will have the same volume ΔV resulting in ΔVj = ΔV, ∀j ∈ {1, 2, …, N}. The term rij(Cmj(t),…,ϑ(t)) accounts for changes due to reactions. The underlying reactions can depend on various factors, including other concentrations within the current tank j or the temperature ϑ(t). As the reactors are usually heated evenly across their entire length, it is assumed, that the temperature ϑ(t) remains uniform throughout the entire reactor system. The input to the tanks-in-series model consists of all the inflowing concentrations C(in)i(t). As these concentrations enter the first tank, the relationship C0i(t) = C(in)i(t) applies. The number of tanks N can be used to simulate various degrees of mixing within the tanks-in-series model. When choosing N = 1 the tanks-in-series model represents a homogeneously mixed reactor while for N → ∞ ideal plug flow is modeled.
In Fig. 3 a reactor of length L with the main effects of the axial-dispersion model is depicted. One can see, that the concentration Ci(z,t) of the i-th species is given as function of space z and time t. Moreover, not only convection due to the flow rate q(t) is present but also axial-dispersion effects.
The axial-dispersion model is given by the partial differential equation (PDE) of the form
![]() | (3) |
In the model, Ci(z,t) denotes the concentration of the i-th species, D denotes the axial-dispersion coefficient and q(t) the flow rate of the solute through the system. Reactions are accounted for by the term ri(Cmj(z,t),…,ϑ(t)), which can depend on various factors, including other concentrations, and the temperature ϑ(t).
In Fig. 4, a fully connected multi-layer perceptron neural network is illustrated. As shown, the neural network is structured into three main components: an input layer, one or more hidden layers, and an output layer. Each layer comprises a specific number of neurons, in which every neuron in a layer is connected to all neurons in the preceding layer. These connections transmit the output values of the previous neuron to the next neurons, whereby each connection has an assigned weight that scales the transmitted value. Within a neuron, the weighted sum of all incoming connections plus a bias is computed, and an activation function is applied to this sum. The activation function, which can be non-linear (e.g., sigmoid or softmax), transforms the value before passing it to the neurons in the next layer. The number of neurons in the input layer must match the number of input features NI, while the output layer must have as many neurons as there are target labels NO. The architecture of the hidden layers, including the number of neurons and layers, depends on the complexity of the specific problem. According to the universal approximation theorem,34,35 even a shallow neural network with a sufficient number of neurons can approximate any continuous function under certain conditions. This demonstrates the theoretical capability of a neural network for a wide range of tasks.
Given the introduced structure, one can define a neural network with NL + 1 layers, as
![]() | (4) |
In eqn (4), θ represents the neural network parameters consisting of the matrices Wi and the bias vectors bi, ∀i ∈ {0, …, NL − 1}. Thereby, the matrices Wi and the bias vectors bi represent the connections of the neurons from layer i to the next layer i + 1 and the bias values of each neuron within the i-th layer respectively. The activation functions within the i-th layer are represented by zi.
The goal of the neural network is to reconstruct an unknown function
such that
where
denotes the input. To achieve that the neural network
maps an input
to the corresponding output
accordingly, the neural network
has to be trained. In the training, the parameters θ of the neural network
are optimized in such a way, that a defined loss function
is minimized. Given a set of NS input–output samples {(mk, nk): k = 1, …, NS}, where
is a input-sample,
the corresponding output-sample, and the prediction
of the neural network
, the loss function can be defined as
![]() | (5) |
In the equation, ‖·‖2 denotes the L2-norm and one can see, that the loss function combines a penalization term and a regularization term, each weighted by the factors λP and λR, respectively. Generally, these terms take various forms: the penalization term penalizes deviations of predicted values from the actual values, while the regularization term mitigates overfitting by discouraging extreme weights in the neural network
. Minimizing the loss function
involves an iterative process, where each iteration consists of a forward and a backward pass. In the forward pass, the loss is computed based on the current neural network parameters θ. During the backward pass, the parameters θ are updated using a gradient-based method derived from the computed loss. This process is commonly referred to as “backpropagation”.
The principle of physics-informed neural networks lies in their ability to integrate physical laws, represented by PDEs or other governing equations, directly into the neural network training process. Unlike traditional neural networks that rely solely on data for training, physics-informed neural networks incorporate these physical principles as part of the loss function. This approach ensures that the learned solution not only fits the available data but also covers the underlying physical laws, such as conservation laws, boundary conditions, or dynamic equations. By embedding this additional layer of information, physics-informed neural networks achieve higher accuracy with smaller datasets and can model complex systems where data might be sparse or noisy, making them particularly powerful for solving scientific and engineering problems.
For the integration of the physical principles into the training of the neural network, the loss function of the physics-informed neural network can be defined as
![]() | (6) |
In the equation, represents the loss from the penalization term, while
corresponds to the regularization term similar as in the loss of a neural network. The terms
and
represent the losses associated with the incorporated physical principles and the boundary conditions, respectively. The two latter terms depend on physical parameters, collectively denoted as Γ. These terms are formulated to measure the deviations between the predicted behavior and the physical behavior. Each of the terms is multiplied by a factor λ to appropriately weight their contributions relative to one another.
By setting λPDE and λB to zero, the corresponding terms in the loss function vanish, reducing the setup to a standard neural network training configuration without physics-informed constraints. On the other hand, setting λP to zero enables the training of a neural network solely to reconstruct the PDE solution without relying on any data. A balanced combination of these factors allows for a trade-off between utilizing data-driven learning and incorporating physical knowledge into the model. This approach also provides the flexibility to identify the physical parameters Γ, ensuring that the model aligns with both empirical observations and the underlying physical principles.
In Fig. 5 the concept of the toolbox is depicted. One can see, how a flow reactor is built by choosing the necessary parts out of the toolbox. It is possible to select from various modeling approaches the best option or use them in combination.
Before using the toolbox, the toolbox has to be initialized whereby all the necessary variables and information of the interface are generated. The initialization of the toolbox can be achieved by calling one provided method within a MATLAB/Simulink script.
In addition to implementing the most common modeling approaches, discussed in more detail in the following subsections, we developed various reactor components, including Pumps, Buffers, Tees, Experiments, Analyzers, toOptimization, and toPlot. Pumps, Buffers, and Tees are used to model inputs and flow distribution within the system. Analyzers enable the analysis of concentrations, flow rates, and temperature at specific points of interest. The Experiments block facilitates the incorporation of input data and measured concentrations into the project, allowing for comparison and ensuring consistency with real-world inputs. The toOptimization block seamlessly transfers setup information to an optimization task, while the toPlot block simplifies the visualization of output data, such as concentrations.
In the equation, the time constants T1 and T2 define the effect of the dispersion effects. Additionally, a delay offset τε can be used, if the real-world behavior shows slightly different results within the nominal delay than expected from theory. The resulting dispersion effects for different time constants T1 and T2 are depicted in Fig. 6. In the figure, a step from 0 to 0.1 at time t = 0 on the inlet concentration is applied. This step is often denoted by C(in)(t) = 0.1σ(t). In the figure, one can see, that the step becomes smoother and more curved as the time constants T1 and T2 increase.
![]() | ||
Fig. 6 Step response of a transfer function using a low-pass filter of 2-nd order for various time constants T1 and T2 and setting the nominal delay τ(q, L) = 0 and τε = 0. |
As the dispersion effects might change for different flow rates q and tube lengths L, also the time constants T1 and T2 have to change for the different settings. Thus the Simulink block provides the possibility, to define several anchor points for different flow rates q and a given tube length L. For flow rates in between two anchor points the parameters T1, T2 and the delay offset τε are linearly interpolated to allow a smooth transition and to allow to have flow rates in between two anchor points.
For the implementation in MATLAB/Simulink, the time-continuous transfer function HL,q(s) is discretized using a definable discretization time Td and using the discretization Method of Tustin.36 Using the Method of Tustin, the discretized transfer function HL,qd(z) is found by
![]() | (7) |
x(t) = [C11(t) C12(t)…C1N(t) … CP1(t) … CPN(t)]T. | (8) |
This results in the state-space model of the form
![]() | (9) |
![]() | (10) |
In the equation, the expressions diag(Λ,P), and diag(b,P) represent a block diagonal matrix where the matrix Λ and the vector b are repeated P times along the diagonal respectively. As
![]() | (11) |
For the implementation, the state-space model is discretized using the ZOH-method37 and a definable discretization time Td. Additionally the implementation allows several reactions within the tanks-in-series model to be defined. The form of the reaction is defined as a second order reaction whereby the reaction rate is described by the Arrhenius equation, which relates the reaction rate to temperature and an activation energy.38 Given a reaction where species m and species n react to species i, the reaction within each tank j can be stated as
![]() | (12) |
In the equation, Ai denotes the pre-exponential factor, and Ea,i the activation energy of the reaction forming species i. The reaction rate ki(ϑ(t)) is the same throughout all tanks. The temperature in Kelvin is denoted with ϑ(t) and the universal gas constant with R.
![]() | (13) |
![]() | (14) |
![]() | (15) |
![]() | (16) |
![]() | (17) |
For the implementation, the resulting state-space model is again discretized using the ZOH-method. As the tanks-in-series model and the axial-dispersion model result in a comparable model, both models are implemented within the same Simulink-block. Defining the axial-dispersion coefficient D accordingly, one can define which model is used.
![]() | (18) |
For the training we use the Adam optimization algorithm39 to optimize the neural network parameters θ. In the implementation, the resulting neural network can be used within a Simulink file or standalone within a MATLAB/Simulink script itself. In general, it is considered good practice to split the available data into separate training and validation (or test) sets. This allows for evaluating the model's ability to generalize and helps prevent overfitting. The toolbox supports this approach by letting users supply only the training data to the training function, while the trained neural network can be evaluated on the remaining validation data. Additionally, the method can be adapted to incorporate test data directly into the training process if needed (for example, for early stopping). Moreover, hyperparameter tuning is commonly applied during neural network training to improve performance. Although no hyperparameter tuning was performed at this stage, the framework is designed to be extensible, enabling users to add such optimization techniques if desired. This could lead to improved model accuracy by systematically selecting the best training configurations.
![]() | (19) |
![]() | (20) |
For the input-sample mk we use the same as for the training of a neural network. When we assume, that we have Ns input–output samples (mk, nk) for k ∈ {1, …, Ns} which can be used for the training, we can define the penalization term within our loss function as
![]() | (21) |
In the equation, the elements C0i,k, and Ci,kN are extracted from the current predictions of the neural network whereas the elements C(out)i,k, and C(in)i,k are from the output-sample nk.
In addition to the data-driven loss , we can define a cost term derived from the incorporated axial-dispersion model. By discretizing the axial-dispersion model from eqn (14) in both the spatial and temporal dimensions, we can compute the residual and utilize it as a cost factor. The resulting cost term
, reflecting the incorporated physical relations, thus reads as:
![]() | (22) |
In the cost term, Δt = Td, , and each concentration Ci,kj is predicted by the neural network
. Additionally, to the two losses and the regularization term, which we described in the theoretical background, we add a loss factor to ensure that the physical parameters Γ stay within physically feasible bounds. We do that, by defining the additional cost
![]() | (23) |
For the total cost , which is used for the training of the physics-informed neural network, we use the combination of all defined costs and weight them with the terms λ relative to each other. The overall cost thus reads as
![]() | (24) |
As we penalize any deviations of our boundary conditions (13) already in the penalization term , we can set the cost term due to the boundary conditions
. For the training of the physics-informed neural network
, the Adam optimization algorithm is again employed. As with the neural network training, no hyperparameter tuning was conducted at this stage. However, the method can also be extended to incorporate such optimization for physics-informed neural networks, which may further improve model performance.
Within our toolbox FlowMat, we can model the reactor setup. Here, we can choose one of the different modeling approaches or combinations of them to model the tubes within the three segments. As the tracer flowing through the pipes will only experience delay and dispersion effects, the approach using transfer functions is the most lightweight one. Besides rebuilding the reactor setup, we can import the measurements from the experiments, to use the real flow rates of the pumps and directly, enabling direct comparisons between the measured and simulated tracer profiles after each segment.
Fig. 8 compares the measured and simulated tracer values from the first tracer experiment. In the first experiment, the tube lengths and diameters remained constant over time for each segment, while the flow rates were varied. To model the tubes, the modeling approach of transfer functions was applied. The time constants T1 and T2 were manually adjusted during the initial use of a tube to ensure alignment between the simulated values and the measured data. The time constants represent the dynamic response of the system and capture the dispersion behavior of the tracer within the tubing. While T1 and T2 were empirically adjusted in the present study to achieve good agreement with experimental data, they are physically motivated and could be estimated based on tube geometry and flow characteristics. The toolbox also allows for optimizing these parameters based on step response experiments, or they can be estimated using correlations from literature. Additionally, Fig. 6 in Section 3.2.1 illustrates the influence of T1 and T2 on a representative step response and can serve as a guide for parameter selection. The overall effort for identifying suitable parameters is low, typically requiring only one or two short tracer experiments per tube, making the approach practical for routine use. While an optimization based on experimental data may require more effort, it can yield more accurate results tailored to specific setups. Subsequently, these time constants were reused in other experiments involving the same tube to demonstrate their applicability and consistency across different experiments. Since the dispersion effects vary with different flow rates, several anchor points were used to define the time constants for some of those flow rates. Between these anchor points, the time parameters of the transfer function were linearly interpolated.
The results seen in the figure demonstrate that the overall concept of simulating delay and dispersion effects is valid, as the simulated and measured traces show good agreement. Additionally, the results clearly demonstrate the validity of the interpolation method between two anchor points. The slight peak observed in the concentration after the first segment of the model prediction around t = 0.6 hours can be attributed to minor inaccuracies during the transition between pump settings at the beginning of a new tracer step. These transient fluctuations cause a short-lived disturbance in the tracer profile. The peak is apparent in the simulation, as the raw pump data is used as input.
The identified parameters of the tubes used can be stored for experiments involving the same tube within a segment. This allows for reusing parameters of previously identified tubes, requiring only the characterization of new tubes.
• the first species C1(t) is iso-propanol, acting as solvent,
• the second species C2(t) is ethanolamine (NH2–CH2–CH2OH) at a concentration of 1.5 mol L−1, and
• the third species C3(t) is 2,5-hexanedione (C6H8O2) at 1.5 mol L−1.
The experimental setup consisted of pumping all three components into a 5 mL flow reactor under controlled flow rates and temperature conditions. Feed solutions were delivered using Knauer AZURA P 4.1S HPLC pumps (10 mL min−1 pump head, Hastelloy/ceramic, equipped with pressure sensors). To maintain consistent system pressure, a back pressure regulator (BPR, Upchurch, P-465) with a 34 bar (green, P-765) cartridge was installed directly downstream of each HPLC pump. The inlet streams were combined using a 7-port mixer (3 ports blocked with blanks), and the flow reactor was assembled with PFA tubing (0.8 mm i.d.) and thermostated using a Huber Ministat 240. The reaction mixture was continuously monitored using inline FTIR spectroscopy (Mettler Toledo React IR 15) with a DS Micro Flow Cell Diamond flow cell. Downstream of the FTIR, a membrane-based BPR (Zaiput BPR-10) set to 5 bar was integrated to regulate pressure within the reactor. Details on the selected input flow rates and reactor temperature are provided in Fig. 9.
The HPLC pumps and the thermostat were integrated into the experimental setup via RS232 connections to the HiTec Zang LabManager. The flow rate and temperature ramps were programmed using HiText (HiTec Zang), with setpoints configured in the LabVision software (HiTec Zang). Inline FTIR spectra were acquired using a Mettler Toledo ReactIR 15 equipped with a DS Micro Flow Cell Diamond. Data points were recorded every 15 seconds, with spectra captured between 4000 and 600 cm−1 at a resolution of 4 cm−1. The spectra were exported using iCIR7 software and automatically processed with a PLS model in Peaxact Process Link (S-PACT), ensuring efficient and accurate data analysis.
Within the reactor, ethanolamine reacts with hexanedione to form the final product (1-(2-hydroxyethyl)-2,5-dimethylpyrrole) along with two molecules of water. The final product is referred to as species C4(t). The concentrations of the final product and residual materials are measured after the flow reactor. To allow the cleaning of the used PAT, an additional path was added in which the solvent is pumped through the end part of the reactor allowing to flush any residual material out of the sensor of the FTIR. One can find the reactor setup and the stoichiometry of the Paal–Knorr reaction with one reaction in Fig. 10.
In our Simulink model we can make use of the tanks-in-series model, the axial-dispersion model or data-driven approaches to include reactions within our reactor model. For the first validation including one reaction, we make use of the axial-dispersion model where we use the parameters found by the external software solution Dynochem.40 Dynochem is a process simulation and optimization software developed by Scale-up Systems, widely used in the pharmaceutical and chemical industries for modeling and optimizing batch and continuous manufacturing processes. It can also be used to identify parameters, supporting rapid scale-up, troubleshooting, and process development to enable efficient and reliable production workflows. After entering the parameters and importing the experimental data, we can simulate the flow reactor using the same flow rates as for the real-world experiment. After the simulation, we can directly compare the results with the measurements from the experiments.
In Fig. 11 the measured and simulated traces for the formed product and the remaining starting material (diketone – C3(t)) is depicted. As one can see, the simulated flow reactor depicts the real-world behavior well and thus validating the results of the toolbox when using the axial-dispersion model. As the axial-dispersion model is comparable to the tanks-in-series model as we can set the axial-dispersion coefficient D = 0, we can also state, that the simulation can be used to validate the tanks-in-series model. Additionally to the outflowing concentrations, the toolbox can also deliver the spatial information within the reactor which is depicted in Fig. 12. Thus it is possible to immediately see how the species are consumed and formed throughout time and space, which might be a useful insight when designing the reactions and the reactor setup.
![]() | ||
Fig. 12 Spatial reactor insight of the Paal–Knorr reaction with one reaction using the axial-dispersion model. |
Besides the PBM, one can also use DDM to model those reactor systems such as a neural network. Thus we used the toolbox to train a shallow fully connected neural network using the experimental data. As mentioned in Section 3.2.4, one can split the available data into a training set and a validation set to evaluate the generalization performance of the neural network. In this example, 70% of the available data was used for training, while the remaining 30% served as the validation set. This can be achieved by providing only the training portion of the data to the FlowMat training method of the neural network. To assess model performance, the mean squared error (MSE) was calculated for both subsets by summing the MSE values across all predicted concentration traces. This resulted in an MSE of 17 × 10−3 for the training set and 35 × 10−3 for the validation set. These values indicate a good fit to the training data while still preserving reasonable generalization to unseen data, as the validation error remains comparable to the training error. The neural network can afterwards be used within the simulation or directly within a MATLAB/Simulink script.
The results of the simulation using the trained neural network are depicted in Fig. 13. In the figure, one can see the 70% split used for training (left section) and validation (right section) of the data. The figure visually confirms that the trained neural network is able to predict the outflowing concentrations not only for the training data but also for the unseen validation data, demonstrating its generalization capability. This validates the method and shows that the method can be applied to simulate a real-world process.
For the identification of reaction parameters we investigated the Paal–Knorr reaction with two reactions. The Paal–Knorr reaction, with two consecutive reaction steps, involves three key species:
• the first species C1(t) is the solvent, a mixture of toluene and methanol in a 2:
1 ratio,
• the second species C2(t) is ethylenediamine (NH2–CH2–CH2–NH2) at a concentration of 0.75 mol L−1, and
• the third species C3(t) is 2,5-hexanedione (C6H8O2) at 1.5 mol L−1.
All three components are pumped into a 4.2 mL flow reactor at controlled flow rates. The same equipment as for the Paal–Knorr reaction with one reaction was used, including Knauer AZURA P 4.1S HPLC pumps, back pressure regulators (BPR), and inline FTIR spectroscopy (Mettler Toledo ReactIR 15). Within the reactor, ethylenediamine reacts with hexanedione to form an intermediate product. This intermediate product reacts further with hexanedione to produce the final product (2,5-dimethyl-1H-pyrrol-1-yl) ethane. The intermediate product and the final product are referred to as species C4(t) and species C5(t) respectively. The concentrations of the final product and residual materials are measured after the flow reactor. The reactor setup and the stoichiometry of the Paal–Knorr reaction with two reactions is depicted in Fig. 14.
It is assumed that both reaction steps follow the Arrhenius equation for which the reaction rates are given by
![]() | (25) |
For the optimization we used an experiment with transient data. The use of transient experimental data eliminates the need to wait for steady-state conditions, thereby reducing overall time, material consumption, and labor. This makes the parameter identification and optimization process significantly more efficient. In the experiment the flow rates and temperature profiles were varied throughout the entire experiment and can be found in Fig. 15. Due to the transient input data, also the outflowing concentrations show a continuous change and never reach steady state. This typically makes it harder to estimate proper reaction parameters. Traditional identification methods do not consider underlying dispersion and delay effects and thus the parameters are often not estimated correctly. As we consider those delay and dispersion effects within our models and within our optimization of the parameters we can also make use of transient data and we are not limited to steady state data.
![]() | ||
Fig. 15 Transient input flow rates and reactor temperature for the Paal–Knorr reaction with two reactions. |
For the Paal–Knorr reaction with two reactions, we model the reactor setup using the axial-dispersion model. In the axial-dispersion model we defined the reaction parameters to be variables which can be optimized. Using the imported experimental data, we can use the used flow rates as input and optimize the parameters in such a way, that the simulated concentration outputs align with the measured outputs from the imported experiment. As the experimental data might show phases which are not representative, the toolbox allows to specify time intervals which should be used for the optimization.
In Fig. 16 we depicted the results after the optimization of the initial reaction parameters found by the external software solution Dynochem. In the figure, one can see the prediction using the reaction parameters found by the external software solution Dynochem and the predictions after the optimization from FlowMat. The simulations for the reaction parameters from Dynochem already show useable predictions yet after the optimization, the predictions agree much better with the measured data.
![]() | ||
Fig. 16 Comparison of the measured and simulated species concentrations for initial parameters and optimized parameters for the Paal–Knorr reaction with two reactions. |
As we used transient data to find the reaction parameters, we want to use the estimated parameters to cross test them with an unseen experiment. In Fig. 17 one can see the inputs and the prediction results when we test the found parameters on an additional experiment. As one can see, the second experiment shows huge differences in the actuation patterns and shows more steady state intervals and less transient phases compared to the experiment which was used to identify the reaction parameters. As seen in the figure, the predicted output agrees with the measured data indicating, that the estimated parameters can also be used to predict the output concentrations for the same flow reactor setup when using different input data.
When applying the training of a physics-informed neural network to estimate the reaction parameters to the introduced Paal–Knorr reaction with two reactions we find comparable parameters like in Section 3.4.1. Additionally, the resulting physics-informed neural network can be used to gain insight in the time-space behavior within the flow reactor. In Fig. 18 the time-space results of the physics-informed neural network after training are depicted. Additionally, the measured concentrations are depicted in black at the reactors output along with the predicted output concentration of the physics-informed neural network in red. As one can see, both traces agree within all concentrations quite well. Moreover, the time-space results are comparable to those of the axial-dispersion/tanks-in-series model and verify that the underlying axial-dispersion model is incorporated.
![]() | (26) |
In the equation, p denotes the modeling technique, and the found estimation errors ζp are summarized in Table 1. The estimation error ζp is calculated as the sum of the squared differences between the measured values Cmeasuredi(τ) and the predicted values Cpredictedi,p(τ) across all concentrations i. This sum is then normalized with respect to the number of concentrations P = 5 and the total experimental duration Tend.
Modeling technique p | Estimation error ζp |
---|---|
Dynochem | 4.17 × 10−4 |
Axial-dispersion model (FlowMat) | 2.45 × 10−4 |
Physics-informed neural network (FlowMat) | 0.88 × 10−4 |
Both FlowMat techniques—the axial-dispersion model and the physics-informed neural network method—demonstrate smaller estimation errors ζp compared to the external software solution Dynochem. Notably, the physics-informed neural network method achieves the lowest estimation error ζp, highlighting its status as the most advanced modeling approach available. However, this technique is accompanied by increased complexity. Despite this higher complexity of the physics-informed neural networks but also the axial-dispersion model, FlowMat offers a user-friendly interface that makes these advanced methods, remarkably easy to use. The identified results highlight that the more complex modeling techniques within FlowMat outperform the external solution, thereby proving the usability and effectiveness of the toolbox's modeling techniques.
To further validate the estimated reaction parameters, we want to cross test the parameters using one modeling technique. Given the reaction parameters Γp = {A4, A5, E4, E5} from the software solution Dynochem (parameter set ΓDyno), the identified reaction parameters using the axial-dispersion model (parameter set ΓAD) and the reaction parameters identified using a physics-informed neural network (parameter set ΓPINN), we want to validate and compare each parameter set Γp using the axial-dispersion model. Our goal is to demonstrate that all three techniques for identifying reaction parameters yield comparable results, which can also be utilized in other modeling approaches.
We tested the identified reaction parameters Γp for the introduced reactor setup on various experiments. Besides the experiment with transient data (Experiment l = 1 – which was used for identification of the parameters and thus serves as a reference), we also used the experiments showing more steady-state phases (Experiment l = 2 – which was also used in Section 3.4.1 to verify the identified reaction parameters from transient data on steady-state data) for validation. The flow reactor setup using the axial-dispersion model was simulated for the various reaction parameters for all available experiments. Afterwards we determined the overall estimation error
![]() | (27) |
The results of the overall estimation error are depicted in Fig. 19. In the figure, one can see, that all sets of reaction parameters Γp result in similar estimation errors ξp,l throughout all experiments l. It is obvious, that the first experiment l = 1 shows the smallest overall simulation errors ξp,l for all reaction parameters as the experiment was used for the identification. Thus the values for the first experiment can be used as a reference. The other experiments show larger values yet are in a comparable range. Despite the small increase in the overall simulation error when cross testing the found parameters, it is essential to see, that the simulation error values ξp,l within an experiment l show a similar performance. We also want to highlight, that for experiment l = 2 the reaction parameters found by our toolbox FlowMat outperform the reaction parameters found by the external software solution Dynochem. Moreover, one can conclude, that all parameters seem to be a valid choice when facing the small gap of the simulate error within one experiment l and the comparable performance for unseen experiments.
We use our toolbox to optimize the operating conditions and the reactor setup for the introduced Paal–Knorr reaction with one side product and one desired product. Within FlowMat we modeled the given reactor setup and determined all necessary reaction parameters as described in Section 3.4. Given a validated reactor model of the real-world flow reactor setup, we can use it for the optimization. We introduce necessary optimization variables such as the flow rates qi with i = 1, 2, 3 for all three input species (solvent, ethylenediamine and 2,5-hexanedione), the temperature ϑ within the reactor, and the total reactor volume V. We can collect the introduced optimization variables in a vector
x = [q1 q2 q3 ϑ V]T. | (28) |
The individual optimization variables can be used within the reactor model. The model can then be simulated for a defined time T using the given parameters in x. We denote the simulation of the reactor model with which returns [C1(t) … C5(t)] where Ci(t) represent the predicted output concentration of species i.
Regarding the objectives, one can, e.g., think of
• maximizing the concentration of the final product C5(t) while minimizing the concentration of the intermediate product C4(t),
• maximizing the total flow rate to maximize the throughput,
• minimizing the temperature ϑ to reduce operational costs,
• minimizing the reactor volume V to reduce the nominal residence time and material costs.
As each of the optimization variables can only be within physically feasible bounds, we define the following constraints:
• the flow rates of the species must be between and
whereby the flow rate of the solvent/species 1 must be greater than
,
• the temperature ϑ must be between 20 °C and 200 °C,
• the total reactor volume V must be between 1 mL and 5 mL,
• the total flow rate q must be between and
.
The optimization problem can afterwards be brought in the form of
![]() | (29) |
![]() | (30) |
![]() | (31) |
The factors αl > 0 for l ∈ {1, …, 5} weight each individual term in the objective f(x) relative to the others. The term , and
represent the lower and upper bounds of x respectively, and thus read as
![]() | (32) |
A = [1,1,1,0,0], b = 2 | (33) |
The found quantities of the optimization problem can easily be entered in our toolbox and allow an easy implementation of the optimization problem. For the weighting factor αl one can choose a proper combination or use the possibility, to keep each objective separate and determine the pareto front using our toolbox.
In this paper we want to present the latter option whereby the resulting pareto front is found in Fig. 20. As we face several optimization variables the illustration is not trivial. Thus we depicted the ratio of the inflowing species 2 and 3 which are consumed in the first reaction, the temperature ϑ and the reactor volume V. The total flow rate was always found to be at a maximum and thus giving no more insight when it was plotted.
In the depicted figure one can see, the pareto front for which no single objective can be improved without compromising another. When allowing higher temperatures ϑ, the total reactor volume V is reduced to a minimum while a very low temperature ϑ require a larger reactor volume V. This might be explained by the reaction rate being highly dependent on the temperature ϑ causing the desired product to be formed faster within a smaller volume for high temperatures and vice versa. Moreover, one can see how the optimal trace of the inlet ratio ζ changes throughout the temperature-volume space.
After introducing the conceptual background, we demonstrated the toolbox's implementation and its ability to simulate real flow reactors, including chemical reactions. We further illustrated how the toolbox can be used to identify underlying parameters of the reactor and reactions by leveraging transient experimental data, enabling the determination of accurate reaction parameters that generalize to unseen data. As the toolbox allows the use of transient experimental data, there is no need to wait for the system to reach steady state, which generally reduces time consumption, material usage, and labor costs. This capability can thus contribute to lowering the overall cost and time associated with experimental parameter determination. Additionally, we employed advanced techniques, such as PINNs, to identify parameters, showing that the results were consistent and performed comparably.
Finally, we showcased the toolbox's potential for optimizing an entire reactor setup. Specifically, we determined the pareto front for a defined scenario, demonstrating its ability to balance multiple objectives and provide valuable insights for decision-making. FlowMat, represents a significant advancement in flow reactor modeling and optimization, offering robust tools for researchers and engineers in the field.
Supplementary information: Experimental, hardware and software details and spectra. See DOI: https://doi.org/10.1039/d5ra06173c.
This journal is © The Royal Society of Chemistry 2025 |