# Tracer: #-------------------- if WITH_TRACER: T_0 = np.zeros((NC, NL)) for C in range(NC): for L in range(NL): x = triangular_mesh.triangulation.x[C] y = triangular_mesh.triangulation.y[C] if x < BOX_X_MAX and x > BOX_X_MIN and y > BOX_Y_MIN and y < BOX_Y_MAX: T_0[C, L] = 0.9 tracers = [ fk.Tracer(triangular_mesh, layer, primitives, Tinit=T_0, label='suspension', settling_velocity=0.0) ] else: tracers = [] ################################################################################ # # Particles: #-------------------- if WITH_PARTICLES: positions = fk.generate_homogeneous_positions(triangular_mesh, layer, primitives, 3000) lagrangian = fk.Lagrangian(positions,
################################################################################ # # Tracer: #--------------------- # ################################################################################ # #.. important:: # # Let us define two tracers, labeled ``polluant_0`` and ``polluant_1``. Labels are # very important to link boundary conditions as well as source terms to the correct # tracer in the code. tracers = [ fk.Tracer(triangular_mesh, layer, primitives, Tinit=0., label='polluant_0'), fk.Tracer(triangular_mesh, layer, primitives, Tinit=10., label='polluant_1') ] ################################################################################ # # Boundary conditions: #--------------------- # #Boundary conditions are the same as in reiver example excepts we define inlet #flowrate in a input file.
simutime = fk.SimuTime(final_time=4., time_iteration_max=20000, second_order=True) create_figure_scheduler = fk.schedules(times=[0., 1., 2., 3., 4., 5.]) triangular_mesh = fk.TriangularMesh.from_msh_file( '../simulations/inputs/square2.mesh') layer = fk.Layer(1, triangular_mesh, topography=0.) def H_0(x, y): h = 2.4 * (1.0 + np.exp(-0.25 * ((x - 10.05)**2 + (y - 10.05)**2))) return h primitives = fk.Primitive(triangular_mesh, layer, height_funct=H_0) tracers = [fk.Tracer(triangular_mesh, layer, primitives, Tinit=1.0)] slides = [fk.Slide(ref=r) for r in [1, 2, 3, 4]] vtk_writer = fk.VTKWriter(triangular_mesh, scheduler=fk.schedules(count=10), scale_h=1.) problem = fk.Problem(simutime, triangular_mesh, layer, primitives, slides=slides, numerical_parameters={'space_second_order': True}, tracers=tracers, vtk_writer=vtk_writer, restart_scheduler=restart_scheduler, custom_funct={'plot': fk_plt.plot_freesurface_3d},
value = 50. return value def Rho_0(x, y): if x < GATE_POSITION: T = 10 value = Rho_sea_water(T, 0.) else: T = 50. value = Rho_sea_water(T, 0.) return value if PHY_PARAMS['variable_density_model'] == 'boussinesq': primitives = fk.Primitive(triangular_mesh, layer, free_surface=2.0) tracers = [fk.Tracer(triangular_mesh, layer, primitives, Tinit_funct=T_0, label='temperature', horizontal_diffusivity=0.0, vertical_diffusivity=0.0)] elif PHY_PARAMS['variable_density_model'] == 'ns-fourier': primitives = fk.Primitive(triangular_mesh, layer, free_surface=2.0, Rhoinit_funct=Rho_0) tracers = [] ################################################################################ # # Custom functions: #---------------------- # def compute_volume(problem): HL = problem.primitives.HL
if x < -1.5: t = 35.0 else: t = 0.0 return t #Plot initial free surface in (x,z) slice plane: if not args.nographics: fk_plt.plot_init_1d_slice(triangular_mesh, surf_xy=eta_0, topo_xy=Topography, primitive_xy=T_0) primitives = fk.Primitive(triangular_mesh, layer, free_surface_funct=eta_0) tracers = [fk.Tracer(triangular_mesh, layer, primitives, Tinit_funct=T_0)] ################################################################################ # # Boundary conditions: #--------------------- slides = [fk.Slide(ref=1), fk.Slide(ref=3)] torrential_outs = [fk.TorrentialOut(ref=2)] tube = fk.RectangularTube(xlim=(0.0, 4.0), ylim=(0.0, 6.0), zlim=(0.0, 6.0)) flowrate = fk.TimeDependentFlowRate(times=[0.0, 0.0], flowrates=[0.0, 0.0]) fluvial_flowrates = [ fk.FluvialFlowRate(ref=4, time_dependent_flowrate=flowrate, rectangular_tube=tube, x_flux_direction=1.0,
return value def T_0(x, y): if x < GATE_POSITION: value = 10. else: value = 4. return value tracers = [ fk.Tracer(triangular_mesh, layer, primitives, Tinit_funct=T_0, label='temperature', horizontal_diffusivity=1.777e-9, vertical_diffusivity=1.777e-9), fk.Tracer(triangular_mesh, layer, primitives, Tinit_funct=S_0, label='salinity', horizontal_diffusivity=1.e-10, vertical_diffusivity=1.e-10) ] ################################################################################ # # External effects (tracer source terms):
# # Primitives: #-------------------- primitives = fk.Primitive(triangular_mesh, layer, free_surface=.5) ################################################################################ # # Tracer: #-------------------- # tracers = [ fk.Tracer(triangular_mesh, layer, primitives, Tinit=0.0, label='temperature') ] ################################################################################ # # Boundary conditions: #--------------------- # #``VerticalFlowRate`` boundary conditions consist of imposing vertical flowrate at the #bottom on designated cells. In case of inlet you can also impose a Tracer value. #If more than one cell is selected, imposed flowrate is shared based on cell area. #As any other boundary condition, there can be as much ``VerticalFlowRate`` as needed #as long as they are defined in a **list**.
#-------------------- # NC = triangular_mesh.NV T_0 = np.zeros((NC, NL)) Lm = int(6 * NL / 10) for C in range(NC): for L in range(NL): T_0[C, L] = 0.1 + 0.65 * np.exp(-(L - Lm)**2 / 20.) tracers = [ fk.Tracer(triangular_mesh, layer, primitives, Tinit=T_0, label='suspension', horizontal_diffusivity=0.0, vertical_diffusivity=0.0, settling_velocity=SETTLING_VELOCITY) ] ################################################################################ # # Boundary conditions: #--------------------- slides = [fk.Slide(ref=r) for r in [1, 2, 3, 4]] ################################################################################ # # Wind forcing: