Skip to content

2. pde

torchfsm.pde.Burgers ¤

Burgers(nu: float) -> Operator
Burgers equation
\[\frac{\partial \mathbf{u}}{\partial t} =-\mathbf{u} \cdot \nabla \mathbf{u} + \nu \nabla^2 \mathbf{u}\]

Parameters:

Name Type Description Default
nu float

Viscosity coefficient.

required

Returns:

Name Type Description
Operator Operator

The operator representing the Burgers equation.

Source code in torchfsm/pde.py
13
14
15
16
17
18
19
20
21
22
23
24
25
def Burgers(nu: float) -> Operator:
    r"""
    Burgers equation:
        $$\frac{\partial \mathbf{u}}{\partial t} =-\mathbf{u} \cdot \nabla \mathbf{u} + \nu \nabla^2 \mathbf{u}$$

    Args:
        nu (float): Viscosity coefficient.    

    Returns:
        Operator: The operator representing the Burgers equation.

    """
    return nu * Laplacian() - Convection()

torchfsm.pde.KortewegDeVries ¤

KortewegDeVries(
    dispersion_coef=1, convection_coef: float = 6.0
) -> Operator
Korteweg-De Vries equation
\[\frac{\partial \phi}{\partial t}=-c_1\frac{\partial^3 \phi}{\partial x^3} + c_2 \phi\frac{\partial\phi}{\partial x}\]

Parameters:

Name Type Description Default
dispersion_coef float

Dispersion coefficient. Default is 1.

1
convection_coef float

Convection coefficient. Default is 6.0.

6.0

Returns:

Name Type Description
Operator Operator

The operator representing the Korteweg-De Vries equation.

Source code in torchfsm/pde.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def KortewegDeVries(dispersion_coef=1, convection_coef: float = 6.0) -> Operator:
    r"""
    Korteweg-De Vries equation:
        $$\frac{\partial \phi}{\partial t}=-c_1\frac{\partial^3 \phi}{\partial x^3} + c_2 \phi\frac{\partial\phi}{\partial x}$$

    Args:
        dispersion_coef (float): Dispersion coefficient. Default is 1.
        convection_coef (float): Convection coefficient. Default is 6.0.

    Returns:
        Operator: The operator representing the Korteweg-De Vries equation.    

    """
    return -dispersion_coef * SpatialDerivative(0, 3) + convection_coef * Convection()

torchfsm.pde.KuramotoSivashinsky ¤

KuramotoSivashinsky() -> Operator
1D Kuramoto-Sivashinsky equation
\[\frac{\partial \phi}{\partial t}=-\frac{\partial^2 \phi}{\partial x^2} -\frac{\partial^4 \phi}{\partial x^4} - \phi\frac{\partial\phi}{\partial x}\]

Returns:

Name Type Description
Operator Operator

The operator representing the Kuramoto-Sivashinsky equation.

Source code in torchfsm/pde.py
27
28
29
30
31
32
33
34
35
36
37
38
39
def KuramotoSivashinsky() -> Operator:
    r"""
    1D Kuramoto-Sivashinsky equation:
        $$\frac{\partial \phi}{\partial t}=-\frac{\partial^2 \phi}{\partial x^2} -\frac{\partial^4 \phi}{\partial x^4} - \phi\frac{\partial\phi}{\partial x}$$

    Returns:
        Operator: The operator representing the Kuramoto-Sivashinsky equation.
    """
    ks_eqn = -Laplacian() - Biharmonic() - Convection()
    ks_eqn.regisiter_additional_check(
        lambda dim_value, dim_mesh: dim_value == 1 and dim_mesh == 1
    )
    return ks_eqn

torchfsm.pde.KuramotoSivashinskyHighDim ¤

KuramotoSivashinskyHighDim() -> Operator
High dimensional Kuramoto-Sivashinsky equation
\[\frac{\partial \mathbf{\phi}}{\partial t}=-\nabla^2 \phi- \nabla^4 \phi - \frac{1}{2}|\nabla \phi|^2\]

Returns:

Name Type Description
Operator Operator

The operator representing the Kuramoto-Sivashinsky equation.

Source code in torchfsm/pde.py
41
42
43
44
45
46
47
48
49
def KuramotoSivashinskyHighDim() -> Operator:
    r"""
    High dimensional Kuramoto-Sivashinsky equation:
        $$\frac{\partial \mathbf{\phi}}{\partial t}=-\nabla^2 \phi- \nabla^4 \phi - \frac{1}{2}|\nabla \phi|^2$$

    Returns:
        Operator: The operator representing the Kuramoto-Sivashinsky equation.
    """
    return -Laplacian() - Biharmonic() - KSConvection()

torchfsm.pde.NavierStokesVorticity ¤

NavierStokesVorticity(
    Re: float, force: Optional[Operator] = None
) -> Operator

Parameters:

Name Type Description Default
Re float

Reynolds number.

required
force Optional[Operator]

Optional external force term. Default is None. If provided, it will be added to the vorticity equation. Note that the provided force should be \(\nabla \times \mathbf{f}\) rather than \(\mathbf{f}\) itself.

None

Returns:

Name Type Description
Operator Operator

The operator representing the Navier-Stokes equation in vorticity form.

Source code in torchfsm/pde.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def NavierStokesVorticity(Re:float,force:Optional[Operator]=None)->Operator:
    r"""
    Navier-Stokes equation in vorticity form:
        $$\frac{\partial \omega}{\partial t} + (\mathbf{u}\cdot\nabla) \omega = \frac{1}{Re} \nabla^2 \omega + \nabla \times \mathbf{f}$$

    Args:
        Re (float): Reynolds number.
        force (Optional[Operator]): Optional external force term. Default is None.
            If provided, it will be added to the vorticity equation. Note that the provided force should be $\nabla \times \mathbf{f}$ rather than $\mathbf{f}$ itself.

    Returns:
        Operator: The operator representing the Navier-Stokes equation in vorticity form.

    """
    ns_vorticity=-VorticityConvection() + 1/Re*Laplacian()
    if force is not None:
        ns_vorticity+=force
    return ns_vorticity

torchfsm.pde.NavierStokes ¤

NavierStokes(
    Re: float, force: Optional[Operator] = None
) -> Operator

Parameters:

Name Type Description Default
Re float

Reynolds number.

required
force Optional[Operator]

Optional external force term. Default is None. If provided, it will be added to the vorticity equation.

None

Returns:

Name Type Description
Operator Operator

The operator representing the Navier-Stokes equation.

Source code in torchfsm/pde.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
def NavierStokes(Re:float,force:Optional[Operator]=None)->Operator:
    r"""
    Navier-Stokes equation:
        $$\frac{\partial\mathbf{u}}{\partial t}=-\nabla (\nabla^{-2} \nabla \cdot (\left(\mathbf{u}\cdot\nabla\right)\mathbf{u}-f))-\left(\mathbf{u}\cdot\nabla\right)\mathbf{u}+\nu \nabla^2 \mathbf{u} + \mathbf{f}$$

    Args:
        Re (float): Reynolds number.
        force (Optional[Operator]): Optional external force term. Default is None.
            If provided, it will be added to the vorticity equation. 

    Returns:
        Operator: The operator representing the Navier-Stokes equation.

    """

    return NSPressureConvection(force)+1/Re*Laplacian()