tplot translational and rotational energy separately - slidergrid - grid of elastic sliders on a frictional surface
 (HTM) git clone git://src.adamsgaard.dk/slidergrid
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 5a85affe06c9ef33083476a69ceddd03b0eb4155
 (DIR) parent 5923f961afa2aca4593b8c4004ae6c5816e7250e
 (HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
       Date:   Wed, 30 Mar 2016 14:13:35 -0700
       
       plot translational and rotational energy separately
       
       Diffstat:
         M postprocessing.py                   |      24 +++++++++++++++++-------
       
       1 file changed, 17 insertions(+), 7 deletions(-)
       ---
 (DIR) diff --git a/postprocessing.py b/postprocessing.py
       t@@ -65,18 +65,25 @@ class sgvis:
                return 0.0
        
            def current_kinetic_energy(self):
       -        E_kin = 0.0
       +        E_t = 0.0
       +        E_r = 0.0
                for idx in np.arange(np.size(self.mass)):
       -            E_kin += self.slider_linear_kinetic_energy(idx)
       -        return E_kin
       +            E_t += self.slider_translational_kinetic_energy(idx)
       +            E_r += self.slider_rotational_kinetic_energy(idx)
       +        return E_t, E_r
        
       -    def slider_linear_kinetic_energy(self, idx):
       +    def slider_translational_kinetic_energy(self, idx):
                return 0.5*self.mass[idx] \
                    * np.sqrt(np.dot(self.vel[idx, :], self.vel[idx, :]))**2
        
       +    def slider_rotational_kinetic_energy(self, idx):
       +        return 0.5*self.moment_of_inertia[idx] \
       +            * np.sqrt(np.dot(self.angvel[idx, :], self.angvel[idx, :]))**2
       +
            def plot_kinetic_energy(self):
                t = []
       -        E_kin = []
       +        E_t_series = []
       +        E_r_series = []
                for filename in os.listdir(self.folder):
                    if 'sliders' in filename \
                            and '.txt' in filename \
       t@@ -84,9 +91,12 @@ class sgvis:
                            and '.png' not in filename:
                        self.read_sliders(filename)
                        t.append(self.current_time)
       -                E_kin.append(self.current_kinetic_energy)
       +                E_t, E_r = self.current_kinetic_energy()
       +                E_t_series.append(E_t)
       +                E_r_series.append(E_r)
        
       -        plt.plot(t, E_kin)
       +        plt.plot(t, E_t_series)
       +        plt.plot(t, E_r_series)
                outfile = self.folder + '/E_kin.pdf'
                print(outfile)
                plt.savefig(outfile)