Abstract
Diffpack is a comprehensive software library for solving partial differential equations. For the experienced user and C++ programmer, Diffpack offers lots of functionality, which simplify the development of new simulators. However, the nature of Diffpack/C++ programming is more detailed and cumbersome than programming in environments like Matlab and Maple. Coupling of Diffpack with other packages at the C++ level is possible, but requires quite some work and knowledge. Operating Diffpack through high-level Python scripts may meet these shortcomings. The Python language is very powerful, yet easy and very convenient to use, and provides a syntax and working style close to that of Matlab and Maple.
Coupling Diffpack/C++ and Python is a non-trivial task. However, there is a tool, SWIG, which provides the possibility to automate the coupling of C/C++ and Python such that Python scripts can call C/C++ functions and operate directly on the C/C++ data structures. Applying SWIG to a large unit of software such as Diffpack faces many technical challenges. The present chapter introduces new tools in Diffpack that enable application of SWIG to generate Python interfaces to Diffpack simulators in an almost automatic way. We present some step-by-step examples on equipping Diffpack simulators with Python interfaces. We also show more complete applications where a controlling Python script runs a Diffpack simulator interactively, modifies its data, and visualizes the data with the aid of the Vtk package. This example demonstrates how Python scripts may act as a glue between Diffpack and other software packages, allowing data to be efficiently sent back and forth as pointers. With the information in this chapter, the reader should be able to steer any Diffpack simulator from a Python script.
Keywords
- Python Script
- Head File
- Source Code File
- Python Module
- Interface File
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
This is a preview of subscription content, access via your institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
D. Ascher, P. F. Dubois, K. Hinsen, J. Hugunin, and T. Oliphant. Numerical Python. Technical report.
D. Beazley. Python Essential Reference. New Riders Publishing, 2000.
D. Beazley et. al. Swig 1.3 Development Documentation. Technical report.
H. P. Langtangen. Python Scripting for Scientific Computing. Springer. Book in preparation.
H. P. Langtangen. Computational Partial Differential Equations-Numerical Methods and Diffpack Programming. Textbook in Computational Science and Engineering. Springer, 2nd edition, 2003.
M. Lutz. Programming Python. O’Reilly, second edition, 2001.
Matlab software package, http://www.mathworks.com.
Maya Vi software package, http://mayavi.sourceforge.net.
Numerical python software package, http://sourceforge.net/projects/numpy.
Pymat Python-Matlab interface, http://claymore.engineer.gvsu.edu/ steriana/Python.
Python-gnuplot interface, http://gnuplot-py.sourceforge.net.
Scientificpython software package, http://starship.python.net/crew/hinsen.
SciPy software package, http://www.scipy.org.
Swig software package, http://www.swig.org.
G. van Rossum. Extending and embedding. Part of the electronic Python documentation at http://www.python.org/doc.
Vtk software software package, http://www.kitware.com.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2003 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Langtangen, H.P., Mardal, KA. (2003). Using Diffpack from Python Scripts. In: Langtangen, H.P., Tveito, A. (eds) Advanced Topics in Computational Partial Differential Equations. Lecture Notes in Computational Science and Engineering, vol 33. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-18237-2_8
Download citation
DOI: https://doi.org/10.1007/978-3-642-18237-2_8
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-01438-6
Online ISBN: 978-3-642-18237-2
eBook Packages: Springer Book Archive
