-
Notifications
You must be signed in to change notification settings - Fork 2
/
TimeIntegrationDEM.py
72 lines (57 loc) · 2.44 KB
/
TimeIntegrationDEM.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import taichi as ti
import time
import EulerAlgorithm as EulerAlgorithm
import VerletAlgorithm as VerletAlgorithm
import Graphic as graphic
import Spying as spy
def Output(t, step, printNum, dem, start, vtkPath, ascPath):
print('------------------------ Time Step = ', step, '------------------------')
print('Simulation time = ', t)
print('Time step = ', dem.Dt[None])
print('Physical time = ', time.time() - start)
graphic.WriteFileVTK_DEM(dem.lp, printNum, vtkPath)
spy.MonitorDEM(t, dem.lp, printNum, ascPath)
print('------------------------------- Running --------------------------------')
# Solvers
def Solver(dem, TIME, saveTime, CFL, vtkPath, ascPath, adaptive):
if dem.Algorithm == 0:
SolverEuler(dem, TIME, saveTime, CFL, vtkPath, ascPath, adaptive)
elif dem.Algorithm == 1:
SolverVerlet(dem, TIME, saveTime, CFL, vtkPath, ascPath, adaptive)
# --------------------------------------- Euler Algorithm ----------------------------------------- #
def SolverEuler(dem, TIME, saveTime, CFL, vtkPath, ascPath, adaptive):
t, step, printNum = 0., 0, 0
st = time.time()
while t <= TIME:
if t == 0:
Output(t, step, printNum, dem, st, vtkPath, ascPath)
printNum += 1
EulerAlgorithm.UpdatePosition(dem)
EulerAlgorithm.NeighborSearching(dem)
EulerAlgorithm.ContactCal(dem)
EulerAlgorithm.UpdateVelocity(dem)
EulerAlgorithm.UpdateAngularVelocity(dem, t)
if t % saveTime < dem.Dt[None]:
Output(t, step, printNum, dem, st, vtkPath, ascPath)
printNum += 1
t += dem.Dt[None]
step += 1
# --------------------------------------- Verlet Algorithm ----------------------------------------- #
def SolverVerlet(dem, TIME, saveTime, CFL, vtkPath, ascPath, adaptive):
t, step, printNum = 0., 0, 0
st = time.time()
while t <= TIME:
if t == 0:
Output(t, step, printNum, dem, st, vtkPath, ascPath)
printNum += 1
VerletAlgorithm.UpdateQuaternion(dem)
VerletAlgorithm.NeighborSearching(dem)
VerletAlgorithm.ContactCal(dem)
VerletAlgorithm.UpdateVelocity(dem)
VerletAlgorithm.UpdateAngularVelocity(dem)
VerletAlgorithm.UpdatePosition(dem)
if t % saveTime < dem.Dt[None]:
Output(t, step, printNum, dem, st, vtkPath, ascPath)
printNum += 1
t += dem.Dt[None]
step += 1