Mercurial > repos > public > sbplib
annotate alignedTimestep.m @ 1337:bf2554f1825d feature/D2_boundary_opt
Add periodic D1 and D2 operators for orders 8,10,12
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 13 May 2022 13:28:10 +0200 |
parents | c71095442c57 |
children |
rev | line source |
---|---|
12
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
1 % Calcualtes the largest timestep smaller than k_max that gives an integer |
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
2 % number of timesteps to time T. |
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
3 % k_max -- largest allowable timestep |
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
4 % T -- time to align with |
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
5 % |
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
6 % Returns: |
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
7 % k -- calculated timestep |
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
8 % N -- number to of timestep to reach T |
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
9 function [k, N] = alignedTimestep(k_max, T) |
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
10 N = ceil(T/k_max); |
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
11 k = T/N; |
c71095442c57
Added function to calculate an aligned timestep.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
12 end |