liqDrop.py 3.31 KB
Newer Older
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
1
# MigFlow - Copyright (C) <2010-2020>
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
2
3
# <Universite catholique de Louvain (UCL), Belgium
#  Universite de Montpellier, France>
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
4
# 	List of the contributors to the development of MigFlow: see AUTHORS file.
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Description and complete License: see LICENSE file.
# 	
# This program (MigFlow) is free software: 
# you can redistribute it and/or modify it under the terms of the GNU Lesser General 
# Public License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public License
# along with this program (see COPYING and COPYING.LESSER files).  If not, 
# see <http://www.gnu.org/licenses/>.

#!/usr/bin/env python
from migflow import fluid
from migflow import scontact
Nathan Coppin's avatar
Nathan Coppin committed
24
from migflow import time_integration
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

import numpy as np
import os
import time
import shutil
import random

outputdir = "output"
if not os.path.isdir(outputdir) :
    os.makedirs(outputdir)

t = 0
ii = 0


#physical parameters
Matthieu Constant's avatar
Matthieu Constant committed
41
g =  0#-9.81                
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
42
43
44
rhof = 1030                                      # fluid density
rhop = 2450                                     # grains density
r=154e-6                                        # grains radii
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
45
R = 0.01                                      # drop radius
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
compacity = .20                                 # solid volume fraction in the drop
phi = 1 - compacity
nuf = 1.17/rhof                                   # kinematic viscosity
muf = nuf*rhof                                     # dynamic viscosity

##mixture properties
rhom = (1-phi)*rhop+phi*rhof                   #mixture density
num = nuf*(1+5/2*phi)                          #Einstein viscosity

print("rhom = %g, num = %g" % (rhom,num))


#numerical parameters
tEnd = 200                                     # final time
60
dt = 1e-2                                       # time step
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
61
outf = 5                                       # number of iterations between output files
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
62
63
64
65
66

def outerBndV(x) :
    print(.4*max(np.sin(t*np.pi*2./1),0))
    return 0.4*max(np.sin(t*np.pi*2./1),0)

Matthieu Constant's avatar
Matthieu Constant committed
67
fluid = fluid.FluidProblem(2,g,[nuf*rhof,num*rhom],[rhof,rhom],coeff_stab=1e-6)
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
68
69
70
71
72
73
74
75
76
77
78
fluid.load_msh("mesh.msh")
fluid.set_wall_boundary("Bottom")
fluid.set_wall_boundary("Lateral")
fluid.set_wall_boundary("Top",pressure=0)
ii = 0
t = 0

s = fluid.solution()
c = np.ndarray((fluid.n_nodes()))
x = fluid.coordinates()

Matthieu Constant's avatar
Matthieu Constant committed
79
80
81
82
83
84
c[:] = 1
c[np.logical_and(np.abs(x[:,0])< R,np.abs(x[:,1])<R)] = 0
#for i in range(len(x[:,0])):
#    z = (x[i,0])**2+(x[i,1])**2
#    R1 = (0.7*R)**2
#    R2 = (1.3*R)**2
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
85
#    #s[i,1] = -0.01
Matthieu Constant's avatar
Matthieu Constant committed
86
#    c[i] = min(max(0,1/(R2-R1)*z-R1/(R2-R1)),1)
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
87
88
89
90
91
92

fluid.set_concentration_cg(c)


#set initial_condition

Nathan Coppin's avatar
Nathan Coppin committed
93
fluid.write_vtk(outputdir,0,0)
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
94
95
96
97
98

ii = 0
tic = time.time()
while t < tEnd : 
    #Fluid solver
Nathan Coppin's avatar
Nathan Coppin committed
99
    time_integration.iterate(fluid,None,dt)
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
100
101
    #if (ii%11==0 and ii != 0):
    #  fluid.adapt_mesh(1e-2,1e-4,5000)
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
102
103
    t += dt
    #Output files writting
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
104
    print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
105
106
    if ii %outf == 0 :
        ioutput = int(ii/outf) + 1
Nathan Coppin's avatar
Nathan Coppin committed
107
        fluid.write_vtk(outputdir, ioutput, t)
Jonathan Lambrechts's avatar
broken  
Jonathan Lambrechts committed
108
    ii += 1