"""Internal mathematical consistency; no experimental-performance validation.""" from pathlib import Path import csv,json,math,itertools OUT=Path(__file__).resolve().parent layers=[('L0',60,'H-S contact film'),('L1',100,'Shared load spreading and travel-stop allocation'),('L2',300,'Matched A/R sensing elements; optional isolated trace wells'), ('L3',80,'Isolation septum'),('L4',240,'W0/WG-C coupling, stable reference, archive and identity'),('L5',100,'Material terminals'), ('L6',620,'Recoil dermis'),('L7',100,'Attachment')] params={'release':'3.0','status':'final standalone technology-aligned material blueprint; integrated performance untested','title':'Ørïelith//9 - The Skin of an Impossible Angel', 'patch_mm':[20,20,1.6],'active_field_mm':[16,16],'taxels':[16,16], 'pitch_um':1000,'island_um':[700,700],'centers_mm':'x=2.5+i, y=2.5+j; i,j=0..15', 'cavity_um':{'diameter':500,'depth':100,'diaphragm':20}, 'ionic_transport_lengths_um':[5,15,50],'illustrative_D_m2_per_s':1e-11, 'witness_ligament_um':[100,10,5],'ligaments_per_taxel':4,'witness_active_length_um':20, 'tag':{'carrier_um':[220,140,30],'grid':[16,8],'pitch_um':10,'site_diameter_um':6, 'code':'RM(1,7)','number_of_codewords':256,'length':128,'minimum_distance':64, 'id':'16*j+i','a':'seven low ID bits','b':'highest ID bit','site':'x=16*row+column'}, 'material_terminal_channel_um':[40,30],'terminal_min_septum_um':10, 'qualification_temperature_C':[20,40], 'ambient_repair_screen':{'temperature_C':20,'relative_humidity_percent':40,'duration_h':24,'requires':'clean host faces recontacted; all assembled outcomes measured separately'}, 'tolerances_targets':{'layer_fraction':0.10,'registration_um':25,'tag_site_placement_um':2}, 'gates_are_targets_not_results':True, 'unresolved':['ionic barrier qualification','W0/WG and C-SH cure/deprotection and interphase qualification', 'skin-scale writer activation window','elastically active WG-C capture and retained force recruitment', 'stable calibrated reference and matched translation','loaded travel-stop validation','permanent tag chemistry', 'full terminal routing mask','assembled functional healing'], 'writable_tether':{'topology':'active sensor ki in series with g_A; parallel stable reference K_R and shared host bypass B', 'ledger':'reduced g=g0-a_loss*m+b_gain*r; 0<=r<=min(m,theta); add -L_B for separately activated inaccessible bulk', 'inventory_reference':'measured force-bearing interface-eligible writer population N_I; not all bulk feed', 'settled_requirement':'b_gain*chi>a_loss AND fractional Ks growth exceeds fractional Kb growth', 'nano_reaction_reach_target_nm':5,'receiver_coat_um':2,'reactive_cassette_to_exposed_host_um':5, 'support_W0_um':4.9,'writer_WG_nominal_nm':100,'writer_WG_tolerance_nm':20, 'WG_screened_DA_mmol_per_10mmol_HMA':[0.05,0.1,0.25], 'reference_KR_N_m':20,'travel_stop_measured_upper_target_um':50, 'fine_post_footprint_um':[100,100], 'active_post_centers_um':[[100,100],[-100,-100]], 'reference_post_centers_um':[[100,-100],[-100,100]], 'example_N_per_m':{'ki':100,'g0':25,'g1':200,'Kb':80,'a_loss':10,'b_gain':185}}} cum=0 for code,t,role in layers: params.setdefault('layers',[]).append({'layer':code,'z0_um':cum,'z1_um':cum+t,'thickness_um':t,'role':role});cum+=t assert cum==1600 with (OUT/'design_parameters.json').open('w') as f:json.dump(params,f,indent=2,ensure_ascii=False) with (OUT/'layer_stack.csv').open('w',newline='') as f: wr=csv.DictWriter(f,fieldnames=['layer','z0_um','z1_um','thickness_um','role']);wr.writeheader();wr.writerows(params['layers']) recipes=[ ['H-S','Aminopropyl-terminated PDMS; nominal Mn5000','2.400',5000,12,'4.800 NH2','use measured amine equivalent weight'], ['H-S','4,4-methylenebis(cyclohexyl isocyanate) MCI/H12MDI','1.680',262.35,0.440748,'3.360 NCO','ACTIVE mass; divide by actual assay for reagent mass'], ['H-S','1,3,5-Triformylbenzene TFB','0.480',162.14,0.0778272,'1.440 CHO','ACTIVE mass; divide by actual assay; imine water removed'], ['I-30','Purified CLPU@E5','not specified','',7,'','prequalified polymer; not a generic chlorinated resin'], ['I-30','EMIM-TFSI','not specified','',3,'','30 wt% of total dry blend'], ['W0','n-Hexyl methacrylate','10.000',170.25,1.7025,'10 vinyl','writer-free permanent support'], ['W0','Ethylene glycol dimethacrylate','0.100',198.22,0.019822,'0.200 vinyl','support must remain percolating'], ['W0','Dibenzoyl peroxide active compound','0.020',242.23,0.0048446,'','initiator screening input; no cure schedule asserted'], ['WG high-feed screen','n-Hexyl methacrylate','10.000',170.25,1.7025,'10 vinyl','untested 100nm gate-coat candidate'], ['WG high-feed screen','Ethylene glycol dimethacrylate','0.100',198.22,0.019822,'0.200 vinyl','coat anchoring and retention require qualification'], ['WG high-feed screen','Published compound 8 DOI10.1039/C5SC03297K','0.250','verify','derive from verified MW','0.500 vinyl','also screen0.050 and0.100mmol; higher feed is not necessarily better'], ['WG high-feed screen','Dibenzoyl peroxide active compound','0.020',242.23,0.0048446,'','initiator screening input; no cure schedule asserted'], ['C-SH protected','n-Hexyl methacrylate','9.500',170.25,1.617375,'9.500 vinyl','untested receiver feed'], ['C-SH protected','2-(Acetylthio)ethyl methacrylate AcSEMA','0.500',188.24,0.09412,'0.500 vinyl; 0.500 protected SH','C8H12O3S; separate deprotection and assay required'], ['C-SH protected','Ethylene glycol dimethacrylate','0.100',198.22,0.019822,'0.200 vinyl','permanent receiver network'], ['C-SH protected','Dibenzoyl peroxide active compound','0.020',242.23,0.0048446,'','initiator screening input'], ] with (OUT/'chemical_formulations.csv').open('w',newline='') as f: wr=csv.writer(f);wr.writerow(['formulation','ingredient','amount_mmol','MW_g_mol','mass_g','group_amount_mmol','qualification']);wr.writerows(recipes) words=[] for ident in range(256): a=ident&127;b=ident>>7 w=sum((((a&x).bit_count()%2)^b)<initial['Ktotal_N_m'] and written['overall_indentation_um']load:hi=q else:lo=q return (lo+hi)/2 max_error=0.;nchecks=0 for load in (.1,.5,1.,2.,4.): for z in (.1,.3,.8,1.4,2.): for beta in (0.,.3,1.,3.): q=equilibrium(load,z,beta) u=q+.1*q**3+q/(1+z)+.05*(q/(1+z))**3 bd=(1+beta*z)*(1+.6*u*u);bz=beta*(u+.2*u**3) uip=1+.3*q*q;ugf=1/(1+z)+.15*q*q/(1+z)**3 ugz=-q/(1+z)**2-.15*q**3/(1+z)**4 exact=-(bd*ugz+bz)/(1+bd*(uip+ugf)) eps=1e-5 numerical=(equilibrium(load,z+eps,beta)-equilibrium(load,z-eps,beta))/(2*eps) max_error=max(max_error,abs(exact-numerical));nchecks+=1 assert max_error<1e-8 report['nonlinear_implicit_derivative_check']={'dimensionless_test_equilibria':nchecks,'max_abs_error':max_error, 'scope':'independent equilibrium-root finite difference against analytic derivative; not an experimental constitutive model'} # Explicit finite-capacity illustrative trajectory. Every output is model-only. force=20000*area;delta_g0=initial['phi']*force/25 def rhs(state): m,r=state;g=25-10*m+185*r mech=mechanics(g,force=force);dg=mech['phi']*force/g kw=.03*math.exp(4*dg/delta_g0) return kw*(1-m),5*(m-r)*(1-r) def rk4(state,dt): k1=rhs(state);k2=rhs(tuple(state[j]+dt*k1[j]/2 for j in (0,1))) k3=rhs(tuple(state[j]+dt*k2[j]/2 for j in (0,1))) k4=rhs(tuple(state[j]+dt*k3[j] for j in (0,1))) return tuple(state[j]+dt*(k1[j]+2*k2[j]+2*k3[j]+k4[j])/6 for j in (0,1)) state=(0.,0.);dt=.01;trajectory=[];min_g=25. for step in range(6001): m,r=state;g=25-10*m+185*r;min_g=min(min_g,g) assert -1e-9<=r<=m+1e-9 and m<=1+1e-9 and r<=1+1e-9 if step%50==0: me=mechanics(g,force=force) trajectory.append([step*dt,m,r,g,me['phi'],me['Ktotal_N_m']]) state=rk4(state,dt) with (OUT/'illustrative_capture_trajectory.csv').open('w',newline='') as f: w=csv.writer(f);w.writerow(['model_time_s','opened_fraction_m','captured_fraction_r','g_N_m','receptor_force_fraction','Ktotal_N_m']);w.writerows(trajectory) assert min_g<25 and min_g>15 report['illustrative_kinetics']={'kw_law':'0.03*exp(4*delta_g/delta_g_initial) s^-1', 'kc_normalized':5,'theta':1,'integration':'RK4 dt=0.01s; 60s, no fitted data', 'inventory_reference':'interface-eligible N_I; reduced model assumes no inaccessible bulk activation (L_B=0)', 'min_g_N_m':min_g,'last_record':trajectory[-1], 'warning':'initial softening is present; finite capacity does not guarantee fracture protection'} report['receiver_protected_feed_g']=sum(float(r[4]) for r in recipes if r[0]=='C-SH protected') report['formal_receiver_deacetylation_mass_loss_g']=.0005*42.037 assert math.isclose(report['receiver_protected_feed_g'],1.7361616,abs_tol=1e-10) cD=1000/.17025*.005;gamma=cD*5e-9 report['upper_bound_accessible_writer_inventory']={'assumed_density_kg_m3':1000,'assumed_writer_repeat_fraction':.005, 'assumed_accessible_depth_nm':5,'cD_mol_m3':cD,'gamma_mol_m2':gamma, 'sites_per_1000_um2':gamma*1e-9*6.02214076e23,'fraction_of_uniform_5um_film_one_face':5e-9/5e-6, 'scope':'uniform bulk CONTROL; not the final gate-coat design or measured active-link density'} report['illustrative_kinetics']['configuration']='reference-free control only; final referenced module is verified below' def paired(g, kb=80., load=20000*area, kr=20., ki=100.): ka=ki*g/(ki+g);total=ka+kr+kb;delta=load/total fa=ka*delta;fr=kr*delta return {'KA_N_m':ka,'KR_N_m':kr,'Ktotal_N_m':total,'delta_um':delta*1e6, 'FA_mN':fa*1000,'FR_mN':fr*1000,'Q':fa/fr, 'xg_um':fa/g*1e6,'xi_um':fa/ki*1e6, 'P_for_active_1mN_kPa':.001/(area*ka/total)/1000} pa=paired(25);pb=paired(200) assert math.isclose(pb['FA_mN']/pa['FA_mN'],2.4,rel_tol=1e-12) assert math.isclose(pb['Q']/pa['Q'],10/3,rel_tol=1e-12) qerr=max(abs(paired(g,kb)['Q']-paired(g,80)['Q']) for g in (25,50,100,150,200) for kb in (0,10,80,200,1000)) assert qerr<1e-12 g_from_ratio={str(rho):100*rho*20/(100-rho*20)for rho in (1,2,3)} assert all(math.isclose(paired(g)['Q'],float(rho),rel_tol=1e-12)for rho,g in g_from_ratio.items()) report['final_referenced_module']={'initial':pa,'written':pb,'actual_FA_gain':pb['FA_mN']/pa['FA_mN'], 'reference_ratio_gain':pb['Q']/pa['Q'],'host_bypass_invariance_max_abs_error':qerr, 'tested_Kb_N_m':[0,10,80,200,1000],'g_programmed_from_Q_N_m':g_from_ratio, 'Q_architectural_ceiling':5,'cannot_infer':'absolute pressure without total-force/bypass calibration'} # Nonlinear reconstruction: independently solve branches and total equilibrium. def invert_monotone(fn,value,hi0=1.): lo=0.;hi=hi0 while fn(hi)value:hi=mid else:lo=mid return (lo+hi)/2 ui=lambda q:q/2+.03*q**3 ug=lambda q,z:q/(1+z)+.02*(q/(1+z))**3 ref=lambda d:1.3*d+.1*d**3 records=[];max_recon=0. for z in (0.,.5,1.,2.): for kb in (.2,1.,3.): for load in (.1,.3,.6,1.,1.5,2.): aforce=lambda d:invert_monotone(lambda q:ui(q)+ug(q,z),d) delta=invert_monotone(lambda d:aforce(d)+ref(d)+kb*d+.15*d**3,load) fa=aforce(delta);fr=ref(delta) x_recon=invert_monotone(ref,fr)-ui(fa);x_true=ug(fa,z) max_recon=max(max_recon,abs(x_recon-x_true)) records.append([z,kb,load,fa,fr,delta,x_recon,x_true]) assert max_recon<1e-11 with (OUT/'nonlinear_reference_reconstruction.csv').open('w',newline='')as f: w=csv.writer(f);w.writerow(['model_state_z','model_host_kb','model_total_force','active_force','reference_force','true_translation','reconstructed_tether_extension','true_tether_extension']);w.writerows(records) report['nonlinear_reference_reconstruction']={'model_equilibria':len(records),'max_absolute_extension_error':max_recon, 'scope':'dimensionless monotone nonlinear constitutive models; no measured material properties'} # Antipodal footprint and affine-tilt test (all contacts engaged). posts={'A':[(100,100),(-100,-100)],'R':[(100,-100),(-100,100)]} assert all(math.hypot(x+dx,y+dy)<250 for pts in posts.values()for x,y in pts for dx in (-50,50)for dy in (-50,50)) delta0=30.;v=(.03,-.04) sumA=sum(10*(delta0+v[0]*x+v[1]*y)for x,y in posts['A']) sumR=sum(10*(delta0+v[0]*x+v[1]*y)for x,y in posts['R']) assert math.isclose(sumA/sumR,1.) report['antipodal_geometry']={'footprints_inside_radius250um':True,'matched_affine_tilt_ratio':sumA/sumR, 'scope':'linear matched positive-contact model; no plate-bending validation'} # Loaded-travel requirement, not a promise from a nominal gap. travel=50e-6;ka_max=pb['KA_N_m'];kr=20;kb=80 report['conditional_loaded_travel_limit']={'required_measured_delta_max_um':50, 'FA_max_mN':ka_max*travel*1000,'FR_max_mN':kr*travel*1000, 'each_active_post_force_cap_mN':ka_max*travel*1000/2, 'active_sensor_extension_um':ka_max*travel/100*1e6, 'generic_g_infinite_FA_bound_mN':100*travel*1000, 'ideal_stop_onset_kPa_initial':travel*(pa['KA_N_m']+kr+kb)/area/1000, 'ideal_stop_onset_kPa_written':travel*(pb['KA_N_m']+kr+kb)/area/1000, 'ideal_stop_force_at200kPa_mN_initial':(200000*area-travel*(pa['KA_N_m']+kr+kb))*1000, 'ideal_stop_force_at200kPa_mN_written':(200000*area-travel*(pb['KA_N_m']+kr+kb))*1000, 'scope':'conditional idealized upper-travel contract; finite stop compliance, impact and survival require tests'} assert pa['delta_um']<50 and pb['delta_um']<50 errx=5e-6/20+5e-6/100 report['example_force_error_budget']={'assumed_each_force_error_uN':5,'extension_error_bound_um':errx*1e6, 'written_xg_um_at20kPa':pb['xg_um'],'scope':'assumed readout error; calibration and mismatch errors excluded'} gamma_new=1000/.17025*.025*5e-9 report['surface_writer_geometry_budget']={'WG_nominal_thickness_nm':100,'WG_thickness_tolerance_nm':20, 'W0_support_um':4.9,'assumed_accessible_depth_nm':5,'accessible_fraction':.05, 'geometric_utilization_ratio_vs5um_control':50,'gamma_upper_mol_m2':gamma_new, 'areal_inventory_ratio_vs_control':gamma_new/gamma, 'total_writer_per_area_ratio_vs_control':(1000/.17025*.025*100e-9)/(cD*5e-6), 'scope':'approximate HMA-repeat inventory geometry; not sensitivity, activation or yield'} (OUT/'calculation_report.json').write_text(json.dumps(report,indent=2)) print(json.dumps({'all_checks_passed':True,'host_feed_g':hs_mass,'final_referenced_module':report['final_referenced_module'], 'nonlinear_reconstruction':report['nonlinear_reference_reconstruction'], 'stop':report['conditional_loaded_travel_limit'],'surface_writer':report['surface_writer_geometry_budget']},indent=2))