URI:
       common.py - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
  HTML git clone git://src.adamsgaard.dk/sphere
   DIR Log
   DIR Files
   DIR Refs
   DIR LICENSE
       ---
       common.py (1323B)
       ---
            1 import math
            2 import numpy
            3 
            4 try:
            5     import matplotlib
            6     matplotlib.use('Agg')
            7     import matplotlib.pyplot as plt
            8     import matplotlib.collections
            9     matplotlib.rcParams.update({'font.size': 7, 'font.family': 'serif'})
           10     matplotlib.rc('text', usetex=True)
           11     matplotlib.rcParams['text.latex.preamble'] = r"\usepackage{amsmath}"
           12     from matplotlib.font_manager import FontProperties
           13     py_mpl = True
           14 except ImportError:
           15     print('Info: Could not find "matplotlib" python module. ' +
           16           'Plotting functionality will be unavailable')
           17     py_mpl = False
           18     matplotlib = None
           19     plt = None
           20     FontProperties = None
           21 try:
           22     import vtk
           23     py_vtk = True
           24 except ImportError:
           25     print('Info: Could not find "vtk" python module. ' +
           26           'Fluid VTK calls will be unavailable')
           27     print('Consider installing with `pip install --user vtk`')
           28     py_vtk = False
           29     vtk = None
           30 
           31 # mutates process-global numpy error handling
           32 numpy.seterr(all='warn', over='raise')
           33 
           34 # Sphere version number. This field should correspond to the value in
           35 # `../src/version.h`.
           36 VERSION = 2.15
           37 
           38 # Transparency on plot legends
           39 legend_alpha = 0.5
           40 
           41 
           42 def V_sphere(r):
           43     '''
           44     Calculates the volume of a sphere with radius r
           45 
           46     :returns: The sphere volume [m^3]
           47     :return type: float
           48     '''
           49     return 4.0/3.0 * math.pi * r**3.0