Overview
Comment:Use sparse computation where possible
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 8d13176e7207bbdd1db8f25170ff7d8745fe1bfae23923a389188977362a3788
User & Date: gawthrop@users.sourceforge.net on 1998-08-14 10:54:58
Other Links: branch diff | manifest | tags
Context
1998-08-14
12:09:13
A passed by value - its destroyed by SVDcm check-in: c254fc6a31 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
10:54:58
Use sparse computation where possible check-in: 8d13176e72 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
10:47:31
Put ImplicitS sub before Implicit!! check-in: 9d5e1b9ab0 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/p/mtt_update.p from [19c3d6b4db] to [6fcd662042].

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
32
33
34
35
36
37
38
39
40
41
42



43
44

45

46
47

48
49
50
51
52

53
54
55


56
57
58
59
60
61
62
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
32


33
34

















35
36
37
38
39
40

41


42





43



44
45
46
47
48
49
50
51
52





-
+
+
+
+
+
+
+
+
+
+






-










+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+


+
-
+
-
-
+
-
-
-
-
-
+
-
-
-
+
+







PROCEDURE mtt_update(VAR xnew	: StateVector;
			 dx,x	: StateVector;
			 DT	: REAL;
			 Nx	: INTEGER;
			 METHOD	: IntegrationMethod;
		     VAR A	: StateMatrix);
			 AA	: StateMatrix );

{
 ###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################
}

CONST
   Small = 0.000001;
   
VAR
   i,j	 : INTEGER;
   AA	 : StateMatrix;
   BB,Ax : StateVector;
   rsq	 : REAL;
   
(*$I mtt_solve.p *)
(*$I mtt_sparse.p *)
   
BEGIN{mtt_update}
   IF Method=1 THEN {Euler}
      FOR i := 1 TO  Nx DO
	 xnew[i] := xnew[i] + dx[i]*DT
	 
      ELSE IF (Method=2) OR (METHOD=3) THEN {Implicit}
      BEGIN
      ELSE IF (Method=2) OR (METHOD=3) OR (METHOD=4) THEN {Implicit}
      BEGIN {Implicit methods}
	 {Set up the solution matrices:
	  AA = eye(Nx)-A*dt
	  BB = x + dt*(dx - A*x)}
	 FOR i := 1 TO  Nx DO
	 BEGIN
	    Ax[i] := 0.0;
	    FOR j := 1 TO  Nx DO
	    BEGIN
	       AA[i,j] := -A[i,j]*DT;
	       Ax[i] := Ax[i] + A[i,j]*x[j];
	       IF i=j THEN
		  AA[i,j] := AA[i,j] + 1.0;
	    END
	 END;
	 
	 FOR i := 1 TO  Nx DO
	    BB[i] := x[i] + DT*(dx[i]-Ax[i]);
	 mtt_asub(x,Ax,Nx); {Sparse computation of (1-A*dt)*x}
	 FOR i := 1 TO  Nx DO {BB is (1-A*dt)*x +dx*dt}
	    BB[i] := Ax[i]+ DT*dx[i];

	 {Solve the equation AAx = B}
	 IF (Method=2) OR (METHOD=3) THEN {Use SVD}
	 mtt_solve(xnew,AA,BB,Nx,Small);
	    mtt_solve(xnew,AA,BB,Nx,Small)
      END
      ELSE IF (METHOD=4) THEN {Sparse CG implicit}
	 ELSE {Sparse CG solution}
      BEGIN
	 mtt_asub(x,Ax,Nx); {Sparse computation of (1-A*dt)*x}
	 FOR i := 1 TO  Nx DO
	    BB[i] := Ax[i]+ DT*dx[i];
	 mtt_sparse(BB,Nx,xnew,rsq); {Sparse CG solution
	    mtt_sparse(BB,Nx,xnew,rsq);
				  - using prev. xnew as starter}
      END
         ELSE
      END{Implicit methods}
      ELSE
	 Writeln("Method >4 is not defined");
   
END{mtt_update};





MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]