File size: 1,767 Bytes
d513eb2 | 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 | """Compare archived free responses and geometry diagnostics without rescaling."""
import json
from pathlib import Path
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
root=Path(__file__).resolve().parents[1]/'results/liquid_calibration_20261005'
cases=[('compact_weak','Newton Q1/Q1d, original'),
('compact_weak_no_tension','Newton Q1/Q1d, zero tensile yield'),
('B2_projected_weak','Newton B2/P0'),
('Q1d_unilateral_fine2mm','Newton Q1/Q1d, zero tensile, 2 mm'),
('physx_dt625','PhysX PBD, 0.625 ms')]
fig,ax=plt.subplots(1,2,figsize=(12.5,4.4),layout='constrained')
for case,label in cases:
report=json.loads((root/case/'report.json').read_text());rows=json.loads((root/case/'trajectory.json').read_text())
end=report['args']['settle']+report['args']['motion_time']
t=np.array([r['time'] for r in rows]);x=np.array([r['fluid_com_local'][0]*1000 for r in rows])
h=np.array([r['center_height_ratio'] for r in rows]);mask=t>=end
ax[0].plot(t[mask]-end,x[mask],label=label,lw=1.6)
ax[1].plot(t,h,label=label,lw=1.6)
ax[0].set(xlabel='Time after cup stops (s)',ylabel='Fluid COM relative to cup, x (mm)',title='Free response: same 5 mm cup displacement')
ax[1].axhspan(.95,1.05,color='#2a9d8f',alpha=.13,label='Provisional 5% geometry band')
ax[1].set(xlabel='Simulation time (s)',ylabel='COM height / uniform-column reference',title='Geometry drift must also pass')
for panel in ax:panel.grid(alpha=.16)
ax[1].legend(fontsize=8,loc='lower left')
fig.suptitle('Fluid candidates: compare free response and geometry together',fontsize=13)
fig.savefig(root/'candidate_comparison.png',dpi=180)
fig.savefig(root/'candidate_comparison.pdf')
print(root/'candidate_comparison.png')
|