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 条
  • [31] Performance analysis of GPU accelerated meshfree q-LSKUM solvers in Fortran, C, Python']Python, and Julia
    Mamidi, Nischay Ram
    Saxena, Dhruv
    Prasun, Kumar
    Nemili, Anil
    Sharma, Bharatkumar
    Deshpande, S. M.
    2022 IEEE 29TH INTERNATIONAL CONFERENCE ON HIGH PERFORMANCE COMPUTING, DATA, AND ANALYTICS, HIPC, 2022, : 156 - 165
  • [33] On hard gamma-rays from Ra (C plus C' plus C" plus D)
    Nishida, S
    PHYSICAL REVIEW, 1937, 51 (11): : 0996 - 0996
  • [34] Fast analysis of source code in C and C plus
    Savitskii, V. O.
    Sidorov, D. V.
    PROGRAMMING AND COMPUTER SOFTWARE, 2013, 39 (01) : 49 - 55
  • [35] HiCRep.py: fast comparison of Hi-C contact matrices in Python']Python
    Lin, Dejun
    Sanders, Justin
    Noble, William Stafford
    BIOINFORMATICS, 2021, 37 (18) : 2996 - 2997
  • [36] Support for the Evolution of C plus plus Generic Functions
    Pirkelbauer, Peter
    Dechev, Damian
    Stroustrup, Bjarne
    SOFTWARE LANGUAGE ENGINEERING, 2011, 6563 : 123 - +
  • [37] CISR-ODE, A C plus plus framework with ODE solver for code based system dynamics simulation
    Mohammadi, Arash
    Mohamed, Shady
    Nahavandi, Saeid
    Ahnert, Karsten
    2015 IEEE INTERNATIONAL CONFERENCE ON SYSTEMS, MAN, AND CYBERNETICS (SMC 2015): BIG DATA ANALYTICS FOR HUMAN-CENTRIC SYSTEMS, 2015, : 401 - 406
  • [38] Clarifying and Compiling C/C plus plus Concurrency: from C++11 to POWER
    Batty, Mark
    Memarian, Kayvan
    Owens, Scott
    Sarkar, Susmit
    Sewell, Peter
    POPL 12: PROCEEDINGS OF THE 39TH ANNUAL ACM SIGPLAN-SIGACT SYMPOSIUM ON PRINCIPLES OF PROGRAMMING LANGUAGES, 2012, : 509 - 520
  • [39] Fast-flow study of the C plus NO and C+O2 reactions
    Bergeat, A
    Calvo, T
    Dorthe, G
    Loison, JC
    CHEMICAL PHYSICS LETTERS, 1999, 308 (1-2) : 7 - 12
  • [40] A C plus plus CLASS FOR ANALYSING VECTOR BOOLEAN FUNCTIONS FROM A CRYPTOGRAPHIC PERSPECTIVE
    Antonio Alvarez-Cubero, Jose
    Zufiria, Pedro J.
    SECRYPT 2010: PROCEEDINGS OF THE INTERNATIONAL CONFERENCE ON SECURITY AND CRYPTOGRAPHY, 2010, : 512 - 520