sympy2c: From symbolic expressions to fast C/C plus plus functions and ODE solvers in Python']Python

被引:4
|
作者
Schmitt, U. [1 ,2 ]
Moser, B. [2 ]
Lorenz, C. S. [2 ]
Refregier, A. [2 ]
机构
[1] Swiss Fed Inst Technol, Sci IT Serv, Binzmuhlestr 130, CH-8092 Zurich, Switzerland
[2] Swiss Fed Inst Technol, Inst Particle Phys & Astrophys, Wolfgang Pauli Str 27, CH-8093 Zurich, Switzerland
基金
瑞士国家科学基金会;
关键词
code generation; ODE solver; !text type='Python']Python[!/text; Computer algebra; ASTROPY;
D O I
10.1016/j.ascom.2022.100666
中图分类号
P1 [天文学];
学科分类号
0704 ;
摘要
Computer algebra systems play an important role in science as they facilitate the development of new theoretical models. The resulting symbolic equations are often implemented in a compiled programming language in order to provide fast and portable codes for practical applications. We describe sympy2c, a new Python package designed to bridge the gap between the symbolic development and the numerical implementation of a theoretical model. sympy2c translates symbolic equations implemented in the SymPy Python package to C/C++ code that is optimized using symbolic transformations. The resulting functions can be conveniently used as an extension module in Python. sympy2c is used within the PyCosmo Python package to solve the Einstein-Boltzmann equations, a large system of ODEs describing the evolution of linear perturbations in the Universe. After reviewing the functionalities and usage of sympy2c, we describe its implementation and optimization strategies. This includes, in particular, a novel approach to generate optimized ODE solvers making use of the sparsity of the symbolic Jacobian matrix. We demonstrate its performance using the Einstein-Boltzmann equations as a test case. sympy2c is general and potentially useful for various areas of computational physics. sympy2c is publicly available at https://cosmology.ethz.ch/research/software-lab/sympy2c.html. (c) 2022 The Author(s). Published by Elsevier B.V.
引用
收藏
页数:11
相关论文
共 50 条
  • [1] Distributed C plus plus -Python']Python embedding for fast predictions and fast prototyping
    Varisteas, Georgios
    Avanesov, Tigran
    State, Radu
    DIDL'18: PROCEEDINGS OF THE SECOND WORKSHOP ON DISTRIBUTED INFRASTRUCTURES FOR DEEP LEARNING, 2018, : 9 - 14
  • [2] Awkward Arrays in Python']Python, C plus plus , and Numba
    Pivarski, Jim
    Elmer, Peter
    Lange, David
    24TH INTERNATIONAL CONFERENCE ON COMPUTING IN HIGH ENERGY AND NUCLEAR PHYSICS (CHEP 2019), 2020, 245
  • [3] Pteros 2.0: Evolution of the Fast Parallel Molecular Analysis Library for C plus plus and Python']Python
    Yesylevskyy, Semen O.
    JOURNAL OF COMPUTATIONAL CHEMISTRY, 2015, 36 (19) : 1480 - 1488
  • [4] C plus plus or Python']Python? Which One to Begin With: A Learners Perspective
    Ateeq, Muhammad
    Habib, Hina
    Umer, Adnan
    Ul Rehman, Muzammil
    2014 INTERNATIONAL CONFERENCE ON TEACHING AND LEARNING IN COMPUTING AND ENGINEERING (LATICE), 2014, : 64 - 69
  • [5] PyAlbany: A Python']Python interface to the C plus plus multiphysics solver Albany
    Liegeois, Kim
    Perego, Mauro
    Hartland, Tucker
    JOURNAL OF COMPUTATIONAL AND APPLIED MATHEMATICS, 2023, 425
  • [6] UNC plus plus Duino: A Kit for Learning to Program Robots in Python']Python and C plus plus Starting from Blocks
    Benotti, Luciana
    Gomez, Marcos J.
    Martinez, Cecilia
    ROBOTICS IN EDUCATION: RESEARCH AND PRACTICES FOR ROBOTICS IN STEM EDUCATION, 2017, 457 : 181 - 192
  • [7] DNest4: Diffusive Nested Sampling in C plus plus and Python']Python
    Brewer, Brendon J.
    Foreman-Mackey, Daniel
    JOURNAL OF STATISTICAL SOFTWARE, 2018, 86 (07): : 1 - 33
  • [8] Exudyn - a C plus plus -based Python']Python package for flexible multibody systems
    Gerstmayr, Johannes
    MULTIBODY SYSTEM DYNAMICS, 2024, 60 (04) : 533 - 561
  • [9] CPPE: An Open-Source C plus plus and Python']Python Library for Polarizable Embedding
    Scheurer, Maximilian
    Reinholdt, Peter
    Kjellgren, Erik Rosendahl
    Olsen, Jogvan Magnus Haugaard
    Dreuw, Andreas
    Kongsted, Jacob
    JOURNAL OF CHEMICAL THEORY AND COMPUTATION, 2019, 15 (11) : 6154 - 6163
  • [10] libepa - A C plus plus /Python']Python library for calculations of cross sections of ultraperipheral collisions
    Zhemchugov, E. V.
    Godunov, S. I.
    Karkaryan, E. K.
    Novikov, V. A.
    Rozanov, A. N.
    Vysotsky, M. I.
    COMPUTER PHYSICS COMMUNICATIONS, 2024, 305