tAdd tests for `allow_*_acc` and add missing implementation in TY3 temporal int… | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 7ef507d6d943a442b153d9b162c4d7c3d07a4672 | |
parent dafb5876273163ab2718cbcd4e8e256534e7a4c3 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Mon, 15 Jan 2018 10:17:40 -0500 | |
Add tests for `allow_*_acc` and add missing implementation in TY3 temporal inte… | |
Diffstat: | |
M src/temporal_integration.jl | 7 ++++++- | |
M test/collision-2floes-normal.jl | 66 +++++++++++++++++++++++++++++… | |
2 files changed, 72 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/src/temporal_integration.jl b/src/temporal_integration.jl | |
t@@ -102,7 +102,12 @@ function updateGrainKinematicsThreeTermTaylor!(grain::Gra… | |
grain.ang_acc = grain.torque/grain.moment_of_inertia | |
if grain.fixed | |
- fill!(grain.lin_acc, 0.) | |
+ if !grain.allow_x_acc | |
+ grain.lin_acc[1] = 0. | |
+ end | |
+ if !grain.allow_y_acc | |
+ grain.lin_acc[2] = 0. | |
+ end | |
grain.ang_acc = 0. | |
elseif !grain.rotating | |
grain.ang_acc = 0. | |
diff --git a/test/collision-2floes-normal.jl b/test/collision-2floes-normal.jl | |
t@@ -207,3 +207,69 @@ E_kin_lin_final = Granular.totalGrainKineticTranslational… | |
E_kin_rot_final = Granular.totalGrainKineticRotationalEnergy(sim) | |
@test E_kin_lin_init > E_kin_lin_final | |
@test E_kin_rot_init ≈ E_kin_rot_final | |
+ | |
+ | |
+info("# Testing allow_*_acc for fixed grains") | |
+sim = Granular.createSimulation(id="test") | |
+Granular.addGrainCylindrical!(sim, [0., 0.], 10., 1., verbose=verbose) | |
+Granular.addGrainCylindrical!(sim, [20.05, 0.], 10., 1., verbose=verbose) | |
+sim.grains[1].lin_vel[1] = 0.1 | |
+sim.grains[2].fixed = true | |
+ | |
+E_kin_lin_init = Granular.totalGrainKineticTranslationalEnergy(sim) | |
+E_kin_rot_init = Granular.totalGrainKineticRotationalEnergy(sim) | |
+grain2_pos_init = sim.grains[2].lin_pos | |
+ | |
+Granular.setTotalTime!(sim, 10.0) | |
+Granular.setTimeStep!(sim, epsilon=0.07) | |
+sim_init = deepcopy(sim) | |
+sim.grains[2].allow_y_acc = true # should not influence result | |
+ | |
+info("Two-term Taylor scheme: allow_y_acc") | |
+sim = deepcopy(sim_init) | |
+sim.grains[2].allow_y_acc = true # should not influence result | |
+tol = 0.2 | |
+Granular.run!(sim, temporal_integration_method="Two-term Taylor", verbose=verb… | |
+ | |
+E_kin_lin_final = Granular.totalGrainKineticTranslationalEnergy(sim) | |
+E_kin_rot_final = Granular.totalGrainKineticRotationalEnergy(sim) | |
+@test E_kin_lin_init ≈ E_kin_lin_final atol=E_kin_lin_init*tol | |
+@test E_kin_rot_init ≈ E_kin_rot_final | |
+@test sim.grains[2].lin_pos ≈ grain2_pos_init | |
+ | |
+info("Two-term Taylor scheme: allow_x_acc") | |
+sim = deepcopy(sim_init) | |
+sim.grains[2].allow_x_acc = true # should influence result | |
+tol = 0.2 | |
+Granular.run!(sim, temporal_integration_method="Two-term Taylor", verbose=verb… | |
+ | |
+E_kin_lin_final = Granular.totalGrainKineticTranslationalEnergy(sim) | |
+E_kin_rot_final = Granular.totalGrainKineticRotationalEnergy(sim) | |
+@test E_kin_lin_init ≈ E_kin_lin_final atol=E_kin_lin_init*tol | |
+@test E_kin_rot_init ≈ E_kin_rot_final | |
+@test sim.grains[2].lin_pos[1] > grain2_pos_init[1] | |
+ | |
+info("Three-term Taylor scheme: allow_y_acc") | |
+sim = deepcopy(sim_init) | |
+tol = 0.02 | |
+sim.grains[2].allow_y_acc = true # should influence result | |
+Granular.run!(sim, temporal_integration_method="Three-term Taylor", verbose=ve… | |
+ | |
+E_kin_lin_final = Granular.totalGrainKineticTranslationalEnergy(sim) | |
+E_kin_rot_final = Granular.totalGrainKineticRotationalEnergy(sim) | |
+@test E_kin_lin_init ≈ E_kin_lin_final atol=E_kin_lin_init*tol | |
+@test E_kin_rot_init ≈ E_kin_rot_final | |
+@test sim.grains[2].lin_pos ≈ grain2_pos_init | |
+ | |
+info("Three-term Taylor scheme: allow_x_acc") | |
+sim = deepcopy(sim_init) | |
+tol = 0.02 | |
+sim.grains[2].allow_x_acc = true # should influence result | |
+Granular.run!(sim, temporal_integration_method="Three-term Taylor", verbose=ve… | |
+ | |
+E_kin_lin_final = Granular.totalGrainKineticTranslationalEnergy(sim) | |
+E_kin_rot_final = Granular.totalGrainKineticRotationalEnergy(sim) | |
+@test E_kin_lin_init ≈ E_kin_lin_final atol=E_kin_lin_init*tol | |
+@test E_kin_rot_init ≈ E_kin_rot_final | |
+@test sim.grains[2].lin_pos[1] > grain2_pos_init[1] | |
+ |