timprove time step computing functionality - sphere - GPU-based 3D discrete ele… | |
git clone git://src.adamsgaard.dk/sphere | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit ee64f1bd2468ca535b33b83acdc78b83eacf615b | |
parent 76aef1aad86deca7d2cb55dd3967abdc91ac30ba | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 6 Nov 2014 10:15:05 +0100 | |
improve time step computing functionality | |
Diffstat: | |
M python/halfshear-darcy-starter.py | 9 +++++++-- | |
M python/sphere.py | 37 ++++++-----------------------… | |
2 files changed, 14 insertions(+), 32 deletions(-) | |
--- | |
diff --git a/python/halfshear-darcy-starter.py b/python/halfshear-darcy-starter… | |
t@@ -34,7 +34,7 @@ sim.cleanup() | |
sim.adjustUpperWall() | |
sim.zeroKinematics() | |
-sim.shear(1.0/20.0) | |
+#sim.shear(0.0/20.0) | |
if fluid: | |
#sim.num[2] *= 2 | |
t@@ -49,13 +49,18 @@ if fluid: | |
sim.beta_f[0] = mu | |
sim.k_c[0] = k_c | |
-sim.initTemporal(total = 20.0, file_dt = 0.01, epsilon=0.07) | |
sim.w_devs[0] = sigma0 | |
sim.w_m[0] = numpy.abs(sigma0*sim.L[0]*sim.L[1]/sim.g[2]) | |
+ | |
+sim.setStiffnessNormal(36.4e9) | |
+sim.setStiffnessTangential(36.4e9/3.0) | |
sim.mu_s[0] = 0.5 | |
sim.mu_d[0] = 0.5 | |
sim.setDampingNormal(0.0) | |
sim.setDampingTangential(0.0) | |
+sim.deleteAllParticles() | |
+ | |
+sim.initTemporal(total = 20.0, file_dt = 0.01, epsilon=0.07) | |
# Fix lowermost particles | |
#dz = sim.L[2]/sim.num[2] | |
diff --git a/python/sphere.py b/python/sphere.py | |
t@@ -2886,7 +2886,9 @@ class sim: | |
if (self.np[0] > 0): | |
print("Warning: Manually specifying the time step length when " | |
+ "simulating particles may produce instabilities.") | |
- else: | |
+ | |
+ elif self.np[0] > 0: | |
+ | |
r_min = numpy.min(self.radius) | |
m_min = self.rho * 4.0/3.0*numpy.pi*r_min**3 | |
k_max = numpy.max([self.k_n[:], self.k_t[:]]) | |
t@@ -2902,36 +2904,11 @@ class sim: | |
# Check numerical stability of the fluid phase, by criteria derived by | |
# von Neumann stability analysis of the diffusion and advection terms | |
- if self.fluid: | |
+ elif self.fluid: | |
+ self.time_dt[0] = self.largestFluidTimeStep(safety = 0.5) | |
- # Cell spacing | |
- dx = numpy.amin((\ | |
- self.L[0]/self.num[0],\ | |
- self.L[1]/self.num[1],\ | |
- self.L[2]/self.num[2])) | |
- | |
- # Diffusion term | |
- if (self.mu[0]*self.time_dt[0]/(dx**2) > 0.5): | |
- raise Exception("Error: The time step is too large to ensure " | |
- + "stability in the diffusive term of the fluid " | |
- + "momentum equation.") | |
- | |
- # Normalized velocities | |
- v_norm = numpy.empty(self.num[0]*self.num[1]*self.num[2]) | |
- idx = 0 | |
- for x in numpy.arange(self.num[0]): | |
- for y in numpy.arange(self.num[1]): | |
- for z in numpy.arange(self.num[2]): | |
- v_norm[idx] = numpy.sqrt(self.v_f[x,y,z,:].dot(\ | |
- self.v_f[x,y,z,:])) | |
- idx += 1 | |
- | |
- # Advection term. This term has to be reevaluated during the | |
- # computations, as the fluid velocity changes. | |
- if (numpy.amax(v_norm)*self.time_dt[0]/dx > 1.0): | |
- raise Exception("Error: The time step is too large to ensure " | |
- + "stability in the advective term of the fluid " | |
- + "momentum equation.") | |
+ else: | |
+ raise Exception('Error: Could not automatically set a time step.') | |
# Time at start | |
self.time_current[0] = current |