论文标题

sympy2c:从符号表达式到python中的快速C/C ++函数和ODE求解器

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

论文作者

Schmitt, Uwe, Moser, Beatrice, Lorenz, Christiane S., Refregier, Alexandre

论文摘要

计算机代数系统在科学中起着重要的作用,因为它们促进了新的理论模型的发展。最终的符号方程通常以编译的编程语言实现,以便为实用应用程序提供快速和便携式的代码。我们描述了Sympy2c,这是一种新的Python软件包,旨在弥合符号发展与理论模型的数值实现之间的差距。 Sympy2c将Sympy Python软件包中实现的符号方程转换为使用符号转换优化的C/C ++代码。所得功能可以方便地用作Python中的扩展模块。 Sympy2c在Pycosmo Python软件包中用于求解Einstein-Boltzmann方程,这是一个描述宇宙中线性扰动演变的大型ODES。在回顾了Sympy2c的功能和使用后,我们描述了其实施和优化策略。这特别是一种新型方法,用于生成优化的ode求解器,利用符号雅各布矩阵的稀疏性。我们使用爱因斯坦 - 博尔兹曼方程作为测试案例来证明其性能。 Sympy2c广泛适用,可能对计算物理的各个领域有用。 Sympy2c可在https://cosmology.ethz.ch/research/software-lab/sympy2c.html上公开获得

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

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源