tfix output file write, test cohesion - Granular.jl - Julia package for granula… | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit c30185511c7d49018623d283187fefe84603e3dd | |
parent ff34b28e15248e7fc441713dccec15de1152fffa | |
Author: Anders Damsgaard <[email protected]> | |
Date: Fri, 26 May 2017 11:15:42 -0400 | |
fix output file write, test cohesion | |
Diffstat: | |
M src/simulation.jl | 10 ++++------ | |
M test/cohesion.jl | 30 ++++++++++++++---------------- | |
2 files changed, 18 insertions(+), 22 deletions(-) | |
--- | |
diff --git a/src/simulation.jl b/src/simulation.jl | |
t@@ -85,14 +85,13 @@ function run!(simulation::Simulation; | |
checkTimeParameters(simulation) | |
- it_file = Int(round(simulation.file_time_since_output_file/ | |
- simulation.time_step)) | |
- n_file_time_step = Int(round(simulation.file_time_step/ | |
- simulation.time_step)) | |
+ # number of time steps between output files | |
+ n_file_time_step = Int(ceil(simulation.file_time_step/simulation.time_step… | |
while simulation.time <= simulation.time_total | |
- if simulation.file_time_step > 0.0 && it_file >= n_file_time_step | |
+ if simulation.file_time_step > 0.0 && | |
+ simulation.time_iteration % n_file_time_step == 0 | |
if show_file_output | |
println() | |
t@@ -120,7 +119,6 @@ function run!(simulation::Simulation; | |
# Update time variables | |
simulation.time_iteration += 1 | |
- n_file_time_step += 1 | |
incrementCurrentTime!(simulation, simulation.time_step) | |
if single_step | |
diff --git a/test/cohesion.jl b/test/cohesion.jl | |
t@@ -8,8 +8,8 @@ info("#### $(basename(@__FILE__)) ####") | |
verbose=false | |
sim_init = SeaIce.createSimulation() | |
-SeaIce.addIceFloeCylindrical(sim_init, [0., 0.], 10., 1., verbose=verbose) | |
-SeaIce.addIceFloeCylindrical(sim_init, [18., 0.], 10., 1., verbose=verbose) | |
+SeaIce.addIceFloeCylindrical(sim_init, [0., 0.], 10., 1.) | |
+SeaIce.addIceFloeCylindrical(sim_init, [18., 0.], 10., 1.) | |
sim_init.ice_floes[1].youngs_modulus = 1e-5 # repulsion is negligible | |
sim_init.ice_floes[2].youngs_modulus = 1e-5 # repulsion is negligible | |
SeaIce.setTimeStep!(sim_init, verbose=verbose) | |
t@@ -21,19 +21,17 @@ sim.time_step = 1. | |
SeaIce.run!(sim, verbose=verbose) | |
@test sim.ice_floes[1].contact_age[1] ≈ sim.time | |
-info("# Check if cohesion increases with time") | |
+info("# Check if bonds add tensile strength") | |
sim = SeaIce.createSimulation(id="cohesion") | |
-SeaIce.addIceFloeCylindrical(sim, [0., 0.], 10., 1., verbose=verbose) | |
-SeaIce.addIceFloeCylindrical(sim, [19.5, 0.], 10., 1., verbose=verbose) | |
-sim.ice_floes[1].youngs_modulus = 1e-5 # repulsion is negligible | |
-sim.ice_floes[2].youngs_modulus = 1e-5 # repulsion is negligible | |
+SeaIce.addIceFloeCylindrical(sim, [0., 0.], 10., 1., tensile_strength=500e3) | |
+SeaIce.addIceFloeCylindrical(sim, [20.1, 0.], 10., 1., tensile_strength=500e3) | |
+sim.ice_floes[1].lin_vel[1] = 0.1 | |
SeaIce.setTimeStep!(sim) | |
-SeaIce.setTotalTime!(sim, 24.*60.*60.) | |
-sim.file_time_step = 60. | |
-# let the contact age for a while | |
-while sim.time_total*.9 > sim.time | |
- SeaIce.run!(sim, single_step=true, verbose=verbose) | |
-end | |
-#sim_init.ice_floes[1].youngs_modulus = 2e7 | |
-#sim_init.ice_floes[2].youngs_modulus = 2e7 | |
-#SeaIce.setTimeStep!(sim) | |
+SeaIce.setTotalTime!(sim, 10.) | |
+SeaIce.run!(sim, verbose=verbose) | |
+@test sim.ice_floes[1].lin_vel[1] > 0. | |
+@test sim.ice_floes[1].lin_vel[2] ≈ 0. | |
+@test sim.ice_floes[2].lin_vel[1] > 0. | |
+@test sim.ice_floes[2].lin_vel[2] ≈ 0. | |
+@test sim.ice_floes[1].ang_vel ≈ 0. | |
+@test sim.ice_floes[2].ang_vel ≈ 0. |