This package contains blocks for the computation of spatial derivative schemes of different order.
Release Notes:
| Name | Description |
|---|---|
PDE.MOL.SpaceDerivative.SDInterfaces.u_xCD2B2
Computes the second-order central difference approximation to the first-order space derivative with second-order biased approximation for boundary points.
By using the Newton-Gregory backward polynomial we obtain
For second-order central difference approximation, we need to fit the polynomial through the three points
xi-1, xi, xi+1. This means to write the polynomial for example around the point xi+1,
drop the higher-oder terms and set s = -1 to obtain
For the boundary point x1 we use biased formula and obtain
By using the same idea we obtain a biased formula for the boundary point xn
Release Notes:
| Type | Name | Default | Description |
|---|---|---|---|
| Real | deltax | 1/(n - 1) |
| Type | Name | Description |
|---|---|---|
| input RealInput | u[n] | |
| output RealOutput | y[n] |
block u_xCD2B2
extends PDE.Icons.BlockIcon;
outer Integer n;
outer Integer bcl;
outer Integer bcr;
parameter Real deltax = 1/(n-1);
// parameter Integer bcl = worldModel1.bcl;
// parameter Integer bcr = worldModel1.bcr;
equation
if bcl == -1 then
y[1] = 0;
else
y[1] = (-u[3] + 4*u[2] - 3*u[1])/(2*deltax);
end if;
for i in 2:n-1 loop
y[i] = (u[i+1] - u[i-1])/(2*deltax);
end for;
if bcr == -1 then
y[n] = 0;
else
y[n] = (3*u[n] - 4*u[n-1] + u[n-2])/(2*deltax);
end if;
public
Modelica.Blocks.Interfaces.RealInput u[n];
Modelica.Blocks.Interfaces.RealOutput y[n];
end u_xCD2B2;
PDE.MOL.SpaceDerivative.SDInterfaces.u_xCD4B4
Computes the fourth-order central difference approximation to the first-order space derivative with fourth-order biased approximation for boundary points.
Release Notes:
| Type | Name | Default | Description |
|---|---|---|---|
| Real | deltax | 1/(n - 1) |
| Type | Name | Description |
|---|---|---|
| input RealInput | u[n] | |
| output RealOutput | y[n] |
block u_xCD4B4
extends PDE.Icons.BlockIcon;
outer Integer n;
outer Integer bcl;
outer Integer bcr;
parameter Real deltax = 1/(n-1);
// parameter Integer bcl = worldModel1.bcl;
// parameter Integer bcr = worldModel1.bcr;
Modelica.Blocks.Interfaces.RealInput u[n];
Modelica.Blocks.Interfaces.RealOutput y[n];
equation
if bcl == -1 then
y[1] = 0;
y[2] = (-u[4] + 8*u[3] + u[2] - 8*u[1])/(12*deltax);
else
y[1] = (-3*u[5] + 16*u[4] - 36*u[3] + 48*u[2] - 25*u[1])/(12*deltax);
y[2] = (u[5] - 6*u[4] + 18*u[3] - 10*u[2] - 3*u[1])/(12*deltax);
end if;
for i in 3:n-2 loop
y[i] = (-u[i+2] + 8*u[i+1] - 8*u[i-1] + u[i-2])/(12*deltax);
end for;
if bcr == -1 then
y[n-1] = (8*u[n] - u[n-1] - 8*u[n-2] + u[n-3])/(12*deltax);
y[n] = 0;
else
y[n-1] = (3*u[n] + 10*u[n-1] - 18*u[n-2] + 6*u[n-3] - u[n-4])/(12*deltax);
y[n] = (25*u[n] - 48*u[n-1] + 36*u[n-2] - 16*u[n-3] + 3*u[n-4])/(12*deltax);
end if;
end u_xCD4B4;
PDE.MOL.SpaceDerivative.SDInterfaces.u_xCD6B6
Computes the sixth-order central difference approximation to the first-order space derivative with sixth-order biased approximation for boundary points.
Release Notes:
| Type | Name | Default | Description |
|---|---|---|---|
| Real | deltax | 1/(n - 1) |
| Type | Name | Description |
|---|---|---|
| input RealInput | u[n] | |
| output RealOutput | y[n] |
block u_xCD6B6
extends Icons.BlockIcon;
outer Integer n;
outer Integer bcl;
outer Integer bcr;
parameter Real deltax = 1/(n-1);
equation
if bcl == -1 then
y[1] = 0;
y[2] = (u[5] - 9*u[4] + 44*u[3] + 9*u[2] - 45*u[1])/(60*deltax);
y[3] = (u[6] - 9*u[5] + 45*u[4] - 46*u[2] + 9*u[1])/(60*deltax);
else
y[1] = (265*u[7] - 478*u[6] + 50*u[5] + 400*u[4] - 450*u[3] + 360*u[2] - 147*u[1])/(60*deltax);
y[2] = (-3463*u[7] + 13845*u[6] - 20740*u[5] + 13760*u[4] - 3315*u[3] - 77*u[2] - 10*u[1])/(60*deltax);
y[3] = (-u[7] + 8*u[6] - 30*u[5] + 80*u[4] - 35*u[3] - 24*u[2] + 2*u[1])/(60*deltax);
end if;
for i in 4:n-3 loop
y[i] = (u[i+3] - 9*u[i+2] + 45*u[i+1] - 45*u[i-1] + 9*u[i-2] - u[i-3])/(60*deltax);
end for;
if bcr == -1 then
y[n-2] = (-9*u[n] + 46*u[n-1] - 45*u[n-3] + 9*u[n-4] - u[n-5])/(60*deltax);
y[n-1] = (45*u[n] - 9*u[n-1] - 44*u[n-2] + 9*u[n-3] - u[n-4])/(60*deltax);
y[n] = 0;
else
y[n-2] = (-2*u[n] + 24*u[n-1] + 35*u[n-2] - 80*u[n-3] + 30*u[n-4] - 8*u[n-5] + u[n-6])/(60*deltax);
y[n-1] = (10*u[n] + 77*u[n-1] - 150*u[n-2] + 100*u[n-3] - 50*u[n-4] + 15*u[n-5] - 2*u[n-6])/(60*deltax);
y[n] = (147*u[n] - 360*u[n-1] + 450*u[n-2] - 400*u[n-3] + 225*u[n-4] - 72*u[n-5] + 10*u[n-6])/(60*deltax);
end if;
public
Modelica.Blocks.Interfaces.RealInput u[n];
Modelica.Blocks.Interfaces.RealOutput y[n];
end u_xCD6B6;
PDE.MOL.SpaceDerivative.SDInterfaces.u_xxCD2B2
Implements the second-order central difference approximation to the second-order space derivative.
For the boundary points second-order biased approximation is used.
Release Notes:
| Type | Name | Default | Description |
|---|---|---|---|
| Real | deltax | 1/(n - 1) |
| Type | Name | Description |
|---|---|---|
| input RealInput | u[n] | |
| output RealOutput | y[n] |
block u_xxCD2B2
extends Icons.BlockIcon;
outer Integer n;
outer Integer bcl;
outer Integer bcr;
parameter Real deltax = 1/(n-1);
Modelica.Blocks.Interfaces.RealInput u[n];
Modelica.Blocks.Interfaces.RealOutput y[n];
equation
//bcl = -1 means: symmetry condition. If we do not have symmetry condition, then we use biased formula.
if bcl == -1 then
y[1] = (1/(deltax^2))*(2*u[2] - 2*u[1]);
else
y[1] = (1/(deltax^2))*(u[3] - 2*u[2] + u[1]);
end if;
for i in 2:n-1 loop
y[i] = (1/(deltax^2))*(u[i+1] - 2*u[i] + u[i-1]);
end for;
if bcr == -1 then
y[n] = (1/(deltax^2))*(2*u[n-1] - 2*u[n]);
else
y[n] = (1/(deltax^2))*(u[n] - 2*u[n-1] + u[n-2]);
end if;
end u_xxCD2B2;
PDE.MOL.SpaceDerivative.SDInterfaces.u_xxCD4B4
Implements the second-order central difference approximation to the second-order space derivative.
For the boundary points fourth-order biased approximation is used.
Release Notes:
| Type | Name | Default | Description |
|---|---|---|---|
| Real | deltax | 1/(n - 1) |
| Type | Name | Description |
|---|---|---|
| input RealInput | u[n] | |
| output RealOutput | y[n] |
block u_xxCD4B4
extends PDE.Icons.BlockIcon;
outer Integer n;
outer Integer bcl;
outer Integer bcr;
parameter Real deltax = 1/(n-1);
equation
//bcl = -1 means: symmetry condition. If we do not have symmetry condition, then we use biased formula.
if bcl == -1 then
y[1] = (1/(12*deltax^2))*(-2*u[3] + 32*u[2] - 30*u[1]);
y[2] = (1/(12*deltax^2))*(-u[4] + 16*u[3] - 31*u[2] + 16*u[1]);
else
y[1] = (1/(12*deltax^2))*(11*u[5] - 56*u[4] + 114*u[3] - 104*u[2] + 35*u[1]);
y[2] = (1/(12*deltax^2))*(-u[5] + 4*u[4] + 6*u[3] - 20*u[2] + 11*u[1]);
end if;
for i in 3:n-2 loop
y[i] = (1/(12*deltax^2))*(-u[i+2] + 16*u[i+1] - 30*u[i] + 16*u[i-1] - u[i-2]);
end for;
if bcr == -1 then
y[n-1] = (1/(12*deltax^2))*(16*u[n] - 31*u[n-1] + 16*u[n-2] - u[n-3]);
y[n] = (1/(12*deltax^2))*(-30*u[n] + 32*u[n-1] - 2*u[n-2]);
else
y[n-1] = (1/(12*deltax^2))*(11*u[n] - 20*u[n-1] + 6*u[n-2] + 4*u[n-3] - u[n-4]);
y[n] = (1/(12*deltax^2))*(35*u[n] - 104*u[n-1] + 114*u[n-2] - 56*u[n-3] + 11*u[n-4]);
end if;
public
Modelica.Blocks.Interfaces.RealInput u[n];
Modelica.Blocks.Interfaces.RealOutput y[n];
end u_xxCD4B4;