/[ascend]/trunk/pygtk/test.py
ViewVC logotype

Contents of /trunk/pygtk/test.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 940 - (show annotations) (download) (as text)
Fri Nov 24 08:07:33 2006 UTC (13 years, 10 months ago) by johnpye
File MIME type: text/x-python
File size: 1282 byte(s)
Fixed 'testLSODE' in test.py, added 'IntegratorReporterNull' that makes no output (for testing purposes)
1 import unittest
2 import ascpy
3 import math
4
5 class AscendTest(unittest.TestCase):
6
7 def setUp(self):
8 import ascpy
9 self.L = ascpy.Library()
10
11 def tearDown(self):
12 self.L.clear()
13 del self.L
14
15 def testlog10(self):
16 self.L.load('johnpye/testlog10.a4c')
17 T = self.L.findType('testlog10')
18 M = T.getSimulation('sim')
19 M.solve(ascpy.Solver("QRSlv"),ascpy.SolverReporter())
20 M.run(T.getMethod('self_test'))
21
22 def testLSODE(self):
23 self.L.load('johnpye/shm.a4c')
24 M = self.L.findType('shm').getSimulation('sim')
25 print M.sim.getChildren()
26 assert float(M.sim.x) == 10.0
27 assert float(M.sim.v) == 0.0
28 t_end = 3 * math.pi
29
30 I = ascpy.Integrator(M)
31 I.setReporter(ascpy.IntegratorReporterNull(I))
32 I.setEngine('LSODE');
33 I.setLinearTimesteps(ascpy.Units("s"), 0.0, t_end, 100);
34 I.setMinSubStep(0.005);
35 I.setMaxSubStep(0.5);
36 I.setInitialSubStep(0.01);
37 I.setMaxSubSteps(100);
38 I.analyse();
39 I.solve();
40 assert abs(float(M.sim.x) + 10) < 1e-2
41 assert abs(float(M.sim.v)) < 1e-2
42 assert I.getNumObservedVars() == 3
43
44 class NotToBeTested:
45 def nothing(self):
46 pass
47
48 def testloading(self):
49 pass
50
51 def testsystema4l(self):
52 self.L.load('simpleflowsheet01.a4c')
53
54 def testatomsa4l(self):
55 self.L.load('atoms.a4l')
56
57 if __name__=='__main__':
58 unittest.main()

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