A Python interface to Diffpack-based classes and solvers

Master thesis English OPEN
Munthe-Kaas, Heidi Vikki;
(2013)
  • Subject: Python | SWIG | Pulse | Diffpack

Python is a programming language that has gained a lot of popularity during the last 15 years, and as a very easy-to-learn and flexible scripting language it is very well suited for computa- tional science, both in mathematics and in physics. Diffpack is a PDE library w... View more
  • References (4)

    1 Introduction 1 1.1 Python for computational science . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Wrapping of compiled code using SWIG . . . . . . . . . . . . . . . . . . . . . 1 1.3 Diffpack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.4 Goal and procedure for the project . . . . . . . . . . . . . . . . . . . . . . . . 3 1.4.1 Heart modelling and Pulse . . . . . . . . . . . . . . . . . . . . . . . . 3 1.4.2 Outline of thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    2 Python interface for a simple simulator, Heat1 5 2.1 Wrapping with Swig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.1.1 First attempt at wrapping Heat1 . . . . . . . . . . . . . . . . . . . . . 5 2.1.2 Warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.1.3 Wrapping Diffpack classes . . . . . . . . . . . . . . . . . . . . . . . . 10 2.2 Testprogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2.2.1 TimeLoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.2.2 solveAtThisTimeStep . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

    3 Python interface for Pulse 25 3.1 Wrapping a single class in Pulse . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.2 Compilation and build of all modules . . . . . . . . . . . . . . . . . . . . . . 27 3.2.1 heart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 3.2.2 cellmodel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.2.3 diffusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.2.4 mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.2.5 ode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.3 Example of use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    4 Summary and discussion 43 4.1 Challenges and results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 4.1.1 Plots from cells.track in Pulse . . . . . . . . . . . . . . . . . . . . . . 46 4.2 Remaining work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 A Setup of PulseWrap 51 A.1 Directory structure of PulseWrap . . . . . . . . . . . . . . . . . . . . . . . . . 51 A.2 Python module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.1 Undefined reference error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.2 Pulselibrary included in .cmake2 in CellModel . . . . . . . . . . . . . . . . . 26 3.3 undefined reference to MAIN__ . . . . . . . . . . . . . . . . . . . . . . . . . 27 class A(): def __init__(self): self.solver = Heat1() self.menu = MenuSystem.MenuSystem() self.menu.init(String("Heat1 menu"), String("Heat1Menu")) self.solver.define(self.menu) tip.initTimeLoop() solver.dt = tip.Delta() save_dt = 0.0 if (heart.dynamicBC()): heart.initTimeLoop(solver.p_cav, solver.restart_time) solver.V_heart = heart.getVheart() while (not tip.finished()): print "Global time is now: " + str(tip.t) print "----------- NEW STEP ---------------"

  • Similar Research Results (8)
  • Metrics
Share - Bookmark