tnew helper functions for energy tracking - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
(HTM) git clone git://src.adamsgaard.dk/sphere
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit fa19daa9878b41a8e6cf6dc0c101d565cefed309
(DIR) parent e5af8fea4a63f670be8409f2531f04d9e57c7150
(HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Fri, 20 Jun 2014 11:27:07 +0200
new helper functions for energy tracking
Diffstat:
M python/sphere.py | 42 +++++++++++++++++++++++++++++++
M src/contactmodels.cuh | 3 +++
2 files changed, 45 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/python/sphere.py b/python/sphere.py
t@@ -2664,6 +2664,48 @@ class sim:
'''
return w_devs[0] + w_devs_A*numpy.sin(2.0*numpy.pi*self.time_current)
+ def volume(self, idx):
+ '''
+ Returns the volume of a particle.
+
+ :param idx: Particle index
+ :type idx: int
+ :returns: The volume of the particle [m^3]
+ '''
+ return V_sphere(self.radius[idx])
+
+ def mass(self, idx):
+ '''
+ Returns the mass of a particle.
+
+ :param idx: Particle index
+ :type idx: int
+ :returns: The mass of the particle [kg]
+ '''
+ return self.rho[0]*self.volume(idx)
+
+ def kineticEnergy(self, idx):
+ '''
+ Returns the kinetic energy for a particle.
+
+ :param idx: Particle index
+ :type idx: int
+ :returns: The kinetic energy of the particle [J]
+ '''
+ return 0.5*self.mass(idx) \
+ *numpy.sqrt(numpy.dot(self.vel[idx,:], self.vel[idx,:]))**2
+
+ def totalKineticEnergy(self):
+ '''
+ Returns the total kinetic energy for all particles.
+
+ :returns: The kinetic energy of all particles [J]
+ '''
+ esum = 0.0
+ for i in range(self.np):
+ esum += kineticEnergy(i)
+ return esum
+
def energy(self, method):
'''
Calculates the sum of the energy components of all particles.
(DIR) diff --git a/src/contactmodels.cuh b/src/contactmodels.cuh
t@@ -309,6 +309,9 @@ __device__ void contactLinear(Float3* F, Float3* T,
Float4 vel_b = dev_vel[idx_b_orig];
Float4 angvel4_b = dev_angvel[idx_b_orig];
+ //printf("\n[%d,%d] vel = [+%e +%e]",
+ //idx_a_orig, idx_b_orig, vel_a, vel_b);
+
// Fetch previous sum of shear displacement for the contact pair
Float4 delta_t0_4 = dev_delta_t[mempos];