Partial Differential Equations

Storing varios PDE’s that can be will be solved in this course. This includes:

  • Diffusive 1D

\[u_{t} = \mu u_{xx} \qquad \forall \, x \in \Omega = [0, 1] \quad \& \quad t>0\]
  • Advective 1D

\[u_{t} + c {u}_{x} = 0 \qquad \forall \, x \in \Omega = [0, 1] \quad \& \quad t>0\]
  • Diffusive-Advective 1D

\[u_{t} + c {u}_{x} = \mu u_{xx} \qquad \forall \, x \in \Omega = [0, 1] \quad \& \quad t>0\]

The goal is to implement the code in python and not rely on existing methods.

Bram Lagerweij COHMAS Mechanical Engineering KAUST 2021

pde.advective(dof, dx, c)

Time derivative of the PDE for advective diffusive problems.

\[u_{t} + c u_{x} = 0 \qquad \forall \, x \in \Omega = [0, 1] \quad \& \quad t>0\]

Thus this returns:

\[u_{t} = - c u_{x}\]

Because we use finite difference based matrix products we can convert this into a matrix vector product, where \(D_x\) is the central difference approximation of \(\partial_x\):

\[u_{t} = -c D_{x} u = K u\]

This function calculates the matrix \(K\). Because it should be compatible with general, non-homogeneous formulation, a part that is independent of \(u\) is also included.

Parameters
  • dof (int) – Number of degrees of freedom.

  • dx (float) – Stepsize in the of spatial discretisation.

  • c (float) – The avective coefficient.

Returns

  • K (matrix (sparse csr format)) – The time derivative part of the pde obtained from the spatial part.

  • b (vector (dense array)) – The remaining term, in this homeneous case it is a zero array.

pde.advectivediffusive(dof, dx, mu, c)

Time derivative of the PDE for advective diffusive problems.

\[u_{t} + c u_{x} = \mu u_{xx} \qquad \forall \, x \in \Omega = [0, 1] \quad \& \quad t>0\]

Thus this returns:

\[u_{t} = - c u_{x} + \mu u_{xx}\]

Because we use finite difference based matrix products we can convert this into a matrix vector product, where \(D_x\) is the central difference approximation of \(\partial_x\) and similarly \(D_{xx}\) the central difference apprximation of \(\partial_{xx}\):

\[u_{t} = -c D_{x} u + \mu D_{xx} u = (-c D_{x} + \mu D_{xx})\, u = K u\]

This function calculates the matrix \(K\). Because it should be compatible with general, non-homogeneous formulation, a part that is independent of \(u\) is also included.

Parameters
  • dof (int) – Number of degrees of freedom.

  • dx (float) – Stepsize in the of spatial discretisation.

  • mu (float) – The diffusive coefficient.

  • c (float) – The avective coefficient.

Returns

  • K (matrix (sparse csr format)) – The time derivative part of the pde obtained from the spatial part.

  • b (vector (dense array)) – The remaining term, in this homeneous case it is a zero array.

pde.diffusive(dof, dx, mu)

Time derivative of the PDE for advective diffusive problems.

\[u_{t} = \mu u_{xx} \qquad \forall \, x \in \Omega = [0, 1] \quad \& \quad t>0\]

Thus this returns:

\[u_{t} = \mu u_{xx}\]

Because we use finite difference based matrix products we can convert this into a matrix vector product, where \(D_xx\) is the central difference approximation of \(\partial_{xx}\):

\[u_{t} = \mu D_{xx} u = K u\]

This function calculates the matrix \(K\). Because it should be compatible with general, non-homogeneous formulation, a part that is independent of \(u\) is also included.

Parameters
  • dof (int) – Number of degrees of freedom.

  • dx (float) – Stepsize in the of spatial discretisation.

  • mu (float) – The defusive coefficient.

Returns

  • K (matrix (sparse csr format)) – The time derivative part of the pde obtained from the spatial part.

  • b (vector (dense array)) – The remaining term, in this homeneous case it is a zero array.