| tdetermine translational kinetic energy - slidergrid - grid of elastic sliders … | |
| git clone git://src.adamsgaard.dk/slidergrid | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| commit 5923f961afa2aca4593b8c4004ae6c5816e7250e | |
| parent b7c2f91bf3969f60232019e78e937aaa8d894f1f | |
| Author: Anders Damsgaard <[email protected]> | |
| Date: Wed, 30 Mar 2016 14:08:04 -0700 | |
| determine translational kinetic energy | |
| Diffstat: | |
| M postprocessing.py | 11 ++++++++++- | |
| 1 file changed, 10 insertions(+), 1 deletion(-) | |
| --- | |
| diff --git a/postprocessing.py b/postprocessing.py | |
| t@@ -65,7 +65,14 @@ class sgvis: | |
| return 0.0 | |
| def current_kinetic_energy(self): | |
| - return 0.0 | |
| + E_kin = 0.0 | |
| + for idx in np.arange(np.size(self.mass)): | |
| + E_kin += self.slider_linear_kinetic_energy(idx) | |
| + return E_kin | |
| + | |
| + def slider_linear_kinetic_energy(self, idx): | |
| + return 0.5*self.mass[idx] \ | |
| + * np.sqrt(np.dot(self.vel[idx, :], self.vel[idx, :]))**2 | |
| def plot_kinetic_energy(self): | |
| t = [] | |
| t@@ -73,8 +80,10 @@ class sgvis: | |
| for filename in os.listdir(self.folder): | |
| if 'sliders' in filename \ | |
| and '.txt' in filename \ | |
| + and '.pdf' in filename \ | |
| and '.png' not in filename: | |
| self.read_sliders(filename) | |
| + t.append(self.current_time) | |
| E_kin.append(self.current_kinetic_energy) | |
| plt.plot(t, E_kin) |