changeset 1111:1a265a376b36 feature/timesteppers

Clean up time.rk.get_rk4_time_step()
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 10 Apr 2019 22:21:13 +0200
parents aa7850e8f68c
children 835c8fa456ec
files +time/+rk/get_rk4_time_step.m
diffstat 1 files changed, 12 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/+time/+rk/get_rk4_time_step.m	Tue Apr 09 22:22:03 2019 +0200
+++ b/+time/+rk/get_rk4_time_step.m	Wed Apr 10 22:21:13 2019 +0200
@@ -1,21 +1,18 @@
 % Calculate the size of the largest time step given the largest evalue for a operator with pure imaginary e.values.
 function k = get_rk4_time_step(lambda,l_type)
     default_arg('l_type','complex')
+	assertIsMember(l_type, {'real', 'imag', 'complex'})
 
     rad = abs(lambda);
-    if strcmp(l_type,'real')
-        % Real eigenvalue
-        % kl > -2.7852
-        k = 2.7852/rad;
-
-    elseif strcmp(l_type,'imag')
-        % Imaginary eigenvalue
-        % |kl| < 2.8284
-        k = 2.8284/rad;
-    elseif strcmp(l_type,'complex')
-        % |kl| < 2.5
-        k = 2.5/rad;
-    else
-        error('l_type must be one of ''real'',''imag'' or ''complex''.')
+    switch l_type
+    	case 'real'
+	        % kl > -2.7852
+	        k = 2.7852/rad;
+    	case 'imag'
+		    % |kl| < 2.8284
+		    k = 2.8284/rad;
+		case 'complex'
+	        % |kl| < 2.5
+	        k = 2.5/rad;
     end
-end
\ No newline at end of file
+end