|
|
|
|
|
import dragon |
|
|
import dragon.rpc as rpc |
|
|
import numpy as np |
|
|
from scipy.fft import fft2 |
|
|
PHI_43 = 22.93606797749979 |
|
|
|
|
|
|
|
|
dragon.init(backend='mpi') |
|
|
world = rpc.new_world_group() |
|
|
rank = world.rank |
|
|
|
|
|
|
|
|
if rank == 0: |
|
|
grid = np.random.randn(512,512,512).astype(np.float32) |
|
|
grid /= PHI_43 |
|
|
world.bcast(grid) |
|
|
|
|
|
|
|
|
for step in range(10000): |
|
|
|
|
|
grid = dragon.navier_stokes_step(grid, dt=0.02) |
|
|
|
|
|
if step % 10 == 0: |
|
|
slice_2d = grid[rank*16:(rank+1)*16] |
|
|
fft_feats = fft2(slice_2d[:,:,0]) |
|
|
coherence = np.abs(fft_feats).mean() / PHI_43 |
|
|
|
|
|
|
|
|
global_coherence = world.allreduce(coherence, 'mean') |
|
|
if rank == 0 and global_coherence > 0.95: |
|
|
print(f"φ⁴³ coherence: {global_coherence:.6f}") |
|
|
|
|
|
dragon.finalize() |