Pipe Assembly Lab v1.3: four power-piping research sections, FE operators and validation
fc468a5 verified Download source/generate_power.py from HaomingLuo/AgentFEM-Pipe-Components: direct link, hf CLI and curl.
- Browser
- Download file 3.52 kB
-
https://huggingface.co/datasets/HaomingLuo/AgentFEM-Pipe-Components/resolve/main/source/generate_power.py
- Command line
-
hf download hf://datasets/HaomingLuo/AgentFEM-Pipe-Components/source/generate_power.py
-
curl -L -o generate_power.py https://huggingface.co/datasets/HaomingLuo/AgentFEM-Pipe-Components/resolve/main/source/generate_power.py
3.52 kB
| """Power-piping research geometries: new solid FE operators, not scaled old labels. | |
| Only the main-steam section derives from a published dimension calculation. | |
| Other sections, routes and elastic properties are explicitly benchmark choices. | |
| """ | |
| from pathlib import Path | |
| import json, time | |
| import numpy as np | |
| from components import assemble, save_component, tube_mesh | |
| from assembly import load, solve | |
| from generate import export | |
| ROOT=Path(__file__).resolve().parents[1] | |
| FAMILIES=[ | |
| dict(id='main-steam',zh='主蒸汽',en='Main steam',diameter=.450,thickness=.060,temperature=546, | |
| young=170e9,alpha=13e-6,source='https://www.energychina.press/article/doi/10.16516/j.gedi.issn2095-8676.2019.04.007', | |
| basis='Table 9: ID 330 mm + calculated wall 60 mm, without corrosion allowance. OD 450 mm is derived; not an as-built purchased section.'), | |
| dict(id='hot-reheat',zh='再热热段',en='Hot reheat',diameter=.800,thickness=.030,temperature=546, | |
| young=170e9,alpha=13e-6,source=None,basis='Author-selected large-diameter research section; not a plant specification.'), | |
| dict(id='cold-reheat',zh='再热冷段',en='Cold reheat',diameter=.800,thickness=.020,temperature=330, | |
| young=190e9,alpha=12.5e-6,source=None,basis='Author-selected research section; not a plant specification.'), | |
| dict(id='feedwater',zh='高压给水',en='High-pressure feedwater',diameter=.450,thickness=.050,temperature=280, | |
| young=195e9,alpha=12.5e-6,source=None,basis='Author-selected thick-wall research section; not a plant specification.'), | |
| ] | |
| def specs(f): | |
| d=f['diameter'] | |
| for kind,ratios in [('straight',[3,5,8]),('elbow',[1.5,2,3])]: | |
| for ratio in ratios: | |
| yield dict(id=f"power-{f['id']}-{kind}-r{ratio}",family=f['id'],kind=kind, | |
| diameter=d,thickness=f['thickness'],length=ratio*d if kind=='straight' else 4*d, | |
| radius=ratio*d if kind=='elbow' else 2*d,stub=2*d if kind=='elbow' else 0, | |
| ns=24,nt=24,nr=2,modes=12,young=f['young'],alpha=f['alpha'],density=7850.,poisson=.3, | |
| material_basis='Constant effective elastic benchmark properties; no grade-specific certification or temperature evolution.') | |
| def main(): | |
| start=time.time(); entries=[] | |
| for f in FAMILIES: | |
| for spec in specs(f): | |
| folder=ROOT/'data/components'/spec['id'] | |
| if (folder/'metadata.json').exists():c=load(folder) | |
| else: | |
| c=assemble(spec) | |
| assert np.isfinite(c['Kr']).all() and c['metrics']['rigid_residual']<1e-8 | |
| save_component(c,folder) | |
| xyz,cells,ports=tube_mesh(**{k:v for k,v in spec.items() if k in ['kind','length','radius','diameter','thickness','ns','nt','nr','stub']}) | |
| np.savez_compressed(folder/'mesh.npz',coordinates=xyz,cells=cells,ports=ports) | |
| (ROOT/'web/data'/f"{spec['id']}.json").write_text(json.dumps(export(c),separators=(',',':'))) | |
| entries.append(dict(**spec,file=spec['id']+'.json',mass_kg=c['metrics']['mass_kg'])) | |
| print(spec['id'],round(time.time()-start,1),flush=True) | |
| path=ROOT/'web/data/catalog.json';catalog=json.loads(path.read_text()) | |
| catalog['components']=[x for x in catalog['components'] if not x['id'].startswith('power-')]+entries | |
| catalog['powerFamilies']=FAMILIES | |
| path.write_text(json.dumps(catalog,ensure_ascii=False,indent=2)) | |
| (ROOT/'data/power_families.json').write_text(json.dumps(FAMILIES,ensure_ascii=False,indent=2)) | |
| if __name__=='__main__':main() | |