Viscoelastic Fluid Simulation With Openfoam
Viscoelastic Fluid Simulation With Openfoam
τs = ηs γ(1) (2)
OBJECTIVE
The parameters used for the viscoelastic fluid are the F. Theoretical results
ones which will allow us to compare with the empirical
results for a specific viscoelastic fluid:
The theoretical result with which we will compare are
obtained by [2]:
Kg
λ = 1.9s ηp = 64 m·s kL cosh(ky)
v(y, ω) = dv (1 − ) (7)
kL − tanh(kL) cosh(kL)
ρ = 1050 Kg
m3
Kg
ηs = 0 m·s
v(y, t) = Re{v(y, ω) exp(iωt)} (8)
We will first simulate the linear case with α = 0 and p
then α = 0.85. with dv = z0 ω and k = (iωρ/η)(1 + iλω).
The amplitude we will use in our simulation is x0 = In figure [1] we can see the plot obtained with these
0.001m. equations for different frequencies.
There is no specific way in the references to calculate The x axis represents the position between the plane
the resonant frequencies but we can use the ones for a and the y axis the velocity.
3
H. Longitude analysis
CONCLUSIONS
boundary conditions of the pistons with the function in about the scientific method and the trial and error which
velocities. characterizes it. We would also like to thank L. Ramı́rez-
Finally we would like to that say we have learned a lot Piscina for conducting such an interesting project.
Introduction
In this annex, the most important code files are presented. They define the
properties of the fluid, the configuration of the simulation, the geomentry and
mesh used and the initial conditions.
λ = 1.9s.
1
29 {
30 solvePassiveScalar off ;
31 D D [ 0 2 −1 0 0 0 0 ] 1e−9;
32 }
33 // ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ //
The numbers between brackets define the units of each constant, they cor-
respond to [kg m s K mol A cd].
Initial conditions
0/
2
42 value uniform (0 0 0) ;
43 }
44
45 outlet
46 {
47 type codedFixedValue ;
48 value uniform (0 0 0) ;
49 redirectType smoothU ;
50 code
51 //Cosinusoidal
52 #{
53 const s c a l a r& t = this−>db( ) . time ( ) . timeOutputValue ( ) ;
54 vector Uav(1 , 0 , 0) ;
55 vector dirN (1 , 0 , 0) ;
56 Uav = ((0.001∗33.760313226149∗Foam : : cos (33.760313226149∗ t ) ) ∗ dirN ) ;
57 operator == (Uav) ;
58 #};
59 }
60
61 frontAndBack
62 {
63 type symmetry ;
64 }
65 }
66 // ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ //
Mesh properties
system/
In this folder we can find the file blockMeshDict which dictates the geometry
in which the simulation will take place.
1 /∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗− C++ −∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗\
2 | ========= | |
3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
4 | \\ / O peration | Version : 4.0 |
5 | \\ / A nd | Web: www.OpenFOAM. org |
6 | \\/ M anipulation | |
7 \∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗/
8 FoamFile
9 {
10 version 2.0;
11 format ascii ;
12 class dictionary ;
13 object blockMeshDict ;
14 }
15 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //
16
17 convertToMeters 0 . 1 ;
18
19 vertices
20 (
21 (0 −0.25 −0.25)
22 (3 −0.25 −0.25)
23 (3 0.25 −0.25)
24 (0 0.25 −0.25)
25 (0 −0.25 0.25)
26 (3 −0.25 0.25)
27 (3 0.25 0.25)
28 (0 0.25 0.25)
29 );
30
3
31 blocks
32 (
33 hex (0 1 2 3 4 5 6 7) (50 60 12) simpleGrading (1 1 1) //0
34 );
35
36 edges
37 (
38 );
39
40 boundary
41 (
42 inlet
43 {
44 type patch ;
45 faces
46 (
47 (0 4 7 3)
48 );
49 }
50
51 outlet
52 {
53 type patch ;
54 faces
55 (
56 (1 2 6 5)
57 );
58 }
59
60 walls
61 {
62 type wall ;
63 faces
64 (
65 (2 3 7 6)
66 (0 1 5 4)
67 );
68 }
69
70 frontAndBack
71 {
72 type symmetry ;
73 faces
74 (
75 (4 5 6 7)
76 (1 0 3 2)
77 );
78 }
79 );
80
81 mergePatchPairs
82 (
83 );
84 // ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ //
4
Simulation parameters
system/
Also, in folder system we can find the file controlDict which dictates the
parameters of the the simulation in itself. Here you can configure the initial and
final times, the time-step and personalized functions in order to retrieve data
from the raw files.
1 /∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗− C++ −∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗\
2 | ========= | |
3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
4 | \\ / O peration | Version : 4.0 |
5 | \\ / A nd | Web: www.OpenFOAM. org |
6 | \\/ M anipulation | |
7 \∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗/
8 FoamFile
9 {
10 version 2.0;
11 format ascii ;
12 class dictionary ;
13 object controlDict ;
14 }
15 // ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ //
16
17 application rheoFoam ;
18
19 startFrom startTime ;
20 startTime 0;
21
22 stopAt endTime ;
23 endTime 0.95;
24
25 deltaT 0.0002;
26
27 writeControl timeStep ;
28 writeInterval 1;
29 purgeWrite 0;
30 writeFormat ascii ;
31 writePrecision 12;
32 writeCompression compressed ;
33 timeFormat general ;
34 timePrecision 10;
35 graphFormat raw ;
36 runTimeModifiable no ;
37 adjustTimeStep o f f ;
38 maxCo 0.1;
39 maxDeltaT 0.01;
40
41 functions
42 {
43 #includeFunc singleGraph
44 }
45 // ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ //
In this case we start the simulation at time 0s and end it at time 0.95s using
a time-step of 0.0002s. Moreover, the function singleGraph can be found in
another file in the same folder, and is the one that retrieves the data of the
velocity profiles:
5
1 /∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗− C++ −∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | Web: www.OpenFOAM. org
6 \\/ M anipulation |
7 −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
8 Description
9 Writes graph data f o r s p e c i f i e d f i e l d s along a l i n e , s p e c i f i e d by s t a r t
10 and end points .
11 \∗−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−∗/
12
13 start (0.15 −0.025 0) ;
14 end (0.15 0.025 0) ;
15 fields (U) ;
16
17 // Sampling and I /O s e t t i n g s
18 #includeEtc ” caseDicts/postProcessing/graphs/sampleDict . cfg ”
19
20 // Override s e t t i n g s here , e . g .
21 // setConfig { type midPoint ; }
22
23 // Must be l a s t entry
24 #includeEtc ” caseDicts/postProcessing/graphs/graph . cfg ”
25 // ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ //
Although there are many more files in each OpenFOAM case, those where
the most important and the only ones we had to modify to make one simulation
or another.
6
ANNEX II
Adrià Barja Romero and Joan Marco Rimmek
May 2017
Introduction
In this annex images and plots obtained from the simulation are present.
Grid
The grid we used in our simulations, which is 0.3m long and has 60 divisions in
the x axis, is 0.05m long and has 60 divisions in the y axis and is 0.05m long
and has 16 divisions in the z axis.
1
Post-processed simulations