| tsimulation_benchmark.jl - seaice-experiments - sea ice experiments using Granu… | |
| git clone git://src.adamsgaard.dk/seaice-experiments | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| tsimulation_benchmark.jl (1482B) | |
| --- | |
| 1 #/usr/bin/env julia | |
| 2 ENV["MPLBACKEND"] = "Agg" | |
| 3 import Granular | |
| 4 import JLD | |
| 5 | |
| 6 | |
| 7 const N = 30e3 | |
| 8 const n_runs = 1000 | |
| 9 | |
| 10 ## Coulomb-frictional model | |
| 11 function prepare_simulation(sim::Granular.Simulation) | |
| 12 sim = Granular.readSimulation(sim) | |
| 13 sim.id = "$(sim.id)-benchmark" | |
| 14 Granular.resetTime!(sim) | |
| 15 Granular.setTotalTime!(sim, 1.) | |
| 16 Granular.setOutputFileInterval!(sim, 0.) | |
| 17 return sim | |
| 18 end | |
| 19 | |
| 20 function benchmark_interaction(sim::Granular.Simulation, n_runs::Int) | |
| 21 time = zeros(n_runs) | |
| 22 for i=1:n_runs | |
| 23 Granular.interact!(sim) | |
| 24 Granular.interact!(sim) | |
| 25 t = @elapsed(Granular.interact!(sim)) | |
| 26 time[i] = t | |
| 27 end | |
| 28 return time | |
| 29 end | |
| 30 | |
| 31 | |
| 32 sim = Granular.createSimulation("mohr_coulomb_mu0.3_sigma_c0kPa.pdf-seed… | |
| 33 sim = prepare_simulation(sim) | |
| 34 time_frictional = benchmark_interaction(sim, n_runs) | |
| 35 | |
| 36 sim = Granular.createSimulation("mohr_coulomb_mu0.3_sigma_c0kPa.pdf-seed… | |
| 37 sim = prepare_simulation(sim) | |
| 38 for grain in sim.grains | |
| 39 grain.rotating = false | |
| 40 end | |
| 41 time_cohesive = benchmark_interaction(sim, n_runs) | |
| 42 | |
| 43 time_frictional_mean = mean(time_frictional) | |
| 44 time_frictional_std = std(time_frictional) | |
| 45 time_cohesive_mean = mean(time_cohesive) | |
| 46 time_cohesive_std = std(time_cohesive) | |
| 47 | |
| 48 println("Frictional: mean = $time_frictional_mean, std = $time_frictiona… | |
| 49 println("Cohesive: mean = $time_cohesive_mean, std = $time_cohesive_st… | |
| 50 println("Speedup of cohesive model: $(time_frictional_mean/time_cohesive… |