/[ascend]/trunk/models/johnpye/solvernotes.py
ViewVC logotype

Contents of /trunk/models/johnpye/solvernotes.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1133 - (show annotations) (download) (as text)
Sun Jan 14 11:51:48 2007 UTC (15 years, 5 months ago) by johnpye
File MIME type: text/x-python
File size: 2158 byte(s)
Removed the 'REX' and 'IEX' array aliases (added the solver parameter comments directly in the slv_param_* calls).
Renamed Simulation::[gs]etSolverParameters to Simulation::[gs]etParameters.
Added [gs]etParameter (singular) methods to SWIG wrapper.
Fixed missing NULL in IDA.
Fixed bug with BDF/AM wrong way round in LSODE.
Removed some debug output from slv.c
1 import ascpy
2 import extpy
3
4 def solvernotes(self):
5 """ use the NOTES DB to set parameters applicable to the current active solver """
6 print "SETUP_SOLVER..."
7 sim = ascpy.Registry().getSimulation('sim')
8
9 browser = extpy.getbrowser()
10 if browser:
11 reporter = browser.reporter
12 else:
13 print "Using console solver reporter"
14 reporter = ascpy.getReporter()
15
16 if browser:
17 print "Using browser.solver"
18 solver = browser.solver
19 else:
20 print "Using hardwired default solver, QRSlv"
21 solver = ascpy.Solver("QRSlv")
22
23
24 db = ascpy.Library().getAnnotationDatabase()
25
26 print "GOT SIM..."
27
28 if not sim:
29 reporter.reportError("No simulation present yet")
30 return
31
32 if not solver:
33 reporter.reportError("No solver yet")
34 return
35
36 # the simulation needs to be built at this point, else solver could not
37 # be selected, and hence solver params could not be assigned.
38 sim.build()
39
40 # use the solver selected in the browser
41 sim.setSolver(solver)
42
43 solvername = solver.getName()
44 reporter.reportNote("Active solver is '%s'" % solvername)
45
46 notes = db.getNotes(self.getType(),ascpy.SymChar(solvername))
47
48 print "GETTINGS SOLVER PARAMS..."
49
50 params = sim.getParameters()
51
52 print "DONE SOLVER PARAMS"
53
54 print params
55
56 paramnames = [p.getName() for p in params]
57
58 print "DONE PARAMS"
59
60 for i in range(0,len(notes)):
61 note = notes[i]
62
63 if note.getId()==None:
64 #browser.reporter.reportNote("Empty note ID...")
65 continue
66 n = note.getId()
67 param = None
68 for p in params:
69 if p.getName()==n:
70 param = p
71 if param:
72 if param.isInt():
73 v = int( note.getText() )
74 param.setIntValue(v)
75 elif param.isReal():
76 v = float( note.getText() )
77 param.setRealValue(v)
78 elif param.isString():
79 v = note.getText()
80 param.setStrValue(v)
81 elif param.isBool():
82 v = bool( note.getText() )
83 param.setBoolValue(v)
84 else:
85 raise Exception("unknown parameter type")
86 reporter.reportNote("Set %s = %s" % (param.getName(),v))
87 else:
88 reporter.reportWarning("Ignoring unrecognised parameter '%s' for solver '%s' (from solver notes)\n%s:%d" % (n,solvername,note.getFilename(),note.getLineNumber()))
89
90 extpy.registermethod(solvernotes)

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