File size: 3,519 Bytes
fc468a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""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()