Lightning Solvers for Potential Flows

: We present a method for computing potential ﬂows in planar domains. Our approach is based on a new class of techniques, known as “lightning solvers”, which exploit rational function approximation theory in order to achieve excellent convergence rates. The method is particularly suitable for ﬂows in domains with corners where traditional numerical methods fail. We outline the mathematical basis for the method and establish the connection with potential ﬂow theory. In particular, we apply the new solver to a range of classical problems including steady potential ﬂows, vortex dynamics, and free-streamline ﬂows. The solution method is extremely rapid and usually takes just a fraction of a second to converge to a high degree of accuracy. Numerical evaluations of the solutions are performed in a matter of microseconds and can be compressed further with novel algorithms.


Introduction
This paper is concerned with the numerical solution of the planar Laplace equation in contexts relevant to fluid dynamics.The domain D is assumed to be unbounded and simply connected (or periodic) and z = x + iy is the spatial co-ordinate.Laplace's equation is sometimes considered the simplest two-dimensional (2-D) partial differential equation but, nevertheless, its numerical solution is challenging in many scenarios of practical interest.In particular, typical numerical methods struggle when the boundary of the flow domain ∂D is not smooth; for example, the solution of (1) admits a singularity where the boundary has sharp corners [1], which hinders traditional techniques such as finite element methods [2,3] and boundary element methods [4].Although these approaches have been successfully adapted to account for corners (e.g., [5]), their implementation is complex and requires expert knowledge.
Recently, a new method that makes use of rational function approximation theory has been proposed for solving Laplace's equation in domains with corners [6,7].Dubbed the "lightning solver" (due to the analogy of lightning striking a corner because of a singular electric potential there), this new solution technique is extremely fast, accurate, and straightforward to implement.Herein, we use the lightning method to devise new strategies for solving potential flow problems in domains with corners.Potential flows are foundational to fluid mechanics.In the fluid mechanics pedagogy, the first problem that students encounter is often incompressible and irrotational flow past a cylinder.Equipped with the solution to this simple flow, students progress to more complicated geometries via conformal mappings such as the Joukowski map [8].The ensuing solutions can usually be expressed in closed form and are, thus, highly interpretable.Much of classical aerodynamics was built on this approach [9][10][11] and the associated solutions continue to be relevant to modern aerodynamics studies today [12,13].Idealised flow also commonly arises as an outer region problem in asymptotic analyses, and can then be matched to an inner boundary layer [14].Another way to improve the physical fidelity of potential flows is by incorporating the effects of flow separation.The Brown-Michael equation [15] is a popular method for modelling point vortices shed from sharp corners [16][17][18] whereas contour dynamics models the shedding and roll-up of vortex sheets [19,20].In Section 3.4, we shall see that the lightning approach of the present work can be used to rapidly compute point vortex trajectories in complicated domains.Free-streamline theory [21,22] provides an alternative approach to modelling flow separation; in Section 3.5, we shall use the lightning solver to calculate the idealised, separated flow past a flat plate.
The mathematically tractable structure of potential flows has inspired a rich mathematical theory rooted predominantly in complex analysis.The theory of conformal mappings [23][24][25] has enabled the study of potential flows in complicated domains beyond the aforementioned Joukowski map.Moreover, a theory for multiply connected flow domains has recently been expounded by Crowdy [26,27], and the present author adapted these studies to periodic domains [28].Both of these approaches make use of the transcendental Schottky-Klein prime function [29].The prime function also provides a closed-form expression for the Kirchhoff-Routh path function [30], which governs the trajectories of point vortices [31].Riemann-Hilbert problems and singular integral equations are also relevant, and have previously been used to study flows through cascades [32], porous aerofoils [33], and dissolution and erosion [34].
Corners are obviously ubiquitous in real-life engineering applications and are often responsible for important physical behaviour; the local behaviour of flow past a sharp corner can have a significant impact on the global properties of the flow.For example, the Kutta condition implies that the flow at the sharp trailing edge of an aerofoil should depart the wing smoothly [35].This specification determines the circulation around the wing and, thus, its lift [36].At the leading edge of a wing, the leading-edge suction is critical in determining the thrust on unsteady bodies and has recently been proposed as a tool for modelling the onset of vortex shedding [37].This approach has been coupled with real measurement data in order to account for absent physics via data assimilation to obtain a model that is simultaneously fast and physically faithful [38].In summary, the flow behaviour at corners must be accurately modelled for physically relevant results.
The remainder of this article is arranged as follows.In Section 2, we explain the lightning solver framework and outline the mathematical details.We then apply this framework to a range of scenarios including potential flows, vortex dynamics, and free-streamline problems in Section 3. Finally, we present a discussion of the results in Section 4. Most of the results that are produced in this paper are computed using straightforward adaptations of the MATLAB code laplace.m available at [39].The reported solve times are based on computations performed on a 2015 MacBook Pro with a 2.9 GHz processor.

Method
We now present the main mathematical ideas behind the lightning method.

The Lightning Method
We are interested in solving Laplace's equation in an unbounded 2-D domain D with corners on the boundary ∂D.Solutions of Laplace's equation typically exhibit singularities with behaviour z α near corners; for example, z α represents the complex potential for flow around an infinite wedge with a corner of interior angle π(2 − 1/α).The absence of viscosity and the infinite curvature of the boundary at the corner imply that the flow there either has infinite velocity or is stagnant.The presence of these singularities suggests that the recently developed lightning solvers can be an efficient and accurate method for computing potential flows.
The ideas behind the lightning method are based in rational approximation theory.A rational function is simply a ratio of two polynomials; we say that a rational function is type (m, n) if the numerator is a polynomial of degree at most m and the denominator is a polynomial of degree at most n.A detailed discussion of rational approximation can be found in chapters 22 to 27 of [40].A principal result of rational approximation is due to Newman [41], who showed that the absolute value function |x| can be approximated on the interval x ∈ [−1, 1] with root-exponential accuracy.In mathematical language, there exist constants A, C > 0 and type (n, n) rational approximants r n such that max ( In contrast, a polynomial approximant can achieve, at best, algebraic convergence (i.e., the error decays in proportion to n −1 ).Motivated by this result, Gopal and Trefethen [6] proved that similar approximants exist for more general types of singularities of the form z α .Again, it is possible to attain root-exponential convergence when approximating with rational functions; there exist constants A, C > 0 and type (n, n) rational approximants r n , such that max where H represents the closed upper half of the unit disc.Theorem 2.3 of [6] extended this result to prove that solutions of Laplace's equation in convex polygons can be represented as rational functions with root-exponential accuracy.Although the theoretical results of [6] were valid when the domain is the interior of a convex polygon, the numerical results of the present paper indicate that they also hold when the domain is the exterior of some bounded domain.
Crucially, the rational approximants r n in both ( 2) and ( 3) possess poles that are exponentially clustered near zero with exponentially decreasing residues.This observation, as well as the above theoretical results, inform a numerical scheme for Laplace's equation by considering an ansatz with poles clustered exponentially close to the corners of the domain.Gopal and Trefethen [6] suggest an ansatz of the form where z * is a point near the center of ∂D, {z j | j = 1, . . ., n 2 } is a prescribed set of poles and {a j | j = 0, . . ., n 1 } and {b j | j = 1, . . ., n 2 } are sets of unknown, complex constants.Equation ( 4) is simply a rational function in partial fraction form.Because rational functions are analytic away from the poles, if all of the poles {z j } are outside D then (4) is a solution to Laplace's equation.The Runge part in (4) corresponds to the smooth part of the solution: it is a polynomial in 1/(z − z * ).If ∂D is smooth then the Runge part is all that is necessary in the ansatz.Conversely, the Newman part takes the singularities on the corners into account.
A key feature of the lightning method is that the poles in the Newman part {z j } are clustered exponentially close to the corners in order to exploit the root-exponential convergence guaranteed by (3).In particular, there is evidence to suggest that the poles should follow a "tapered" distribution near the corners [42].In this case, the poles that are clustered around a given corner should be of distance from that corner.In our numerical results we use σ = 3 although σ = 4 is also a good choice.By the linearity of Laplace's equation, the coefficients {a j } and {b j } can be determined by fitting f to satisfy some prescribed linear boundary conditions.This is achieved by sampling the ansatz (4) at a number of points on the boundary and solving for {a j } and {b j } in the least-squares sense.The sample points should also be exponentially clustered near the corners in order to ensure that the poles exponentially near the corners are properly resolved.For example, if the boundary condition is collocated at m points then the coefficients are given by arg min c Ac − d 2 (6) where c ∈ R 2n 1 +2n 2 +2 is the stacked vector of the real and imaginary parts of the unknown coefficients, d ∈ R m represents the sampled boundary condition, and A ∈ R m×(2n 1 +2n 2 +2) represents the sampled basis functions in (4).For example, suppose that the boundary condition is Im[ f (z)] = d(z) for some function d.Subsequently, for an M × 1 vector of sample points Z, we have where the blocks R and N correspond to the Runge and Newman parts respectively: Thus, Im[ f (Z)] = Ac.It is important to note that the matrix R is exponentially ill-conditioned since its columns are the real and imaginary parts of the columns of a Vandermonde matrix.To address this issue, the Vandermonde matrix is not formed explicitly: instead, we form an equivalent matrix with orthogonal columns via the Vandermonde with Arnoldi algorithm [43].Using these matrix constructions, the least-squares problem (6) can be easily solved using, for example, the backslash operator in MATLAB.Having obtained the coefficients {a j } and {b j }, the rational approximant f can be computed via (4).This completes the description of the lightning solver.Pseudocode describing the main steps is included in Algorithm 1 and we refer the reader to [6] for further details.
Algorithm 1: Laplace lightning solver (Gopal and Trefethen, 2019 [6]).The lightning solver belongs to a broader class of techniques known as Methods of Fundamental Solutions (MFS) [44][45][46].In these methods, the solution is expanded as a distribution of free-space solutions whose coefficients are tuned to satisfy a given boundary condition.However, the lightning solver differs from typical MFS in two important ways.Firstly, the singularities are exponentially clustered near the corners, which is a new idea in MFS.Secondly, the fundamental solutions that are used here are dipoles (1/(z − z j )), whereas traditional MFS typically use point sources (log(z − z j )).These two qualities are essential to the root-exponential convergence of solutions that we observe herein.

Input
The main idea of this paper is to use the lightning solver to solve potential flow problems.We will apply this approach to a plethora of scenarios to showcase its versatility, but as a first example, consider uniform flow past a stationary boundary ∂D.If w represents the complex potential then the no-flux condition states that Im[w(z)] = 0 for z ∈ ∂D and the far-field condition is w ∼ z as |z| → ∞.Thus, we may write w(z) = z + f (z) where f is the ansatz expressed in (4).After arranging the poles to cluster near the corners, the coefficients a j and b j are chosen in order to satisfy the no-flux condition.The resulting streamlines are plotted in Figure 1a for a square with a circular sector removed.The background color represents the horizontal perturbation velocity, which can be obtained by differentiating f .In Figure 1b, we plot the convergence of the solution as the number of degrees of freedom (N = 2(n 1 + n 2 + 1)) is increased.The problem is solved to six digits of accuracy in 0.5 s.Evaluating the solution takes 20 microseconds for each point.The root-exponential convergence is clear, and the approximation is accurate throughout the entire boundary, including the corners.The problem takes 0.5 s to solve to six digits of accuracy and 5 s for eight digits.In (a) the black dots represent the poles.The background colour in (a) represents the horizontal velocity of the perturbation to the flow from uniformity.Note that in (b) the y-axis is on a log scale whereas the x-axis is √ N, so that a straight line indicates root-exponential convergence.

Compression of Solutions
While the rational function representation ( 4) is very fast to evaluate, even faster evaluations are possible.In certain applications-such as the vortex dynamics example we shall encounter later-the solution f will be evaluated a large number of times and thus an inexpensive evaluation of f is desirable.
Recently, the AAA (adaptive Antoulas-Anderson) algorithm has emerged as a robust, flexible, and accurate tool for rational approximation and compression [47,48].Given sets of sample points Z and function values F = { f (z) | z ∈ Z}, the AAA algorithm returns a rational function r that approximates f to some specified tolerance.One important feature of the AAA algorithm is that the rational function is expressed in barycentric form, i.e., The set of support points {t j } ⊆ Z is a subset of the sample points and w j are known as the weights.Note that r(t j ) = f j so r interpolates f at the support points.The AAA algorithm selects support points and weights by iteratively reducing the residual error.At each iteration, the next support point is chosen "greedily" as the one with the largest residual error between the approximant and function value.Subsequently, the weight w j is updated by solving a minimisation problem via a singular value decomposition (SVD).When a desired accuracy is reached then the algorithm terminates-( 10) consists of m support points and thus m iterations.These features-the barycentric form, greedy selection of support points and least-squares minimisation via SVD-are all central to the success of the AAA algorithm.The algorithm is straightforward to implement and use: the original article [47] contained an implementation in 40 lines of MATLAB code and a full implementation is available in Chebfun [49] (www.chebfun.org).The author has also developed a periodic version of the AAA algorithm, called AAAtrig [50].The algorithm is built on the same principals as the original AAA algorithm, except the barycentric form ( 10) is replaced with its periodic analogue.
Let us return to the relevance of AAA to our compression problem.Suppose that we have computed a solution f of the form (4) to Laplace's equation satisfying some boundary conditions.If we evaluate f at a number of points on the boundary and run these points through the AAA/AAAtrig algorithm then we obtain a new function r that approximates f on the boundary.If r contains no poles in D, then r also solves Laplace's Equation (1).Moreover, AAA/AAAtrig usually selects an approximation that uses fewer poles than the original function and is, thus, faster to evaluate.Moreover, by the maximum value principle, |r − f | is maximised on the boundary, so the error in D is guaranteed to be no larger than the approximation error on the boundary.
We illustrate the effects of compression in Figure 2. The problem is uniform flow around a rectangle with a reentrant corner.The lightning solver uses 617 poles to achieve eight digits of accuracy.Figure 2c indicates that the algorithm attains root-exponential convergence.After a sample of the boundary points have been passed through AAA, we obtain a rational approximant using only 412 poles.Thus, the new approximant r is faster to evaluate than the original solution f .Note that AAA has chosen a slightly different set of poles with which to represent the function; we believe that this alternative choice of poles is responsible for the enhanced compression.The idea of compressing harmonic functions using AAA originated in [51].

Results and Discussion
Having outlined the mathematical preliminaries of the lightning solver, we now consider a number of fluid dynamics problems.

Potential Flows
The examples presented in the previous section were for simple uniform flows.The inclusion of more complicated flows follows in an analogous manner.Suppose that a given flow-which may consist of a background flow and a distribution of singularities in D-has a free-space solution g(z).Subsequently, we represent the complex potential as w(z) = f (z) + g(z).Thus, f (z) is the correction term that is induced by the boundaries and can be found using the methods of Section 2. In order for the boundary to be a streamline, we enforce the boundary condition For example, suppose that we wish to calculate the potential flow that is generated by a uniform flow of magnitude U at an angle α with a distribution of N vortices of circulations {Γ j } at locations {v j }.
The free-space solution for the complex potential is The lightning method presented in Section 2 can used to find a harmonic function that satisfies the boundary condition (11).In Figure 3, we visualise the flow past a curved boundary embedded in a uniform flow with two point vortices by plotting a set of streamlines and the horizontal velocity perturbation.
The method is also valid when the boundary is not a streamline.For example, when the boundary is rotating about the point c with angular velocity ω, (11) is replaced by

Periodic Domains
Potential flows through periodic domains arise in a number of practical scenarios including turbomachinery flows [32], super-hydrophobic surfaces [53], and geological flows [54].Recently, the author proposed a "calculus" for the analytical treatment of potential flows in general periodic domains with multiply connected period windows [28] thus extending the calculus of vortex dynamics proposed by Crowdy [27].The analytical solutions in that work were based on the Schottky-Klein prime function [29].The present lightning approach may be viewed as a complementary approach to those analytical solutions.
We now seek solutions of Laplace's equation that are periodic so that f (z) = f (z + 2πk) for k ∈ Z (solutions of different periods can easily be constructed by rescaling the domain).An analogous approach to that of Section 2 can be employed with the ansatz (4) replaced by The connection between the periodic ansatz ( 14) and the original ansatz ( 4) is clarified by noting the partial fraction expansion of cotangent: Thus, ( 14) is analogous to (4) when the poles in ( 4) are repeated with period 2π.Similarly to the non-periodic case, the coefficients {a j } and {b j } are found by solving the least-squares problem.
In Figure 4 we plot the streamlines and horizontal velocity perturbation for uniform flow at angle −π/4 past a periodic array of curved boundaries with embedded point vortices.The periodicity has a significant effect on the flow field and the vortices can be seen to deflect the flow angle.At present, this problem cannot be solved with conformal maps, because the form of the required (polycircular) maps has not yet been found.Indeed, the general form of periodic polygonal maps has only been found recently [55].Accordingly, the lightning approach provides a new method for tackling flows in periodic domains that were previously inaccessible.

The Kutta Condition
In the lightning ansatz (4), the circulation around ∂D is necessarily zero.It is possible to give ∂D arbitrary circulation Γ by replacing the ansatz (4) with and solving for {a j } and {b j } subject to the relevant boundary condition.However, in most applications, the circulation is not prescribed, but must be found as part of the problem.One method for selecting the circulation is to apply the Kutta condition [35,36].On ∂D, a corner ẑ is nominated as the downstream corner and the Kutta condition states that the fluid should leave ẑ smoothly.In our potential flow framework (for a stationary boundary), this is equivalent to specifying that the corner represents a stagnation point.In other words, the circulation must be such that the velocity vanishes at the nominated corner, i.e., where g is the free-space solution and the prime indicates differentiation with respect to z. Practically, enforcing the Kutta condition simply involves supplementing the least-squares problem (6) with an extra row corresponding to the vectorised form of (17).Note that only one extra row is required as (17) is already satisfied in one direction by the no-flux condition.
In Figure 5, we illustrate the effect of the Kutta condition by computing the uniform flow past a bullet-shaped object with and without the Kutta condition applied.Applying the Kutta condition to the bottom right corner drastically increases the flow velocity in the vicinity of the boundary.It can be seen that the flow departs the selected corner smoothly, thus indicating that the Kutta condition is indeed satisfied.

Vortex Dynamics
The transport of vortical structures is an important phenomenon in fluid mechanics and is relevant to flow control, turbulence modelling, vortex shedding, and flow separation.A point vortex may be used in order to represent a discretised quantity of vorticity as an approximation to more complicated structures [56].The dynamics of these point vortices-which has been described as "a classical mathematics playground" [57]-is another area that is amenable to these lightning methods.
The point vortex equation states that the velocity of a vortex is equal to the de-singularised velocity field at the vortex center [58].Mathematically, if z is the position of a vortex of circulation Γ, then the motion of the vortex is governed by where w is the complex potential and w is the complex velocity.In (18), the tilde indicates that the velocity field has been de-singularised, i.e., Accordingly, if we know the velocity field w when the vortex is at z then we can calculate the trajectory of the vortex.We could, in principle, use the lightning method of Section 3.1 to directly calculate w at each time step, but, since the vortices are moving, this approach would require solving a different Laplace problem at each time step, which would become prohibitively expensive.Nevertheless, we can still use the lightning framework to attack this problem.
Our approach is to use the lightning solver to conformally map the physical domain to a simple domain and then analytically construct w with the method of images.There are a number of techniques available that can be used to compute conformal mappings.The pre-eminent method is the Schwarz-Christoffel transformation [23,55,59] which provides analytical formulae for conformal maps to polygonal domains in terms of a number of accessory parameters that must generally be determined numerically.To circumvent this "parameter problem", an approach for numerically computing conformal maps was suggested in [60]; we briefly review the approach here.
In the simply connected case, the natural domain to map into is the interior of the unit disc.We denote the unit disc coordinate as ζ and the conformal map f , so that z = f (ζ). Figure 6 illustrates an example of a mapping.The inverse map (from the physical domain to the circular domain) is written as f −1 , so that ζ = f −1 (z).To compute the mappings we express the inverse map as for analytic h.Taking the logarithm of both sides and evaluating on the boundary yields where we have used the fact that the boundary ∂D z maps to |ζ| = 1.Note that the logarithm on the left side is pure imaginary since we are evaluating it on the unit circle.This imaginary function is unknown as we do not know the image of each boundary point a priori; we only know that the boundary is mapped to the unit circle.Accordingly, to determine f −1 , we must find an analytic function who's real part satisfies (21).In other words, we want to solve the Laplace problem Re[h(z)] = log(|z|), for z ∈ ∂D z , ( 23) The last equation specifies a degree of freedom in the map and simplifies some of the ensuing formulae.This type of Laplace problem is amenable to the method that is presented in Section 2: we consider an ansatz in the form of a rational function ( 4) with poles clustered near the corners and then solve for the coefficients in the least-squares sense by collocating ( 23) on the boundary.Given h, we obtain f −1 by ( 20).Now, we may compute the forward mapping f using the approach of [51].By sampling f −1 (z) at a number of points on the boundary z ∈ ∂D z , we are equipped with a set of sample points {z j } and a set of function values {ζ j } where ζ j = f −1 (z j ).Subsequently we construct an approximant with the AAA algorithm using {z j } as function values and {ζ j } as sample points.Thus, provided a rich enough sample set is selected, the approximant produced by AAA maps the boundary ∂D ζ to ∂D z ; in other words, the new approximant computed by AAA approximates the forward mapping f .Moreover, by the maximum value principle, the accuracy of the approximation to the conformal map is bounded by the error on the boundary.Accordingly, we are now free to accurately and quickly map between the circular and physical domains using f and f −1 .
Armed with these numerical representations of the mappings, we now transform the point vortex Equation ( 18) into the circular domain D ζ .Carefully applying L'Hôpital's rule to (18) where W(ζ) = w(z) is the complex potential in D ζ and W (ζ) is the de-singularised velocity field in D ζ : The advantage of our approach is that the complex potential in the ζ-plane can be constructed analytically.For example, the complex potential that is induced by an arrangement of N vortices of strengths {Γ j |j = 1, . . ., N} located at positions {ζ j |j = 1, . . ., N} embedded in a background uniform flow of strength U at angle of attack α is given by where a = e h(∞) is the residue of the simple pole of the map.In this case, the de-singularised velocity Substituting (28) into the transformed point vortex equation (25) results in an autonomous dynamical system that can be integrated with standard numerical techniques such as the Euler method or Runge-Kutta methods.In Figure 7, the resulting trajectories are plotted for 30 vortices outside a curved domain.The vortices have strengths that are randomly distributed in the interval [−1, 1] and there is no background flow.A number of vortices are shot out to infinity, but a distinct structure emerges that traces out the boundary ∂D z .This model could be used as, for example, an approximation for the motion of oceanic eddies [17] around a boundary.Alternatively, on use of the Blasius theorem, this model could provide estimates for the forces exerted on ∂D z due to the transport of vorticity.The sound produced by such interactions could be also analysed with the vortex sound model of Howe [61].This approach also applies to multiply connected domains-the analogous complex potential ( 27) can be constructed in a multiply connected circular domain using the formulae of Crowdy [26,27].Additionally, this conformal mapping method can be applied to Kirchhoff-Routh theory to study the Hamiltonian dynamics of point vortices [58,62].Again, analytic formulae for the multiply connected Kirchhoff-Routh path function are readily available [31].A further consideration is that, in reality, a number of vortices will be shed from the sharp corners of the domain.The trajectories of these shed vortices could be modelled using the Brown-Michael equation [15] or the other approaches discussed in the introduction.

Free-Streamline Flows
Incompressible flow past a bluff body usually results in flow separation.This separation can generate a downstream wake or a cavity flow and can have a significant effect on estimates of the drag and lift coefficients.Free-streamline theory attempts to reconcile the physical reality of flow separation with the mathematical tractability of potential flows.In these problems, the boundaries of the domain are not known a priori-the boundary incorporates a "free streamline" whose shape must be found as part of the problem.Thus, we cannot use a direct conformal mapping approach as in Section 3.4.The typical approach for solving these problems is to construct mappings between auxiliary domains and then find the shape of the streamlines by considering the relationships between the auxiliary domains.Previous authors have presented numerical conformal mapping approaches in order to solve these problems [22,63,64]; we now demonstrate that the lightning approach can be leveraged in order to solve free-streamline problems.We consider a rigid body immersed in a separated flow that is uniform in the far-field.The goal is to calculate the velocity field induced by the boundary and the shape of the separation region behind the body.As before, we define the complex potential as w(z) = φ(z) + iψ(z) and the complex velocity as w (z) = u(z) − iv(z).In this situation, enforcing the Kutta condition specifies that the flow detaches from the solid body at the edges.We assume that the fluid inside the separation region is stagnant and it is therefore of constant pressure.The free streamlines are the curves that divide the moving fluid from the stagnant fluid; therefore, they represent an infinitesimal shear layer.Because there can be no pressure jump either side of shear layer, the pressure along the free streamline must be constant.Accordingly, Bernoulli's theorem implies that (subject to a suitable scaling) the speed of fluid along the boundary of the wake is unity: Furthermore, the no-flux condition specifies that, on the surface of the solid body, the fluid velocity must be tangent to the boundary: where s is the arc length of the boundary.
The streamfunction is piecewise constant on both the rigid boundary and the free streamlines.We say 'piecewise constant' here, because there may be multiple free streamlines that correspond to different values of the streamfunction.Since both w and w are analytic functions in simply connected domains, and assuming that they have a 1-to-1 relation, there exists a conformal map f between them: We can now connect the physical coordinate z to the complex potential w and complex velocity w by The above maps a complex velocity value (w ) to a physical coordinate (z).Thus, if f can be determined, then we know z and the corresponding velocity value there.The boundary conditions on f follow from ( 29) and ( 30), as The precise constants that Im[ f ] attains on the boundaries are application dependent.The problem of finding an analytic function f subject to the boundary conditions ( 33) may be solved using the lightning method introduced in Section 2. The lightning method is very appropriate to this problem, because the w domain typically contains corners even though the physical z domain does not.While conventional methods struggle to resolve the singularities at the corners, the lightning method achieves root-exponential convergence.
In Figure 8, we illustrate the procedure for the separated flow past a flat plate.The incoming flow is inclined at an angle of −π/8.Along the free streamline, the velocity has magnitude 1 and along the plate the flow has zero normal velocity.Accordingly, the flow domain in the w domain is a semicircle.We use the lightning method to compute the mapping from the complex velocity (w ) domain to the complex potential domain (w), such that the semicircle is a streamline and the point w = e −iπ/8 maps to infinity.Poles are clustered exponentially close to the corners of the semicircle in order to exploit the root-exponential convergence afforded by rational function approximation.In the complex potential domain, the boundaries are the upper and lower parts of the positive real axis.Having computed f , we may then use (32) to establish the relationship between the velocity and the spatial position z, which is plotted at the bottom of Figure 8.This problem can actually be solved analytically by appropriately placing image doublets in the w domain, but the example is included here in order to illustrate the applicability of the lightning solver to free-streamline flows.
There are several methods available for improving the physical fidelity of free-streamline theory, the most conspicuous of which is the approach of Wu [21].By allowing the pressure on the free streamline to increase monotonically, Wu [21] ensures that the free streamlines become asymptotically parallel to the background flow at infinity.This yields favourable comparisons for the lift and drag coefficients against experimental results.The simple example that we have presented does not allow the pressure on the free streamline to vary, but this effect could be incorporated to improve the realism of the model.
o 4 l 4 z 8 q h L m u R P 0 i 9 B M 9 S 6 3 / A 0 m 0 A L W V 9 / n d 7 d b m t m 7 v j r P j t t K G 7 7 R 2 N j c 2 l 3 2 + 3 2 q 6 W 0 3 n t F V / 0 S k 6 f s 3 6 z v r e + s F y r R 3 r h X V g n V g 9 y 7 e 4 9 a f 1 l / V 3 7 d f a u 9 p v t d 9 z 9 P 6 9 I u Z b y 7 h q f / w H z Z l G / Q = = < / l a t e x i t > |w 0 | = 1 < l a t e x i t s h a 1 _ b a s e 6 4 = " a Y j d 4 U w f u H + f R g e B q 7 / u e P e 5 8 N Y

Conclusions
In this paper we have presented a new method for numerically solving potential flow problems.Our method is based on the lightning method introduced by Gopal and Trefethen [6,7], and exploits the approximation power of rational functions.We believe that the technique will be useful to researchers in fluid mechanics who wish to quickly compute solutions to potential flows with modest accuracy in domains that prohibit fully analytical solutions and traditional numerical methods.The technique is comparatively simple and does not require specialised knowledge of finite element methods or boundary element methods.We have demonstrated that the method is valuable for several physical problems, including steady potential flows, unsteady vortex dynamics, and free streamline flows.Periodic domains are not an issue and are handled with a slightly different ansatz.The solutions converge extremely fast (with root-exponential convergence) and are themselves very fast to evaluate.When the solution is to be evaluated a large number of times, such as in the vortex dynamics simulations presented in Section 3.4, the solutions can be compressed using the AAA or AAAtrig algorithms.

Figure 1 .
Figure 1.Incompressible, irrotational (i.e., potential) flow past a square circular sector removed.The problem takes 0.5 s to solve to six digits of accuracy and 5 s for eight digits.In (a) the black dots represent the poles.The background colour in (a) represents the horizontal velocity of the perturbation to the flow from uniformity.Note that in (b) the y-axis is on a log scale whereas the x-axis is √ N, so that a straight line indicates root-exponential convergence.

Figure 2 .
Figure 2.An example of AAA compression for the flow past a rectangle with a reentrant corner.The black dots in (a) and (b) indicate the poles used to represent the full and compressed solutions respectively.

Figure 3 .
Figure 3. Uniform flow past the polycircular domain from [52] with embedded point vortices.The lines are the streamlines and background color is the horizontal perturbation velocity.The black dots represent the prescribed poles of the rational function.The solution converges to five digits of accuracy in 0.8 s and 8 digits in 6 s.

Figure 4 .
Figure 4. Uniform flow past a periodic array of boundaries with embedded point vortices.The black dots represent the prescribed poles of the rational function.The solution converges to 9 digits of accuracy in 0.8 s.

Figure 5 .
Figure 5.An illustration of the effects of the Kutta condition on the flow past a bullet-shaped object.The solutions are computed to 6 digits of accuracy; in (a) the solver takes 0.3 s and in (b) the solver takes 0.8 s.The color scale is the same in both figures.

Figure 6 .
Figure 6.An example of a conformal map computed using the method of [60].The red dots indicate the poles of the map and their size is proportional to their residue.

Figure 7 .
Figure 7.The trajectories of 30 vortices computed with the lightning method.The circulations of the vortices are randomly distributed in the interval [−1, 1].The initial positions of the vortices are equispaced on a circle, as indicated by the coloured dots.The background flow is set to U = 0.
separation region < l a t e x i t s h a 1 _ b a s e 6 4 = " 9 W b A 6 3 P D p S j g D i c e L f y s d j r i O u 0 y a U j p U g K z j / / k d 8 p A 6 4 v H i k A j p O P / e u / / J g 0 8 / e 1 h 7 t P b 5 F 1 9 + 9 f X j J 9 / 0 B Z t y H 3 o + C x k f e F h A S C L o S S J D G M Q c M P V C O P e u u 6 n / / A a 4 I C w 6 k / M Y h h S P I z I i P p Z a u m y 8 v b 1 E M S c U 3 u 6 5 j a v H d a f Z 3 n C d X d d 2 m j v t L d d 1 t N F u t 7 e d L d t t O t l V t 4 r r 5 O r J w 3 9 Q w P w p h U j 6 I R b i w n V i O V S Y S + K H k K y h q Y A Y + 9 d 4 D B f a j D A F M V R Z 2 o m 9 r p X A H j G u 7 0 j a m b o a o T A V Y k 4 9 T V I s J 6 L s S 8 W 7 f B d T O d o d K h L F U w m R n 0 8 0 m o a 2 Z H a 6 B 3 Z A O P g y n G s D + 5 z o X G 1 / g j n 2 p d 4 p Y 5 Z Z n q q h p f N J x k K h 5 Q B G C B S S M J O c K k g K i S w l s p C C p R Q s p W M W w I n W J y D x V X T 5 0 6 p + / F 5 / X u j 7 g o w V S q f 3 c a j 2 k 6 u o c H Q M R + e 9 o 2 s 4 u p k j 9 w x I J O t u 4 Z s w 4 s O a b d s K D 9 I o y W o r b z P 7 + + 2 t n d 1 e 3 e c P b e V N n y n t b e 9 t b 3 q 8 5 F R U M w 1 0 4 p k R 6 c 6 J a C r A 9 0 S Q G / Z F 3 r r v j g 6 5 Z S A D z r w o Q R M d G B S A m 5 0 4 K Y E z H R g V g K O d e A 4 T g 4 e j U h P t 8 K C M 6 0 4 1 sU t 5 E V O 6 m h I W R B f 2 X 2 J f B g K 5 H e B q e M A M T I a C 8 S S f 8 W x L / V x L 8 t 1 p Q M n J e B I B 4 4 S g M E q c h z E W T E 6 j t q I R R s I k u w 3 k X 5 O a I 3 G Y f g a k o x / B d V c G Z y q I d 5 F w L C g 7 G e J M F O V q F 6 E e q K X i f V / I A k X o L K y P r + / 2 9 j e V e 3 d s v b s R t L w r c b e 9 t b 2 s s 9 3 G 3 V 7 p 2 6 d N 6 q v W 3 n H r x h P j W f G c 8 M 2 9 o z X x p F x Z n Q M 1 5 g a f x l / G / 9 U B p X f K 3 9 U / s z Q u 3 f y m C e G d l U + / g f n / 0 e R < / l a t e x i t > w = f (w 0 ) < l a t e x i t s h a 1 _ b a s e 6 4 = " M V Q Y T c 7 C V m v M J O q e R N q o J e h b F q s = " > A A A K P X i c j Z Z b b 9 s 2 F M f V 7 h Z n t 3 R 7 3 M O 0 O Q W 6 r T U k 5 2 p g A W p 7 K x I g a Z M u d g y Y j k d J t E 1 E t 1 L 0 b Q Q / 0 j 7D H v a y r 7 A P s L e h r x 2 w l x 1 J l m N K b l c B t o 7 + 5 3 f I w y O S o h W 6 N O K G 8 e e d u + + 8 + 9 7 7 H 2 y U N j / 8 6 O N P P t 2 6 9 1 k 7 C s b M J i 0 7 c A P W s X B E X O q T F q f c J Z 2 Q E e x Z L r m y b p q x / 2 p C W E Q D / 5 L P Q 9 L z 8 N C n A 2 p j D l J / y 0 K c z H j S j r B c b N 9 I 8 Y t + p C P q 8 2 s x v U Y h o x 6 R O h o w b A v k 6 F O Z / P f N N a 5 b U a z Y s r 9 V N i q 1 H d M 4 N H W j c l D b M 0 0 D j F q t t m / s 6 W b F S K 7 y 4 / r 3 v / 7 8 5 b / H 5 / 1 7 G 7 8 j J 7 D H H v G 5 7 e I o 6 p p G y H s C M 0 5 t l 8 h N N I 5 I C L n i I e m C 6 W O P R D 2 R D E L q 9 0 F x 9 E H A 4 O d z P V F X I w T 2 o m j u W U B 6 m I

1 <
8 w J w p g J n B c B S A a s A v F C B F 3 m A M 9 k 1 e 2 m F Y U e 7 Z B K 5 Z M A f l E 3 E 6 H D E v 8 n x Z B b C h p t 8 y J L A N N K y x I 8 y j e x m k b 1 c 5 A S r X b U x + 5 8 I O 5 g oE U 1 4 f n O E N V a H O y 7 U Y 6 I C k w I w U 4 F Z A T h R g R M Z b 8 Q K k e z 2 u Q m Q a v m 2 L t e Q l w t S R f 2 A e W k x 4 g I g t 0 0 Y z 6 q A W P y U b / t K b f e q u M 5 U 4 L Q A H K v A c Q w w s o q c e H I 5 A U 5 k 9 l n 0 k u z V b V P 5 7 l o M 3 5 A 4 4 R 8 I n D U Y O Y M W n o W E Y R 6 w b w X C D B Y m v A e 4 o 4 e x 9 S a Q + h k I V n r s O d y v 7 u 7 D a c c w D s x q f P 4 x q g e 7 O 7 v L Y 0 + 7 W j H 3 K s Y F n H 8 a W n p t a F 9 o X 2 s P N F M 7 0 B 5 r x 9 q 5 1 t J s 7 Q / t p f Z K + 6 f 0 W + m v 0 t + l l y l 6 9 8 4 i 5 n N N u U q v / g P O D 9 q C < / l a t e x i t > l a t e x i t s h a 1 _ b a s e 6 4 = " W V 6 7 C e k 6 N u z N L v U 6 1 Q h 9 0 J R T j W k = " > A A A I 4 3 i c j Z X N b t t G E M e Z p G 1 U 9 y N O c + i h F 7 a S g a J N B F L + 1 M F A L B W B D d i J j V q y A K 8 q L M m R t D D J Z X Z X t o Q F n6 C 3 o t e e e m 1 v f Z m + T X d J S t G S T h E C k k b / + c 3 u 7 H D I 8 Z K Q c O E 4 / z 5 4 + O i j j z 9 5 X P t 0 4 7 P P v / j y y e b T r / q c z p g P P Z+ G l A 0 8 z C E k M f Q E E S E M E g Y 4 8 k K 4 8 m 6 6 2 n 9 1 C 4 w T G l + K R Q L D C E 9 i M i Y + F k o a b X 6 N s j V k t L i b E g F p A y W c H D q N 0 W b d a b a 3 X e f A t Z 3 m f n v X d R 1 l t N v t P W f X d p t O d t W t 4 j o f P X 3 8 D w q o P 4 s g F n 6 I O b 9 2 n U Q M J W a C + C G k G 2 j G I c H + D Z 7 A t T J j H A E f y m z 3 1 N 5 S S m C P K V O f W N i Z u h 4 h c c T 5 I v I U G W E x 5 W W f F u / z X c / E + G A o S Z z M B M R + v t F 4 F t q C 2 r o c d k A Y + C J c K A P 7 j K h c b X + K G f a F K p q x y z x P 1 d D 0 f o L S k C s 5 g D E C i Q T M B Y s k p I V E V h J Z S s F K C l b S G Q 3 g X O l T EH g U / / L j u n 7 2 T n 9 R 6 E e c T C T S 2 / s 4 l E f p K C 4 c H c P R e e f o G o 5 u 5 s g 9 A x K L u l v 4 p p T 4 s G H b t k Q D 7 U A B 4 U m I F 1 w s Q s j S z i x Z d 9 N 0 a 5 1 b u R B X d U z e h 6 0 5 l / Y H 4 B 8 W h L 5 F K q Y 4 7 y A / V r 1 V 3 5 Y S c R A e n T u H a K p + Z E M d V z t S m Q U 0 U h 2 t 4 m 9 9 1 b z A 5 J J S S C N N 0 Q 2 w + E V z F 9 0 F z u p + B Z h P V a z M q n e 4 V N f F 4 l a p 5 9 J 8 w i S b e K l U T 9 J z e / m l y B j u f B p F O F b 5 9 r 6 P 5 D E S 1 B Z + Z w / 2 G v t 7 K n x 7 j j 7 b k s P f K e 1 v 7 O 9 s 5 r z / V b T 3 W 0 6 F 6 3 6 y 0 4 x 8 W v W N 9 Z 3 1 v e W a + 1 b L 6 1 j 6 9 z q W b 6 V W n 9 a f 1 l / 1 6 D 2 a + 2 3 2 u 8 5 + v B B E f P M M q 7 a H / 8 B V N R L Y w = = < / l a t e x i t > = 0 < l a t e x i t s h a 1 _ b a s e 6 4 = " B J o e x 8 K c w O 7 T 3 X 3 r E P N c C 8 b l Z D Y = " > A A A I 3 H i c j Z V L b 9 s 4 E M f V d n f r Z h 9 N u 8 e 9 q L U D F N v G k J y n D w U a u y g S I G k T N H Y M h I 5 B S W O b i C S q J O 3 Y I H T b 2 2 K v P f W 6 + w n 2 y + y 3 W e p h 1 5 T S o g J k j f / z G 3 J I j T h O 5 B M u L O u / O 3 f v f f f 9 D / c r D 9 Z + / O n n X x 6 u P 3 r c 5 X T C X O i 4 1 K e s 5 2 A O P g m h I 4 j w o R c x w I H j w 4 V z 3 U 7 8 F 1 N g n N D w X M w j 6 A d 4 F J I h c b F Q 0 m B 9 v X Z z h S J G A q h t R j 4 O Y b B e t e r N L d v a t 0 2 r v t f c s W 1 L G c 1 m c 9 f a M e 2 6 l V 5 V I 7 9 O B 4 / u / 4 s 8 6 k 4 C C I X r Y 8 4 v b S s S f Y m Z I K 4 P 8 R q a c I i w e 4 1 H c r e 2 l 3 2 + 2 6 j b O 3 X r r F F 9 1 c o 7 f s X 4 z X h q P D N s Y 8 9 4 Z R w a p 0 b H c I 2 p 8 c n 4 2 / i n c l X 5 o / J n 5 a 8 M v X s n j / n V 0 K 7 K x / 8 B i e Z I G Q = = < / l a t e x i t > w 0 -plane < l a t e x i t s h a 1 _ b a s e 6 4 = " 4 4 C U y H f Y W N t x X W 7 A G e m r U + E F f e o = " > A A A I 0

Figure 8 .
Figure 8.The separated flow past a flat plate at angle of attack −π/8.The lines are the streamlines and the colour represents the vertical velocity component.

: A domain boundary ∂D, boundary data d(z) and a tolerance Output: A function handle f that is harmonic and satisfies the boundary conditions. begin Identify the m corners of the boundary and define the interior point z * for n increasing (with √ n approximately evenly spaced) do 1
(5) n 1 = O(mn) poles {z j } clustered inside the corners according to(5)