-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnavier_stokes_1d.007
More file actions
34 lines (30 loc) · 1004 Bytes
/
Copy pathnavier_stokes_1d.007
File metadata and controls
34 lines (30 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- SPDX-License-Identifier: MPL-2.0
-- CONFIDENTIAL — EXPERIMENTAL — NOT FOR DISTRIBUTION
--
-- 1D Diffusion Equation (simplified Navier-Stokes)
--
-- du/dt = nu * d²u/dx²
--
-- Discretized with forward Euler + central differences:
-- u(i,n+1) = u(i,n) + nu * dt/dx² * (u(i+1,n) - 2*u(i,n) + u(i-1,n))
--
-- This tests: float arithmetic, list operations, pure functions,
-- iterative computation through function composition.
-- Physical parameters
@total data nu = 0.1
@total data dx = 0.1
@total data dt = 0.001
@total data diffusion_coeff = nu * dt / (dx * dx)
-- Initial condition: step function (1.0 for first half, 0.0 for second)
@total data initial = [1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]
-- The diffusion coefficient determines stability:
-- For stability, nu * dt / dx² < 0.5
@total data stability_check = diffusion_coeff
-- Compute result
@total data result = {
nu: nu,
dx: dx,
dt: dt,
diffusion_coeff: diffusion_coeff,
stable: diffusion_coeff
}