Advection-Diffusion¤
In 1D:
\[ \frac{\partial u}{\partial t} + c \frac{\partial u}{\partial x} = \nu \frac{\partial^2 u}{\partial x^2} \]
In higher dimensions:
\[ \frac{\partial u}{\partial t} + \vec{c} \cdot \nabla u = \nu \nabla \cdot \nabla u \]
(often just \(\vec{c} = c \vec{1}\)) and potentially with anisotropic diffusion.
exponax.stepper.AdvectionDiffusion
¤
Bases: BaseStepper
Source code in exponax/stepper/_linear.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
|
__init__
¤
__init__(
num_spatial_dims: int,
domain_extent: float,
num_points: int,
dt: float,
*,
velocity: Union[Float[Array, D], float] = 1.0,
diffusivity: Union[
Float[Array, "D D"], Float[Array, D], float
] = 0.01
)
Timestepper for the d-dimensional (d ∈ {1, 2, 3}
) advection-diffusion
equation on periodic boundary conditions.
In 1d, the advection-diffusion equation is given by
uₜ + c uₓ = ν uₓₓ
with c ∈ ℝ
being the velocity/advection speed and ν ∈ ℝ
being the
diffusivity.
In higher dimensions, the advection-diffusion equation can be written as
uₜ + c ⋅ ∇u = ν Δu
with c ∈ ℝᵈ
being the velocity/advection vector.
See also exponax.stepper.Diffusion
for additional details on
anisotropic diffusion.
Arguments:
num_spatial_dims
: The number of spatial dimensionsd
.domain_extent
: The size of the domainL
; in higher dimensions the domain is assumed to be a scaled hypercubeΩ = (0, L)ᵈ
.num_points
: The number of pointsN
used to discretize the domain. This includes the left boundary point and excludes the right boundary point. In higher dimensions; the number of points in each dimension is the same. Hence, the total number of degrees of freedom isNᵈ
.dt
: The timestep sizeΔt
between two consecutive states.velocity
(keyword-only): The advection speedc
. In higher dimensions, this can be a scalar (=float) or a vector of lengthd
. If a scalar is given, the advection speed is assumed to be the same in all spatial dimensions. Default:1.0
.diffusivity
(keyword-only): The diffusivityν
. In higher dimensions, this can be a scalar (=float), a vector of lengthd
, or a matrix of shaped ˣ d
. If a scalar is given, the diffusivity is assumed to be the same in all spatial dimensions. If a vector (of lengthd
) is given, the diffusivity varies across dimensions (=> diagonal diffusion). For a matrix, there is fully anisotropic diffusion. In this case,A
must be symmetric positive definite (SPD). Default:0.01
.
Notes:
- The stepper is unconditionally stable, not matter the choice of
any argument because the equation is solved analytically in Fourier
space. However, note that initial conditions with modes higher
than the Nyquist freuency (
(N//2)+1
withN
being thenum_points
) lead to spurious oscillations. - Ultimately, only the factors
c Δt / L
andν Δt / L²
affect the characteristic of the dynamics. See alsoexponax.normalized.NormalizedLinearStepper
withnormalized_coefficients = [0, alpha_1, alpha_2]
withalpha_1 = - velocity * dt / domain_extent
andalpha_2 = diffusivity * dt / domain_extent**2
.
Source code in exponax/stepper/_linear.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
__call__
¤
__call__(
u: Float[Array, "C ... N"]
) -> Float[Array, "C ... N"]
Performs a check
Source code in exponax/_base_stepper.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|