TL;DR
This paper presents a characteristics-based Simulink subsystem for solving first-order quasilinear PDEs, offering improved numerical stability and accuracy over traditional space discretization methods, demonstrated through a feedback example.
Contribution
It introduces a novel Simulink implementation of the method of characteristics for PDEs, enhancing stability and accuracy in online simulation environments.
Findings
Better numerical stability than space discretization methods
Achieved higher accuracy in a feedback control example
Implementation is publicly available for diverse models
Abstract
The paper deals with solving first-order quasilinear partial differential equations in an online simulation environment, such as Simulink, utilizing the well-known and well-recommended method of characteristics. Compared to the commonly applied space discretization methods on static grids, the characteristics-based approach provides better numerical stability. Simulink subsystem implementing the method of characteristics is developed. It employs Simulink's built-in solver and its zero-crossing detection algorithm to perform simultaneous integration of a pool of characteristics as well as to create new characteristics dynamically and discard the old ones. Numerical accuracy of the solution thus obtained is established. The subsystem has been tested on a full-state feedback example and produced better results than the space discretization-based "method of lines". The implementation is…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Characteristics-based Simulink implementation of first-order quasilinear partial differential equations
Anton Ponomarev1
, Julian Hofmann2
and Lutz Gröll2
1**Saint Petersburg State University, 7/9 Universitetskaya nab., St. Petersburg, 199034 Russia
*2**Karlsruhe Institute of Technology, Institute for Automation and Applied Informatics,
Hermann-von-Helmholtz-Platz 1, 76344 Eggenstein-Leopoldshafen, Germany*
[email protected], {julian.hofmann, lutz.groell}@kit.edu https://orcid.org/0000-0002-8753-9759 https://orcid.org/0000-0003-3210-4368 https://orcid.org/0000-0003-3433-1425
Abstract
The paper deals with solving first-order quasilinear partial differential equations in an online simulation environment, such as Simulink, utilizing the well-known and well-recommended method of characteristics. Compared to the commonly applied space discretization methods on static grids, the characteristics-based approach provides better numerical stability. Simulink subsystem implementing the method of characteristics is developed. It employs Simulink’s built-in solver and its zero-crossing detection algorithm to perform simultaneous integration of a pool of characteristics as well as to create new characteristics dynamically and discard the old ones. Numerical accuracy of the solution thus obtained is established. The subsystem has been tested on a full-state feedback example and produced better results than the space discretization-based “method of lines”. The implementation is available for download and can be used in a wide range of models.
1 INTRODUCTION
Dynamical systems described by first-order quasilinear partial differential equations (PDEs) are commonly interpreted as convective-reactive processes, i.e., they represent transport phenomena with sources and sinks. Such phenomena play an important role in chemical and process engineering, traffic flow models, material science, biology, etc. [Mahmoudi et al., 2019, Kachroo and Özbay, 2018, Ingham and Pop, 1998, Truskey et al., 2004]. PDEs of this form typically arise as mathematical formulation of the physical conservation laws of spatially distributed quantities (mass, momentum, etc.) applied locally (to an infinitesimal volume) in which case they are also known as continuity equations [Greenkorn, 2018].
In this paper we discuss computer simulation of arbitrary convection-reaction dynamics described by the following first-order quasilinear PDE on a bounded spatial domain :
[TABLE]
where , , , is the internal state of the system, and are partial derivatives of at the point , is an (square-integrable) initial state function, represents the convection velocity ( for all possible arguments), can be interpreted as a source, sink, or reaction term, and plays the role of a boundary input into the system. Symbol stands for the restriction of the function to .
The terms and in (1) depend on time , spatial position , and full system state . In addition, they may also depend on other signals, e.g., on the output of a dynamic feedback controller. The same holds true for the boundary input .
Remark 1**.**
From the theoretical standpoint, it would be enough to define functions and only for . However, our simulation algorithm described below requires that the system be defined on a larger domain with some (see Remark 6). Although a sufficiently large but finite could be estimated, for the sake of brevity we opt to assume that the system is defined for all . In the practical sense, it means that the functions and should be extended from to in a physically meaningful way.
Remark 2**.**
The system (1) admits unique classical solution (i.e., well-defined single-valued function) if there are no intersecting characteristics [Polyanin et al., 2002]. Otherwise, the so-called shock waves appear which can be dealt with using the concept of multi-valued solutions or by introducing discontinuity at the shock wave’s front. In this paper we avoid making restrictive a priori assumptions that would exclude the possibility of intersecting characteristics. Furthermore, our algorithm will not handle the shock waves by itself. Instead, the algorithm will detect intersecting characteristics during runtime and inform the user of the problem.
Let us discuss the existing approaches to computer simulation of the dynamical system (1) in the MATLAB/Simulink environment paying primary attention to the method of characteristics [Polyanin et al., 2002] as it is arguably the most accurate and efficient tool to solve a general PDE like (1a).
There are numerous MATLAB scripts that implement the method of characteristics, e.g., [von Petersdorff, 2012]. Assuming that the functions , , and are given as functions of , , and (to some extent) , such MATLAB scripts can be used to calculate solutions of the systems of the form (1). However, these solvers are “offline” in the sense that the state is available for all values of and only after the script is executed completely. We cannot, in a straightforward manner, embed such an “offline” solver into a Simulink model as a MATLAB Function block because it will not output the full state as the simulation time increases.
We are interested in an “online” solver, which is to say that, as the simulation time increases, it should continuously produce an approximation of the current state . An “online” solver is required if at each moment in time the terms , , and in (1) depend on the full system state in a non-trivial manner or are defined via feedback of the full system state through another dynamical system which may be the case, e.g., under feedback control.
Simulink is a suitable environment to implement (1) in the “online” fashion. Having a block which takes the values of , , and and outputs a discrete approximation of the full system state , it would be easy to plug it into a larger system. However, we are not aware of Simulink implementations of the method of characteristics for the general case of system (1). Let us describe some alternatives that are available in Simulink at the moment and motivate our effort to implement the method of characteristics.
Space discretization (finite difference) method, also known as the Method of Lines [Schiesser, 2012], can be used to transform the PDE into a system of ordinary differential equations (ODEs) which has native Simulink implementation. In general, these approaches suffer from instability because of numerical diffusion and dispersion [Zijlema, 2015]. We illustrate this problem in Section 4.
Another approach is to reformulate the PDE as a time-delay system. For example, [Witrant and Niculescu, 2010] consider a variable-velocity transport system with sinks or sources
[TABLE]
Using the method of characteristics, it is transformed into a delay-differential equation which can be plugged into a Simulink model. The special case of (2) with is included in Simulink under the name of Variable Transport Delay block [Zhang and Yeddanapudi, 2012]. In general, however, converting a model like (1) into a time-delay form requires deep analysis and may not always be possible.
Finally, there are examples of connecting Simulink to dedicated PDE solving environments [Van Schijndel, 2009] but such an approach is only justified for simulating complex phenomena. For a simple transport process the overhead is excessive.
Hence, we set the goal of designing a simple but versatile Simulink block which can simulate the dynamics of a wide range of first-order quasilinear PDEs based on the method of characteristics. The block is to be employed in modeling the systems like (1). The accuracy of simulation should be adjustable via some parameters. The block has to be easy to use without extensive analysis of the mathematical model. Furthermore, it must have straightforward interface and be easily embeddable into larger Simulink models.
Remark 3**.**
To the best of the authors’ knowledge, the only example that comes close to reaching the goal of this paper is [Herrán-González et al., 2009]. It is a library of Simulink blocks modeling gas ducts, valves, compressors, etc. Although the blocks indeed implement the method of characteristics, the library is directed exclusively at modeling gas distribution pipeline networks which results in a limited choice of possible dynamics. Our approach is more general as we model dynamics (1) in an abstract sense. We allow arbitrary velocity and source terms as well as initial functions.
The plan of the paper is as follows. In Sec. 2 we provide theoretical background to the proposed simulation approach. Specifically, in Sec. 2.1 we recall the method of characteristics whereas in Sec. 2.2 we introduce its algorithmic realization suitable for “online” simulation and assess the accuracy of the algorithm. Sec. 3 describes implementation of the algorithm as a Simulink block. In Sec. 4, performance of the block is compared with the method of lines using an illustrative example.
2 METHOD
2.1 The Method of Characteristics
Our approach to simulation of the dynamics (1) is based on the method of characteristics [Polyanin et al., 2002]. Let us recall the definition of the characteristics.
Definition**.**
The characteristics of the system (1) starting at the point on the initial boundary ( and ) or on the input boundary ( and ) are the solutions and of the system of ordinary differential equations (ODEs)
[TABLE]
where , with initial conditions
[TABLE]
(in the case of initial boundary) or
[TABLE]
(in the case of input boundary). Here and denote the derivatives of and with respect to .
The functions and being a solution of (3), we know from [Polyanin et al., 2002] that the solution of (1) takes the values along the curve \big{(}t,\xi(t;t_{0},x_{0})\big{)}, i.e.,
[TABLE]
Thus, starting at a number of points on the initial and input boundaries and integrating the characteristic ODEs (3) one can find the solution of the PDE problem (1) along a number of curves spanning the domain. However, the structure of (1) is such that the full state of the PDE is involved in the characteristic ODEs (3). Therefore, the ODEs (3) pertaining to different characteristics are to be integrated together (in parallel, so to speak) while the function is interpolated using the relations (4). In the next Section we clarify this approach.
2.2 Simulation Algorithm
Our proposal is to start simulation at with a set of characteristics spread across the spatial domain and integrate their respective ODEs (3) in parallel. To this end, the full state must be plugged into the right-hand side of (3). However, the full state is unknown. Only its values on the characteristic curves are available, according to (4). Therefore, we will approximate in (3) via interpolation between the characteristics. Once a characteristic has moved far enough out of the spatial domain and has no effect on the full PDE state anymore, it is removed from the set. New characteristics are created on the input boundary and added to the set when appropriate according to some rules given below.
To give a precise description of the algorithm, let us represent the set of characteristics as two variable-length vectors and each of which at time contains elements:
[TABLE]
These vectors are to be handled by the following hybrid algorithm which combines continuous integration with event-triggered state resets.
Algorithm**.**
Given parameters , , and , the rules for the simulation of (1) are:
Initialization: initial number of characteristics and the elements of the vectors and are selected to approximate the initial function such that
[TABLE]
and
[TABLE]
Moreover, an auxiliary variable , denoting the last time when new characteristic was created, is initialized as . 2. 2.
Dynamics (continuous integration): and evolve according to the equations similar to (3):
[TABLE]
with initial conditions (6). The ODEs (7) are obtained from (3) by substitution, in place of the unknown , its approximation . The latter function is an interpolant over the grid consisting of a point on the input boundary and points on the characteristic curves, as suggested by (4):
[TABLE]
Depending on the expected analytic properties of the solution, a suitable interpolation scheme should be chosen here: nearest neighbor, linear, spline, etc.
The values and are kept constant during integration of the ODEs. 3. 3.
Removal trigger (state reset): fulfillment of the condition
[TABLE]
triggers removal of the oldest (’th) characteristic from the set:
[TABLE]
where the argument indicates the updated value of the variable during the state reset. 4. 4.
Creation triggers (state reset): fulfillment of any of the conditions
[TABLE]
triggers creation of a new characteristic at the input boundary and resetting :
[TABLE] 5. 5.
Output: the algorithm outputs vectors and which can be used to construct an approximation of the full PDE state by interpolation over the grid (8).
Remark 4**.**
Assuming exact trigger detection, the algorithm preserves the condition because characteristic creation trigger (11a), thanks to the requirement , ensures that for all which guarantees that removal condition (9) cannot be satisfied if . Thus, cannot drop below 2.
Straightforward estimations of the solutions of the characteristic equations (3) yield the following statements regarding the accuracy of the Algorithm.
Theorem**.**
Suppose the PDE (1a) has the form
[TABLE]
and there exist positive constants and such that the inequalities
[TABLE]
hold for all values of and where denotes Euclidean vector norm in . Then, assuming that ODEs (7) are integrated exactly and triggers (9), (11) are detected perfectly on time, the following estimation is valid for all and , :
[TABLE]
where is the exact solution of the problem (1) and functions and are the outputs of the Algorithm.
Corollary**.**
Under the assumptions of the Theorem, the following holds for all and :
[TABLE]
where is the exact solution of the problem (1) and is the approximation of obtained via linear or nearest-neighbor interpolation over the grid (8).
Remark 5**.**
The Theorem assumes that the PDE (1a) has the form (12) which excludes dependence of the dynamics on the full state of the system. Such full-state feedback may, in general, lead to divergence of the Algorithm and there would be no time-invariant accuracy estimation (although it can be established when is small enough). This is due to an interpolant being used in place of the full PDE state in the characteristic ODEs (7) which leads to unbounded error accumulation. Nonetheless, as can be seen in the example of Section 4, the Algorithm may produce good results even in presence of full-state feedback.
Remark 6**.**
The Algorithm implies that the oldest (’th) characteristic lies outside the spatial domain , i.e., such that the interpolation grid (8) covers the whole interval . This is the reason for our assumption that the system (1) is defined for all instead of (see Remark 1).
3 IMPLEMENTATION
The above Algorithm has been realized in Simulink in the form of a masked subsystem FOQL PDE (“first-order quasilinear PDE”) which can be found in the library PDECharactLib.slx at [Ponomarev et al., 2020]. An example Simulink model (Fig. 1(a)) which uses the subsystem can also be found there under the name FOQL_PDE_SimpleExample.slx. It implements (1) with , velocity , source/sink term , boundary input
[TABLE]
boundary output , and initial state function . The reader is advised to download and inspect the model as description below is kept brief. The mask parameters of the FOQL PDE block are:
- •
“Domain length (L)” – corresponds to .
- •
“Maximum number of characteristics (Nmax)” – hard upper bound on the number of characteristics for the purpose of static memory allocation.
- •
“x-values” and “w-values” describe the initial function by a grid of its values .
- •
“x”, “w”, and “t” correspond to the parameters , , and of the Algorithm.
- •
“Tolerance for crossing characteristics” – sets the allowable upper bound on . Crossing characteristics (i.e., the event ) indicate a shock wave in the solution which makes the method of characteristics not physically sound [Polyanin et al., 2002]. Simulation will be terminated in this case with an error message. Setting the tolerance to a small positive number, firstly, helps to avoid termination caused by numerical inaccuracies rather than actual shock wave and, secondly, allows jumps in the solution. The jump is when but . At zero tolerance, this situation would be interpreted as two characteristics crossing though in fact it may be a valid discontinuous solution (see also Remark 9).
- •
The check box “Terminate on overflow”, if checked, causes an error message when the current number of characteristics equals its upper bound specified in the field “Nmax” above and the algorithm requires that another characteristic be created; otherwise, the simulation will silently continue without creating the characteristic. Unsetting the check box suppresses the characteristic creation trigger and may adversely affect the quality of the solution. The accuracy estimation given by the Theorem can no longer be guaranteed in this case.
The insides of the FOQL PDE block are exposed in Fig. 1(b). The outputs x and w are constant-length vectors, their size specified in the mask parameter “Nmax”. They contain the variable-length vectors and from (5) as sub-vectors. To facilitate adding and removing elements to and from and according to the Algorithm, vectors x and w are endowed with cyclic buffer structure, meaning that the span of the elements containing and may wrap around the ends of x and w. The outputs i1 and i2 are the head and tail of the buffer, i.e., the indices at which the first characteristic and the last one are stored in x and w.
Two topmost Integrator blocks in Fig. 1(b) are used to solve the characteristic equations (7), and the rest are employed to store i1, i2, and . Creation and removal of the characteristics is done by triggering the Integrator blocks’ state reset.
4 EXAMPLE
The repository [Ponomarev et al., 2020] contains three example models with the FOQL PDE block: FOQL_PDE_SimpleExample.slx is mentioned in the previous section, FOQL_PDE_OutputFeedback.slx is a real-life model of heat exchanger with output feedback control, and FOQL_PDE_StateFeedback.slx is an illustrative plant with full-state feedback. Here we discuss the latter and compare the solution produced by the FOQL PDE block to those obtained using the space discretization-based Method of Lines (MOL).
The plant under consideration is
[TABLE]
with a tunable constant and full-state feedback
[TABLE]
Assuming the initial state is
[TABLE]
one can obtain the exact output
[TABLE]
where is the rounding-down operation and
[TABLE]
For the purposes of simulation, the integral in (14a) is approximated using the trapezoidal rule.
As the first approach to simulating the dynamics (13)-(15) we consider MOL with central finite difference approximations of the spatial derivative [Schiesser, 2012] with discretization segments:
[TABLE]
where , and . Applying (17) to (13) yields the ODE system
[TABLE]
The results of this approach are shown in Fig. 2.
The wiggles in the MOL solution appear because the initial function from (16) is non-monotonic. Indeed, in general, finite difference-based MOL solutions suffer numerical diffusion, i.e., amplitude errors (smearing), and/or dispersion, i.e., phase errors (wiggles). In order to alleviate the effects, an upwind scheme for the spatial derivative, i.e.,
[TABLE]
has been implemented [Zijlema, 2015]. The results are smooth (Fig. 3), however, a high resolution of discretization is required (). Furthermore, the numerical solution departs from the exact one rather quickly due to numerical diffusion.
Finally, Fig. 4 presents the results of simulation using our characteristics-based FOQL PDE block. It yields better results than the MOL as neither numerical dispersion nor diffusion are apparent.
Remark 7**.**
Further improvement of the MOL solution with upwind scheme could be achieved by creating higher order, monotone, nonlinear upwind schemes using, e.g., the flux limiting technique [Zijlema, 2015]. However, flux limiters such as Minimod, Superbee, or Van Leerm limiter, are difficult to implement due to their nonlinearity.
Remark 8**.**
Performance of the FOQL PDE block can be enhanced by adjusting the parameters of the block itself as well as the Simulink solver configuration. For instance, to obtain the results in Fig. 4 we had to set “Max step size” in Simulink’s Solver Configuration Parameters to 0.1 and reduce the FOQL PDE block’s parameter “w” to 0.01.
Remark 9**.**
The discontinuous initial state (16) has been defined by setting the FOQL PDE block parameter “x-values” to [0, 0.5, 0.5, 1] and “w-values” to [0, 0, 1, 1]. Thus, two characteristics are initialized at the same point of the initial boundary with different “w-values”, specifically, , , . This approach lets one define initial state with a jump exactly. It is allowed thanks to non-zero “Tolerance for crossing characteristics”. At zero tolerance simulation would fail immediately.
To sum up, the finite difference-based MOL often yields inaccurate results due to the described numerical artifacts (diffusion and dispersion) whereas the results produced by the FOQL PDE block agree well with the exact solution.
5 CONCLUSIONS
The method of characteristics has been implemented in Simulink in the form of a masked subsystem which can be set up to simulate a wide range of dynamics described by first-order quasilinear PDEs. The solution showed good accuracy surpassing that of the discretization-based method of lines.
We conclude that the subsystem is a viable option for simulation of convection-reaction dynamics in Simulink. In the future, the approach may be extended to a larger class of equations such as first-order nonlinear PDEs and higher-order hyperbolic PDEs.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1Greenkorn, 2018 Greenkorn, R. (2018). Momentum, heat, and mass transfer fundamentals . CRC Press.
- 2Herrán-González et al., 2009 Herrán-González, A., Cruz, J. M. D. L., Andrés-Toro, B. D., and Risco-Martín, J. L. (2009). Modeling and simulation of a gas distribution pipeline network. Applied Mathematical Modelling , 33(3):1584–1600.
- 3Ingham and Pop, 1998 Ingham, D. B. and Pop, I. (1998). Transport phenomena in porous media . Elsevier.
- 4Kachroo and Özbay, 2018 Kachroo, P. and Özbay, K. M. (2018). Traffic flow theory. In Feedback Control Theory for Dynamic Traffic Assignment , pages 57–87. Springer.
- 5Mahmoudi et al., 2019 Mahmoudi, Y., Hooman, K., and Vafai, K. (2019). Convective heat transfer in porous media . CRC Press.
- 6Polyanin et al., 2002 Polyanin, A. D., Zaitsev, V. F., and Moussiaux, A. (2002). Handbook of first order partial differential equations . Taylor & Francis.
- 7Ponomarev et al., 2020 Ponomarev, A., Hofmann, J., and Gröll, L. (2020). PDE Charact Simulink. https://github.com/antonponmath/PDE Charact Simulink . [Online].
- 8Schiesser, 2012 Schiesser, W. E. (2012). The numerical method of lines: Integration of partial differential equations . Elsevier.
