mill.py 4.57 KB
Newer Older
Nathan Coppin's avatar
Nathan Coppin committed
1
# Migflow - Copyright (C) <2010-2018>
2
3
4
5
6
7
# <Universite catholique de Louvain (UCL), Belgium
#  Universite de Montpellier, France>
# 	
# List of the contributors to the development of Marblesbag: see AUTHORS file.
# Description and complete License: see LICENSE file.
# 	
Nathan Coppin's avatar
Nathan Coppin committed
8
# This program (Migflow) is free software: 
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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
Nathan Coppin's avatar
Nathan Coppin committed
23
from migflow import scontact
24
from migflow import fluid
Matthieu Constant's avatar
Matthieu Constant committed
25
from migflow import time_integration
26
27
28
29
30
31

import numpy as np
import os
import time
import shutil
import random
Nathan Coppin's avatar
mill    
Nathan Coppin committed
32
outputdir = "output"
33
34
35
if not os.path.isdir(outputdir) :
    os.makedirs(outputdir)

Matthieu Constant's avatar
Matthieu Constant committed
36

Nathan Coppin's avatar
Nathan Coppin committed
37
def genInitialPosition(filename, r, rout, rhop) :
Matthieu Constant's avatar
Matthieu Constant committed
38
39
40
41
42
43
44
45
46
    """Set all the particles centre positions and create the particles objects to add in the computing structure

    Keyword arguments:
    filename -- name of the output file
    r -- radius of the particles
    rout -- the outer radius of the geometry
    rin -- the inner radius of the geometry
    rhop -- the particles density
    """
Nathan Coppin's avatar
Nathan Coppin committed
47
    p = scontact.ParticleProblem(2)
48
    #Loading of the mesh.msh file specifying physical boundaries name and material
Nathan Coppin's avatar
mill    
Nathan Coppin committed
49
    p.load_msh_boundaries("mesh.msh", ["Outer","Top",],material="PVC")
50
    #Definition of the points where the grains are located
Nathan Coppin's avatar
Nathan Coppin committed
51
    x = np.arange(rout-1.2*r, -rout+1.2*r, -2*r*1.05)
52
53
54
    x, y = np.meshgrid(x, x)
    R2 = x**2 + y**2
    #condition to be inside the outer boundary
Nathan Coppin's avatar
Nathan Coppin committed
55
    keep = R2 < (rout - r*1.05)**2
56
57
58
59
    x = x[keep]
    y = y[keep]
    R2 = x**2 + y**2
    for i in range(x.shape[0]) :
Nathan Coppin's avatar
Nathan Coppin committed
60
61
        if y[i]<0.005:
            r1 = np.random.normal(r,0.05*r)
62
            #Addition of an particle object at each point
Nathan Coppin's avatar
mill    
Nathan Coppin committed
63
            p.add_particle((x[i], y[i]), r1, r1**2 * np.pi * rhop,"Glass");
64
65
66
67
68
    p.write_vtk(filename,0,0)

t = 0
ii = 0
#physical parameters
Nathan Coppin's avatar
Nathan Coppin committed
69
g    = -9.81                            # gravity
Nathan Coppin's avatar
mill    
Nathan Coppin committed
70
rhop = 2500                             # grains density
71
72
rho = 1000
nu = 1e-6
73
tEnd = 10                               # final time
74
75
76
77
78

#numerical parameters
dt = 1e-3                               # time step

#geometry parameters
Nathan Coppin's avatar
mill    
Nathan Coppin committed
79
80
rout = 0.05                             # outer radius
r  = 1e-3                               # grains radius
Matthieu Constant's avatar
Matthieu Constant committed
81
82
Fr = 8e-3				                # Froude number
v = 0.0715                              # Corresponding tangent velocity
83

84
shutil.copy("mesh.msh", outputdir +"/mesh.msh")
85

Matthieu Constant's avatar
Matthieu Constant committed
86
87
88
89
90
#
# PARTICLE PROBLEM
#
# Initialise particles
genInitialPosition(outputdir, r, rout, rhop)
Nathan Coppin's avatar
Nathan Coppin committed
91
p = scontact.ParticleProblem(2,True)
Matthieu Constant's avatar
Matthieu Constant committed
92
93
p.read_vtk(outputdir,0)
outf = 250                                       # number of iterations between output files
94
#Taking friction into account
Matthieu Constant's avatar
Matthieu Constant committed
95
96
97
98
99
p.set_friction_coefficient(.4,"Glass","Glass")   # between particles
p.set_friction_coefficient(.5,"Glass","PVC")     # between particles and boundaries

p.set_tangent_boundary_velocity("Outer",-v)      # setting the tangent velocity of the rotating mill
p.set_tangent_boundary_velocity("Top",-v)        # setting the tangent velocity of the rotating mill
100
101
102
103
104
105
106

#
# FLUID PROBLEM
#
fluid = fluid.FluidProblem(2,g,[nu*rho],[rho])
# Set the mesh geometry for the fluid computation
fluid.load_msh("mesh.msh")
Nathan Coppin's avatar
mill    
Nathan Coppin committed
107
108
109
fluid.set_strong_boundary("Outer",0,lambda x : (x[:,1]/rout)*-v )
fluid.set_strong_boundary("Outer",1,lambda x : (-x[:,0]/rout)*-v)
fluid.set_wall_boundary("Top",0)
110
# Set location of the grains in the mesh and compute the porosity in each computation cell
Nathan Coppin's avatar
mill    
Nathan Coppin committed
111
112
113
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces())
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity(),p.contact_forces())
fluid.solution()[:,2] = g*rho*(fluid.coordinates()[:,1] - rout/2)
114
fluid.export_vtk(outputdir, 0.,0)
115

116
117
G = np.zeros_like(p.velocity())
G[:,1] = p.mass()[:,0]*g
Matthieu Constant's avatar
Matthieu Constant committed
118
119
120
121

#
# COMPUTATION LOOP
#
122
while t < tEnd :
Matthieu Constant's avatar
Matthieu Constant committed
123
    time_integration.iterate(fluid, p, dt, min_nsub=15, external_particles_forces=G)
124
125
126
127
128
    t += dt
    #Output files writting
    if ii %outf == 0 :
        ioutput = int(ii/outf) + 1
        p.write_vtk(outputdir, ioutput, t)
129
        fluid.export_vtk(outputdir, t, ioutput)
130
    ii += 1