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

Contents of /trunk/test.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1292 - (show annotations) (download) (as text)
Mon Feb 26 06:47:08 2007 UTC (17 years, 4 months ago) by johnpye
File MIME type: text/x-python
File size: 37013 byte(s)
Added undefined test for defaults with ARE_THE_SAME
1 #!/usr/bin/env python
2 # ASCEND modelling environment
3 # Copyright (C) 2006, 2007 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, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330,
18 # Boston, MA 02111-1307, USA.
19
20 # This script gives a test suite for the high-level interface of ASCEND via
21 # Python. It is also planned to be a wrapper for the CUnit test suite, although
22 # this is still experimental.
23
24 import unittest
25 import os, sys
26 import math
27 import atexit
28
29 import platform
30 if platform.system() != "Windows":
31 try:
32 import dl
33 _dlflags = dl.RTLD_GLOBAL|dl.RTLD_NOW
34 except:
35 # On platforms that unilaterally refuse to provide the 'dl' module
36 # we'll just set the value and see if it works.
37 print "Note: python 'dl' module not available on this system, guessing value of RTLD_* flags"
38 _dlflags = 258
39
40 sys.setdlopenflags(_dlflags)
41
42 class Ascend(unittest.TestCase):
43
44 def setUp(self):
45 import ascpy
46 self.L = ascpy.Library()
47
48 def tearDown(self):
49 self.L.clear()
50 del self.L
51
52 class AscendSelfTester(Ascend):
53
54 def _run(self,modelname,solvername="QRSlv",filename=None,parameters={}):
55 if filename==None:
56 filename = 'johnpye/%s.a4c' % modelname
57 self.L.load(filename)
58 T = self.L.findType(modelname)
59 M = T.getSimulation('sim')
60 M.setSolver(ascpy.Solver(solvername))
61 for k,v in parameters.iteritems():
62 M.setParameter(k,v)
63 M.solve(ascpy.Solver(solvername),ascpy.SolverReporter())
64 M.run(T.getMethod('self_test'))
65 return M
66
67 class TestCompiler(Ascend):
68
69 def _run(self,filen,modeln=""):
70 self.L.load('test/compiler/%s.a4c' % filen)
71 T = self.L.findType('%s%s' % (filen,modeln))
72 M = T.getSimulation('sim')
73 M.build()
74
75 def _runfail(self,filen,n,msg="failed"):
76 try:
77 self._run(filen,'fail%d' % n)
78 except Exception,e:
79 print "(EXPECTED) ERROR: %s" % e
80 return
81 self.fail(msg)
82
83
84 def testloading(self):
85 """library startup"""
86 pass
87
88 def testsystema4l(self):
89 """loading system.a4l?"""
90 self.L.load('system.a4l')
91
92 def testatomsa4l(self):
93 """loading atoms.a4l?"""
94 self.L.load('atoms.a4l')
95
96 def testmissingreq(self):
97 """flagging a missing REQUIRE"""
98 self._runfail('missingreq',1)
99
100 def testmissingsubreq(self):
101 """flagging a subsidiary missing REQUIRE"""
102 self._runfail('missingreq',1)
103
104 def defaultmethodstest(self,modelname):
105 self.L.load("test/defaultmethods.a4c")
106 T = self.L.findType(modelname)
107 M = T.getSimulation('sim')
108 M.run(T.getMethod('on_load'))
109 M.run(T.getMethod('self_test'))
110 return M
111
112 def testdefault1(self):
113 self.defaultmethodstest('testdefault1')
114
115 def testdefault2(self):
116 self.defaultmethodstest('testdefault2')
117
118 def testdefault3(self):
119 self.defaultmethodstest('testdefault3')
120
121 def testdefault4(self):
122 self.defaultmethodstest('testdefault4')
123
124 def testdefault5(self):
125 self.defaultmethodstest('testdefault5')
126
127 def testdefault6(self):
128 self.defaultmethodstest('testdefault6')
129
130 def testdefault7(self):
131 self.defaultmethodstest('testdefault7')
132
133 def testdefault8(self):
134 self.defaultmethodstest('testdefault8')
135
136 def testdefault9(self):
137 self.defaultmethodstest('testdefault9')
138
139 def testdefault10(self):
140 self.defaultmethodstest('testdefault10')
141
142 def testdefault11(self):
143 self.defaultmethodstest('testdefault11')
144
145 def testdefault12(self):
146 self.defaultmethodstest('testdefault12')
147
148 def testdefault13(self):
149 self.defaultmethodstest('testdefault13')
150
151 def testdefault14(self):
152 self.defaultmethodstest('testdefault14')
153
154 def testdefault15(self):
155 self.defaultmethodstest('testdefault15')
156
157 def testdefault16(self):
158 self.defaultmethodstest('testdefault16')
159
160 class TestSolver(AscendSelfTester):
161
162 def testlog10(self):
163 self._run('testlog10')
164
165 def testrootsofpoly(self):
166 self._run('roots_of_poly',filename="roots_of_poly.a4c")
167
168 def testcollapsingcan(self):
169 self._run('collapsingcan',filename="collapsingcan.a4c")
170
171 def testdistancecalc(self):
172 self._run('distance_calc',filename="distance_calc.a4c")
173
174 def testconopt(self):
175 self._run('testconopt',"CONOPT")
176
177 def testcmslv2(self):
178 self._run('testcmslv2',"CMSlv")
179
180 def testsunpos1(self):
181 self._run('example_1_6_1',"QRSlv","johnpye/sunpos.a4c")
182
183 def testsunpos2(self):
184 self._run('example_1_6_2',"QRSlv","johnpye/sunpos.a4c")
185
186 def testsunpos3(self):
187 self._run('example_1_7_1',"QRSlv","johnpye/sunpos.a4c")
188
189 def testsunpos4(self):
190 self._run('example_1_7_2',"QRSlv","johnpye/sunpos.a4c")
191
192 def testsunpos5(self):
193 self._run('example_1_7_3',"QRSlv","johnpye/sunpos.a4c")
194
195 def testsunpos6(self):
196 self._run('example_1_8_1',"QRSlv","johnpye/sunpos.a4c")
197
198 def testinstanceas(self):
199 M = self._run('example_1_6_1',"QRSlv","johnpye/sunpos.a4c")
200 self.assertAlmostEqual( float(M.t_solar), M.t_solar.as("s"))
201 self.assertAlmostEqual( float(M.t_solar)/3600, M.t_solar.as("h"))
202
203
204 class TestCMSlv(AscendSelfTester):
205 def testheatex(self):
206 self._run('heatex',"CMSlv","heatex.a4c")
207 def testphaseeq(self):
208 self._run('phaseq',"CMSlv","phaseq.a4c")
209 def testpipeline(self):
210 self._run('pipeline',"CMSlv","pipeline.a4c"
211 ,{'infinity':3.2e9}
212 )
213 def testrachford(self):
214 self._run('rachford',"CMSlv","rachford.a4c")
215 def testlinmassbal(self):
216 self._run('linmassbal',"CMSlv","linmassbal.a4c")
217
218
219 class TestMatrix(AscendSelfTester):
220 def testlog10(self):
221 M = self._run('testlog10')
222 print M.getMatrix().write(sys.stderr,"mmio")
223
224
225 class TestIntegrator(Ascend):
226
227 def testListIntegrators(self):
228 I = ascpy.Integrator.getEngines()
229 s1 = sorted([str(i) for i in I.values()])
230 s2 = sorted(['IDA','LSODE','AWW'])
231 assert s1==s2
232
233 # this routine is reused by both testIDA and testLSODE
234 def _testIntegrator(self,integratorname):
235 self.L.load('johnpye/shm.a4c')
236 M = self.L.findType('shm').getSimulation('sim')
237 M.setSolver(ascpy.Solver('QRSlv'))
238 P = M.getParameters()
239 M.setParameter('feastol',1e-12)
240 print M.getChildren()
241 assert float(M.x) == 10.0
242 assert float(M.v) == 0.0
243 t_end = math.pi
244
245 I = ascpy.Integrator(M)
246 I.setReporter(ascpy.IntegratorReporterNull(I))
247 I.setEngine(integratorname);
248 I.setLinearTimesteps(ascpy.Units("s"), 0.0, t_end, 100);
249 I.setMinSubStep(0.0001); # these limits are required by IDA at present (numeric diff)
250 I.setMaxSubStep(0.1);
251 I.setInitialSubStep(0.001);
252 I.setMaxSubSteps(200);
253 if(integratorname=='IDA'):
254 I.setParameter('autodiff',False)
255 for p in M.getParameters():
256 print p.getName(),"=",p.getValue()
257 I.analyse();
258 I.solve();
259 print "At end of simulation,"
260 print "x = %f" % M.x
261 print "v = %f" % M.v
262 assert abs(float(M.x) + 10) < 1e-2
263 assert abs(float(M.v)) < 1e-2
264 assert I.getNumObservedVars() == 3
265
266 def testInvalidIntegrator(self):
267 self.L.load('johnpye/shm.a4c')
268 M = self.L.findType('shm').getSimulation('sim')
269 M.setSolver(ascpy.Solver('QRSlv'))
270 I = ascpy.Integrator(M)
271 try:
272 I.setEngine('___NONEXISTENT____')
273 except RuntimeError:
274 return
275 self.fail("setEngine did not raise error!")
276
277 def testLSODE(self):
278 self._testIntegrator('LSODE')
279
280 def testIDA(self):
281 self._testIntegrator('IDA')
282
283 def testparameters(self):
284 self.L.load('johnpye/shm.a4c')
285 M = self.L.findType('shm').getSimulation('sim')
286 M.build()
287 I = ascpy.Integrator(M)
288 I.setEngine('IDA')
289 P = I.getParameters()
290 for p in P:
291 print p.getName(),"=",p.getValue()
292 assert len(P)==12
293 assert P[0].isStr()
294 assert P[0].getName()=="linsolver"
295 assert P[0].getValue()=='SPGMR'
296 assert P[2].getName()=="maxord"
297 assert P[3].getName()=="autodiff"
298 assert P[3].getValue()==True
299 assert P[8].getName()=="atolvect"
300 assert P[8].getBoolValue() == True
301 P[3].setBoolValue(False)
302 assert P[3].getBoolValue()==False
303 I.setParameters(P)
304 assert I.getParameterValue('autodiff')==False
305 I.setParameter('autodiff',True)
306 try:
307 v = I.getParameterValue('nonexist')
308 except KeyError:
309 pass
310 else:
311 self.fail('Failed to trip invalid Integrator parameter')
312
313 class TestLSODE(Ascend):
314
315 def testzill(self):
316 self.L.load('johnpye/zill.a4c')
317 T = self.L.findType('zill')
318 M = T.getSimulation('sim')
319 M.setSolver(ascpy.Solver('QRSlv'))
320 I = ascpy.Integrator(M)
321 I.setEngine('LSODE')
322 I.setMinSubStep(1e-7)
323 I.setMaxSubStep(0.001)
324 I.setMaxSubSteps(10000)
325 I.setReporter(ascpy.IntegratorReporterConsole(I))
326 I.setLinearTimesteps(ascpy.Units(), 1.0, 1.5, 5)
327 I.analyse()
328 I.solve()
329 M.run(T.getMethod('self_test'))
330
331 def testnewton(self):
332 sys.stderr.write("STARTING TESTNEWTON\n")
333 self.L.load('johnpye/newton.a4c')
334 T = self.L.findType('newton')
335 M = T.getSimulation('sim')
336 M.solve(ascpy.Solver("QRSlv"),ascpy.SolverReporter())
337 I = ascpy.Integrator(M)
338 I.setEngine('LSODE')
339 I.setParameter('rtolvect',False)
340 I.setParameter('rtol',1e-7)
341 I.setParameter('atolvect',False)
342 I.setParameter('atol',1e-7)
343 I.setMinSubStep(1e-7)
344 I.setMaxSubStep(0.001)
345 I.setMaxSubSteps(10000)
346
347 I.setReporter(ascpy.IntegratorReporterConsole(I))
348 I.setLinearTimesteps(ascpy.Units("s"), 0, 2*float(M.v)/float(M.g), 2)
349 I.analyse()
350 I.solve()
351 print "At end of simulation,"
352 print "x = %f" % M.x
353 print "v = %f" % M.v
354 M.run(T.getMethod('self_test'))
355
356 def testlotka(self):
357 self.L.load('johnpye/lotka.a4c')
358 M = self.L.findType('lotka').getSimulation('sim')
359 M.setSolver(ascpy.Solver("QRSlv"))
360 I = ascpy.Integrator(M)
361 I.setEngine('LSODE')
362 I.setReporter(ascpy.IntegratorReporterConsole(I))
363 I.setLinearTimesteps(ascpy.Units("s"), 0, 200, 5)
364 I.analyse()
365 print "Number of vars = %d" % I.getNumVars()
366 assert I.getNumVars()==2
367 I.solve()
368 assert I.getNumObservedVars() == 3;
369 assert abs(M.R - 832) < 1.0
370 assert abs(M.F - 21.36) < 0.1
371
372 #-------------------------------------------------------------------------------
373 # Testing of a external blackbox functions
374
375 class TestBlackBox(AscendSelfTester):
376 def testparsefail0(self):
377 try:
378 self.L.load('test/blackbox/parsefail0.a4c')
379 self.fail("parsefail0 should not have loaded without errors")
380 except:
381 pass
382
383 def testparsefail1(self):
384 try:
385 self.L.load('test/blackbox/parsefail1.a4c')
386 self.fail("parsefail1 should not have loaded without errors")
387 except:
388 pass
389
390 def testparsefail2(self):
391 try:
392 self.L.load('test/blackbox/parsefail2.a4c')
393 self.fail("parsefail2 should not have loaded without errors")
394 except:
395 pass
396
397 def testparsefail3(self):
398 try:
399 self.L.load('test/blackbox/parsefail3.a4c')
400 self.fail("parsefail3 should not have loaded without errors")
401 except:
402 pass
403
404 def testparsefail4(self):
405 try:
406 self.L.load('test/blackbox/parsefail4.a4c')
407 self.fail("parsefail4 should not have loaded")
408 except:
409 pass
410
411 def testfail1(self):
412 """Mismatched arg counts check-- tests bbox, not ascend."""
413 self.L.load('test/blackbox/fail1.a4c')
414 try:
415 M = self.L.findType('fail1').getSimulation('sim')
416 self.fail("expected exception was not raised")
417 except RuntimeError,e:
418 print "Caught exception '%s', assumed ok" % e
419
420 def testfail2(self):
421 """Incorrect data arg check -- tests bbox, not ascend"""
422 self.L.load('test/blackbox/fail2.a4c')
423 try:
424 M = self.L.findType('fail2').getSimulation('sim')
425 self.fail("expected exception was not raised")
426 except RuntimeError,e:
427 print "Caught exception '%s', assumed ok (should mention errors during instantiation)" % e
428
429 def testpass1(self):
430 """simple single bbox forward solve"""
431 M = self._run('pass1',filename='test/blackbox/pass.a4c')
432
433 def testpass2(self):
434 """simple single bbox reverse solve"""
435 M = self._run('pass2',filename='test/blackbox/pass.a4c')
436
437 def testpass3(self):
438 """simple double bbox solve"""
439 M = self._run('pass3',filename='test/blackbox/pass3.a4c')
440
441 def testpass4(self):
442 """simple double bbox reverse solve"""
443 M = self._run('pass4',filename='test/blackbox/pass3.a4c')
444
445 def testpass5(self):
446 M = self._run('pass5',filename='test/blackbox/pass5.a4c')
447
448 def testpass6(self):
449 M = self._run('pass6',filename='test/blackbox/pass5.a4c')
450
451 def testpass7(self):
452 M = self._run('pass7',filename='test/blackbox/passmerge.a4c')
453
454 def testpass8(self):
455 M = self._run('pass8',filename='test/blackbox/passmerge.a4c')
456
457 def testpass9(self):
458 M = self._run('pass9',filename='test/blackbox/passmerge.a4c')
459
460 def testpass10(self):
461 M = self._run('pass10',filename='test/blackbox/passmerge.a4c')
462
463 def testpass11(self):
464 M = self._run('pass11',filename='test/blackbox/passmerge.a4c')
465
466 def testpass12(self):
467 M = self._run('pass12',filename='test/blackbox/passmerge.a4c')
468
469 # this test doesn't work: 'system is inconsistent' -- and structurally singular
470 # def testpass13(self):
471 # """cross-merged input/output solve"""
472 # M = self._run('pass13',filename='test/blackbox/passmerge.a4c')
473
474 def testpass14(self):
475 """cross-merged input/output reverse solve"""
476 M = self._run('pass14',filename='test/blackbox/passmerge.a4c')
477
478 def testpass20(self):
479 M = self._run('pass20',filename='test/blackbox/passarray.a4c')
480
481 def testparsefail21(self):
482 """dense array of black boxes wrong syntax"""
483 try:
484 self.L.load('test/blackbox/parsefail21.a4c')
485 self.fail("parsefail21 should not have loaded without errors")
486 except:
487 pass
488
489 def testpass22(self):
490 M = self._run('pass22',filename='test/blackbox/passarray.a4c')
491
492 def testpass23(self):
493 M = self._run('pass23',filename='test/blackbox/passarray.a4c')
494
495 def testpass61(self):
496 M = self._run('pass61',filename='test/blackbox/reinstantiate.a4c')
497
498 def testpass62(self):
499 M = self._run('pass62',filename='test/blackbox/reinstantiate.a4c')
500
501 def testpass64(self):
502 M = self._run('pass64',filename='test/blackbox/reinstantiate.a4c')
503
504 def testpass65(self):
505 M = self._run('pass65',filename='test/blackbox/reinstantiate.a4c')
506
507 def testpass66(self):
508 M = self._run('pass66',filename='test/blackbox/reinstantiate.a4c')
509
510 def testpass67(self):
511 M = self._run('pass67',filename='test/blackbox/reinstantiate.a4c')
512
513 class TestExtFn(AscendSelfTester):
514 def testextfntest(self):
515 M = self._run('extfntest',filename='johnpye/extfn/extfntest.a4c')
516 self.assertAlmostEqual(M.y, 2);
517 self.assertAlmostEqual(M.x, 1);
518 self.assertAlmostEqual(M.y, M.x + 1);
519
520 def testextrelfor(self):
521 M = self._run('extrelfor',filename='johnpye/extfn/extrelfor.a4c')
522
523 ## @TODO fix bug with badly-named bbox rel in a loop (Ben, maybe)
524 # def testextrelforbadnaming(self):
525 # self.L.load('johnpye/extfn/extrelforbadnaming.a4c')
526 # T = self.L.findType('extrelfor')
527 # M = T.getSimulation('sim')
528 # M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
529 # print "x[1] = %f" % M.x[1]
530 # print "x[2] = %f" % M.x[2]
531 # print "x[3] = %f" % M.x[3]
532 # print "x[4] = %f" % M.x[4]
533 # print "x[5] = %f" % M.x[5]
534 # M.run(T.getMethod('self_test'))
535
536 def testextrelrepeat(self):
537 M = self._run('extrelrepeat',filename='johnpye/extfn/extrelrepeat.a4c')
538
539 #-------------------------------------------------------------------------------
540 # Testing of Sensitivity module
541
542 class TestSensitivity(AscendSelfTester):
543 def test1(self):
544 self.L.load('sensitivity_test.a4c')
545 T = self.L.findType('sensitivity_test')
546 M = T.getSimulation('sim',False)
547 M.run(T.getMethod('on_load'))
548 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
549 M.run(T.getMethod('analyse'))
550 M.run(T.getMethod('self_test'))
551
552 # def testall(self):
553 # self.L.load('sensitivity_test.a4c')
554 # T = self.L.findType('sensitivity_test_all')
555 # M = T.getSimulation('sim',False)
556 # M.run(T.getMethod('on_load'))
557 # M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
558 # M.run(T.getMethod('analyse'))
559 # M.run(T.getMethod('self_test'))
560 # CAUSES CRASH
561
562 #-------------------------------------------------------------------------------
563 # Testing of a ExtPy - external python methods
564
565 class TestExtPy(AscendSelfTester):
566 def test1(self):
567 self.L.load('johnpye/extpy/extpytest.a4c')
568 T = self.L.findType('extpytest')
569 M = T.getSimulation('sim')
570 M.run(T.getMethod('self_test'))
571
572 def test2(self):
573 self.L.load('johnpye/extpy/extpytest.a4c')
574 T = self.L.findType('extpytest')
575 M = T.getSimulation('sim')
576 M.run(T.getMethod('pythonthing'))
577 M.run(T.getMethod('pythonthing'))
578 M.run(T.getMethod('pythonthing'))
579 M.run(T.getMethod('pythonthing'))
580 M.run(T.getMethod('pythonthing'))
581 M.run(T.getMethod('pythonthing'))
582 M.run(T.getMethod('pythonthing'))
583 # causes crash!
584
585 #-------------------------------------------------------------------------------
586 # Testing of saturated steam properties library (iapwssatprops.a4c)
587
588 class TestSteam(AscendSelfTester):
589
590 def testiapwssatprops1(self):
591 M = self._run('testiapwssatprops1',filename='steam/iapwssatprops.a4c')
592 def testiapwssatprops2(self):
593 M = self._run('testiapwssatprops2',filename='steam/iapwssatprops.a4c')
594 def testiapwssatprops3(self):
595 M = self._run('testiapwssatprops3',filename='steam/iapwssatprops.a4c')
596
597 # test the stream model basically works
598 def testsatsteamstream(self):
599 M = self._run('satsteamstream',filename='steam/satsteamstream.a4c')
600
601 # test that we can solve in terms of various (rho,u)
602 def testsatuv(self):
603 self.L.load('steam/iapwssat.a4c')
604 T = self.L.findType('testiapwssatuv')
605 M = T.getSimulation('sim',False)
606 M.run(T.getMethod('on_load'))
607 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
608 print "p = %f bar" % M.p.as('bar');
609 print "T = %f C" % (M.T.as('K') - 273.15);
610 print "x = %f" % M.x;
611 M.run(T.getMethod('self_test'))
612 M.run(T.getMethod('values2'))
613 # M.v.setRealValueWithUnits(1.0/450,"m^3/kg");
614 # M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
615 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
616 print "p = %f bar" % M.p.as('bar');
617 print "T = %f C" % (M.T.as('K') - 273.15);
618 print "x = %f" % M.x;
619 M.run(T.getMethod('self_test2'))
620
621
622 ## @TODO fix error capture from bounds checking during initialisation
623 # def testiapwssat1(self):
624 # M = self._run('testiapwssat1',filename='steam/iapwssat.a4c')
625
626 def testdsgsat(self):
627 self.L.load('steam/dsgsat3.a4c')
628 T = self.L.findType('dsgsat3')
629 M = T.getSimulation('sim',False)
630 M.run(T.getMethod('on_load'))
631 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
632 self.assertAlmostEqual(M.dTw_dt[2],0.0);
633 M.run(T.getMethod('configure_dynamic'))
634 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
635 return M
636
637 def testdsgsatrepeat(self):
638 self.L.load('steam/dsgsat3.a4c')
639 T = self.L.findType('dsgsat3')
640 M = T.getSimulation('sim',False)
641 M.run(T.getMethod('on_load'))
642 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
643 M.run(T.getMethod('on_load'))
644 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
645 M.run(T.getMethod('on_load'))
646 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
647
648 def testvary(self):
649 self.L.load('steam/dsgsat3.a4c')
650 T = self.L.findType('dsgsat3')
651 M = T.getSimulation('sim',False)
652 M.run(T.getMethod('on_load'))
653 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
654 print "----- setting qdot_s -----"
655 M.qdot_s.setRealValueWithUnits(1000,"W/m")
656 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
657 print "----- setting qdot_s -----"
658 M.qdot_s.setRealValueWithUnits(2000,"W/m")
659 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
660
661 def teststeadylsode(self):
662 "test that steady conditions are stable with LSODE"
663 M = self.testdsgsat()
664 #M.qdot_s.setRealValueWithUnits(1000,"W/m")
665 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
666 #M.setParameter('
667 I = ascpy.Integrator(M)
668 I.setEngine('LSODE')
669 I.setReporter(ascpy.IntegratorReporterConsole(I))
670 I.setLinearTimesteps(ascpy.Units("s"), 0, 3600, 10)
671 I.analyse()
672 I.solve()
673
674 # DOESN'T CONVERGE
675 # def testpeturblsode(self):
676 # "test that steady conditions are stable with LSODE"
677 # M = self.testdsgsat()
678 # # here is the peturbation...
679 # M.qdot_s.setRealValueWithUnits(1000,"W/m")
680 # M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
681 # I = ascpy.Integrator(M)
682 # I.setEngine('LSODE')
683 # I.setReporter(ascpy.IntegratorReporterConsole(I))
684 # I.setLinearTimesteps(ascpy.Units("s"), 0, 5, 1)
685 # I.analyse()
686 # I.solve()
687
688 def teststeadyida(self):
689 M = self.testdsgsat()
690 self.assertAlmostEqual(M.dTw_dt[2],0.0)
691 Tw1 = float(M.T_w[2])
692 T = self.L.findType('dsgsat3')
693 M.run(T.getMethod('free_states'))
694 I = ascpy.Integrator(M)
695 I.setEngine('IDA')
696 I.setParameter('linsolver','DENSE')
697 I.setParameter('safeeval',True)
698 I.setParameter('rtol',1e-4)
699 I.setParameter('atolvect',False)
700 I.setParameter('atol',1e-4)
701 I.setParameter('maxord',3)
702 I.setInitialSubStep(0.001)
703 I.setReporter(ascpy.IntegratorReporterConsole(I))
704 I.setLinearTimesteps(ascpy.Units("s"), 0, 3600, 10)
705 I.analyse()
706 I.solve()
707 self.assertAlmostEqual(float(M.T_w[2]),Tw1)
708 M.qdot_s.setRealValueWithUnits(1000,"W/m")
709 self.assertAlmostEqual(M.qdot_s.as("W/m"),1000)
710 M.solve(ascpy.Solver('QRSlv'),ascpy.SolverReporter())
711 print "dTw/dt = %f" % M.dTw_dt[2]
712 self.assertNotAlmostEqual(M.dTw_dt[2],0.0)
713
714 def testpeturbida(self):
715 M = self.testdsgsat()
716 self.assertAlmostEqual(M.dTw_dt[2],0.0)
717 T = self.L.findType('dsgsat3')
718 M.run(T.getMethod('free_states'))
719 # here is the peturbation...
720 M.qdot_s.setRealValueWithUnits(6000,"W/m")
721 # IDA has its own initial conditions solver, so no need to call QRSlv here
722 I = ascpy.Integrator(M)
723 I.setEngine('IDA')
724 I.setParameter('linsolver','DENSE')
725 I.setParameter('safeeval',True)
726 I.setParameter('rtol',1e-4)
727 I.setParameter('atolvect',False)
728 I.setParameter('atol',1e-4)
729 I.setParameter('maxord',3)
730 I.setInitialSubStep(0.001)
731 I.setReporter(ascpy.IntegratorReporterConsole(I))
732 I.setLogTimesteps(ascpy.Units("s"), 0.001, 3600, 40)
733 I.analyse()
734 I.solve()
735
736 #-------------------------------------------------------------------------------
737 # Testing of freesteam external steam properties functions
738
739 with_freesteam = True
740 try:
741 # we assume that if the freesteam python module is installed, the ASCEND
742 # external library will also be.
743 import freesteam
744 have_freesteam = True
745 except ImportError,e:
746 have_freesteam = False
747
748 if with_freesteam and have_freesteam:
749 class TestFreesteam(AscendSelfTester):
750 # def testfreesteamtest(self):
751 # """run the self-test cases bundled with freesteam"""
752 # self._run('testfreesteam',filename='testfreesteam.a4c')
753
754 def testload(self):
755 """check that we can load 'thermalequilibrium2' (IMPORT "freesteam", etc)"""
756 self.L.load('johnpye/thermalequilibrium2.a4c')
757
758 def testinstantiate(self):
759 """load an instantiate 'thermalequilibrium2'"""
760 self.testload()
761 M = self.L.findType('thermalequilibrium2').getSimulation('sim')
762 return M
763
764 def testintegrate(self):
765 """integrate transfer of heat from one mass of water/steam to another
766 according to Newton's law of cooling"""
767 M = self.testinstantiate()
768 M.setSolver(ascpy.Solver("QRSlv"))
769 I = ascpy.Integrator(M)
770 I.setEngine('LSODE')
771 I.setReporter(ascpy.IntegratorReporterConsole(I))
772 I.setLinearTimesteps(ascpy.Units("s"), 0, 3000, 30)
773 I.setMinSubStep(0.01)
774 I.setInitialSubStep(1)
775 I.analyse()
776 print "Number of vars = %d" % I.getNumVars()
777 assert I.getNumVars()==2
778 I.solve()
779 assert I.getNumObservedVars() == 3;
780 print "S[1].T = %f K" % M.S[1].T
781 print "S[2].T = %f K" % M.S[2].T
782 print "Q = %f W" % M.Q
783 self.assertAlmostEqual(float(M.S[1].T),506.77225109,4);
784 self.assertAlmostEqual(float(M.S[2].T),511.605173967,5);
785 self.assertAlmostEqual(float(M.Q),-48.32922877329,3);
786 self.assertAlmostEqual(float(M.t),3000);
787 print "Note that the above values have not been verified analytically"
788
789 def testcollapsingcan2(self):
790 """ solve the collapsing can model using IAPWS-IF97 steam props """
791 M = self._run("collapsingcan2",filename="collapsingcan2.a4c");
792
793 #-------------------------------------------------------------------------------
794 # Testing of IDA's analysis module
795
796 class TestIDA(Ascend):
797 def _run(self,filen,modeln=""):
798 self.L.load('test/ida/%s.a4c' % filen)
799 T = self.L.findType('%s%s' % (filen,modeln))
800 M = T.getSimulation('sim')
801 M.build()
802 I = ascpy.Integrator(M)
803 I.setEngine('IDA')
804 I.analyse()
805 return M;
806
807 def _runfail(self,filen,n,msg="failed"):
808 try:
809 self._run(filen,'fail%d' % n)
810 except Exception,e:
811 print "(EXPECTED) ERROR: %s" % e
812 return
813 self.fail(msg)
814
815 def testsinglederiv(self):
816 self._run('singlederiv')
817
818 def testsinglederivfail1(self):
819 self._runfail('singlederiv',1
820 ,"t.ode_id=-1 did not trigger error")
821
822 def testsinglederivfail2(self):
823 self._runfail('singlederiv',2
824 ,"dy_dt.ode_id=2 did not trigger error")
825
826 def testsinglederivfail3(self):
827 self._runfail('singlederiv',3
828 ,"dy_dt.ode_type=3 did not trigger error")
829
830 def testsinglederivfail4(self):
831 self._runfail('singlederiv',4
832 ,"duplicate ode_type=1 did not trigger error")
833
834 def testsinglederivfail5(self):
835 self._runfail('singlederiv',5
836 ,"duplicate ode_type=1 did not trigger error")
837
838 def testsinglederivfail6(self):
839 self._runfail('singlederiv',6
840 ,"duplicate ode_type=1 did not trigger error")
841
842 def testtwoderiv(self):
843 self._run('twoderiv')
844
845 def testtwoderivfail1(self):
846 self._runfail('twoderiv',1)
847
848 def testtwoderivfail2(self):
849 self._runfail('twoderiv',2)
850
851 def testtwoderivfail3(self):
852 self._runfail('twoderiv',3)
853 def testtwoderivfail4(self):
854 self._runfail('twoderiv',4)
855 def testtwoderivfail5(self):
856 self._runfail('twoderiv',5)
857
858 def testnoderivs(self):
859 self._runfail('noderivs',1)
860
861 def testnoindeps(self):
862 self._runfail('indeps',1)
863
864 def testtwoindeps(self):
865 self._runfail('indeps',2)
866
867 def testfixedvars(self):
868 self._run('fixedvars')
869
870 def testfixedvars1(self):
871 self._run('fixedvars',1)
872
873 def testfixedvars2(self):
874 self._run('fixedvars',2)
875
876 def testfixedvars3(self):
877 self._run('fixedvars',3)
878
879 def testincidence(self):
880 self._run('incidence')
881
882 def testincidence1(self):
883 self._run('incidence',1)
884 def testincidence2(self):
885 self._run('incidence',2)
886 def testincidence3(self):
887 M = self._run('incidence',3)
888
889 def testincidence4(self):
890 self._run('incidence',4)
891 def testincidencefail5(self):
892 self._runfail('incidence',5)
893
894 # doesn't work yet:
895 # def testincidence5(self):
896 # self._run('incidence',5)
897
898
899 #-------------------------------------------------------------------------------
900 # Testing of IDA models using DENSE linear solver
901
902 class TestIDADENSE(Ascend):
903 """IDA DAE integrator, DENSE linear solver"""
904
905 def testlotka(self):
906 self.L.load('johnpye/lotka.a4c')
907 M = self.L.findType('lotka').getSimulation('sim')
908 M.setSolver(ascpy.Solver("QRSlv"))
909 I = ascpy.Integrator(M)
910 I.setEngine('IDA')
911 I.setReporter(ascpy.IntegratorReporterConsole(I))
912 I.setLinearTimesteps(ascpy.Units("s"), 0, 200, 5);
913 I.setParameter('linsolver','DENSE')
914 I.setParameter('rtol',1e-8);
915 I.analyse()
916 assert I.getNumVars()==2
917 assert abs(M.R - 1000) < 1e-300
918 I.solve()
919 assert I.getNumObservedVars() == 3
920 assert abs(M.R - 832) < 1.0
921 assert abs(M.F - 21.36) < 0.1
922
923 def testdenx(self):
924 print "-----------------------------====="
925 self.L.load('johnpye/idadenx.a4c')
926 M = self.L.findType('idadenx').getSimulation('sim')
927 M.setSolver(ascpy.Solver("QRSlv"))
928 I = ascpy.Integrator(M)
929 I.setEngine('IDA')
930 I.setParameter('calcic','YA_YDP')
931 I.setParameter('linsolver','DENSE')
932 I.setParameter('safeeval',True)
933 I.setReporter(ascpy.IntegratorReporterConsole(I))
934 I.setLogTimesteps(ascpy.Units("s"), 0.4, 4e10, 11)
935 I.setMaxSubStep(0);
936 I.setInitialSubStep(0)
937 I.setMaxSubSteps(0)
938 I.setParameter('autodiff',True)
939 I.analyse()
940 I.solve()
941 assert abs(float(M.y1) - 5.1091e-08) < 2e-9
942 assert abs(float(M.y2) - 2.0437e-13) < 2e-14
943 assert abs(float(M.y3) - 1.0) < 1e-5
944
945 def testhires(self):
946 self.L.load('test/hires.a4c')
947 T = self.L.findType('hires')
948 M = T.getSimulation('sim')
949 M.setSolver(ascpy.Solver('QRSlv'))
950 I = ascpy.Integrator(M)
951 I.setEngine('IDA')
952 I.setParameter('linsolver','DENSE')
953 I.setParameter('rtol',1.1e-15)
954 I.setParameter('atolvect',0)
955 I.setParameter('atol',1.1e-15)
956 I.setReporter(ascpy.IntegratorReporterConsole(I))
957 I.setLogTimesteps(ascpy.Units(""), 1, 321.8122, 5)
958 I.setInitialSubStep(1e-5)
959 I.setMaxSubSteps(10000)
960 I.analyse()
961 I.solve()
962 for i in range(8):
963 print "y[%d] = %.20g" % (i+1, M.y[i+1])
964 M.run(T.getMethod('self_test'))
965
966 def testchemakzo(self):
967 self.L.load('test/chemakzo.a4c')
968 T = self.L.findType('chemakzo')
969 M = T.getSimulation('sim')
970 M.setSolver(ascpy.Solver('QRSlv'))
971 I = ascpy.Integrator(M)
972 I.setEngine('IDA')
973 I.setParameter('linsolver','DENSE')
974 I.setParameter('rtol',1e-15)
975 I.setParameter('atolvect',0)
976 I.setParameter('atol',1e-15)
977 I.setReporter(ascpy.IntegratorReporterConsole(I))
978 I.setLinearTimesteps(ascpy.Units("s"), 1, 180, 5)
979 I.setInitialSubStep(1e-13)
980 I.setMaxSubSteps(10000)
981 I.analyse()
982 I.solve()
983 for i in range(6):
984 print "y[%d] = %.20g" % (i+1, M.y[i+1])
985 M.run(T.getMethod('self_test'))
986
987 def testtransamp(self):
988 self.L.load('test/transamp.a4c')
989 T = self.L.findType('transamp')
990 M = T.getSimulation('sim')
991 M.setSolver(ascpy.Solver('QRSlv'))
992 I = ascpy.Integrator(M)
993 I.setEngine('IDA')
994 I.setParameter('linsolver','DENSE')
995 I.setParameter('rtol',1e-7)
996 I.setParameter('atolvect',0)
997 I.setParameter('atol',1e-7)
998 I.setReporter(ascpy.IntegratorReporterConsole(I))
999 I.setLinearTimesteps(ascpy.Units("s"), 0.05, 0.2, 20)
1000 I.setInitialSubStep(0.00001)
1001 I.setMaxSubSteps(10000)
1002 I.analyse()
1003 I.solve()
1004 for i in range(6):
1005 print "y[%d] = %.20g" % (i+1, M.y[i+1])
1006 M.run(T.getMethod('self_test'))
1007
1008 # MODEL FAILS ANALYSIS: we need to add support for non-incident differential vars
1009 # def testpollution(self):
1010 # self.L.load('test/pollution.a4c')
1011 # T = self.L.findType('pollution')
1012 # M = T.getSimulation('sim')
1013 # M.setSolver(ascpy.Solver('QRSlv'))
1014 # I = ascpy.Integrator(M)
1015 # I.setEngine('IDA')
1016 # I.setParameter('linsolver','DENSE')
1017 # I.setParameter('rtol',1.1e-15)
1018 # I.setParameter('atolvect',0)
1019 # I.setParameter('atol',1.1e-15)
1020 # I.setReporter(ascpy.IntegratorReporterConsole(I))
1021 # I.setLogTimesteps(ascpy.Units("s"), 1, 60, 5)
1022 # I.setInitialSubStep(1e-5)
1023 # I.setMaxSubSteps(10000)
1024 # I.analyse()
1025 # I.solve()
1026 # for i in range(20):
1027 # print "y[%d] = %.20g" % (i+1, M.y[i+1])
1028 # M.run(T.getMethod('self_test'))
1029
1030 ## @TODO fails during IDACalcIC (model too big?)
1031 # def testkryx(self):
1032 # self.L.load('johnpye/idakryx.a4c')
1033 # ascpy.getCompiler().setUseRelationSharing(False)
1034 # M = self.L.findType('idakryx').getSimulation('sim')
1035 # M.setSolver(ascpy.Solver('QRSlv'))
1036 # M.build()
1037 # I = ascpy.Integrator(M)
1038 # I.setEngine('IDA')
1039 # I.setReporter(ascpy.IntegratorReporterConsole(I))
1040 # I.setParameter('linsolver','DENSE')
1041 # I.setParameter('maxl',8)
1042 # I.setParameter('gsmodified',False)
1043 # I.setParameter('autodiff',True)
1044 # I.setParameter('rtol',0)
1045 # I.setParameter('atol',1e-3);
1046 # I.setParameter('atolvect',False)
1047 # I.setParameter('calcic','YA_YDP')
1048 # I.analyse()
1049 # I.setLogTimesteps(ascpy.Units("s"), 0.01, 10.24, 11)
1050 # I.solve()
1051 # assert abs(M.u[2][2].getValue()) < 1e-5
1052
1053 #-------------------------------------------------------------------------------
1054 # Testing of IDA models using SPGMR linear solver (Krylov)
1055
1056 # these tests are disabled until SPGMR preconditioning has been implemented
1057 class TestIDASPGMR:#(Ascend):
1058 def testlotka(self):
1059 self.L.load('johnpye/lotka.a4c')
1060 M = self.L.findType('lotka').getSimulation('sim')
1061 M.setSolver(ascpy.Solver("QRSlv"))
1062 I = ascpy.Integrator(M)
1063 I.setEngine('IDA')
1064 I.setReporter(ascpy.IntegratorReporterConsole(I))
1065 I.setLinearTimesteps(ascpy.Units("s"), 0, 200, 5)
1066 I.setParameter('rtol',1e-8)
1067 I.analyse()
1068 assert I.getNumVars()==2
1069 assert abs(M.R - 1000) < 1e-300
1070 I.solve()
1071 assert I.getNumObservedVars() == 3
1072 assert abs(M.R - 832) < 1.0
1073 assert abs(M.F - 21.36) < 0.1
1074
1075
1076 def testkryx(self):
1077 self.L.load('johnpye/idakryx.a4c')
1078 M = self.L.findType('idakryx').getSimulation('sim')
1079 M.build()
1080 I = ascpy.Integrator(M)
1081 I.setEngine('IDA')
1082 I.setReporter(ascpy.IntegratorReporterConsole(I))
1083 I.setParameter('linsolver','SPGMR')
1084 I.setParameter('prec','JACOBI')
1085 I.setParameter('maxl',8)
1086 I.setParameter('gsmodified',False)
1087 I.setParameter('autodiff',True)
1088 I.setParameter('gsmodified',True)
1089 I.setParameter('rtol',0)
1090 I.setParameter('atol',1e-3);
1091 I.setParameter('atolvect',False)
1092 I.setParameter('calcic','Y')
1093 I.analyse()
1094 I.setLogTimesteps(ascpy.Units("s"), 0.01, 10.24, 10);
1095 print M.udot[1][3]
1096 I.solve()
1097 assert 0
1098
1099 def testzill(self):
1100 self.L.load('johnpye/zill.a4c')
1101 T = self.L.findType('zill')
1102 M = T.getSimulation('sim')
1103 M.setSolver(ascpy.Solver('QRSlv'))
1104 I = ascpy.Integrator(M)
1105 I.setEngine('IDA')
1106 I.setParameter('safeeval',False)
1107 I.setMinSubStep(1e-7)
1108 I.setMaxSubStep(0.001)
1109 I.setMaxSubSteps(10000)
1110 I.setReporter(ascpy.IntegratorReporterConsole(I))
1111 I.setLinearTimesteps(ascpy.Units(), 1.0, 1.5, 5)
1112 I.analyse()
1113 I.solve()
1114 M.run(T.getMethod('self_test'))
1115
1116 def testdenxSPGMR(self):
1117 self.L.load('johnpye/idadenx.a4c')
1118 M = self.L.findType('idadenx').getSimulation('sim')
1119 M.setSolver(ascpy.Solver('QRSlv'))
1120 I = ascpy.Integrator(M)
1121 I.setEngine('IDA')
1122 I.setReporter(ascpy.IntegratorReporterConsole(I))
1123 I.setLogTimesteps(ascpy.Units("s"), 0.4, 4e10, 11)
1124 I.setMaxSubStep(0);
1125 I.setInitialSubStep(0);
1126 I.setMaxSubSteps(0);
1127 I.setParameter('autodiff',True)
1128 I.setParameter('linsolver','SPGMR')
1129 I.setParameter('gsmodified',False)
1130 I.setParameter('maxncf',10)
1131 I.analyse()
1132 I.solve()
1133 assert abs(float(M.y1) - 5.1091e-08) < 1e-10
1134 assert abs(float(M.y2) - 2.0437e-13) < 1e-15
1135 assert abs(float(M.y3) - 1.0) < 1e-5
1136
1137 # move code above down here if you want to temporarily avoid testing it
1138 class NotToBeTested:
1139 def nothing(self):
1140 pass
1141
1142 def testnewton(self):
1143 sys.stderr.write("STARTING TESTNEWTON\n")
1144 self.L.load('johnpye/newton.a4c')
1145 T = self.L.findType('newton')
1146 M = T.getSimulation('sim')
1147 M.solve(ascpy.Solver("QRSlv"),ascpy.SolverReporter())
1148 I = ascpy.Integrator(M)
1149 I.setEngine('IDA')
1150 I.setParameter('linsolver','DENSE')
1151 I.setParameter('safeeval',True)
1152 I.setParameter('rtol',1e-8)
1153 I.setMaxSubStep(0.001)
1154 I.setMaxSubSteps(10000)
1155
1156 I.setReporter(ascpy.IntegratorReporterConsole(I))
1157 I.setLinearTimesteps(ascpy.Units("s"), 0, 2*float(M.v)/float(M.g), 2)
1158 I.analyse()
1159 I.solve()
1160 print "At end of simulation,"
1161 print "x = %f" % M.x
1162 print "v = %f" % M.v
1163 M.run(T.getMethod('self_test'))
1164
1165 if __name__=='__main__':
1166 # a whole bag of tricks to make sure we get the necessary dirs in our ascend, python and ld path vars
1167 restart = 0
1168
1169 if platform.system()=="Windows":
1170 LD_LIBRARY_PATH="PATH"
1171 SEP = ";"
1172 else:
1173 LD_LIBRARY_PATH="LD_LIBRARY_PATH"
1174 SEP = ":"
1175
1176 freesteamdir = os.path.expanduser("~/freesteam/ascend")
1177 modeldirs = [os.path.abspath(os.path.join(sys.path[0],"models")),os.path.abspath(freesteamdir)]
1178 if not os.environ.get('ASCENDLIBRARY'):
1179 os.environ['ASCENDLIBRARY'] = SEP.join(modeldirs)
1180 restart = 1
1181 else:
1182 envmodelsdir = [os.path.abspath(i) for i in os.environ['ASCENDLIBRARY'].split(SEP)]
1183 for l in modeldirs:
1184 if l in envmodelsdir[len(modeldirs):]:
1185 envmodelsdir.remove(l)
1186 restart = 1
1187 for l in modeldirs:
1188 if l not in envmodelsdir:
1189 envmodelsdir.insert(0,l)
1190 restart = 1
1191 os.environ['ASCENDLIBRARY'] = SEP.join(envmodelsdir)
1192
1193 libdirs = ["pygtk","."]
1194 libdirs = [os.path.normpath(os.path.join(sys.path[0],l)) for l in libdirs]
1195 if not os.environ.get(LD_LIBRARY_PATH):
1196 os.environ[LD_LIBRARY_PATH]=SEP.join(libdirs)
1197 restart = 1
1198 else:
1199 envlibdirs = [os.path.normpath(i) for i in os.environ[LD_LIBRARY_PATH].split(SEP)]
1200 for l in libdirs:
1201 if l in envlibdirs[len(libdirs):]:
1202 envlibdirs.remove(l)
1203 restart = 1
1204 for l in libdirs:
1205 if l not in envlibdirs:
1206 envlibdirs.insert(0,l)
1207 restart = 1
1208 os.environ[LD_LIBRARY_PATH] = SEP.join(envlibdirs)
1209
1210 pypath = os.path.normpath(os.path.join(sys.path[0],"pygtk"))
1211 if not os.environ.get('PYTHONPATH'):
1212 os.environ['PYTHONPATH']=pypath
1213 else:
1214 envpypath = os.environ['PYTHONPATH'].split(SEP)
1215 if pypath not in envpypath:
1216 envpypath.insert(0,pypath)
1217 os.environ['PYTHONPATH']=SEP.join(envpypath)
1218 restart = 1
1219
1220 if restart:
1221 script = os.path.join(sys.path[0],"test.py")
1222 print "Restarting with..."
1223 print " export LD_LIBRARY_PATH=%s" % os.environ.get(LD_LIBRARY_PATH)
1224 print " export PYTHONPATH=%s" % os.environ.get('PYTHONPATH')
1225 print " export ASCENDLIBRARY=%s" % os.environ.get('ASCENDLIBRARY')
1226
1227 os.execvp("python",[script] + sys.argv)
1228
1229 import ascpy
1230
1231 try:
1232 import cunit
1233 except:
1234 pass
1235
1236 atexit.register(ascpy.shutdown)
1237 #suite = unittest.TestSuite()
1238 #suite = unittest.defaultTestLoader.loadTestsFromName('__main__')
1239 #unittest.TextTestRunner(verbosity=2).run(suite)
1240 unittest.main()

Properties

Name Value
svn:executable *

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