Skip to content

Repository files navigation

made-with-MATLAB GitHub latest commit SISC Paper X (formerly Twitter) Follow

LARS: Lightning/AAA Rational Stokes Solver

This repository contains MATLAB codes for the paper

Computation of two-dimensional Stokes flows via lightning and AAA rational approximation
Yidan Xue, Sarah L. Waters, and Lloyd N. Trefethen.

The arXiv preprint is available at https://arxiv.org/abs/2306.13545, and the SISC publication is available at https://doi.org/10.1137/23M1576876.

The primary implementation in this repository is the MATLAB version. A Python port is also included in pylars/, but the MATLAB scripts are the reference codes for reproducing the paper examples and for working through the tutorials.

Overview

LARS computes two-dimensional Stokes flows by representing the two Goursat functions with rational approximations. The method combines:

  • lightning poles clustered near corner singularities,
  • AAA poles placed near smooth boundary singularities,
  • polynomial, Laurent, and logarithmic terms for simply and multiply connected domains,
  • Vandermonde with Arnoldi orthogonalization for stable basis construction,
  • least-squares enforcement of velocity, pressure, and wall boundary conditions.

The examples cover smooth channels, domains with corners, multiply connected geometries, moving or rotating cylinders, and particle-in-channel computations.

Requirements

The MATLAB codes were developed for MATLAB R2023b. They should also be largely compatible with recent MATLAB releases.

For examples or tutorials using the AAA algorithm, MATLAB must be able to find aaa.m. The easiest way to obtain it is to install Chebfun and add Chebfun to the MATLAB path:

https://www.chebfun.org

Some scripts may also run in Octave, but MATLAB is recommended, especially for the tutorial scripts that are intended to be rendered with MATLAB's publish function.

Reproducing the Paper Examples

The repository root contains four MATLAB scripts corresponding to the main examples in the paper.

Script Description
constricted_channel.m Stokes flow through a smoothly constricted channel. Uses AAA poles for the smooth wall geometry and reproduces the example associated with Fig. 3.
Stokes_flow_between_two_cylinders.m Stokes flow between translating and rotating cylinders. Demonstrates a multiply connected domain using Laurent and logarithmic terms. The default parameters correspond to Case A in the paper.
heart_eddies.m High-accuracy visualization of Moffatt eddies near a cusp-like heart-shaped hole.
particle_in_bifurcation.m Stokes flow past an elliptical particle in a bifurcating channel. Combines lightning poles, AAA poles, Laurent series, and logarithmic terms.

Most scripts are self-contained: helper functions such as VAorthog, VAeval, makerows, and plotcontours are included at the end of the file.

Tutorials

The tutorials/ folder contains MATLAB scripts designed to be read and rendered with MATLAB's publish function. Each tutorial is organized with %% sections and includes local helper functions at the end of the file.

Tutorial sequence:

Tutorial Topic
t1_lid_driven_cavity.m First lightning Stokes solver example; lid-driven cavity, clustered boundary points, corner poles, row weighting, and boundary errors.
t2_expanded_channel.m Expanded channel with corner singularities and parabolic inlet/outlet data.
t3_letter_N.m Nonconvex letter-N geometry; illustrates tuning the pole clustering for more difficult domains.
t4_constricted_channel.m Smooth constricted channel; introduces AAA pole placement through approximation of the Schwarz function.
t5_bifurcation.m Smooth bifurcating geometry with pressure boundary conditions and AAA poles.
t6_AAA_and_lightning.m Comparison of AAA-selected poles and lightning pole clustering near corners.
t7_two_cylinders.m First multiply connected tutorial; two cylinders with Laurent and logarithmic terms.
t8_contact_boundary.m Nearly touching boundaries; image Laurent series and improved accuracy by moving Laurent centers.
t9_four_cylinders.m Multiply connected domain with several circular holes.
t10_cylinder_cavity.m Rotating cylinder in a cavity; combines lightning poles with multiply connected basis terms.

The tutorials are intended as explanatory documents as well as executable scripts. The root-level paper examples are better starting points if you only want to reproduce the main figures.

Python Version

A Python version is included in pylars/. It mirrors the MATLAB routines at a package level:

  • pylars/core.py: core basis construction, row assembly, row weighting, and function evaluation;
  • pylars/plot.py: plotting utilities;
  • pylars/examples/: Python versions of the four root-level MATLAB examples.

The Python code can be run in the numerics conda environment, for example:

conda run -n numerics python -m pylars.examples.ex1_constricted_channel

At present, the MATLAB implementation should be regarded as the reference version. The Python port is useful for experimentation, comparison, and future software development.

Suggested Workflow

  1. Start with the published MATLAB examples in the repository root.
  2. Work through the tutorials using MATLAB publish if you want a guided explanation of the method.
  3. Modify geometry, boundary conditions, pole placement, polynomial degree, and Laurent/log terms in the MATLAB scripts.
  4. Use the Python version for prototyping or for building a larger software interface around the method.

Citation

Xue, Y., Waters, S.L. and Trefethen, L.N. (2024) 'Computation of two-dimensional Stokes flows via lightning and AAA rational approximation', SIAM Journal on Scientific Computing, 46(2), pp. A1214-A1234. doi: 10.1137/23M1576876.

BibTeX:

@article{xue2024,
  author  = {Xue, Yidan and Waters, Sarah L. and Trefethen, Lloyd N.},
  title   = {Computation of Two-Dimensional Stokes Flows via Lightning and AAA Rational Approximation},
  journal = {SIAM Journal on Scientific Computing},
  volume  = {46},
  number  = {2},
  pages   = {A1214--A1234},
  year    = {2024},
  doi     = {10.1137/23M1576876},
  url     = {https://doi.org/10.1137/23M1576876}
}

About

This repository is for the paper: Computation of two-dimensional Stokes flows via lightning and AAA rational approximation. These MATLAB codes compute the example Stokes flow cases in the presented paper using lightning and AAA rational approximation.

Resources

Stars

17 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages