In this tutorial, we propose to add a source term in the advection equation. The problem reads
where \(c\) is a constant scalar (typically \(c=1\)). Additional boundary and initial conditions will be given in the following. \(S\) is the source term that can depend on the time \(t\), the space \(x\) and the solution \(u\).
In order to simulate this problem, we use the \(\DdQq{1}{2}\) scheme
and we add an additional key:value
in the dictionary for the source
term. We deal with two examples.
In this example, we takes \(S(t, x, u) = -\alpha u\) where \(\alpha\) is a positive constant. The dictionary of the simulation then reads:
If the source term \(S\) depends explicitely on the time or on the space, we have to specify the corresponding variables in the dictionary through the key parameters. The time variable is prescribed by the key ‘time’. Moreover, sympy functions can be used to define the source term like in the following example. This example is just for testing the feature... no physical meaning in mind !