Files

59 lines
3.4 KiB
Diff

--- a/examples/fixed_patch_jet.py
+++ b/examples/fixed_patch_jet.py
@@ -8,6 +8,10 @@
Scale estimates use the continuous peak A=.02, not inlet mean speed: W/A=600,
H/A=2250, W**2/nu=1440, H**2/nu=20250, where H=NY-3=45 between on-site planes.
An acoustic crossing (~78 steps) does not imply that transients have disappeared.
+Mach is sampled over all leaves every 50 steps and is usually inlet dominated;
+the discrete inlet peak is slightly below continuous A. This is not an accuracy test.
+The 120s checks are cooperative, not an exact interruption deadline. main elapsed
+includes construction, advancement and plotting; it is not pure CFD timing.
"""
import argparse
from dataclasses import replace
@@ -87,7 +91,7 @@
ax.set_title('Native leaf grid: coarse dx=1, fine dx=0.5\n'
'Red: internal patch; orange: coarse slot; dashed: reservoir\n'
'Flow may cross patch sides; patch does not contain all startup flow', fontsize=10)
- fig.savefig(out/'layout.png', dpi=150)
+ fig.savefig(out/'layout.png', dpi=150, bbox_inches='tight', pad_inches=.15)
plt.close(fig)
vmax = max(1., *(np.nanmax(np.hypot(f[..., 1], f[..., 2]))/AMPLITUDE
for fields in snapshots for f in fields))
@@ -130,7 +134,8 @@
report = dict(config=dict(nx=48, ny=48, bounds=BOUNDS, W=WIDTH, A=AMPLITUDE, nu=.1,
rho=1, tau_coarse=.8, tau_fine=1.1, coarse_boundary='slot_reservoir'),
guards=dict(check_every=50, positive_density=True, finite=True,
- max_Mach=MAX_MACH, max_seconds=MAX_SECONDS),
+ max_Mach=MAX_MACH, max_seconds=MAX_SECONDS,
+ timing='cooperative checks, not an exact interruption deadline'),
scale_estimates=dict(velocity_basis='continuous peak A, not inlet mean', H=cfg.ny-3,
W_over_A=WIDTH/AMPLITUDE, H_over_A=(cfg.ny-3)/AMPLITUDE,
W_squared_over_nu=WIDTH**2/cfg.viscosity,
@@ -168,6 +173,8 @@
if step:
run.step(50)
report['last_synchronized_coarse_step'] = run.step_count
+ if time.monotonic()-start > MAX_SECONDS:
+ raise TimeoutError('120 second demonstration limit reached after chunk')
fields, sample = measure(run.download(), masks, centers, mass0)
sample.update(t=step, coarse_steps=step, fine_steps=2*step)
report['samples'].append(sample)
@@ -177,6 +184,8 @@
with tempfile.TemporaryDirectory(prefix='.plot-', dir=out) as cache:
os.environ['MPLCONFIGDIR'] = cache
draw(out, snapshots, masks, centers)
+ if time.monotonic()-start > MAX_SECONDS:
+ raise TimeoutError('120 second demonstration limit reached after plotting')
report['status'] = 'complete'
except BaseException as exc:
report.update(status='failed', error=f'{type(exc).__name__}: {exc}',
@@ -184,6 +193,7 @@
raise
finally:
report['elapsed_seconds'] = time.monotonic()-start
+ report['elapsed_scope'] = 'main construction, advancement and plotting; not pure CFD time'
(out/'summary.json').write_text(json.dumps(report, indent=2)+'\n')
print(f'{report["status"]}: last synchronized coarse step '
f'{report["last_synchronized_coarse_step"]}; output={out}', flush=True)