This package contains two integrator blocks: IntegratorMOL and IntegratorFVM.
Release Notes:
| Name | Description |
|---|---|
PDE.General.Interfaces.IntegratorMOL
This is a slightly modified version of the MOL integrator block implemented in PDE->MOL->Integrator. The integrator block accepts the equations of the form
u_t = R(u, u_xx, ...)
where R is a function of u, u_xx, and so on. Once the equation is transformed in this form
we can construct the right part R and pass it to the input R of the integrator block.
The unknown varible u which we need for the construction of the right part of the equation is
provided by the Var output of the integrator block.
The initial condition is passed to the IC input, whereas the left and right boundary conditions are
passed to the BCL and BCR inputs respectively.
Release Notes:
| Type | Name | Description |
|---|---|---|
| input RealInput | u[n] | |
| output RealOutput | y[n] | |
| input RealInput | u1[n] | |
| input RealInput | u2 | |
| input RealInput | u3 |
block IntegratorMOL
extends PDE.Icons.BlockIcon1;
outer Integer n;
outer Integer bcl;
outer Integer bcr;
outer Integer vb;
outer Integer ve;
outer Integer icb;
outer Integer ice;
Real f[n];
equation
y = f;
if bcl == 1 then
f[1] = u2;
end if;
if bcr == 1 then
f[n] = u3;
end if;
for i in vb:ve loop
der(f[i]) = u[i];
end for;
initial equation
for i in icb:ice loop
f[i] = u1[i];
end for;
public
Modelica.Blocks.Interfaces.RealInput u[n];
Modelica.Blocks.Interfaces.RealOutput y[n];
Modelica.Blocks.Interfaces.RealInput u1[n];
Modelica.Blocks.Interfaces.RealInput u2;
Modelica.Blocks.Interfaces.RealInput u3;
equation
end IntegratorMOL;
PDE.General.Interfaces.IntegratorFVM
The IntegratorFVM block is a slightly modified version of the FVMIntegrator (PDE->FiniteVolume->FVMIntegrator).
It implements the cell average update rule. In one dimension, the finite volume method subdivide the domain into
cells (intervals) and approximates the integral of the unknown function q over each of these cells at each time step (see figure below).
The ghost cells are the boundary cells that are introduced to avoid writing special formulas for the boundary cells.
Denote the i-th cell by
Then the approximation to the average of q in the cell Ci at time t, which we denote with Qi is
The approximation to this average derives from the integral form of the conservation law
which states that the average within the cell can only changes due to the fluxes at the boundaries (if we assume that
no source or sink is present in the cell).
If we integrate this expression in time from t to t+deltat, we obtain
and dividing by deltax we reach the form
which give us an explicit time marching algorithm. By using the notation for averages introduced above we can write
where
approximates the average flux along the interface xi-1/2.
The FVMIntegrator block implements this average update rule. Initial condition of the problem can be passed to the IC input of the block,
whereas the boundary conditions to the corresponding ghost cells. The number of ghost cells depends on the method we use. In the present
package, two ghost cells at the left and at the right are enough for every method implemented.
Release Notes:
| Type | Name | Default | Description |
|---|---|---|---|
| Real | delta_x | 1/n | |
| Unknowns | |||
| Integer | vb | gcl + 1 | The left most unknown |
| Integer | ve | gcl + n | The right most unknown |
| Initial Condition | |||
| Integer | icb | gcl + 1 | Begin of the initial condition |
| Integer | ice | gcl + n | End of the initial condition |
| Boundary Conditions | |||
| Integer | bcl | 1 | Boundary condition at the left (0: no; 1: yes) |
| Integer | bcr | 1 | Boundary condition at the right (0: no; 1: yes) |
| Integer | gcl | 2 | Number of ghost cells at the left |
| Integer | gcr | 2 | Number of ghost cells at the right |
| Type | Name | Description |
|---|---|---|
| input RealInput | u[n + 1] | |
| output RealOutput | y[n + 4] | |
| input RealInput | u2[n] | |
| input RealInput | u3[2] | |
| input RealInput | u4[2] |
block IntegratorFVM
extends Icons.BlockIcon1;
outer Integer n;
parameter Integer vb = gcl+1 "|Unknowns| The left most unknown";
parameter Integer ve = gcl + n "|Unknowns| The right most unknown";
parameter Integer icb = gcl+1
"|Initial Condition| Begin of the initial condition";
parameter Integer ice = gcl + n
"|Initial Condition| End of the initial condition";
parameter Integer bcl = 1
"|Boundary Conditions| Boundary condition at the left (0: no; 1: yes)";
parameter Integer bcr = 1
"|Boundary Conditions| Boundary condition at the right (0: no; 1: yes)";
parameter Integer gcl = 2
"|Boundary Conditions| Number of ghost cells at the left";
parameter Integer gcr = 2
"|Boundary Conditions| Number of ghost cells at the right";
parameter Real delta_x = 1/n;
//parameter Real delta_t = 0.1;
Real q[n+gcl+gcr];
equation
y = q;
for i in 1:gcl loop
q[i]= u3[i];
end for;
if bcl == 1 then
q[gcl+1] = q[gcl];
end if;
for i in 1:gcr loop
q[gcl+n+i] = u4[i];
end for;
if bcr == 1 then
q[gcl+n] = q[gcl+n+1];
end if;
for i in vb:ve loop
der(q[i]) = -(1/delta_x)*(u[i-gcl+1]-u[i-gcl]);
end for;
initial equation
for i in icb:ice loop
q[i] = u2[i-gcl];
end for;
// equation
// y = q;
//
// if bcl == 1 then
// for i in 1:gcl loop
// q[i]= u3[i];
// end for;
// end if;
//
// if bcr == 1 then
// for i in 1:gcr loop
// q[gcl+n+i] = u4[i];
// end for;
// end if;
//
// for i in vb:ve loop
// der(q[i]) = -(1/delta_x)*(u[i-gcl+1]-u[i-gcl]);
// end for;
//
// initial equation
//
// for i in icb:ice loop
// q[i] = u2[i-gcl];
// end for;
public
Modelica.Blocks.Interfaces.RealInput u[n + 1];
Modelica.Blocks.Interfaces.RealOutput y[n + 4];
Modelica.Blocks.Interfaces.RealInput u2[n];
Modelica.Blocks.Interfaces.RealInput u3[2];
Modelica.Blocks.Interfaces.RealInput u4[2];
end IntegratorFVM;