Skip to content

Commit b810ab7

Browse files
Merge pull request #1 from LIBRA-project/parametrisation
Parametrisation
2 parents 0e3c28c + 4ea1d07 commit b810ab7

2 files changed

Lines changed: 67 additions & 16 deletions

File tree

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
# libra_sparging
1+
# libra_sparging
2+
3+
To run the model:
4+
5+
1. Create the right conda environment
6+
7+
> [!NOTE]
8+
> Requires and conda to be installed
9+
10+
> [!NOTE]
11+
> This uses `dolfinx` which doesn't run on Linux. For windows users, consider using Windows Subsystem for Linux (WSL)
12+
13+
```
14+
conda env create -f environment.yml
15+
conda activate libra_sparging
16+
```
17+
18+
19+
```
20+
python model.py
21+
```

model.py

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,36 @@
1111

1212
log.set_log_level(log.LogLevel.INFO)
1313

14-
mesh = dolfinx.mesh.create_interval(MPI.COMM_WORLD, 1000, points=[0, 1])
14+
avogadro_number = 6.022e23 # 1/mol
15+
16+
tank_height = 1 # m
17+
tank_diameter = 0.5 # m
18+
K_S = 1e20 / avogadro_number # solubility of breeder mol/m3/Pa
19+
diffusivity = 1e-9 # breeder diffusivity m2/s
20+
21+
22+
source_term = 0.001 # mol/m3/s generation term
23+
24+
u_b = 0.3 # m/s bubble velocity
25+
d_b = 0.002 # m bubble diameter
26+
27+
P = 151988 # total gas pressure # TODO should be 7 PSIG - differential at the top
28+
h_l = (
29+
(diffusivity * u_b) / (ufl.pi * d_b)
30+
) ** 0.5 # mass transport coefficient Higbie penetration model
31+
32+
R = 8.314 # J/mol/K
33+
T = 900 # K temperature
34+
epsilon_g = 0.03 # gas void fraction # TODO from correlations
35+
epsilon_l = 1 - epsilon_g # liquid void fraction
36+
a = 6 * epsilon_g / d_b # specific interfacial area
37+
38+
# FIXME is this homogeneous?
39+
E_g = 0.2 * tank_diameter**2 * u_b # gas phase diffusivity (dispersion coefficient)
40+
E_l = diffusivity # liquid phase diffusivity # FIXME
41+
42+
# MESH AND FUNCTION SPACES
43+
mesh = dolfinx.mesh.create_interval(MPI.COMM_WORLD, 10000, points=[0, tank_height])
1544
fdim = mesh.topology.dim - 1
1645
cg_el = basix.ufl.element("Lagrange", mesh.basix_cell(), degree=1, shape=(2,))
1746

@@ -27,47 +56,49 @@
2756

2857
dt = 0.2
2958

30-
vel_x = 1.0
59+
vel_x = u_b
3160
vel = dolfinx.fem.Constant(mesh, PETSc.ScalarType([vel_x]))
3261

33-
K_S = 1 # solubility of breeder
34-
D = 0.001
35-
P = 1 # total gas pressure
36-
h_l = 0.1 # mass transport coefficient
62+
3763
EPS = 1e-16
3864

39-
gen = dolfinx.fem.Constant(mesh, PETSc.ScalarType(1.0)) # generation term (neutrons)
65+
gen = dolfinx.fem.Constant(
66+
mesh, PETSc.ScalarType(source_term)
67+
) # generation term (neutrons)
68+
69+
70+
# VARIATIONAL FORMULATION
4071

4172
# mass transfer rate
42-
J = h_l * (c_T - K_S * (P * y_T2 + EPS) ** 0.5)
73+
J = a * h_l * (c_T - K_S * (P * y_T2 + EPS))
4374

4475
F = 0 # variational formulation
4576

4677
# transient terms
47-
F += ((c_T - c_T_n) / dt) * v_c * ufl.dx + ((y_T2 - y_T2_n) / dt) * v_y * ufl.dx
48-
78+
F += epsilon_l * ((c_T - c_T_n) / dt) * v_c * ufl.dx
79+
F += epsilon_g * 1 / (R * T) * (P * (y_T2 - y_T2_n) / dt) * v_y * ufl.dx
4980

5081
# diffusion/dispersion terms
51-
F += D * ufl.dot(ufl.grad(c_T), ufl.grad(v_c)) * ufl.dx
52-
F += ufl.dot(ufl.grad(y_T2), ufl.grad(v_y)) * ufl.dx
82+
F += epsilon_l * E_l * ufl.dot(ufl.grad(c_T), ufl.grad(v_c)) * ufl.dx
83+
F += epsilon_g * E_g * ufl.dot(ufl.grad(P * y_T2), ufl.grad(v_y)) * ufl.dx
5384

5485

5586
# mass exchange (coupling term)
56-
F += J * v_c * ufl.dx - 0.5 * J * v_y * ufl.dx
87+
F += J * v_c * ufl.dx - J * v_y * ufl.dx
5788

5889
# Generation term in the breeder
5990
F += -gen * v_c * ufl.dx
6091

6192
# advection of gas
62-
F += ufl.inner(ufl.dot(ufl.grad(y_T2), vel), v_y) * ufl.dx
93+
F += 1 / (R * T) * ufl.inner(ufl.dot(ufl.grad(P * y_T2), vel), v_y) * ufl.dx
6394

6495

6596
# BOUNDARY CONDITIONS
6697
gas_inlet_facets = dolfinx.mesh.locate_entities_boundary(
6798
mesh, fdim, lambda x: np.isclose(x[0], 0.0)
6899
)
69100
gas_outlet_facets = dolfinx.mesh.locate_entities_boundary(
70-
mesh, fdim, lambda x: np.isclose(x[0], 1.0)
101+
mesh, fdim, lambda x: np.isclose(x[0], tank_height)
71102
)
72103
bc1 = dolfinx.fem.dirichletbc(
73104
dolfinx.fem.Constant(mesh, 0.0),

0 commit comments

Comments
 (0)