1 |
(*********************************************************************\ |
2 |
sensitivity_test.asc |
3 |
by Ben Allan |
4 |
Part of the Ascend Library |
5 |
|
6 |
This file is part of the Ascend modeling library. |
7 |
|
8 |
Copyright (C) 1996 |
9 |
|
10 |
The Ascend modeling library is free software; you can redistribute |
11 |
it and/or modify it under the terms of the GNU General Public License as |
12 |
published by the Free Software Foundation; either version 2 of the |
13 |
License, or (at your option) any later version. |
14 |
|
15 |
The Ascend Language Interpreter is distributed in hope that it will be |
16 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 |
General Public License for more details. |
19 |
|
20 |
You should have received a copy of the GNU General Public License along with |
21 |
the program; if not, write to the Free Software Foundation, Inc., 675 |
22 |
Mass Ave, Cambridge, MA 02139 USA. Check the file named COPYING. |
23 |
|
24 |
This module is used to calculate the sensitity matrix dX/dU where |
25 |
X is a vector OF vapor compositions and U is a vector OF liquid |
26 |
compositions. This sensitivity matrix is THEN used to calculate |
27 |
J, the Jacobian, as described IN Fidkowski et al. (1995). |
28 |
|
29 |
\*********************************************************************) |
30 |
|
31 |
REQUIRE "system.a4l"; |
32 |
|
33 |
IMPORT "sensitivity/sensitivity"; |
34 |
|
35 |
MODEL sensitivity_test; |
36 |
nc IS_A integer_constant; |
37 |
X[1..nc] IS_A solver_var; |
38 |
U[1..nc], Unew[1..nc] IS_A solver_var; |
39 |
dx_du[1..nc][1..nc] IS_A solver_var; |
40 |
(* system *) |
41 |
k,x,y,u IS_A solver_var; |
42 |
k*x - y = 7; |
43 |
y = u^2; |
44 |
(* dx/du = 2*u/k *) |
45 |
nc:==1; |
46 |
u,U[1] ARE_THE_SAME; |
47 |
x,X[1] ARE_THE_SAME; |
48 |
|
49 |
METHODS |
50 |
|
51 |
METHOD values; |
52 |
END values; |
53 |
|
54 |
METHOD specify; |
55 |
FIX u, k; |
56 |
END specify; |
57 |
|
58 |
METHOD on_load; |
59 |
RUN reset; |
60 |
RUN values; |
61 |
END on_load; |
62 |
|
63 |
METHOD analyse; |
64 |
EXTERNAL do_sensitivity(SELF,U[1..nc],X[1..nc],dx_du[1..nc][1..nc]); |
65 |
END analyse; |
66 |
|
67 |
END sensitivity_test; |