/[ascend]/trunk/models/sensitivity_test.a4c
ViewVC logotype

Annotation of /trunk/models/sensitivity_test.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2649 - (hide annotations) (download) (as text)
Wed Dec 12 12:39:25 2012 UTC (9 years, 8 months ago) by jpye
File MIME type: text/x-ascend
File size: 2369 byte(s)
Fixing GPL header, removing postal address (rpmlint incorrect-fsf-address)
1 johnpye 1163 (* ASCEND modelling environment
2     Copyright (C) 1996 Carnegie Mellon University
3     Copyright (C) 2006 Carnegie Mellon University
4 ben.allan 468
5 johnpye 1163 This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2, or (at your option)
8     any later version.
9 ben.allan 468
10 johnpye 1163 This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     GNU General Public License for more details.
14    
15     You should have received a copy of the GNU General Public License
16 jpye 2649 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 johnpye 1163 *)
18 ben.allan 468 REQUIRE "system.a4l";
19 johnpye 1162 IMPORT "sensitivity/sensitivity";
20 johnpye 1163 (*
21 johnpye 1165 A very simple test model for the external sensitivity analysis
22     module.
23    
24     by Ben Allan, 1996
25     Self-testing added by John Pye, 2007
26    
27     --- old comments (don't seem to be accurate) ---
28    
29 johnpye 1163 This module is used to calculate the sensitity matrix dX/dU where
30     X is a vector OF vapor compositions and U is a vector OF liquid
31     compositions. This sensitivity matrix is THEN used to calculate
32     J, the Jacobian, as described IN Fidkowski et al. (1995).
33     *)
34    
35 ben.allan 468 MODEL sensitivity_test;
36     nc IS_A integer_constant;
37     X[1..nc] IS_A solver_var;
38 johnpye 1163 U[1..nc] IS_A solver_var;
39 ben.allan 468 dx_du[1..nc][1..nc] IS_A solver_var;
40 johnpye 1163
41     (* system for investigation *)
42 ben.allan 468 k,x,y,u IS_A solver_var;
43     k*x - y = 7;
44     y = u^2;
45 johnpye 1163 (* hence, dx/du = 2*u/k *)
46    
47 ben.allan 468 nc:==1;
48     u,U[1] ARE_THE_SAME;
49     x,X[1] ARE_THE_SAME;
50 johnpye 534
51 ben.allan 468 METHODS
52 johnpye 1163 METHOD values;
53     FOR j IN [1..nc] DO
54     U[j] := j;
55     END FOR;
56     END values;
57 johnpye 534
58 johnpye 1163 METHOD specify;
59     FIX u, k;
60     END specify;
61 johnpye 534
62 johnpye 1163 METHOD on_load;
63     RUN reset;
64     RUN values;
65     END on_load;
66 johnpye 534
67 johnpye 1163 METHOD analyse;
68     EXTERNAL do_sensitivity(SELF,U[1..nc],X[1..nc],dx_du[1..nc][1..nc]);
69     END analyse;
70 johnpye 534
71 johnpye 1163 METHOD self_test;
72     FOR i IN [1..nc] DO (* X[i] *)
73     FOR j IN [1..nc] DO (* U[j] *)
74     ASSERT abs(dx_du[i][j] - 2*U[j]/k) < 0.00001 * 2 * U[j]/k;
75     END FOR;
76     END FOR;
77     END self_test;
78 ben.allan 468 END sensitivity_test;
79    
80 johnpye 1167 MODEL sensitivity_test_all REFINES sensitivity_test;
81     U_new[1..nc] IS_A real;
82     stepsize IS_A real_constant;
83     stepsize :== 0.0001;
84     METHODS
85     METHOD analyse;
86     EXTERNAL do_sensitivity_all(SELF,U[1..nc],U_new[1..nc],stepsize);
87     END analyse;
88    
89     METHOD self_test;
90     ASSERT 1==0;
91     END self_test;
92     END sensitivity_test_all;

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22