Download source/generate_assemblies.py from HaomingLuo/AgentFEM-Pipe-Components: direct link, hf CLI and curl.
- Browser
- Download file 2.36 kB
-
https://huggingface.co/datasets/HaomingLuo/AgentFEM-Pipe-Components/resolve/main/source/generate_assemblies.py
- Command line
-
hf download hf://datasets/HaomingLuo/AgentFEM-Pipe-Components/source/generate_assemblies.py
-
curl -L -o generate_assemblies.py https://huggingface.co/datasets/HaomingLuo/AgentFEM-Pipe-Components/resolve/main/source/generate_assemblies.py
2.36 kB
| """512 reproducible ROM-labelled assembly cases; no claim of full-FE labels.""" | |
| from pathlib import Path | |
| import json | |
| import numpy as np | |
| from assembly import load,solve | |
| root=Path(__file__).resolve().parents[1];rng=np.random.default_rng(20261010) | |
| catalog=json.loads((root/'web/data/catalog.json').read_text())['components'];cache={} | |
| def get(kind,r,d,t): | |
| id=f'{kind}-d{d:03d}-t{t:02d}-r{r:g}' | |
| if id not in cache:cache[id]=load(root/'data/components'/id) | |
| return cache[id] | |
| rows=[] | |
| for i in range(512): | |
| family=['L','U','spatial','offset'][i%4];d=int(rng.choice([120,160,200,240]));t=int(rng.choice([4,6]));kinds=['straight','elbow','straight'] if family=='L' else ['straight','elbow','straight','elbow','straight'] | |
| chain=[get(k,float(rng.choice([3,5,8])) if k=='straight' else float(rng.choice([1.5,2,3])),d,t) for k in kinds] | |
| # Match the compact :g component ID convention. | |
| rolls=[0]*len(chain) | |
| if family=='spatial':rolls[3]=np.pi/2 | |
| if family=='offset':rolls[3]=np.pi | |
| supports=[{'node':0,'fixed':list(range(6))}];stype=['free','spring','guide','fixed'][(i//4)%4] | |
| if stype=='spring':supports.append({'node':len(chain),'spring':[0,0,float(10**rng.uniform(4,6)),0,0,0]}) | |
| if stype=='guide':supports.append({'node':len(chain),'fixed':[2]}) | |
| if stype=='fixed':supports.append({'node':len(chain),'fixed':list(range(6))}) | |
| temp=float(rng.choice([0,25,50,100,150,200]));a=solve(chain,rolls=rolls,deltaT=temp,supports=supports,nmodes=3) | |
| assert a['free_residual']<1e-7 | |
| row={'id':f'assembly-{i:04d}','family':family,'split':'heldout_spatial' if family=='spatial' else 'development','label_source':'solid_FE_component_ROM','component_ids':[c['spec']['id'] for c in chain],'rolls_rad':rolls,'supports':supports,'delta_temperature_K':temp,'gravity_m_s2':[0,0,-9.81],'port_displacements_SI':a['q'].tolist(),'fixed_reactions_SI':a['reaction'].tolist(),'frequencies_Hz':a['frequency'].tolist(),'centerline_m':[p.tolist() for p in a['paths']],'displacement_m':[p.tolist() for p in a['displacements']],'free_residual':a['free_residual']} | |
| rows.append(row) | |
| out=root/'data/assemblies';out.mkdir(exist_ok=True) | |
| for split in ['development','heldout_spatial']: | |
| (out/(split+'.jsonl')).write_text(''.join(json.dumps(r,separators=(',',':'))+'\n' for r in rows if r['split']==split)) | |
| print('512 ROM-labelled cases saved; held-out split is topology-based, not an accuracy claim.') | |