<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ascend4.org/index.php?action=history&amp;feed=atom&amp;title=PythonWrapper</id>
	<title>PythonWrapper - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ascend4.org/index.php?action=history&amp;feed=atom&amp;title=PythonWrapper"/>
	<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=PythonWrapper&amp;action=history"/>
	<updated>2026-05-03T19:14:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://ascend4.org/index.php?title=PythonWrapper&amp;diff=541&amp;oldid=prev</id>
		<title>Jpye: /* Building the Python Interface */</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=PythonWrapper&amp;diff=541&amp;oldid=prev"/>
		<updated>2010-05-19T03:11:32Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Building the Python Interface&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:11, 19 May 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l55&quot;&gt;Line 55:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 55:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The Python interface code is in the code repository under &amp;lt;tt&amp;gt;trunk/pygtk/interface&amp;lt;/tt&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The Python interface code is in the code repository under &amp;lt;tt&amp;gt;trunk/pygtk/interface&amp;lt;/tt&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;(See &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[BuildPygtkByAWW]] &lt;/del&gt;for Art Westerberg&#039;s experience to build this interface.)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;(See for Art Westerberg&#039;s experience to build this interface. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;page has been lost.&#039;&#039;&#039;&lt;/ins&gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l82&quot;&gt;Line 82:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 82:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Note that Python 2.3 is not currently supported. Let us know if that&amp;#039;s a problem for you&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Note that Python 2.3 is not currently supported. Let us know if that&amp;#039;s a problem for you&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Launching the PyGTK GUI ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Launching the PyGTK GUI ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jpye</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=PythonWrapper&amp;diff=104&amp;oldid=prev</id>
		<title>UploadBot: Restored page from Google Cache, uploaded by John Pye</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=PythonWrapper&amp;diff=104&amp;oldid=prev"/>
		<updated>2010-05-13T13:51:04Z</updated>

		<summary type="html">&lt;p&gt;Restored page from Google Cache, uploaded by John Pye&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;notice metadata&amp;quot; id=&amp;quot;outdated&amp;quot; style=&amp;quot;border:solid 2pt orange; width:70ex; background-color:#FFEEDD;padding:4px;margin-bottom:6px&amp;quot;&amp;gt;&amp;#039;&amp;#039;This article is &amp;#039;&amp;#039;&amp;#039;outdated&amp;#039;&amp;#039;&amp;#039;. You can help out by &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt;[http://ascendwiki.cheme.cmu.edu/index.php?title=PythonWrapper&amp;amp;action=edit updating it]&amp;lt;/span&amp;gt;. &amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;You&amp;#039;re probably looking for the page [[Scripting ASCEND using Python]] instead of this one!&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Python Interface for ASCEND =&lt;br /&gt;
&lt;br /&gt;
Basic operations can be performed on the ASCEND engine from Python. At present you can&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Create a library and load files into it, query the library to see what it contains&lt;br /&gt;
* Query the library to see what external functions have been loaded&lt;br /&gt;
* Instantiate types from the library&lt;br /&gt;
* Set values of bool and integer values in the model instance&lt;br /&gt;
* Get/set real-valued instances including units of measurement; calculate conversions from any given measurement unit back to SI.&lt;br /&gt;
* (Invisibly) store your preferred units of measure for different real-atom types&lt;br /&gt;
* Run METHODs defined in your model&lt;br /&gt;
* Fix and free solver variables in your model&lt;br /&gt;
* Solve the instance using solver with expressions compiled in native C&lt;br /&gt;
* Access plot data and meta-data from &amp;#039;plottable&amp;#039; instances in the model heirarchy&lt;br /&gt;
* Examine all variables in your model; set values, bounds, scaling.&lt;br /&gt;
* Register solvers, query solvers for their names, apply specific solvers to simulation instances&lt;br /&gt;
* Clear the library&lt;br /&gt;
* Query an instance to get the string representation of a relation/equation.&lt;br /&gt;
* View the entire incidence matrix in graphical form, zoom in and move around.&lt;br /&gt;
* Set the solver parameters for a particular simulation&lt;br /&gt;
* Get the solver&amp;#039;s incidence matrix, and examine which rows and columns correspond which relations and variables.&lt;br /&gt;
* Attach callback functions to monitor solver status, residuals, iterations, etc as iteration proceeds.&lt;br /&gt;
&lt;br /&gt;
A preliminary [http://www.pygtk.org PyGTK] GUI interface (see [[PyGTK Screenshots]]) has also been developed which allows some interactive work on a model instance. Currently, it allows you to&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Open ASCEND modules from the GUI (only one is open at a time, opening a new one empties the library)&lt;br /&gt;
* Browse modules present in memory, instantiate a specified model&lt;br /&gt;
* Run methods&lt;br /&gt;
* Adjust values of real, bool and int variables and constants&lt;br /&gt;
* Fix and free different variables including units of measurement&lt;br /&gt;
* View plots of plottable instances&lt;br /&gt;
* Specify (and read off) values in your preferred units of measurement for each real-atom type&lt;br /&gt;
* View relations (as string, on the console)&lt;br /&gt;
* View and set solver parameters for a particular simulation.&lt;br /&gt;
* Plot the solver incidence matrix&lt;br /&gt;
* Create an &amp;#039;observer&amp;#039; into which you can record your different scenario data points&lt;br /&gt;
* View block-by-block breakdown of your system and examine the equations and variables assigned to each block&lt;br /&gt;
* Set upper and lower bounds for variables, set scaling values.&lt;br /&gt;
* Follow solver progress: current block, elapsed time, RMS residual, etc, using a popup window&lt;br /&gt;
&lt;br /&gt;
Errors are reported in a friendly way at the bottom of the screen and when a value is update, the solver can be set to automatically re-solve the model, so for small models you canvery quickly perform &amp;#039;what if&amp;#039; analysis; very similar to using a standard spreadsheet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Building the Python Interface ==&lt;br /&gt;
&amp;lt;div class=&amp;quot;notice metadata&amp;quot; id=&amp;quot;outdated&amp;quot; style=&amp;quot;border:solid 2pt orange; width:70ex; background-color:#FFEEDD;padding:4px;margin-bottom:6px&amp;quot;&amp;gt;&amp;#039;&amp;#039;This article is &amp;#039;&amp;#039;&amp;#039;outdated&amp;#039;&amp;#039;&amp;#039;. You can help out by &amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt;[http://ascendwiki.cheme.cmu.edu/index.php?title=PythonWrapper&amp;amp;action=edit updating it]&amp;lt;/span&amp;gt;. &amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
{{task}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
The Python interface code is in the code repository under &amp;lt;tt&amp;gt;trunk/pygtk/interface&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
(See [[BuildPygtkByAWW]] for Art Westerberg&amp;#039;s experience to build this interface.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To compile the Python interface you will need &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [http://www.swig.org/ SWIG] version 1.3.24. (the default FC4 version is good) Versions 1.3.27 and newer &amp;#039;&amp;#039;&amp;#039;should&amp;#039;&amp;#039;&amp;#039; be OK as well, but haven&amp;#039;t been tried yet.&lt;br /&gt;
* [http://www.python.org/ Python] version 2.4 including developer header files. You will also need libglade and its python bindings.&lt;br /&gt;
&lt;br /&gt;
To run the PyGTK GUI you will additionally need (be sure to read [[PythonGUIOnWindows]] if you are on Windows)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [http://www.pygtk.org PyGTK] (also part of FC4). We develop with&amp;amp;nbsp;!PyGTK2 2.6.2.&lt;br /&gt;
* [http://matplotlib.sourceforge.net/ matplotlib].&lt;br /&gt;
&lt;br /&gt;
We &amp;#039;&amp;#039;&amp;#039;don&amp;#039;t&amp;#039;&amp;#039;&amp;#039; recommend that you build all of the above from source. Instead use your distribution&amp;#039;s package manager to download and install binary versions of these.&lt;br /&gt;
&lt;br /&gt;
For example, the above can very easily be installed in Fecora Core 4 (the platform used by most of the developers), provided you have your FC4 &amp;#039;updates&amp;#039; and &amp;#039;extras&amp;#039; repositories enabled, by typing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;yum install swig python-devel pygtk2 python-libglade python-matplotlib&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once you have the prerequisites, you need to build the ASCEND static libraries. We recommend using the Autotools build process: &amp;lt;tt&amp;gt;cd trunk/base/autotools &amp;amp;amp;&amp;amp;amp; ./reconfig &amp;amp;amp;&amp;amp;amp; make libs&amp;lt;/tt&amp;gt; works for me, but you may find you need to run ./configure directly with platform-specific settings.&lt;br /&gt;
&lt;br /&gt;
Next change to the &amp;lt;tt&amp;gt;trunk/pygtk/interface&amp;lt;/tt&amp;gt; directory and type &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that Python 2.3 is not currently supported. Let us know if that&amp;#039;s a problem for you&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Launching the PyGTK GUI ==&lt;br /&gt;
&lt;br /&gt;
If the build completes correctly, set your &amp;lt;tt&amp;gt;ASCENDLIBRARY&amp;lt;/tt&amp;gt; environment variable to the location of your model files (for example &amp;lt;tt&amp;gt;~/src/ascend/trunk/models&amp;lt;/tt&amp;gt;) then:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Launch the PyGTK GUI: &amp;lt;tt&amp;gt;./ascend&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Launch the GUI and load a specific module: &amp;lt;tt&amp;gt;./ascend johnpye/testlog10.a4c&amp;lt;/tt&amp;gt; (for example)&lt;br /&gt;
* Instantiate a specific model: &amp;lt;tt&amp;gt;./ascend johnpye/testlog10.a4c -m testlog10&amp;lt;/tt&amp;gt; (for example)&lt;br /&gt;
&lt;br /&gt;
So far the PyGTK GUI has only been used successfully on Linux, but we&amp;#039;re confident that it should run OK on Windows without too much extra work.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 [[Category:Outdated]]&lt;br /&gt;
[[Category:Articles_to_be_merged]]&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>UploadBot</name></author>
	</entry>
</feed>