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 条
  • [21] New and efficient Python']Python/C plus plus modular library for real and complex response functions at the level of Kohn-Sham density functional theory
    Rinkevicius, Zilvinas
    Xin, Li
    Vahtras, Olav
    Brand, Manuel
    Ahmadzadeh, Karan
    Ringholm, Magnus
    List, Nanna
    Norman, Patrick
    ABSTRACTS OF PAPERS OF THE AMERICAN CHEMICAL SOCIETY, 2019, 257
  • [22] GalaPy: A highly optimised C plus plus /Python']Python spectral modelling tool for galaxies I. Library presentation and photometric fitting
    Ronconi, T.
    Lapi, A.
    Torsello, M.
    Bressan, A.
    Donevski, D.
    Pantoni, L.
    Behiri, M.
    Boco, L.
    Cimatti, A.
    D'Amato, Q.
    Danese, L.
    Giulietti, M.
    Perrotta, F.
    Silva, L.
    Talia, M.
    Massardi, M.
    ASTRONOMY & ASTROPHYSICS, 2024, 685
  • [23] A Python']Python/C plus plus library for bound-constrained global optimization using a biased random-key genetic algorithm
    Silva, R. M. A.
    Resende, M. G. C.
    Pardalos, P. M.
    JOURNAL OF COMBINATORIAL OPTIMIZATION, 2015, 30 (03) : 710 - 728
  • [24] A Joint Python']Python/C plus plus Library for Efficient yet Accessible Black-Box and Gray-Box Optimization with GOMEA
    Bouter, Anton
    Bosman, Peter A. N.
    PROCEEDINGS OF THE 2023 GENETIC AND EVOLUTIONARY COMPUTATION CONFERENCE COMPANION, GECCO 2023 COMPANION, 2023, : 1864 - 1872
  • [25] Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm plus plus , C plus plus , HPX, Go, Julia, Python']Python, Rust, Swift, and Java']Java
    Diehl, Patrick
    Morris, Max
    Brandt, Steven R.
    Gupta, Nikunj
    Kaiser, Hartmut
    EURO-PAR 2023: PARALLEL PROCESSING WORKSHOPS, PT II, EURO-PAR 2023, 2024, 14352 : 127 - 138
  • [26] C/C plus plus conditional compilation analysis using symbolic execution
    Hu, Y
    Merlo, E
    Dagenais, M
    Lagüe, B
    INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING, PROCEEDINGS, 2000, : 196 - 206
  • [27] Marine Geospatial Ecology Tools: An integrated framework for ecological geoprocessing with ArcGIS, Python']Python, R, MATLAB, and C plus
    Roberts, Jason J.
    Best, Benjamin D.
    Dunn, Daniel C.
    Treml, Eric A.
    Halpin, Patrick N.
    ENVIRONMENTAL MODELLING & SOFTWARE, 2010, 25 (10) : 1197 - 1207
  • [28] Galvanostatic performance of single-particle Li-ion battery materials: a rapid diagram diagnosis assisted by a Python']Python / C plus plus software
    Ruderman, Andres
    Gavilan-Arriazu, Edgardo Maximiliano
    Fernandez, Francisco
    Ein-Eli, Yair
    Leiva, Ezequiel P. M.
    PHYSICA SCRIPTA, 2025, 100 (01)
  • [29] Automatic Test Generation for C and C plus plus Programs, Using Symbolic Execution
    Yoshida, Hiroaki
    Li, Guodong
    Kamiya, Takuki
    Ghosh, Indradeep
    Rajan, Sreeranga
    Tokumoto, Susumu
    Munakata, Kazuki
    Uehara, Tadahiro
    IEEE SOFTWARE, 2017, 34 (05) : 30 - 37
  • [30] Accelerating linear solvers for Stokes problems with C plus plus metaprogramming
    Demidov, Denis
    Mu, Lin
    Wang, Bin
    JOURNAL OF COMPUTATIONAL SCIENCE, 2021, 49