Advection
The Advection function adds advection to a system of equations. This is useful for modeling the transport of a substance by a fluid. Advection is implemented with the Advection type.
!warning Fully symbolic partial differential equations like those shown here don't currently work on domains that have a large number of grid cells. See here for additional information.
To demonstrate how this can work, we will start with a simple system of equations:
using EarthSciMLBase, ModelingToolkit
using ModelingToolkit: t_nounits, D_nounits
t = t_nounits
D = D_nounits
function ExampleSys()
@variables y(t)
@parameters p=2.0 x=1
System([D(y) ~ p], t, [y], [p, x]; name = :ExampleSys)
end
ExampleSys()Model ExampleSys:
Equations (1):
1 standard: see equations(ExampleSys)
Unknowns (1): see unknowns(ExampleSys)
y(t)
Parameters (2): see parameters(ExampleSys)
p
xWe also need to create our initial and boundary conditions.
using DomainSets
@parameters x
domain = DomainInfo(constIC(0.0, t ∈ Interval(0, 1.0)), constBC(1.0, x ∈ Interval(0, 1.0)))Now we convert add advection to each of the state variables. We're also adding a constant wind (ConstantWind) in the x-direction, with a speed of 1.0.
sys_advection = couple(ExampleSys(), domain, ConstantWind(t, 1.0), Advection())
sys_mtk = convert(PDESystem, sys_advection)PDESystem
Equations: Symbolics.Equation[δExampleSys₊x_transform(t, x) ~ 1, MeanWind₊v_x(t, x) ~ ConstantWind₊v_1(t, x), Differential(t, 1)(ExampleSys₊y(t, x)) ~ ExampleSys₊p - Differential(x, 1)(ExampleSys₊y(t, x))*MeanWind₊v_x(t, x), ConstantWind₊v_1(t, x) ~ ConstantWind₊c_v1]
Boundary Conditions: Symbolics.Equation[δExampleSys₊x_transform(0.0, x) ~ 0.0, MeanWind₊v_x(0.0, x) ~ 0.0, ConstantWind₊v_1(0.0, x) ~ 0.0, ExampleSys₊y(0.0, x) ~ 0.0, ConstantWind₊v_1(0.0, x) ~ 0.0, MeanWind₊v_x(0.0, x) ~ 0.0, δExampleSys₊x_transform(t, 0.0) ~ 1.0, δExampleSys₊x_transform(t, 1.0) ~ 1.0, MeanWind₊v_x(t, 0.0) ~ 1.0, MeanWind₊v_x(t, 1.0) ~ 1.0, ConstantWind₊v_1(t, 0.0) ~ 1.0, ConstantWind₊v_1(t, 1.0) ~ 1.0, ExampleSys₊y(t, 0.0) ~ 1.0, ExampleSys₊y(t, 1.0) ~ 1.0, ConstantWind₊v_1(t, 0.0) ~ 1.0, ConstantWind₊v_1(t, 1.0) ~ 1.0, MeanWind₊v_x(t, 0.0) ~ 1.0, MeanWind₊v_x(t, 1.0) ~ 1.0]
Domain: Symbolics.VarDomainPairing[Symbolics.VarDomainPairing(t, 0.0 .. 1.0), Symbolics.VarDomainPairing(x, 0.0 .. 1.0)]
Dependent Variables: Symbolics.Num[δExampleSys₊x_transform(t, x), MeanWind₊v_x(t, x), ConstantWind₊v_1(t, x), ExampleSys₊y(t, x), ConstantWind₊v_1(t, x), MeanWind₊v_x(t, x)]
Independent Variables: Symbolics.Num[t, x]
Parameters: SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}[ExampleSys₊p, ExampleSys₊x]
Default Parameter ValuesModelingToolkitBase.AtomicArrayDict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, Dict{SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}, SymbolicUtils.BasicSymbolicImpl.var"typeof(BasicSymbolicImpl)"{SymbolicUtils.SymReal}}}()Discretization and numerical solution of this PDE system requires MethodOfLines.jl, which is not currently compatible with the latest ModelingToolkit ecosystem.