PureOne's picture
Release UPMV 1.0.1: standalone research, data and code
860030d verified
Raw
History Blame Contribute Delete
5 kB
from pathlib import Path
import csv, math
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
ROOT=Path(__file__).resolve().parents[1];OUT=ROOT/'figures';OUT.mkdir(exist_ok=True)
plt.rcParams.update({'font.size':10,'axes.spines.top':False,'axes.spines.right':False,'font.family':'DejaVu Sans','figure.dpi':160})
colors=['#9299a5','#475b75','#d29539','#8761a9','#168b8c','#bd4b56']
modes=['random','coded','hierarchical','proofreading','proofreading_hierarchy','locking']
labels=['Random','Coded','Hierarchy','Proofreading','Proofreading + hierarchy','Plus locking']
def read(name):return list(csv.DictReader((ROOT/'results'/name).open()))
r=read('baseline.csv')
fig,ax=plt.subplots(2,2,figsize=(9,6.8),constrained_layout=True)
for mode,col,lab in zip(modes,colors,labels):
s=[x for x in r if x['mode']==mode];n=[int(x['N']) for x in s]
for a,key in zip(ax.flat,['correct_fraction','wrong_fraction','missing_fraction','log10_perfect_yield']):
y=[float(x[key]) for x in s]
if key=='log10_perfect_yield':y=[max(-100,v) for v in y]
a.plot(n,y,'o-',color=col,label=lab,markersize=3)
for a,title in zip(ax.flat,['Correct join fraction','Wrong join fraction','Missing join fraction','log10 perfect yield (clipped at -100)']):
a.set_xscale('log');a.set_xlabel('Number of carriers N');a.set_title(title,loc='left',fontweight='bold',fontsize=10);a.grid(alpha=.2)
for a in [ax[0,0],ax[0,1],ax[1,0]]:a.set_ylim(-.025,1.025)
ax[1,1].set_ylim(-103,3)
fig.legend(*ax[0,0].get_legend_handles_labels(),loc='outside lower center',ncol=3,fontsize=9)
fig.suptitle('Local-socket model | fixed solids, 20,000 s deadline',fontsize=13,fontweight='bold')
fig.savefig(OUT/'kinetics.png',dpi=220);fig.savefig(OUT/'kinetics.pdf');plt.close(fig)
fig,ax=plt.subplots(2,2,figsize=(9,6.5),constrained_layout=True)
sweep=read('sweep.csv')
for alpha,col,lab in [(0.,'#168b8c','Module concentration restored'),(1.,'#bd4b56','Fixed primary-material concentration')]:
ss=[x for x in sweep if x['mode']=='locking' and float(x['gap_kbt'])==6. and float(x['progress_rate'])==.1 and float(x['dilution_exponent'])==alpha]
ax[0,0].semilogx([float(x['N']) for x in ss],[float(x['correct_fraction']) for x in ss],'o-',label=lab,color=col)
ax[0,0].set_title('Transport policy changes the result',loc='left',fontweight='bold',fontsize=10);ax[0,0].set_ylabel('Correct fraction');ax[0,0].set_xlabel('Carriers N');ax[0,0].legend(fontsize=7)
n=np.logspace(2,18,300)
for eta,c in zip([1e-4,1e-8,1e-14],['#d29539','#168b8c','#475b75']):
y=np.exp(np.maximum(-750,n*np.log1p(-eta)))
ax[0,1].semilogx(n,y,label=f'Late fault = {eta:g}',color=c)
ax[0,1].set_title('An uncorrected final process limits perfection',loc='left',fontweight='bold',fontsize=9);ax[0,1].set_ylabel('Perfect probability');ax[0,1].set_xlabel('Essential sites N');ax[0,1].legend(fontsize=8)
for eta,c in zip([0.,1e-8,1e-5,1e-3],['#475b75','#168b8c','#d29539','#bd4b56']):
p=.01;ys=[p]
for _ in range(5):p=min(1,28*p*p+eta);ys.append(p)
ax[1,0].semilogy(range(6),ys,'o-',label=f'Floor {eta:g}',color=c)
ax[1,0].set_ylim(1e-21,.1);ax[1,0].set_title('Conditional threshold recurrence, C = 28',loc='left',fontweight='bold',fontsize=10);ax[1,0].set_xlabel('Encoding depth h');ax[1,0].set_ylabel('Upper-bound recurrence');ax[1,0].legend(fontsize=8)
side=np.logspace(2,7,200);h=50.
ax[1,1].loglog(side/1e3,(side/h)**3,label='Uniform 50 nm volume cells',color='#bd4b56')
ax[1,1].loglog(side/1e3,6*(side/h)**2,label='External surface patches only',color='#168b8c')
ax[1,1].set_title('Geometric count only; filling still required',loc='left',fontweight='bold',fontsize=10);ax[1,1].set_xlabel('Cube side (micrometers)');ax[1,1].set_ylabel('Component/patch count');ax[1,1].legend(fontsize=8)
for a in ax.flat:a.grid(alpha=.2)
fig.savefig(OUT/'scaling.png',dpi=220);fig.savefig(OUT/'scaling.pdf');plt.close(fig)
# Exact conceptual tile map, not a molecular structure rendering.
fig,ax=plt.subplots(figsize=(7,4.5),constrained_layout=True)
from matplotlib.patches import Rectangle,Circle
for i in range(4):
for j in range(4):
col=['#dae9ee','#e0e8de','#e8dfec','#f0e6d4'][(i//2)*2+j//2]
ax.add_patch(Rectangle((i,j),.85,.85,facecolor=col,edgecolor='#344455',lw=1.5))
if j in (1,2) and i in (1,2):ax.add_patch(Circle((i+.425,j+.425),.27,facecolor='#d4a846',edgecolor='#8d6c21'))
ax.text(i+.12,j+.12,f'{i+4*j+1}',fontsize=8,color='#344455')
ax.text(4.1,3.5,'16 repeated carriers',fontsize=13,fontweight='bold')
ax.text(4.1,2.8,'Four tetramers\nthen one sensor tile',fontsize=11)
ax.text(4.1,1.75,'Gold payload sites\nplus empty structural sites',fontsize=11)
ax.text(4.1,.65,'Silica joins structural contacts.\nOptical gaps must remain open.',fontsize=10)
ax.set_xlim(-.3,8.2);ax.set_ylim(-.4,4.2);ax.set_aspect('equal');ax.axis('off')
fig.suptitle('First experiment: logical layout, not a molecular CAD design',fontsize=11)
fig.savefig(OUT/'experiment.png',dpi=220);plt.close(fig)
print('Saved three figures and two vector plot PDFs')