Download explore/PhaseLatch/scripts/plot_latest_fluid_comparison.py from Travor278/RheoBench: direct link, hf CLI and curl.
- Browser
- Download file 2.61 kB
-
https://huggingface.co/datasets/Travor278/RheoBench/resolve/main/explore/PhaseLatch/scripts/plot_latest_fluid_comparison.py
- Command line
-
hf download hf://datasets/Travor278/RheoBench/explore/PhaseLatch/scripts/plot_latest_fluid_comparison.py
-
curl -L -o plot_latest_fluid_comparison.py https://huggingface.co/datasets/Travor278/RheoBench/resolve/main/explore/PhaseLatch/scripts/plot_latest_fluid_comparison.py
2.61 kB
| """Compare measured single-cup responses; keep solver qualifications separate.""" | |
| import json | |
| from pathlib import Path | |
| import numpy as np | |
| import matplotlib | |
| matplotlib.use('Agg') | |
| import matplotlib.pyplot as plt | |
| from analyze_liquid_calibration import slosh_fit | |
| ROOT=Path(__file__).resolve().parents[1] | |
| cases=[('Newton MPM / 2 mm','liquid_calibration_20261005/Q1d_unilateral_fine2mm','#2e718f'), | |
| ('Newton WCSPH / 2 mm','native_sph_reference_20261006/weak_fine2mm','#c57630'), | |
| ('SPlisHSPlasH DFSPH / 3 mm','liquid_calibration_20261005/dfsph_weak_clearance','#698747')] | |
| fig,axes=plt.subplots(1,3,figsize=(14.5,4.2),layout='constrained');summary=[] | |
| for label,path,color in cases: | |
| folder=ROOT/'results'/path;report=json.loads((folder/'report.json').read_text());rows=json.loads((folder/'trajectory.json').read_text()) | |
| fit=slosh_fit(rows,report);t=np.array([r['time'] for r in rows]);release=report['args']['settle']+report['args']['motion_time'] | |
| mask=t>=release | |
| axes[0].plot(t[mask]-release,[1000*r['fluid_com_local'][0] for r,m in zip(rows,mask) if m],color=color, | |
| label=f"{label}\nf={fit['fit_frequency_hz']:.3f} Hz; decay={fit['decay_rate_per_s']:.2f}/s",lw=1.7) | |
| axes[1].plot(t,[r['height_ratio'] for r in rows],color=color,lw=1.7) | |
| axes[2].plot(t,[r['center_height_ratio'] for r in rows],color=color,lw=1.7) | |
| summary.append({'label':label,'source':str(folder),'slosh':fit,'final_height_ratio':rows[-1]['height_ratio'], | |
| 'final_center_ratio':rows[-1]['center_height_ratio'],'escaped_fraction':rows[-1]['escape_fraction']}) | |
| axes[0].set(xlabel='Time after pulse (s)',ylabel='Fluid COM relative to cup (mm)',title='Free response',xlim=(0,2));axes[0].legend(fontsize=8) | |
| for ax,title,key in zip(axes[1:],('Liquid height','Vertical center of mass'),('Height / mass-implied height','COM height / uniform-column COM')): | |
| ax.axhspan(.95,1.05,color='#487f65',alpha=.10);ax.axhline(1,color='#75818b',lw=.8,ls=':') | |
| ax.set(xlabel='Simulation time (s)',ylabel=key,title=title,xlim=(0,3.15),ylim=(.9,1.2)) | |
| for ax in axes:ax.grid(alpha=.18);ax.spines[['right','top']].set_visible(False) | |
| fig.suptitle('Same cup and mass; independent numerical configurations',fontsize=14) | |
| fig.supxlabel('WCSPH startup escape: 0.00082%. DFSPH uses initial wall clearance. Single-cup evidence does not certify a full robot episode.',fontsize=9) | |
| out=ROOT/'results/studio_demos_verified_20261005' | |
| fig.savefig(out/'latest_fluid_comparison.png',dpi=180);fig.savefig(out/'latest_fluid_comparison.pdf') | |
| (out/'latest_fluid_comparison.json').write_text(json.dumps(summary,indent=2)) | |