annotate +time/+rk/get_rk4_time_step.m @ 1114:f2988a63c3aa feature/timesteppers

Add tests for time.Rungekutta4 and time.Rungekutta4SecondOrder
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 10 Apr 2019 23:10:13 +0200
parents 1a265a376b36
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
1 % Calculate the size of the largest time step given the largest evalue for a operator with pure imaginary e.values.
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
2 function k = get_rk4_time_step(lambda,l_type)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
3 default_arg('l_type','complex')
1111
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
4 assertIsMember(l_type, {'real', 'imag', 'complex'})
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
5
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
6 rad = abs(lambda);
1111
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
7 switch l_type
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
8 case 'real'
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
9 % kl > -2.7852
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
10 k = 2.7852/rad;
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
11 case 'imag'
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
12 % |kl| < 2.8284
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
13 k = 2.8284/rad;
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
14 case 'complex'
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
15 % |kl| < 2.5
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
16 k = 2.5/rad;
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
17 end
1111
1a265a376b36 Clean up time.rk.get_rk4_time_step()
Jonatan Werpers <jonatan@werpers.com>
parents: 887
diff changeset
18 end