Download source/validate_retention.py from HaomingLuo/AgentFEM-Pipe-Components: direct link, hf CLI and curl.
- Browser
- Download file 936 Bytes
-
https://huggingface.co/datasets/HaomingLuo/AgentFEM-Pipe-Components/resolve/main/source/validate_retention.py
- Command line
-
hf download hf://datasets/HaomingLuo/AgentFEM-Pipe-Components/source/validate_retention.py
-
curl -L -o validate_retention.py https://huggingface.co/datasets/HaomingLuo/AgentFEM-Pipe-Components/resolve/main/source/validate_retention.py
936 Bytes
| from pathlib import Path | |
| import json | |
| import numpy as np | |
| from components import assemble,save_component | |
| from assembly import load,solve | |
| root=Path(__file__).resolve().parents[1];base=[];rich=[] | |
| for kind,ratio in [('straight',5),('elbow',2)]: | |
| c=load(root/f'data/components/{kind}-d200-t06-r{ratio}');base.append(c) | |
| spec=dict(c['spec']);spec.update(id='modes24-'+kind,modes=24) | |
| full=assemble(spec);save_component(full,root/'data/mode-refinement'/kind);rich.append(full) | |
| rows=[] | |
| for name,ids,rolls in [('L',[0,1,0],[0,0,0]),('spatial',[0,1,0,1,0],[0,0,0,np.pi/2,0])]: | |
| a=solve([base[i] for i in ids],rolls=rolls);b=solve([rich[i] for i in ids],rolls=rolls) | |
| err=abs(a['frequency']/b['frequency']-1) | |
| rows.append({'assembly':name,'modes_per_component':[12,24],'frequency_relative_errors':err.tolist()}) | |
| assert max(err[:3])<.01 | |
| (root/'reports/mode_retention.json').write_text(json.dumps({'cases':rows,'passed':True},indent=2));print(rows) | |