Skip to main content

Using Diffpack from Python Scripts

  • Chapter
  • 1062 Accesses

Part of the Lecture Notes in Computational Science and Engineering book series (LNCSE,volume 33)

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

Chapter
USD   29.95
Price excludes VAT (Canada)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (Canada)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (Canada)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. D. Ascher, P. F. Dubois, K. Hinsen, J. Hugunin, and T. Oliphant. Numerical Python. Technical report.

    Google Scholar 

  2. D. Beazley. Python Essential Reference. New Riders Publishing, 2000.

    Google Scholar 

  3. D. Beazley et. al. Swig 1.3 Development Documentation. Technical report.

    Google Scholar 

  4. H. P. Langtangen. Python Scripting for Scientific Computing. Springer. Book in preparation.

    Google Scholar 

  5. H. P. Langtangen. Computational Partial Differential Equations-Numerical Methods and Diffpack Programming. Textbook in Computational Science and Engineering. Springer, 2nd edition, 2003.

    Google Scholar 

  6. M. Lutz. Programming Python. O’Reilly, second edition, 2001.

    Google Scholar 

  7. Matlab software package, http://www.mathworks.com.

    Google Scholar 

  8. Maya Vi software package, http://mayavi.sourceforge.net.

    Google Scholar 

  9. Numerical python software package, http://sourceforge.net/projects/numpy.

    Google Scholar 

  10. Pymat Python-Matlab interface, http://claymore.engineer.gvsu.edu/ steriana/Python.

    Google Scholar 

  11. Python-gnuplot interface, http://gnuplot-py.sourceforge.net.

    Google Scholar 

  12. Scientificpython software package, http://starship.python.net/crew/hinsen.

    Google Scholar 

  13. SciPy software package, http://www.scipy.org.

    Google Scholar 

  14. Swig software package, http://www.swig.org.

    Google Scholar 

  15. G. van Rossum. Extending and embedding. Part of the electronic Python documentation at http://www.python.org/doc.

    Google Scholar 

  16. Vtk software software package, http://www.kitware.com.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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