@@ -12,7 +12,7 @@ using OrdinaryDiffEq
1212
1313# ==========================================================================================
1414# ==== Resolution
15- particle_spacing = 0.05
15+ particle_spacing = 0.02
1616
1717# Make sure that the kernel support of fluid particles at a boundary is always fully sampled
1818boundary_layers = 4
@@ -21,7 +21,7 @@ boundary_layers = 4
2121# fully sampled.
2222# Note: Due to the dynamics at the inlets and outlets of open boundaries,
2323# it is recommended to use `open_boundary_layers > boundary_layers`
24- open_boundary_layers = 8
24+ open_boundary_layers = 6
2525
2626# ==========================================================================================
2727# ==== Experiment Setup
@@ -30,65 +30,71 @@ tspan = (0.0, 2.0)
3030# Boundary geometry and initial fluid particle positions
3131domain_size = (1.0 , 0.4 )
3232
33- flow_direction = [1.0 , 0.0 ]
3433reynolds_number = 100
35- const prescribed_velocity = 2.0
34+ const prescribed_velocity = (1.0 , 0.0 )
35+ flow_direction = [1.0 , 0.0 ]
3636
37- boundary_size = (domain_size[1 ] + 2 * particle_spacing * open_boundary_layers,
38- domain_size[2 ])
37+ open_boundary_size = (particle_spacing * open_boundary_layers, domain_size[2 ])
3938
4039fluid_density = 1000.0
4140
42- # For this particular example, it is necessary to have a background pressure.
43- # Otherwise the suction at the outflow is to big and the simulation becomes unstable.
44- pressure = 1000.0
45-
46- sound_speed = 20 * prescribed_velocity
47-
48- state_equation = nothing
41+ sound_speed = 10 * maximum (abs .(prescribed_velocity))
4942
50- pipe = RectangularTank (particle_spacing, domain_size, boundary_size , fluid_density,
51- pressure = pressure, n_layers = boundary_layers ,
43+ pipe = RectangularTank (particle_spacing, domain_size, domain_size , fluid_density,
44+ n_layers = boundary_layers, velocity = prescribed_velocity ,
5245 faces= (false , false , true , true ))
5346
54- # Shift pipe walls in negative x-direction for the inflow
55- pipe. boundary. coordinates[1 , :] .- = particle_spacing * open_boundary_layers
47+ min_coords_inlet = (- open_boundary_layers * particle_spacing, 0.0 )
48+ inlet = RectangularTank (particle_spacing, open_boundary_size, open_boundary_size,
49+ fluid_density, n_layers= boundary_layers,
50+ min_coordinates= min_coords_inlet,
51+ faces= (false , false , true , true ))
52+
53+ min_coords_outlet = (pipe. fluid_size[1 ], 0.0 )
54+ outlet = RectangularTank (particle_spacing, open_boundary_size, open_boundary_size,
55+ fluid_density, n_layers= boundary_layers,
56+ min_coordinates= min_coords_outlet,
57+ faces= (false , false , true , true ))
5658
5759NDIMS = ndims (pipe. fluid)
5860
59- n_buffer_particles = 5 * pipe. n_particles_per_dimension[2 ]^ (NDIMS - 1 )
61+ n_buffer_particles = 10 * pipe. n_particles_per_dimension[2 ]^ (NDIMS - 1 )
6062
6163# ==========================================================================================
6264# ==== Fluid
63- wcsph = false
65+ wcsph = true
6466
6567smoothing_length = 1.5 * particle_spacing
6668smoothing_kernel = WendlandC2Kernel {NDIMS} ()
6769
6870fluid_density_calculator = ContinuityDensity ()
6971
70- kinematic_viscosity = prescribed_velocity * domain_size[2 ] / reynolds_number
72+ kinematic_viscosity = maximum ( prescribed_velocity) * domain_size[2 ] / reynolds_number
7173
7274viscosity = ViscosityAdami (nu= kinematic_viscosity)
7375
74- fluid_system = EntropicallyDampedSPHSystem (pipe. fluid, smoothing_kernel, smoothing_length,
75- sound_speed, viscosity= viscosity,
76- density_calculator= fluid_density_calculator,
77- shifting_technique= ParticleShiftingTechnique (),
78- buffer_size= n_buffer_particles)
79-
8076# Alternatively the WCSPH scheme can be used
8177if wcsph
8278 state_equation = StateEquationCole (; sound_speed, reference_density= fluid_density,
83- exponent= 1 , background_pressure= pressure)
84- alpha = 8 * kinematic_viscosity / (smoothing_length * sound_speed)
85- viscosity = ArtificialViscosityMonaghan (; alpha, beta= 0.0 )
79+ exponent= 1 )
80+ density_diffusion = DensityDiffusionMolteniColagrossi (delta= 0.1 )
8681
8782 fluid_system = WeaklyCompressibleSPHSystem (pipe. fluid, fluid_density_calculator,
8883 state_equation, smoothing_kernel,
84+ density_diffusion= density_diffusion,
8985 smoothing_length, viscosity= viscosity,
9086 shifting_technique= ParticleShiftingTechnique (),
9187 buffer_size= n_buffer_particles)
88+ else
89+ # Alternatively the EDAC scheme can be used
90+ state_equation = nothing
91+
92+ fluid_system = EntropicallyDampedSPHSystem (pipe. fluid, smoothing_kernel,
93+ smoothing_length, sound_speed,
94+ viscosity= viscosity,
95+ density_calculator= fluid_density_calculator,
96+ shifting_technique= ParticleShiftingTechnique (),
97+ buffer_size= n_buffer_particles)
9298end
9399
94100# ==========================================================================================
@@ -98,63 +104,61 @@ function velocity_function2d(pos, t)
98104 # Use this for a time-dependent inflow velocity
99105 # return SVector(0.5prescribed_velocity * sin(2pi * t) + prescribed_velocity, 0)
100106
101- return SVector (prescribed_velocity, 0.0 )
107+ return SVector (prescribed_velocity)
102108end
103109
104- open_boundary_model = BoundaryModelLastiwka ( )
110+ open_boundary_model = BoundaryModelMirroringTafuni (; mirror_method = ZerothOrderMirroring () )
105111
112+ reference_velocity_in = velocity_function2d
113+ reference_pressure_in = nothing
114+ reference_density_in = nothing
106115boundary_type_in = InFlow ()
107116plane_in = ([0.0 , 0.0 ], [0.0 , domain_size[2 ]])
108117inflow = BoundaryZone (; plane= plane_in, plane_normal= flow_direction, open_boundary_layers,
109118 density= fluid_density, particle_spacing,
110- boundary_type= boundary_type_in)
111-
112- reference_velocity_in = velocity_function2d
113- reference_pressure_in = pressure
114- reference_density_in = fluid_density
115- open_boundary_in = OpenBoundarySPHSystem (inflow; fluid_system,
116- boundary_model= open_boundary_model,
117- buffer_size= n_buffer_particles,
118- reference_density= reference_density_in,
119- reference_pressure= reference_pressure_in,
120- reference_velocity= reference_velocity_in)
121-
119+ reference_density= reference_density_in,
120+ reference_pressure= reference_pressure_in,
121+ reference_velocity= reference_velocity_in,
122+ initial_condition= inlet. fluid, boundary_type= boundary_type_in)
123+
124+ reference_velocity_out = nothing
125+ reference_pressure_out = nothing
126+ reference_density_out = nothing
122127boundary_type_out = OutFlow ()
123- plane_out = ([domain_size [1 ], 0.0 ], [domain_size [1 ], domain_size[2 ]])
128+ plane_out = ([min_coords_outlet [1 ], 0.0 ], [min_coords_outlet [1 ], domain_size[2 ]])
124129outflow = BoundaryZone (; plane= plane_out, plane_normal= (- flow_direction),
125130 open_boundary_layers, density= fluid_density, particle_spacing,
126- boundary_type= boundary_type_out)
127-
128- reference_velocity_out = velocity_function2d
129- reference_pressure_out = pressure
130- reference_density_out = fluid_density
131- open_boundary_out = OpenBoundarySPHSystem (outflow; fluid_system,
132- boundary_model= open_boundary_model,
133- buffer_size= n_buffer_particles,
134- reference_density= reference_density_out,
135- reference_pressure= reference_pressure_out,
136- reference_velocity= reference_velocity_out)
131+ reference_density= reference_density_out,
132+ reference_pressure= reference_pressure_out,
133+ reference_velocity= reference_velocity_out,
134+ initial_condition= outlet. fluid, boundary_type= boundary_type_out)
135+
136+ open_boundary = OpenBoundarySPHSystem (inflow, outflow; fluid_system,
137+ boundary_model= open_boundary_model,
138+ buffer_size= n_buffer_particles)
139+
137140# ==========================================================================================
138141# ==== Boundary
139- viscosity_boundary = ViscosityAdami (nu= 1e-4 )
140- boundary_model = BoundaryModelDummyParticles (pipe. boundary. density, pipe. boundary. mass,
142+ wall = union (pipe. boundary, inlet. boundary, outlet. boundary)
143+ viscosity_boundary = viscosity
144+ boundary_model = BoundaryModelDummyParticles (wall. density, wall. mass,
141145 AdamiPressureExtrapolation (),
142146 state_equation= state_equation,
143147 viscosity= viscosity_boundary,
144148 smoothing_kernel, smoothing_length)
145149
146- boundary_system = BoundarySPHSystem (pipe . boundary , boundary_model)
150+ boundary_system = BoundarySPHSystem (wall , boundary_model)
147151
148152# ==========================================================================================
149153# ==== Simulation
150- min_corner = minimum (pipe . boundary . coordinates .- particle_spacing, dims= 2 )
151- max_corner = maximum (pipe . boundary . coordinates .+ particle_spacing, dims= 2 )
154+ min_corner = minimum (wall . coordinates .- particle_spacing, dims= 2 )
155+ max_corner = maximum (wall . coordinates .+ particle_spacing, dims= 2 )
152156
153157nhs = GridNeighborhoodSearch {NDIMS} (; cell_list= FullGridCellList (; min_corner, max_corner),
154158 update_strategy= ParallelUpdate ())
155159
156- semi = Semidiscretization (fluid_system, open_boundary_in, open_boundary_out ,
157- boundary_system, neighborhood_search= nhs,
160+ semi = Semidiscretization (fluid_system, open_boundary, boundary_system ,
161+ neighborhood_search= nhs,
158162 parallelization_backend= PolyesterBackend ())
159163
160164ode = semidiscretize (semi, tspan)
0 commit comments