tadd zeroKinematics function - Granular.jl - Julia package for granular dynamics simulation
 (HTM) git clone git://src.adamsgaard.dk/Granular.jl
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 096493f9edeeac3865b46f0f99699401ac4a3622
 (DIR) parent 03f252d361bad9d81b06ea1643a28f95835bb337
 (HTM) Author: Anders Damsgaard <andersd@riseup.net>
       Date:   Mon,  6 Nov 2017 22:15:47 -0500
       
       add zeroKinematics function
       
       Diffstat:
         M src/grain.jl                        |      66 +++++++++++++++++++++++++++++++
         M test/grain.jl                       |      11 +++++++++++
       
       2 files changed, 77 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/grain.jl b/src/grain.jl
       t@@ -568,6 +568,8 @@ end
        
        export totalGrainKineticTranslationalEnergy
        """
       +    totalGrainKineticTranslationalEnergy(simulation)
       +
        Returns the sum of translational kinetic energies of all grains in a 
        simulation
        """
       t@@ -587,6 +589,8 @@ end
        
        export totalGrainKineticRotationalEnergy
        """
       +    totalGrainKineticRotationalEnergy(simulation)
       +
        Returns the sum of rotational kinetic energies of all grains in a simulation
        """
        function totalGrainKineticRotationalEnergy(simulation::Simulation)
       t@@ -761,3 +765,65 @@ function plotGrainSizeDistribution(simulation::Simulation;
                info(filename)
            end
        end
       +
       +export enableOceanDrag!
       +"""
       +    enableOceanDrag!(grain)
       +
       +Enable ocean-caused drag on the grain, with values by Hunke and Comeau (2011).
       +"""
       +function enableOceanDrag!(grain::GrainCylindrical)
       +    grain.ocean_drag_coeff_vert = 0.85
       +    grain.ocean_drag_coeff_horiz = 5e-4
       +end
       +
       +export enableAtmosphereDrag!
       +"""
       +    enableAtmosphereDrag!(grain)
       +
       +Enable atmosphere-caused drag on the grain, with values by Hunke and Comeau
       +(2011).
       +"""
       +function enableAtmosphereDrag!(grain::GrainCylindrical)
       +    grain.atmosphere_drag_coeff_vert = 0.4
       +    grain.atmosphere_drag_coeff_horiz = 2.5e-4
       +end
       +export disableOceanDrag!
       +"""
       +    disableOceanDrag!(grain)
       +
       +Disable ocean-caused drag on the grain.
       +"""
       +function disableOceanDrag!(grain::GrainCylindrical)
       +    grain.ocean_drag_coeff_vert = 0.
       +    grain.ocean_drag_coeff_horiz = 0.
       +end
       +
       +export disableAtmosphereDrag!
       +"""
       +    disableAtmosphereDrag!(grain)
       +
       +Disable atmosphere-caused drag on the grain.
       +"""
       +function disableAtmosphereDrag!(grain::GrainCylindrical)
       +    grain.atmosphere_drag_coeff_vert = 0.
       +    grain.atmosphere_drag_coeff_horiz = 0.
       +end
       +
       +export zeroKinematics!
       +"""
       +    zeroKinematics!(simulation)
       +
       +Set all grain forces, torques, accelerations, and velocities (linear and
       +rotational) to zero in order to get rid of all kinetic energy.
       +"""
       +function zeroKinematics!(sim::Simulation)
       +    for grian in sim.grains
       +        grain.lin_vel .= zeros(2)
       +        grain.lin_acc .= zeros(2)
       +        grain.force .= zeros(2)
       +        grain.ang_vel .= zeros(2)
       +        grain.ang_acc .= zeros(2)
       +        grain.torque .= zeros(2)
       +    end
       +end
 (DIR) diff --git a/test/grain.jl b/test/grain.jl
       t@@ -52,3 +52,14 @@ Granular.setBodyForce!(sim.grains[1], [1., 2.])
        Test.@test sim.grains[1].external_body_force ≈ [1., 2.]
        Granular.addBodyForce!(sim.grains[1], [1., 2.])
        Test.@test sim.grains[1].external_body_force ≈ [2., 4.]
       +
       +info("Testing zeroKinematics!")
       +sim.grains[1].force .= ones(2)
       +sim.grains[1].lin_acc .= ones(2)
       +sim.grains[1].lin_vel .= ones(2)
       +sim.grains[1].torque .= ones(2)
       +sim.grains[1].ang_acc .= ones(2)
       +sim.grains[1].ang_vel .= ones(2)
       +Granular.zeroKinematics!(sim)
       +Test.@test Grain.totalGrainKineticTranslationalEnergy(sim) ≈ 0.
       +Test.@test Grain.totalGrainKineticRotationalEnergy(sim) ≈ 0.