File: sim.t

package info (click to toggle)
tela 1.28-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 6,596 kB
  • ctags: 5,519
  • sloc: ansic: 14,013; cpp: 13,376; lex: 1,651; fortran: 1,048; yacc: 834; sh: 715; makefile: 464
file content (31 lines) | stat: -rw-r--r-- 411 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
dt = 0.1;
L = 10;
tmax = 50;
v = 0.5;
N = 50;
dx = L/(N-3);
x = dx*(0:N-1);
counter = 0;

disp x;
disp pi;
disp L;
disp 2.0*pi*x;
disp 2*pi*x/L;

u = sin(2*pi*x/L);
unew = u;

disp u;

/*
for (t=0; t<tmax; t=t+dt) {
	unew[[2:N-1]] = 0.5*(u[1:N-2]+u[3:N]) - v*dt*(u[3:N] - u[1:N-2])/(2*dx);
	unew[1] = unew[N-1];
	unew[N] = unew[2];
	u = unew;
	//if (counter mod 50 == 0) plot(x,u);
	counter = counter+1;
};
*/