Skip to content

Commit

Permalink
feat: init the NS post.
Browse files Browse the repository at this point in the history
  • Loading branch information
Panadestein committed Jan 24, 2025
1 parent 358045a commit 260e3f3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 24 deletions.
5 changes: 5 additions & 0 deletions src/bqn/ns.bqn
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cn ← {
_p ⇐ {(-´𝔽¨)(+´𝔽¨)}
Cis ⇐ (•math.Cos≍•math.Sin)¯π×↕÷
}
FFT ← {𝕊: -´˘{≠÷˜·𝔽𝔾𝔽}𝕊𝕩; (1=≠)⟨(+∾-)(⊢×cn._p˘cn.Cis)´(𝕊¨⊢⊔˜2|⊒˜), 𝕩}
1 change: 1 addition & 0 deletions src/index.org
Original file line number Diff line number Diff line change
Expand Up @@ -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: </div>
24 changes: 0 additions & 24 deletions src/nm.org

This file was deleted.

44 changes: 44 additions & 0 deletions src/ns.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- eval: (face-remap-add-relative 'default '(:family "BQN386 Unicode" :height 180)); -*-
#+TITLE: Navier-Stokes simulator (WIP)
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="assets/style.css"/>
#+HTML_HEAD: <link rel="icon" href="assets/favicon.ico" type="image/x-icon">
#+HTML_HEAD: <style>
#+HTML_HEAD: mjx-container[jax="CHTML"] {
#+HTML_HEAD: overflow-x: auto !important;
#+HTML_HEAD: }
#+HTML_HEAD: </style>

** 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
<div style="text-align: center; font-size: 2em; padding: 20px 0;">
<a href="https://panadestein.github.io/blog/" style="text-decoration: none;">⊑∘∞</a>
</div>
#+END_EXPORT

0 comments on commit 260e3f3

Please sign in to comment.