~ubuntu-branches/debian/jessie/yade/jessie

« back to all changes in this revision

Viewing changes to examples/sph/dam_break.py

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-10-20 21:31:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20141020213137-wt0doalgtw493ohd
Tags: 1.12.0-1
* [3bba065] Imported Upstream version 1.12.0. (Closes: #763259)
* [1ac4c00] Remove patch applied by upstream.
* [0b5f802] Set Standards-Version: 3.9.6. No changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# encoding: utf-8
 
3
 
 
4
from yade import utils, plot, qt
 
5
o = Omega()
 
6
 
 
7
# Physical parameters
 
8
fr = 0.5;
 
9
rho= 1000.0
 
10
 
 
11
k = 1000.0
 
12
mu = 10.0
 
13
tc = 0.01; en = 0.7; et = 0.7;
 
14
vel = 0.0
 
15
 
 
16
#Rad = 0.006
 
17
#h = 0.011
 
18
 
 
19
Rad = 0.015
 
20
h = 0.03
 
21
 
 
22
#Rad = 0.02
 
23
#h = 0.04
 
24
 
 
25
o.dt = 0.0005
 
26
 
 
27
X = 4.0
 
28
Z = 3.0
 
29
yCoeff = 4.0
 
30
 
 
31
SpheresX = 1.0
 
32
SpheresZ = 2.0
 
33
 
 
34
# Add material
 
35
mat1 = O.materials.append(ViscElMat(frictionAngle=fr,density=rho, SPHmode=True, h=h, mu=mu,tc=tc, en=en, et=et, KernFunctionPressure = 1, KernFunctionVisco = 1))
 
36
idBox = pack.regularHexa(pack.inAlignedBox((0.0,-Rad*yCoeff,0.0),(X,Rad*yCoeff,Z)),radius=Rad,gap=0.0,color=(0,1,1), material=mat1, mask = 1, fixed=True)
 
37
 
 
38
idBoxAdd = []
 
39
idSpheresAdd = []
 
40
 
 
41
for i in range(len(idBox)):
 
42
  if (((idBox[i].state.pos[0])<yCoeff*Rad) or
 
43
      ((idBox[i].state.pos[0])>(X-yCoeff*Rad - 2.0*Rad)) or
 
44
      ((idBox[i].state.pos[2])<(yCoeff*Rad)) or
 
45
      ((idBox[i].state.pos[2])>(Z - 2.0*Rad))):
 
46
    idBoxAdd.append(idBox[i])
 
47
  elif (((idBox[i].state.pos[0])<SpheresX) and
 
48
        ((idBox[i].state.pos[2])<SpheresZ) and
 
49
        ((idBox[i].state.pos[1])>-Rad) and
 
50
        ((idBox[i].state.pos[1])<2.0*Rad)):
 
51
          idBox[i].shape.color = Vector3(1,0,0)
 
52
          idBox[i].state.fixed = False
 
53
          idBox[i].state.blockedDOFs = 'y'
 
54
          idSpheresAdd.append(idBox[i])
 
55
    
 
56
 
 
57
 
 
58
O.bodies.append(idBoxAdd)
 
59
idSpheres = O.bodies.append(idSpheresAdd)
 
60
 
 
61
    
 
62
# Add engines
 
63
o.engines = [
 
64
  ForceResetter(),
 
65
  InsertionSortCollider([Bo1_Sphere_Aabb(label='is2aabb')],ompThreads=1),
 
66
  InteractionLoop(
 
67
    [Ig2_Sphere_Sphere_ScGeom(label='ss2sc')],
 
68
    [Ip2_ViscElMat_ViscElMat_ViscElPhys()],
 
69
    [Law2_ScGeom_ViscElPhys_Basic()],
 
70
  ),
 
71
  NewtonIntegrator(damping=0.01,gravity=[0,0,-9.81]),
 
72
  SPHEngine(mask=1, k=k, rho0 = rho, h=h, KernFunctionDensity= 1),
 
73
  PyRunner(command='addPlotData()',iterPeriod=10,initRun=True,dead=False),
 
74
]
 
75
 
 
76
enlargeF = h/Rad*1.1
 
77
print "enlargeF = %g"%enlargeF
 
78
is2aabb.aabbEnlargeFactor = enlargeF
 
79
ss2sc.interactionDetectionFactor = enlargeF
 
80
 
 
81
 
 
82
# Function to add data to plot
 
83
def addPlotData(): 
 
84
  plot.addData(t = O.time, eKin = utils.kineticEnergy())
 
85
  
 
86
plot.plots={'t':('eKin')};
 
87
plot.plot()
 
88
 
 
89
qt.View()