transiflow.BoundaryConditions

class BoundaryConditions(nx, ny, nz, dim, dof, x, y, z)

Bases: object

Boundary conditions for the Discretization class. Every method expects and atom, modifies it accordingly and also modifies the forcing that is stored internally. This class is only used from within the Discretization class.

Parameters:
nxint

Grid size in the x direction.

nyint

Grid size in the y direction.

nzint

Grid size in the z direction. This is set to 1 for 2-dimensional problems.

dimint

Physical dimension of the problem. In case this is set to 2, w is not referenced in the state vector.

dofint

Degrees of freedom for this problem. This should be set to dim plus 1 for each of pressure, temperature and salinity, if they are required for your problem. For example a 3D differentially heated cavity has dof = 3 + 1 + 1 = 5.

xarray_like, optional

Coordinate vector in the x direction.

yarray_like, optional

Coordinate vector in the y direction.

zarray_like, optional

Coordinate vector in the z direction.

free_slip_bottom(atom)

Apply a free slip boundary condition at the south boundary. At this boundary $w_{k-1} = 0$, $(u_k - u_{k-1}) / h = 0$ and similar for $v$. So we simply replace $u_{k-1}$ by $u_k$, $v_{k-1}$ by $v_k$ and set all references to cells outside the domain to zero as well.

free_slip_east(atom)

Apply a free slip boundary condition at the east boundary. At this boundary $u_i = 0$, $(v_{i+1} - v_i) / h = 0$ and similar for $w$. So we replace $v_{i+1}$ by $v_i$, $w_{i+1}$ by $w_i$, set $u_i$ to zero and set all references to cells outside the domain to zero as well.

free_slip_north(atom)

Apply a free slip boundary condition at the north boundary. At this boundary $v_j = 0$, $(u_{j+1} - u_j) / h = 0$ and similar for $w$. So we replace $u_{j+1}$ by $u_j$, $w_{j+1}$ by $w_j$, set $v_j$ to zero and set all references to cells outside the domain to zero as well.

free_slip_south(atom)

Apply a free slip boundary condition at the south boundary. At this boundary $v_{j-1} = 0$, $(u_j - u_{j-1}) / h = 0$ and similar for $w$. So we simply replace $u_{j-1}$ by $u_j$, $w_{j-1}$ by $w_j$ and set all references to cells outside the domain to zero as well.

free_slip_top(atom)

Apply a free slip boundary condition at the top boundary. At this boundary $w_k = 0$, $(u_{k+1} - u_k) / h = 0$ and similar for $v$. So we replace $u_{k+1}$ by $u_k$, $v_{k+1}$ by $v_k$, set $w_k$ to zero and set all references to cells outside the domain to zero as well.

free_slip_west(atom)

Apply a free slip boundary condition at the west boundary. At this boundary $u_{i-1} = 0$, $(v_i - v_{i-1}) / h = 0$ and similar for $w$. So we simply replace $v_{i-1}$ by $v_i$, $w_{i-1}$ by $w_i$ and set all references to cells outside the domain to zero as well.

get_forcing()

Return the forcing that is required to be added the the RHS.

heat_flux_bottom(atom, heat_flux, biot=0.0)

Apply a heat flux $Q$ at the bottom boundary. We have $(T_k - T_{k-1}) / h - \mathrm{Bi} (T_{k-1} + T_i) / 2 = Q$ so we get $T_{k-1} = T_k (1 + h \mathrm{Bi} / 2) / (1 - h \mathrm{Bi} / 2) + h Q / (1 - h \mathrm{Bi} / 2)$. By default, the Biot number is assumed to be zero.

heat_flux_east(atom, heat_flux, biot=0.0)

Apply a heat flux $Q$ at the east boundary. We have $(T_{i+1} - T_i) / h - \mathrm{Bi} (T_{i+1} + T_i) / 2 = Q$ so we get $T_{i+1} = T_i (1 - h \mathrm{Bi} / 2) / (1 + h \mathrm{Bi} / 2) + h Q / (1 + h \mathrm{Bi} / 2)$. By default, the Biot number is assumed to be zero.

heat_flux_north(atom, heat_flux, biot=0.0)

Apply a heat flux $Q$ at the north boundary. We have $(T_{j+1} - T_j) / h - \mathrm{Bi} (T_{j+1} + T_j) / 2 = Q$ so we get $T_{j+1} = T_j (1 - h \mathrm{Bi} / 2) / (1 + h \mathrm{Bi} / 2) + h Q / (1 + h \mathrm{Bi} / 2)$. By default, the Biot number is assumed to be zero.

heat_flux_south(atom, heat_flux, biot=0.0)

Apply a heat flux $Q$ at the south boundary. We have $(T_j - T_{j-1}) / h - \mathrm{Bi} (T_{j-1} + T_i) / 2 = Q$ so we get $T_{j-1} = T_j (1 + h \mathrm{Bi} / 2) / (1 - h \mathrm{Bi} / 2) + h Q / (1 - h \mathrm{Bi} / 2)$. By default, the Biot number is assumed to be zero.

heat_flux_top(atom, heat_flux, biot=0.0)

Apply a heat flux $Q$ at the top boundary. We have $(T_{k+1} - T_k) / h - \mathrm{Bi} (T_{k+1} + T_k) / 2 = Q$ so we get $T_{k+1} = T_k (1 - h \mathrm{Bi} / 2) / (1 + h \mathrm{Bi} / 2) + h Q / (1 + h \mathrm{Bi} / 2)$. By default, the Biot number is assumed to be zero.

heat_flux_west(atom, heat_flux, biot=0.0)

Apply a heat flux $Q$ at the west boundary. We have $(T_i - T_{i-1}) / h - \mathrm{Bi} (T_{i-1} + T_i) / 2 = Q$ so we get $T_{i-1} = T_i (1 + h \mathrm{Bi} / 2) / (1 - h \mathrm{Bi} / 2) + h Q / (1 - h \mathrm{Bi} / 2)$. By default, the Biot number is assumed to be zero.

moving_lid_bottom(atom, velocity)

Apply a moving lid at the bottom boundary with velocity U. At this boundary $w_k = 0$, $(u_k + u_{k-1}) / 2 = U$ and no slip for $v$. So we replace $u_{k-1}$ by $2U - u_k$ and then apply the no slip condition.

moving_lid_east(atom, velocity)

Apply a moving lid at the east boundary with velocity V. At this boundary $u_i = 0$, $(v_i + v_{i+1}) / 2 = V$ and no slip for $w$. So we replace $v_{i+1}$ by $2V - v_i$ and then apply the no slip condition.

moving_lid_north(atom, velocity)

Apply a moving lid at the north boundary with velocity U. At this boundary $v_j = 0$, $(u_j + u_{j+1}) / 2 = U$ and no slip for $w$. So we replace $u_{j+1}$ by $2U - u_j$ and then apply the no slip condition.

moving_lid_south(atom, velocity)

Apply a moving lid at the south boundary with velocity U. At this boundary $v_j = 0$, $(u_j + u_{j-1}) / 2 = U$ and no slip for $w$. So we replace $u_{j-1}$ by $2U - u_j$ and then apply the no slip condition.

moving_lid_top(atom, velocity)

Apply a moving lid at the top boundary with velocity U. At this boundary $w_k = 0$, $(u_k + u_{k+1}) / 2 = U$ and no slip for $v$. So we replace $u_{k+1}$ by $2U - u_k$ and then apply the no slip condition.

moving_lid_west(atom, velocity)

Apply a moving lid at the west boundary with velocity V. At this boundary $u_i = 0$, $(v_i + v_{i-1}) / 2 = V$ and no slip for $w$. So we replace $v_{i-1}$ by $2V - v_i$ and then apply the no slip condition.

no_slip_bottom(atom)

Apply a no slip boundary condition at the bottom boundary. At this boundary $w_{k-1} = 0$, $(u_{k-1} + u_k) / 2 = 0$ and similar for $v$. So we simply replace $u_{k-1}$ by $-u_k$, $v_{k-1}$ by $-v_k$, and set all references to cells outside the domain to zero.

no_slip_east(atom)

Apply a no slip boundary condition at the east boundary. At this boundary $u_i = 0$, $(v_i + v_{i+1}) / 2 = 0$ and similar for $w$. So we replace $v_{i+1}$ by $-v_i$, $w_{i+1}$ by $-w_i$, set $u_i$ to zero and set all references to cells outside the domain to zero as well.

no_slip_north(atom)

Apply a no slip boundary condition at the north boundary. At this boundary $v_j = 0$, $(u_j + u_{j+1}) / 2 = 0$ and similar for $w$. So we replace $u_{j+1}$ by $-u_j$, $w_{j+1}$ by $-w_j$, set $v_j$ to zero and set all references to cells outside the domain to zero as well.

no_slip_south(atom)

Apply a no slip boundary condition at the south boundary. At this boundary $v_{j-1} = 0$, $(u_{j-1} + u_j) / 2 = 0$ and similar for $w$. So we simply replace $u_{j-1}$ by $-u_j$, $w_{j-1}$ by $-w_j$ and set all references to cells outside the domain to zero.

no_slip_top(atom)

Apply a no slip boundary condition at the top boundary. At this boundary $w_k = 0$, $(u_k + u_{k+1}) / 2 = 0$ and similar for $v$. So we replace $u_{k+1}$ by $-u_k$, $v_{k+1}$ by $-v_k$, set $w_k$ to zero and set all references to cells outside the domain to zero as well.

no_slip_west(atom)

Apply a no slip boundary condition at the west boundary. At this boundary $u_{i-1} = 0$, $(v_{i-1} + v_i) / 2 = 0$ and similar for $w$. So we simply replace $v_{i-1}$ by $-v_i$, $w_{i-1}$ by $-w_i$ and set all references to cells outside the domain to zero.

salinity_flux_bottom(atom, salinity_flux)

Apply a salinity flux $Q$ at the bottom boundary. We have $(S_k - S_{k-1}) / h = Q$ so we replace $S_{k-1}$ by $S_k - hQ$.

salinity_flux_east(atom, salinity_flux)

Apply a salinity flux $Q$ at the east boundary. We have $(S_{i+1} - S_i) / h = Q$ so we replace $S_{i+1}$ by $S_i + hQ$.

salinity_flux_north(atom, salinity_flux)

Apply a salinity flux $Q$ at the north boundary. We have $(S_{j+1} - S_j) / h = Q$ so we replace $S_{j+1}$ by $S_j + hQ$.

salinity_flux_south(atom, salinity_flux)

Apply a salinity flux $Q$ at the south boundary. We have $(S_j - S_{j-1}) / h = Q$ so we replace $S_{j-1}$ by $S_j - hQ$.

salinity_flux_top(atom, salinity_flux)

Apply a salinity flux $Q$ at the top boundary. We have $(S_{k+1} - S_k) / h = Q$ so we replace $S_{k+1}$ by $S_k + hQ$.

salinity_flux_west(atom, salinity_flux)

Apply a salinity flux $Q$ at the west boundary. We have $(S_i - S_{i-1}) / h = Q$ so we replace $S_{i-1}$ by $S_i - hQ$.

temperature_bottom(atom, temperature)

Apply a fixed temperature $T_b$ at the bottom boundary. We have $(T_k + T_{k-1}) / 2 = T_b$ so we replace $T_{k-1}$ by $2T_b - T_k$.

temperature_east(atom, temperature)

Apply a fixed temperature $T_b$ at the east boundary. We have $(T_i + T_{i+1}) / 2 = T_b$ so we replace $T_{i+1}$ by $2T_b - T_i$.

temperature_north(atom, temperature)

Apply a fixed temperature $T_b$ at the north boundary. We have $(T_j + T_{j+1}) / 2 = T_b$ so we replace $T_{j+1}$ by $2T_b - T_j$.

temperature_south(atom, temperature)

Apply a fixed temperature $T_b$ at the south boundary. We have $(T_j + T_{j-1}) / 2 = T_b$ so we replace $T_{j-1}$ by $2T_b - T_j$.

temperature_top(atom, temperature)

Apply a fixed temperature $T_b$ at the top boundary. We have $(T_k + T_{k+1}) / 2 = T_b$ so we replace $T_{k+1}$ by $2T_b - T_k$.

temperature_west(atom, temperature)

Apply a fixed temperature $T_b$ at the west boundary. We have $(T_i + T_{i-1}) / 2 = T_b$ so we replace $T_{i-1}$ by $2T_b - T_i$.

\[\]