@@ -307,7 +307,6 @@ def solve(
307307 T = self .sim_input .temperature .to ("K" ).magnitude
308308 E_g = self .sim_input .E_g .to ("m**2/s" ).magnitude
309309 E_l = self .sim_input .E_l .to ("m**2/s" ).magnitude
310- u_g0 = self .sim_input .u_g0 .to ("m/s" ).magnitude
311310 Q_T2 = self .sim_input .Q_T .to ("molT2/s" ).magnitude
312311
313312 dt = (
@@ -337,40 +336,13 @@ def solve(
337336 u_n = dolfinx .fem .Function (V )
338337 v_c , v_y = ufl .TestFunctions (V )
339338
340- # set initial concentration
341- c_T2_0_ufl_expr = dolfinx .fem .Constant (
342- mesh , self .sim_input .c_T2_0 .to ("molT2/m**3" ).magnitude
343- ) * self .normalize_profile (
344- self .sim_input .profile_c_T2_0 , tank_height , mesh , V_profile
345- )
346- u_n .sub (0 ).interpolate (
347- dolfinx .fem .Expression (
348- c_T2_0_ufl_expr , V .sub (0 ).element .interpolation_points
349- )
350- )
351-
352- c_T2 , y_T2 = ufl .split (u )
353- c_T2_n , y_T2_n = ufl .split (u_n )
354-
355- vel_x = u_g0 # TODO velocity should vary with hydrostatic pressure
356- vel = dolfinx .fem .Constant (mesh , PETSc .ScalarType ([vel_x ]))
357-
358- h_l_const = dolfinx .fem .Constant (mesh , PETSc .ScalarType (h_l ))
359-
360- gen_T2_ave = dolfinx .fem .Constant (
361- mesh , Q_T2 / tank_volume * self .sim_input .signal_irr (0 * ureg .s )
362- ) # magnitude of the generation term
363-
364- gen_T2 = gen_T2_ave * self .normalize_profile (
365- self .sim_input .profile_source_T , tank_height , mesh , V_profile
366- )
367-
368339 # define spatially varying profiles
369340 if not self .constant_profiles :
370341 eps_g = dolfinx .fem .Function (V_profile )
371342 eps_l = dolfinx .fem .Function (V_profile )
372343 a = dolfinx .fem .Function (V_profile )
373344 P_g = dolfinx .fem .Function (V_profile )
345+ u_g = dolfinx .fem .Function (V_profile )
374346
375347 eps_g .interpolate (
376348 lambda x : (
@@ -387,16 +359,49 @@ def solve(
387359 P_g .interpolate (
388360 lambda x : self .sim_input .P_g (x [0 ] * ureg .m ).to ("Pa" ).magnitude
389361 )
362+ u_g .interpolate (
363+ lambda x : self .sim_input .u_g (x [0 ] * ureg .m ).to ("m/s" ).magnitude
364+ )
390365 else :
391366 # use values at z=0 for constant profiles
392- eps_g_0 = self .sim_input .eps_g_0 .to ("dimensionless" ).magnitude
367+ eps_g0 = self .sim_input .eps_g0 .to ("dimensionless" ).magnitude
393368 a_0 = self .sim_input .a_0 .to ("1/m" ).magnitude
394- P_g_0 = self .sim_input .P_g_0 .to ("Pa" ).magnitude
369+ P_g0 = self .sim_input .P_g0 .to ("Pa" ).magnitude
370+ u_g0 = self .sim_input .u_g0 .to ("m/s" ).magnitude
395371
396- eps_g = dolfinx .fem .Constant (mesh , PETSc .ScalarType (eps_g_0 ))
397- eps_l = dolfinx .fem .Constant (mesh , PETSc .ScalarType (1 - eps_g_0 ))
372+ eps_g = dolfinx .fem .Constant (mesh , PETSc .ScalarType (eps_g0 ))
373+ eps_l = dolfinx .fem .Constant (mesh , PETSc .ScalarType (1 - eps_g0 ))
398374 a = dolfinx .fem .Constant (mesh , PETSc .ScalarType (a_0 ))
399- P_g = dolfinx .fem .Constant (mesh , PETSc .ScalarType (P_g_0 ))
375+ P_g = dolfinx .fem .Constant (mesh , PETSc .ScalarType (P_g0 ))
376+ u_g = dolfinx .fem .Constant (mesh , PETSc .ScalarType (u_g0 ))
377+
378+ # set initial concentration
379+ c_T2_0_ufl_expr = dolfinx .fem .Constant (
380+ mesh , self .sim_input .c_T2_0 .to ("molT2/m**3" ).magnitude
381+ ) * self .normalize_profile (
382+ self .sim_input .profile_c_T2_0 , tank_height , mesh , V_profile
383+ )
384+ u_n .sub (0 ).interpolate (
385+ dolfinx .fem .Expression (
386+ c_T2_0_ufl_expr , V .sub (0 ).element .interpolation_points
387+ )
388+ )
389+
390+ c_T2 , y_T2 = ufl .split (u )
391+ c_T2_n , y_T2_n = ufl .split (u_n )
392+
393+ # vel_x = u_g0 # TODO velocity should vary with hydrostatic pressure
394+ # vel = dolfinx.fem.Constant(mesh, PETSc.ScalarType([vel_x]))
395+
396+ h_l_const = dolfinx .fem .Constant (mesh , PETSc .ScalarType (h_l ))
397+
398+ gen_T2_ave = dolfinx .fem .Constant (
399+ mesh , Q_T2 / tank_volume * self .sim_input .signal_irr (0 * ureg .s )
400+ ) # magnitude of the generation term
401+
402+ gen_T2 = gen_T2_ave * self .normalize_profile (
403+ self .sim_input .profile_source_T , tank_height , mesh , V_profile
404+ )
400405
401406 # VARIATIONAL FORMULATION
402407
@@ -431,7 +436,9 @@ def solve(
431436 F += (
432437 1
433438 / (const .R * T )
434- * ufl .inner (ufl .dot (ufl .grad (P_g * y_T2 ), vel ), v_y )
439+ # * ufl.inner(ufl.dot(ufl.grad(P_g * y_T2), vel), v_y)
440+ * ufl .grad (u_g * P_g * y_T2 )[0 ]
441+ * v_y
435442 * ufl .dx
436443 )
437444
@@ -458,13 +465,7 @@ def solve(
458465
459466 # Danckwert BC at gas inlet
460467 P_T2_inlet = 0
461- F += (
462- 1
463- / (const .R * T )
464- * vel_x
465- * ufl .inner ((P_g * y_T2 - P_T2_inlet ), v_y )
466- * ds (1 )
467- )
468+ F += 1 / (const .R * T ) * u_g * ufl .inner ((P_g * y_T2 - P_T2_inlet ), v_y ) * ds (1 )
468469
469470 # n = ufl.FacetNormal(mesh)
470471
@@ -527,7 +528,7 @@ def post_process(t):
527528
528529 flux_T2 = dolfinx .fem .assemble_scalar (
529530 dolfinx .fem .form (
530- vel_x * P_g / (const .R * T ) * y_T2_post * tank_area * ds (2 )
531+ u_g * P_g / (const .R * T ) * y_T2_post * tank_area * ds (2 )
531532 )
532533 )
533534 flux_T2_2 = dolfinx .fem .assemble_scalar (
0 commit comments