/[ascend]/branches/fprops2/test.py
ViewVC logotype

Diff of /branches/fprops2/test.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 965 by johnpye, Tue Dec 12 14:34:18 2006 UTC revision 966 by johnpye, Thu Dec 14 14:04:54 2006 UTC
# Line 2  import unittest Line 2  import unittest
2  import ascpy  import ascpy
3  import math  import math
4  import os, subprocess  import os, subprocess
5    import atexit
6    
7  class CUnit(unittest.TestCase):  class CUnit(unittest.TestCase):
8      def setUp(self):      def setUp(self):
# Line 24  class Ascend(unittest.TestCase): Line 25  class Ascend(unittest.TestCase):
25          self.L.clear()          self.L.clear()
26          del self.L          del self.L
27    
28    class TestCompiler(Ascend):
29    
30      def testloading(self):      def testloading(self):
31          pass          pass
32    
# Line 33  class Ascend(unittest.TestCase): Line 36  class Ascend(unittest.TestCase):
36      def testatomsa4l(self):      def testatomsa4l(self):
37          self.L.load('atoms.a4l')          self.L.load('atoms.a4l')
38    
39      def testlog10(self):  class TestSolver(Ascend):
40          self.L.load('johnpye/testlog10.a4c')      
41          T = self.L.findType('testlog10')      def _run(self,modelname,solvername="QRSlv",filename=None):
42            if filename==None:
43                filename = 'johnpye/%s.a4c' % modelname
44            self.L.load(filename)
45            T = self.L.findType(modelname)
46          M = T.getSimulation('sim')          M = T.getSimulation('sim')
47          M.solve(ascpy.Solver("QRSlv"),ascpy.SolverReporter())            M.solve(ascpy.Solver(solvername),ascpy.SolverReporter())    
48          M.run(T.getMethod('self_test'))              M.run(T.getMethod('self_test'))
49    
50        def testlog10(self):
51            self._run('testlog10')
52    
53        def testconopt(self):
54            self._run('testconopt',"CONOPT")                
55    
56        def testcmslv2(self):
57            self._run('testcmslv2',"CONOPT")    
58    
59        def testsunpos1(self):
60            self._run('example_1_6_1',"QRSlv","johnpye/sunpos.a4c")
61    
62        def testsunpos2(self):
63            self._run('example_1_6_2',"QRSlv","johnpye/sunpos.a4c")
64    
65        def testsunpos3(self):
66            self._run('example_1_7_1',"QRSlv","johnpye/sunpos.a4c")
67    
68        def testsunpos4(self):
69            self._run('example_1_7_2',"QRSlv","johnpye/sunpos.a4c")
70    
71        def testsunpos5(self):
72            self._run('example_1_7_3',"QRSlv","johnpye/sunpos.a4c")
73    
74        def testsunpos6(self):
75            self._run('example_1_8_1',"QRSlv","johnpye/sunpos.a4c")
76    
77    class TestIntegrator(Ascend):
78    
79      def testListIntegrators(self):      def testListIntegrators(self):
80          I = ascpy.Integrator.getEngines()          I = ascpy.Integrator.getEngines()
# Line 75  class Ascend(unittest.TestCase): Line 111  class Ascend(unittest.TestCase):
111          assert I.getNumObservedVars() == 3          assert I.getNumObservedVars() == 3
112    
113      def testInvalidIntegrator(self):      def testInvalidIntegrator(self):
114          self.L.load('johnpye/shm.a4c')          self.L.load('johnpye/shm.a4c')
115          M = self.L.findType('shm').getSimulation('sim')          M = self.L.findType('shm').getSimulation('sim')
116          I = ascpy.Integrator(M)          I = ascpy.Integrator(M)
117          try:          try:
# Line 93  class Ascend(unittest.TestCase): Line 129  class Ascend(unittest.TestCase):
129          M = T.getSimulation('sim')          M = T.getSimulation('sim')
130          M.solve(ascpy.Solver("QRSlv"),ascpy.SolverReporter())            M.solve(ascpy.Solver("QRSlv"),ascpy.SolverReporter())  
131          I = ascpy.Integrator(M)          I = ascpy.Integrator(M)
132          I.setEngine('LSODE')                  I.setEngine('LSODE')
133            I.setMinSubStep(1e-7)
134            I.setMaxSubStep(0.001)
135            I.setMaxSubSteps(10000)
136          I.setReporter(ascpy.IntegratorReporterConsole(I))          I.setReporter(ascpy.IntegratorReporterConsole(I))
137          I.setLinearTimesteps(ascpy.Units(), 0, 1.5, 2);          I.setLinearTimesteps(ascpy.Units(), 0, 1.5, 5);
138          I.analyse()          I.analyse()
139          I.solve()          I.solve()
140          M.run(T.getMethod('self_test'))          M.run(T.getMethod('self_test'))
# Line 236  class NotToBeTested: Line 275  class NotToBeTested:
275          pass          pass
276                    
277  if __name__=='__main__':  if __name__=='__main__':
278        atexit.register(ascpy.shutdown)
279      unittest.main()      unittest.main()

Legend:
Removed from v.965  
changed lines
  Added in v.966

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