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

Diff of /trunk/test.py

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

revision 1250 by johnpye, Sat Jan 27 00:11:34 2007 UTC revision 1251 by johnpye, Sat Jan 27 05:04:49 2007 UTC
# Line 772  class TestIDA(Ascend): Line 772  class TestIDA(Ascend):
772  class TestIDADENSE(Ascend):  class TestIDADENSE(Ascend):
773      """IDA DAE integrator, DENSE linear solver"""      """IDA DAE integrator, DENSE linear solver"""
774    
     def testnewton(self):  
         sys.stderr.write("STARTING TESTNEWTON\n")  
         self.L.load('johnpye/newton.a4c')  
         T = self.L.findType('newton')  
         M = T.getSimulation('sim')  
         M.solve(ascpy.Solver("QRSlv"),ascpy.SolverReporter())    
         I = ascpy.Integrator(M)  
         I.setEngine('IDA')  
         I.setParameter('linsolver','DENSE')  
         I.setParameter('safeeval',True)  
         I.setParameter('rtol',1e-8)  
         I.setMaxSubStep(0.001)  
         I.setMaxSubSteps(10000)  
           
         I.setReporter(ascpy.IntegratorReporterConsole(I))  
         I.setLinearTimesteps(ascpy.Units("s"), 0, 2*float(M.v)/float(M.g), 2)  
         I.analyse()  
         I.solve()  
         print "At end of simulation,"  
         print "x = %f" % M.x  
         print "v = %f" % M.v  
         M.run(T.getMethod('self_test'))  
   
775      def testlotka(self):      def testlotka(self):
776          self.L.load('johnpye/lotka.a4c')          self.L.load('johnpye/lotka.a4c')
777          M = self.L.findType('lotka').getSimulation('sim')          M = self.L.findType('lotka').getSimulation('sim')
# Line 843  class TestIDADENSE(Ascend): Line 820  class TestIDADENSE(Ascend):
820          I = ascpy.Integrator(M)          I = ascpy.Integrator(M)
821          I.setEngine('IDA')          I.setEngine('IDA')
822          I.setParameter('linsolver','DENSE')          I.setParameter('linsolver','DENSE')
823          I.setParameter('rtol',1e-7)          I.setParameter('rtol',1.1e-15)
824          I.setParameter('atolvect',0)          I.setParameter('atolvect',0)
825          I.setParameter('atol',1e-7)          I.setParameter('atol',1.1e-15)
826          I.setReporter(ascpy.IntegratorReporterConsole(I))          I.setReporter(ascpy.IntegratorReporterConsole(I))
827          I.setLogTimesteps(ascpy.Units(""), 1, 321.8122, 5)          I.setLogTimesteps(ascpy.Units(""), 1, 321.8122, 5)
828          I.setMaxSubStep(1);          I.setInitialSubStep(1e-5)
829          I.setInitialSubStep(1e-9)          I.setMaxSubSteps(10000)
         I.setMaxSubSteps(5000)  
830          I.analyse()          I.analyse()
831          I.solve()          I.solve()
832            for i in range(8):
833                print "y[%d] = %.20g" % (i+1, M.y[i+1])
834          M.run(T.getMethod('self_test'))          M.run(T.getMethod('self_test'))
835    
836  ## @TODO fails during IDACalcIC (model too big?)  ## @TODO fails during IDACalcIC (model too big?)
# Line 967  class NotToBeTested: Line 945  class NotToBeTested:
945      def nothing(self):      def nothing(self):
946          pass          pass
947    
948        def testnewton(self):
949            sys.stderr.write("STARTING TESTNEWTON\n")
950            self.L.load('johnpye/newton.a4c')
951            T = self.L.findType('newton')
952            M = T.getSimulation('sim')
953            M.solve(ascpy.Solver("QRSlv"),ascpy.SolverReporter())  
954            I = ascpy.Integrator(M)
955            I.setEngine('IDA')
956            I.setParameter('linsolver','DENSE')
957            I.setParameter('safeeval',True)
958            I.setParameter('rtol',1e-8)
959            I.setMaxSubStep(0.001)
960            I.setMaxSubSteps(10000)
961            
962            I.setReporter(ascpy.IntegratorReporterConsole(I))
963            I.setLinearTimesteps(ascpy.Units("s"), 0, 2*float(M.v)/float(M.g), 2)
964            I.analyse()
965            I.solve()
966            print "At end of simulation,"
967            print "x = %f" % M.x
968            print "v = %f" % M.v
969            M.run(T.getMethod('self_test'))
970    
971  if __name__=='__main__':  if __name__=='__main__':
972      # a whole bag of tricks to make sure we get the necessary dirs in our ascend, python and ld path vars      # a whole bag of tricks to make sure we get the necessary dirs in our ascend, python and ld path vars
973      restart = 0      restart = 0

Legend:
Removed from v.1250  
changed lines
  Added in v.1251

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