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

Contents of /trunk/models/testfunc.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 835 - (show annotations) (download) (as text)
Wed Sep 6 15:52:46 2006 UTC (17 years, 8 months ago) by aw0a
File MIME type: text/x-ascend
File size: 3099 byte(s)
corrected collocation.a4l errors created when changing FIXED statements
1 REQUIRE "atoms.a4l";
2
3 MODEL testtan;
4 x IS_A angle;
5 y IS_A factor;
6
7 y=tan(x);
8
9 METHODS
10 METHOD on_load;
11 FIX x;
12 x := 0.19{rad};
13 END on_load;
14 METHOD self_test;
15 ASSERT abs(y - 0.1923198) < 1.0e-7;
16 END self_test;
17 END testtan;
18
19 MODEL testfunc;
20 (* dependent variables *)
21 yArccosh,yArcsinh,yArctanh,
22 yCos,yCosh,
23 yExp,yLn,yLnm,
24 ySin,ySinh,
25 yTan,yTanh IS_A factor;
26
27 yArcsin,yArccos,
28 yArctan IS_A angle;
29
30 this IS_A angle;
31
32 (* fixed variables *)
33 xArccos,xArccosh,
34 xArcsin,xArcsinh,
35 xArctan,xArctanh,
36 xCosh,
37 xExp,xLn,xLnm,
38 xSinh,
39 xTanh IS_A factor;
40
41 xCos,xSin,
42 xTan IS_A angle;
43
44 (* equations *)
45 arccosEqn: yArccos = arccos(xArccos);
46 arccoshEqn: yArccosh = arccosh(xArccosh);
47 arcsinEqn: yArcsin = arcsin(xArcsin);
48 arcsinhEqn: yArcsinh = arcsinh(xArcsinh);
49 duh: this = 0.0{radian};
50 arctanEqn: yArctan = this+arctan(xArctan)+this;
51 arctanhEqn: yArctanh = arctanh(xArctanh);
52 cosEqn: yCos = cos(xCos);
53 coshEqn: yCosh = cosh(xCosh);
54 expEqn: yExp = exp(xExp);
55 lnEqn: yLn = ln(xLn);
56 lnmEqn: yLnm = lnm(xLnm);
57 sinEqn: ySin = sin(xSin);
58 sinhEqn: ySinh = sinh(xSinh);
59 tanEqn: yTan = tan(xTan);
60 tanhEqn: yTanh = tanh(xTanh);
61
62 METHODS
63
64 METHOD default_self;
65 END default_self;
66
67 METHOD specify;
68 FIX xExp,xLn;
69 FIX xSin,xCos,xTan;
70 FIX xArcsin,xArccos,xArctan;
71 FIX xSinh,xCosh,xTanh;
72 FIX xArccosh,xArcsinh,xArctanh;
73 FIX xLnm;
74 END specify;
75
76 METHOD on_load;
77 RUN default_self;
78 RUN reset; ASSERT abs(yTan - 0.1877619) < 1.0e-7;
79 RUN values;
80 END on_load;
81
82 METHOD self_test;
83 ASSERT abs(yArctan - 1.1441688{rad}) < 1.0e-7{rad};
84 ASSERT abs(yArctanh - 0.1205810) < 1.0e-7;
85 ASSERT abs(yTan - 0.1923198) < 1.0e-7;
86 END self_test;
87
88 METHOD values;
89 xArccos := 0.10; (* magnitude must not exceed 1.0 *)
90 xArccosh := 2.0; (* value must be 1.0 or greater *)
91 xArcsin := 0.11; (* magnitude must not exceed 1.0 *)
92 xArcsinh := 2.1;
93 xArctan := 2.2;
94 xArctanh := 0.12; (* magnitude must not exceed 1.0 *)
95 xCos := 0.13 {radian};
96 xCosh := 0.14;
97 xExp := 0.15;
98 xLn := 0.16; (* value must be greater than 0 *)
99 xLnm := 0.16;
100 xSin := 0.17 {radian};
101 xSinh := 0.18;
102 xTan := 0.19 {radian};
103 xTanh := 0.2;
104 END values;
105
106
107 (* set up to recover original x values. Note mapping
108 after solving. *)
109
110 METHOD valuesRecover;
111 xArccos := yCos; (* yArccos becomes xCos orig value *)
112 xArccosh := yCosh; (* yArccosh becomes xCosh orig value *)
113 xArcsin := ySin; (* etc *)
114 xArcsinh := ySinh;
115 xArctan := yTan;
116 xArctanh := yTanh;
117 xCos := yArccos;
118 xCosh := yArccosh;
119 xExp := yLn;
120 xLn := yExp;
121 xLnm := yExp;
122 xSin := yArcsin;
123 xSinh := yArcsinh;
124 xTan := yArctan;
125 xTanh := yArctanh;
126 END valuesRecover;
127
128 END testfunc;

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