sympy2c: from symbolic expressions to fast C/C++ functions and ODE solvers in Python

03/22/2022
by   Uwe Schmitt, et al.
0

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 widely applicable and may prove useful for various areas of computational physics. sympy2c is publicly available at https://cosmology.ethz.ch/research/software-lab/sympy2c.html

READ FULL TEXT

page 1

page 2

page 3

page 4

research
07/03/2023

musif: a Python package for symbolic music feature extraction

In this work, we introduce musif, a Python package that facilitates the ...
research
04/17/2022

SymForce: Symbolic Computation and Code Generation for Robotics

We present SymForce, a library for fast symbolic computation, code gener...
research
09/30/2022

Cadabra and Python algorithms in General Relativity and Cosmology II: Gravitational Waves

Computer Algebra Systems (CASs) like Cadabra Software play a prominent r...
research
05/20/2016

OPESCI-FD: Automatic Code Generation Package for Finite Difference Models

In this project, we introduce OPESCI-FD, a Python package built on symbo...
research
05/04/2022

pyRDF2Vec: A Python Implementation and Extension of RDF2Vec

This paper introduces pyRDF2Vec, a Python software package that reimplem...
research
07/01/2016

Massively parallel implementation in Python of a pseudo-spectral DNS code for turbulent flows

Direct Numerical Simulations (DNS) of the Navier Stokes equations is a v...

Please sign up or login with your details

Forgot password? Click here to reset