diff --git a/src/bqn/ns.bqn b/src/bqn/ns.bqn new file mode 100644 index 0000000..6514ee4 --- /dev/null +++ b/src/bqn/ns.bqn @@ -0,0 +1,5 @@ +cn ← { + _p ⇐ {(-´𝔽¨)⋈(+´𝔽¨)⟜⌽} + Cis ⇐ (⍉•math.Cos≍•math.Sin)¯π×↕⊸÷ +} +FFT ← {𝕊⁼: ⋈⟜-´˘{≠÷˜·𝔽𝔾∘𝔽}𝕊𝕩; (1=≠)◶⟨(+∾-)⟜(⊢×cn._p˘cn.Cis∘≠)´(𝕊¨⊢⊔˜2|⊒˜), ⊢⟩𝕩} diff --git a/src/index.org b/src/index.org index f03b06c..6a62bec 100644 --- a/src/index.org +++ b/src/index.org @@ -36,5 +36,6 @@ 5. [[./si.org][Scheming a mise-en-abîme in BQN]] 6. [[./aoc24.org][Coding in Advent]] 7. [[./nn.org][The miniaturist's neural network]] +8. [[./ns.org][Navier-Stokes simulator]] #+HTML: diff --git a/src/nm.org b/src/nm.org deleted file mode 100644 index 3c1f134..0000000 --- a/src/nm.org +++ /dev/null @@ -1,24 +0,0 @@ -# -*- eval: (face-remap-add-relative 'default '(:family "BQN386 Unicode" :height 180)); -*- -#+TITLE: A numerical bonsai display -#+HTML_HEAD: -#+HTML_HEAD: - -** Foreword - -** Bibliography - -These are my favorite books on numerical analysis, in descending order of preference. -I use the first two very often, and consult the others to deepen my understanding: - -1. [[https://www.equalsharepress.com/][Numerical Methods for Scientific Computing: The Definitive Manual for Math Geeks]] -2. [[https://link.springer.com/book/10.1007/978-3-031-08121-7][Numerical Analysis: A Graduate Course]] -3. [[https://epubs.siam.org/doi/book/10.1137/1.9781421407944][Matrix computations]] -4. [[https://numerical.recipes/book.html][Numerical Recipes]] -5. [[https://epubs.siam.org/doi/10.1137/1.9781611976557][Numerical Linear Algebra with Julia]] -6. [[https://link.springer.com/book/10.1007/978-0-387-40065-5][Numerical Optimization]] - -#+BEGIN_EXPORT html -
- ⊑∘∞ -
-#+END_EXPORT diff --git a/src/ns.org b/src/ns.org new file mode 100644 index 0000000..37db5f7 --- /dev/null +++ b/src/ns.org @@ -0,0 +1,44 @@ +# -*- eval: (face-remap-add-relative 'default '(:family "BQN386 Unicode" :height 180)); -*- +#+TITLE: Navier-Stokes simulator (WIP) +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: + +** Foreword + +We want to solve the following [[https://en.wikipedia.org/wiki/Derivation_of_the_Navier%E2%80%93Stokes_equations][system]] of partial differential equations +in two dimensions for an incompressible fluid, imposing periodic boundary conditions: + +\begin{equation*} + \begin{aligned} + \nabla \cdot \mathbf{q} &= 0,\\ + \frac{\partial \mathbf{q}}{\partial t} + + \nabla \cdot (\mathbf{q} \otimes \mathbf{q}) &= + -\nabla p + \frac{1}{\text{Re}} \nabla^2 \mathbf{q}, + \end{aligned} +\end{equation*} + +** Simulator + +The numerical solution will be obtained using this zero-dependency BQN code: + +#+begin_src bqn :tangle bqn/ns.bqn :exports code + cn ← { + _p ⇐ {(-´𝔽¨)⋈(+´𝔽¨)⟜⌽} + Cis ⇐ (⍉•math.Cos≍•math.Sin)¯π×↕⊸÷ + } + FFT ← {𝕊⁼: ⋈⟜-´˘{≠÷˜·𝔽𝔾∘𝔽}𝕊𝕩; (1=≠)◶⟨(+∾-)⟜(⊢×cn._p˘cn.Cis∘≠)´(𝕊¨⊢⊔˜2|⊒˜), ⊢⟩𝕩} +#+end_src + +#+RESULTS: +: (function block) + +#+BEGIN_EXPORT html +
+ ⊑∘∞ +
+#+END_EXPORT