Parametric studies: Difference between revisions
Restored page from Google Cache, uploaded by John Pye |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{experimental}} | |||
''If you are interested in '''parametric models''', see the page on [[object-oriented modelling]] instead.'' | |||
The following code snippet implements something like the old <tt>[[STUDY]]</tt> method from the Tcl/Tk GUI. In this version, it is implemented as a plot, as shown above. At present the python script must be modified each time you want to change the parameters in your study. With some work, we hope to encapsulate this so that the [[STUDY]] can be created with only a METHOD call in the .a4l file. | The following code snippet implements something like the old <tt>[[STUDY]]</tt> method from the Tcl/Tk GUI. In this version, it is implemented as a plot, as shown above. At present the python script must be modified each time you want to change the parameters in your study. With some work, we hope to encapsulate this so that the [[STUDY]] can be created with only a METHOD call in the .a4l file. | ||
[[Image:Parameter-study.png]|thumb|400|none|Results of parametric study using [[ExtPy]] functionality]] | |||
<source lang=" | <source lang="py">import extpy; | ||
from pylab import * | |||
from solverreporter import * | |||
def studyplot(self): | |||
# following is an unfortunate necessity in the current system architecture: | # following is an unfortunate necessity in the current system architecture: | ||
| Line 24: | Line 25: | ||
figure() | figure() | ||
#self.inlet.p.setRealValueWithUnits(20, | #self.inlet.p.setRealValueWithUnits(20,"bar"); | ||
#self.inlet.T.setRealValueWithUnits(100+273.15, | #self.inlet.T.setRealValueWithUnits(100+273.15,"K") | ||
betavals = [0.2177, 0.25, 0.275,0.3, 0.325,0.35,0.4,0.45,0.5, 0.7,0.9] | betavals = [0.2177, 0.25, 0.275,0.3, 0.325,0.35,0.4,0.45,0.5, 0.7,0.9] | ||
| Line 33: | Line 34: | ||
plots = 0 | plots = 0 | ||
for beta in betavals: | for beta in betavals: | ||
print | print "BETA = %f" % beta | ||
self.OP.beta.setRealValue(beta) | self.OP.beta.setRealValue(beta) | ||
| Line 42: | Line 43: | ||
mdot = mdot_min + (mdot_max-mdot_min)*i/n | mdot = mdot_min + (mdot_max-mdot_min)*i/n | ||
self.mdot.setRealValueWithUnits(mdot, | self.mdot.setRealValueWithUnits(mdot,"kg/s") | ||
try: | try: | ||
browser.sim.solve(browser.solver,SimpleSolverReporter(browser, | browser.sim.solve(browser.solver,SimpleSolverReporter(browser,"beta = %f, mdot = %f"%(beta,mdot))) | ||
except: | except: | ||
browser.reporter.reportError('Failed to solve for mdot = | browser.reporter.reportError('Failed to solve for mdot = %d' % mdot) | ||
continue | continue | ||
xdata.append(mdot) | xdata.append(mdot) | ||
ydata.append(-self.dp.as( | ydata.append(-self.dp.as("bar")) | ||
if xdata: | if xdata: | ||
| Line 63: | Line 64: | ||
if plots: | if plots: | ||
xlabel( | xlabel("Mass flow rate / [kg/s]") | ||
ylabel( | ylabel("Pressure drop / [bar]") | ||
title( | title("Pressure drop vs flow rate, various orifice ratios") | ||
legend(loc='upper left') | legend(loc='upper left') | ||
| Line 73: | Line 74: | ||
show() | show() | ||
else: | else: | ||
browser.reporter.reportError( | browser.reporter.reportError("NO PLOTS CREATED") | ||
extpy.registermethod(studyplot) | |||
#the above method can be called using "EXTERNAL studyplot(SELF)" in ASCEND.</source> | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
Latest revision as of 08:13, 29 March 2011
If you are interested in parametric models, see the page on object-oriented modelling instead.
The following code snippet implements something like the old STUDY method from the Tcl/Tk GUI. In this version, it is implemented as a plot, as shown above. At present the python script must be modified each time you want to change the parameters in your study. With some work, we hope to encapsulate this so that the STUDY can be created with only a METHOD call in the .a4l file.
[[Image:Parameter-study.png]|thumb|400|none|Results of parametric study using ExtPy functionality]]
Invalid language.
You need to specify a language like this: <source lang="html">...</source>
Supported languages for syntax highlighting:
a4c, abap, abc, abnf, actionscript, ada, agda, alan, algol, ampl, amtrix, applescript, arc, arm, as400cl, ascend, asciidoc, asp, aspect, assembler, ats, autohotkey, autoit, avenue, awk, ballerina, bat, bbcode, bcpl, bibtex, biferno, bison, blitzbasic, bms, bnf, boo, c, carbon, ceylon, charmm, chill, chpl, clean, clearbasic, clipper, clojure, clp, cmake, cobol, coffeescript, coldfusion, conf, cpp2, critic, crk, crystal, cs_block_regex, csharp, css, d, dart, delphi, diff, dockerfile, dts, dylan, ebnf, ebnf2, eiffel, elixir, elm, email, erb, erlang, euphoria, exapunks, excel, express, factor, fame, fasm, felix, fish, fortran77, fortran90, frink, fsharp, fstab, fx, gambas, gdb, gdscript, go, graphviz, haml, hare, haskell, haxe, hcl, html, httpd, hugo, icon, idl, idlang, inc_luatex, informix, ini, innosetup, interlis, io, jam, jasmin, java, javascript, js_regex, json, jsp, jsx, julia, kotlin, ldif, less, lhs, lilypond, limbo, lindenscript, lisp, logtalk, lotos, lotus, lua, luban, makefile, maple, markdown, matlab, maya, mercury, meson, miranda, mod2, mod3, modelica, moon, ms, msl, mssql, mxml, n3, nasal, nbc, nemerle, netrexx, nginx, nice, nim, nix, nsis, nxc, oberon, objc, ocaml, octave, oorexx, org, os, oz, paradox, pas, pdf, perl, php, pike, pl1, plperl, plpython, pltcl, po, polygen, pony, pov, powershell, pro, progress, ps, psl, pure, purebasic, purescript, pyrex, python, q, qmake, qml, qu, r, rebol, rego, rexx, rnc, rpg, rpl, rst, ruby, rust, s, sam, sas, scad, scala, scilab, scss, shellscript, slim, small, smalltalk, sml, snmp, snobol, solidity, spec, spn, sql, squirrel, styl, svg, swift, sybase, tcl, tcsh, terraform, tex, toml, tsql, tsx, ttcn3, txt, typescript, upc, vala, vb, verilog, vhd, vimscript, vue, wat, whiley, wren, xml, xpp, yaiff, yaml, yaml_ansible, yang, zig, znn