Download source/check_equivalence.py from HaomingLuo/AgentFEM-Pipe-Components: direct link, hf CLI and curl.
- Browser
- Download file 937 Bytes
-
https://huggingface.co/datasets/HaomingLuo/AgentFEM-Pipe-Components/resolve/main/source/check_equivalence.py
- Command line
-
hf download hf://datasets/HaomingLuo/AgentFEM-Pipe-Components/source/check_equivalence.py
-
curl -L -o check_equivalence.py https://huggingface.co/datasets/HaomingLuo/AgentFEM-Pipe-Components/resolve/main/source/check_equivalence.py
937 Bytes
| """Cross-language check: identical released operators, independent assemblers.""" | |
| import json | |
| from pathlib import Path | |
| import numpy as np | |
| from assembly import load,solve | |
| root=Path(__file__).resolve().parents[1] | |
| fixture=json.loads((root/'reports/browser_fixture.json').read_text()) | |
| r=fixture['request']; browser=fixture['result'] | |
| chain=[load(root/'data/components'/c['spec']['id']) for c in r['components']] | |
| out=solve(chain,rolls=r.get('rolls'),deltaT=r['deltaT'],supports=r['supports'],nmodes=3) | |
| errors={ | |
| 'displacement_relative':float(np.linalg.norm(out['q']-browser['q'])/np.linalg.norm(out['q'])), | |
| 'frequency_max_relative':float(np.max(abs(out['frequency']/browser['frequency']-1))), | |
| 'reaction_relative':float(np.linalg.norm(out['reaction']-browser['reaction'])/np.linalg.norm(out['reaction']))} | |
| assert max(errors.values())<1e-6,errors | |
| (root/'reports/browser_equivalence.json').write_text(json.dumps(errors,indent=2)) | |
| print(errors) | |