~hassanidin/matlab/development

« back to all changes in this revision

Viewing changes to 00_code/GENERIC_rk4.m

  • Committer: Dzhelil Rufat
  • Date: 2007-05-30 03:49:28 UTC
  • Revision ID: dzhelil@gmail.com-20070530034928-zvm8nc4rbarqebm9
added my first file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [g1, sigma] = GENERIC_rk4(t0,h,g0, face, Nf, verts, Nv)
 
2
% D Rufat, February 16, 2005
 
3
% Fourth order fixed time step Runge-Kutta scheme to advance motion in
 
4
% time.
 
5
 
 
6
global MODE;
 
7
%-------------import source distributions----------------%
 
8
global sigma_x;  global sigma_y;  global sigma_w;
 
9
global sigma_s1; global sigma_s2; global sigma_s3; 
 
10
%--------------------------------------------------------%
 
11
 
 
12
% shape variables
 
13
[s_0, sdot_0] = GENERIC_shape_var(t0);
 
14
[s_1, sdot_1] = GENERIC_shape_var(t0+h/2);
 
15
[s_2, sdot_2] = GENERIC_shape_var(t0+h);
 
16
 
 
17
% connection
 
18
A0 = eval([MODE '_connection(s_0, sdot_0, face, Nf, verts, Nv)']);
 
19
A1 = eval([MODE '_connection(s_1, sdot_1, face, Nf, verts, Nv)']);
 
20
A2 = eval([MODE '_connection(s_2, sdot_2, face, Nf, verts, Nv)']);
 
21
 
 
22
K1 = GENERIC_vel_fun(A0,g0);
 
23
K2 = GENERIC_vel_fun(A1,g0 + h*K1/2);
 
24
K3 = GENERIC_vel_fun(A1,g0 + h*K2/2);
 
25
K4 = GENERIC_vel_fun(A2,g0 + h*K3);
 
26
 
 
27
g1 = g0 + h*(K1+2*K2+2*K3+K4)/6;
 
28
sigma = sigma_x*A2(1)      + sigma_y*A2(2)      + sigma_w*A2(3) + ...
 
29
      sigma_s1*sdot_2(1) + sigma_s2*sdot_2(2) + sigma_s3*sdot_2(3);
 
 
b'\\ No newline at end of file'