Mercurial > repos > public > sbplib
comparison +time/Timestepper.m @ 126:54055b32d516
Changed evolve so that it always stops as close to tend as possible.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 01 Feb 2016 17:08:19 +0100 |
parents | f7975c054bc3 |
children | b361a04894e3 b5e5b195da1e |
comparison
equal
deleted
inserted
replaced
125:d52e5cdb6eff | 126:54055b32d516 |
---|---|
70 v = obj.getV; | 70 v = obj.getV; |
71 t = obj.t; | 71 t = obj.t; |
72 end | 72 end |
73 | 73 |
74 function evolve_without_progress(obj, tend) | 74 function evolve_without_progress(obj, tend) |
75 while obj.t < tend - obj.k/100 | 75 while obj.t < tend - obj.k/2 |
76 obj.step(); | 76 obj.step(); |
77 end | 77 end |
78 end | 78 end |
79 | 79 |
80 function evolve_with_progress(obj, tend) | 80 function evolve_with_progress(obj, tend) |
82 | 82 |
83 steps_to_update = 1; | 83 steps_to_update = 1; |
84 steps_since_update = 0; | 84 steps_since_update = 0; |
85 last_update = tic(); | 85 last_update = tic(); |
86 s = util.replace_string('',' %d %%',0); | 86 s = util.replace_string('',' %d %%',0); |
87 while obj.t < tend - obj.k/100 | 87 while obj.t < tend - obj.k/2 |
88 obj.step(); | 88 obj.step(); |
89 | 89 |
90 steps_since_update = steps_since_update + 1; | 90 steps_since_update = steps_since_update + 1; |
91 | 91 |
92 if steps_since_update >= steps_to_update | 92 if steps_since_update >= steps_to_update |