This package contains diffusion equation solved with the Method of Lines.
Release Notes:
| Name | Description |
|---|---|
| DiffusionEquation | |
Implements the diffusion equation
where sigma is a constant value. The initial condition is
and boundary conditions are
The analytical solution of this problem is implemented in DiffusionAnalytic block
Release Notes:
model DiffusionEquation
PDE.MOL.Integrator.UniversalIntegrator Diffusion(
vb=2,
icb=2,
bcl=1,
n=worldModel1.n,
ve=worldModel1.n - 1,
ice=worldModel1.n - 1,
bcr=1);
inner World.worldModel worldModel1(n=40);
Modelica.Blocks.Math.Product product[worldModel1.n];
Modelica.Blocks.Sources.RealExpression sigma[worldModel1.n](y=0.01);
DIC1 dIC1_1;
DiffusionAnalytic diffusionAnalytic(alpha=0.1);
Modelica.Blocks.Sources.RealExpression BC;
PDE.MOL.SpaceDerivative.Derivatives.u_xx u_xx(
bcr=-1);
equation
connect(product.y, Diffusion.u);
connect(dIC1_1.y, Diffusion.u1);
connect(BC.y, Diffusion.u2);
connect(BC.y, Diffusion.u3);
connect(sigma.y, product.u2);
connect(u_xx.y, product.u1);
connect(Diffusion.y, u_xx.u);
end DiffusionEquation;
PDE.MOL.Examples.Diffusion.DiffusionIC
Implements the initial condition cos(x) of the diffusion equation
Release Notes:
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | n | worldModel1.n |
| Type | Name | Description |
|---|---|---|
| output RealOutput | y[worldModel1.n] |
block DiffusionIC
extends PDE.Icons.BlockIcon;
outer PDE.World.worldModel worldModel1;
inner parameter Integer n = worldModel1.n;
Modelica.Blocks.Math.Add add[worldModel1.n];
Modelica.Blocks.Sources.IntegerExpression integerExpression[worldModel1.n](
y=-1);
Modelica.Blocks.Math.Division division[worldModel1.n];
Modelica.Blocks.Sources.IntegerExpression integerExpression1[worldModel1.n](y=n - 1);
Modelica.Blocks.Math.Product product[worldModel1.n];
Modelica.Blocks.Sources.RealExpression realExpression[worldModel1.n](y=1.0);
Modelica.Blocks.Math.Cos cos[worldModel1.n];
Modelica.Blocks.Interfaces.RealOutput y[worldModel1.n];
Modelica.Blocks.Sources.Constant index_i[worldModel1.n](k=1:worldModel1.
n);
equation
connect(integerExpression.y, add.u2);
connect(add.y, division.u1);
connect(integerExpression1.y, division.u2);
connect(division.y, product.u1);
connect(realExpression.y, product.u2);
connect(cos.y, y);
connect(index_i.y, add.u1);
connect(product.y, cos.u);
end DiffusionIC;
PDE.MOL.Examples.Diffusion.DIC1
Implements the initial condition of the diffusion equation
Release Notes:
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | n | worldModel1.n |
| Type | Name | Description |
|---|---|---|
| output RealOutput | y[worldModel1.n] |
block DIC1
extends Icons.BlockIcon;
outer PDE.World.worldModel worldModel1;
parameter Integer n = worldModel1.n;
equation
for i in 1:n loop
y[i] = sin(3.14*((i-1)/n)) + 0.5*sin(3*3.14*((i-1)/n));
end for;
public
Modelica.Blocks.Interfaces.RealOutput y[worldModel1.n];
end DIC1;
PDE.MOL.Examples.Diffusion.DiffusionAnalytic
Implements the analytical solution of the diffusion equation
Release Notes:
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | n | worldModel1.n | |
| Real | alpha | 0.0 |
| Type | Name | Description |
|---|---|---|
| output RealOutput | y[worldModel1.n] |
block DiffusionAnalytic
extends Icons.BlockIcon4;
outer PDE.World.worldModel worldModel1;
parameter Integer n = worldModel1.n;
parameter Real alpha = 0.0;
equation
for i in 1:n loop
y[i] = exp(-((3.14*alpha)^2)*time)*sin(3.14*((i-1)/n)) + 0.5*exp(-((3*3.14*alpha)^2)*time)*sin(3*3.14*((i-1)/n));
end for;
public
Modelica.Blocks.Interfaces.RealOutput y[worldModel1.n];
end DiffusionAnalytic;