Parent Directory | Revision Log

Revision **2649** -
(**show annotations**)
(**download**)
(**as text**)

*Wed Dec 12 12:39:25 2012 UTC*
(11 years, 6 months ago)
by *jpye*

File MIME type: text/x-ascend

File size: 2369 byte(s)

File MIME type: text/x-ascend

File size: 2369 byte(s)

Fixing GPL header, removing postal address (rpmlint incorrect-fsf-address)

1 | (* ASCEND modelling environment |

2 | Copyright (C) 1996 Carnegie Mellon University |

3 | Copyright (C) 2006 Carnegie Mellon University |

4 | |

5 | 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 | |

10 | 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 | along with this program. If not, see <http://www.gnu.org/licenses/>. |

17 | *) |

18 | REQUIRE "system.a4l"; |

19 | IMPORT "sensitivity/sensitivity"; |

20 | (* |

21 | 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 | 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 | MODEL sensitivity_test; |

36 | nc IS_A integer_constant; |

37 | X[1..nc] IS_A solver_var; |

38 | U[1..nc] IS_A solver_var; |

39 | dx_du[1..nc][1..nc] IS_A solver_var; |

40 | |

41 | (* system for investigation *) |

42 | k,x,y,u IS_A solver_var; |

43 | k*x - y = 7; |

44 | y = u^2; |

45 | (* hence, dx/du = 2*u/k *) |

46 | |

47 | nc:==1; |

48 | u,U[1] ARE_THE_SAME; |

49 | x,X[1] ARE_THE_SAME; |

50 | |

51 | METHODS |

52 | METHOD values; |

53 | FOR j IN [1..nc] DO |

54 | U[j] := j; |

55 | END FOR; |

56 | END values; |

57 | |

58 | METHOD specify; |

59 | FIX u, k; |

60 | END specify; |

61 | |

62 | METHOD on_load; |

63 | RUN reset; |

64 | RUN values; |

65 | END on_load; |

66 | |

67 | METHOD analyse; |

68 | EXTERNAL do_sensitivity(SELF,U[1..nc],X[1..nc],dx_du[1..nc][1..nc]); |

69 | END analyse; |

70 | |

71 | 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 | END sensitivity_test; |

79 | |

80 | 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 |