-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparametric_study_thickness.py
153 lines (130 loc) · 5.19 KB
/
parametric_study_thickness.py
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
from main import (
my_model,
heat_transfer_bcs,
h_implantation_top,
recombination_flux_coolant,
instantaneous_recombination_poloidal_W,
instantaneous_recombination_poloidal_Cu,
instantaneous_recombination_top_pipe,
instantaneous_recombination_bottom,
instantaneous_recombination_toroidal,
recombination_poloidal_W,
recombination_poloidal_Cu,
recombination_toroidal,
recombination_top_pipe,
tungsten,
copper,
cucrzr,
)
import festim as F
import fenics as f
class AverageSurface(F.DerivedQuantity):
def __init__(self, field, surface) -> None:
super().__init__(field)
self.surface = surface
self.title = "Average {} surface {}".format(self.field, self.surface)
def compute(self):
return f.assemble(self.function * self.ds(self.surface)) / f.assemble(
1 * self.ds(self.surface)
)
def run_mb(thickness: float, instant_recomb: bool, transient: bool, gap: bool):
"""Runs a MB simulation
Args:
thickness (float): the poloidal thickness
instant_recomb (bool): If True, instantaneous recombination will be
assumed on poloidal surfaces. Else, isolated.
transient (bool): if True, transient sim, else steady state.
gap (bool): if True, an extrusion on the CuCrZr pipe is modelled.
"""
print(
f"\n Running for {thickness} mm Transient: {transient} Recomb: {instant_recomb} Gap : {gap} \n"
)
folder = "meshes/{}mm_thickness".format(thickness)
if not gap:
volume_file = "{}/mesh_cells_no_gap.xdmf".format(folder)
boundary_file = "{}/mesh_facets_no_gap.xdmf".format(folder)
else:
volume_file = "{}/mesh_cells.xdmf".format(folder)
boundary_file = "{}/mesh_facets.xdmf".format(folder)
my_model.mesh = F.MeshFromXDMF(volume_file=volume_file, boundary_file=boundary_file)
folder = "results/{}mm_thickness".format(thickness)
if transient:
folder += "/transient"
else:
folder += "/steady_state"
if instant_recomb:
folder += "/instant_recomb"
else:
folder += "/no_recomb"
if not gap:
folder += "/no_gap"
print(folder)
derived_quantities = F.DerivedQuantities(
[
F.TotalVolume(field="retention", volume=tungsten.id),
F.TotalVolume(field="retention", volume=copper.id),
F.TotalVolume(field="retention", volume=cucrzr.id),
F.TotalVolume(field="solute", volume=tungsten.id),
F.TotalVolume(field="solute", volume=copper.id),
F.TotalVolume(field="solute", volume=cucrzr.id),
F.SurfaceFlux(
field="solute", surface=recombination_flux_coolant.surfaces[0]
),
F.SurfaceFlux(
field="solute", surface=instantaneous_recombination_poloidal_W.surfaces[0]
),
F.SurfaceFlux(
field="solute", surface=instantaneous_recombination_poloidal_Cu.surfaces[0]
),
F.SurfaceFlux(
field="solute", surface=instantaneous_recombination_bottom.surfaces[0]
),
F.SurfaceFlux(
field="solute", surface=instantaneous_recombination_toroidal.surfaces[0]
),
AverageSurface(field="T", surface=recombination_flux_coolant.surfaces[0]),
],
filename="{}/derived_quantities.csv".format(folder),
)
if gap:
derived_quantities.derived_quantities.append(
F.SurfaceFlux(
field="solute", surface=instantaneous_recombination_top_pipe.surfaces[0]
)
)
my_model.exports = F.Exports(
[
derived_quantities,
F.XDMFExport("T", folder=folder),
F.XDMFExport("solute", folder=folder),
F.XDMFExport("retention", folder=folder),
F.XDMFExport("1", folder=folder,checkpoint=True),
F.XDMFExport("2", folder=folder,checkpoint=True),
]
)
h_transport_bcs = [recombination_flux_coolant]
my_model.boundary_conditions = heat_transfer_bcs + h_transport_bcs
my_model.boundary_conditions.append(instantaneous_recombination_toroidal)
my_model.boundary_conditions.append(instantaneous_recombination_bottom)
if instant_recomb:
my_model.boundary_conditions.append(instantaneous_recombination_poloidal_W)
my_model.boundary_conditions.append(instantaneous_recombination_poloidal_Cu)
if gap:
my_model.boundary_conditions.append(instantaneous_recombination_top_pipe)
my_model.boundary_conditions.append(h_implantation_top) # add it at the end
if transient:
my_model.t = 0
my_model.dt = F.Stepsize(initial_value=1e5, stepsize_change_ratio=1.1)
my_model.settings.transient = True
my_model.settings.final_time = 1e5
else:
my_model.dt = None
my_model.settings.transient = False
my_model.settings.final_time = None
my_model.initialise()
my_model.run()
# parametric study thickness
for thickness in [4, 5, 6, 7, 8, 9, 10, 14]:
for gap in [True, False]:
for instant_recomb in [True, False]:
run_mb(thickness, instant_recomb=instant_recomb, transient=False, gap=gap)