Creating a Julia interface to the DACE differential algebra library
The below case study shares some of the technical details and outcomes of the scientific and HPC-focused programming support provided to a research project through NeSI’s Consultancy Service.
This service supports projects across a range of domains, with an aim to lift researchers’ productivity, efficiency, and skills in research computing. If you are interested to learn more or apply for Consultancy support, visit our Consultancy Service page.
Research background
In the Astrodynamics research group at the University of Auckland, Professor Roberto Armellin, his PhD students Jack Yarndley and Adam Evan, along with their collaborator, Alberto Fossà, a Postdoctoral Fellow at the University of Texas at Austin, are working on innovative solutions for spacecraft guidance and space situational awareness.
These problems require understanding how uncertainties propagate nonlinearly in dynamical systems and how to control their evolution. Differential algebra leverages the algebra of truncated Taylor polynomials to automatically compute the multivariate and arbitrary-order Taylor expansion of any sufficiently differentiable function, including those required for numerical propagation.
This is where the DACE (Differential Algebra Computational Toolbox) library comes into play. The original version of DACE was developed in COSY-Infinity and later translated into C++ for the European Space Agency, and is a crucial tool used in this research group's work.
Project challenges
One of the main challenges related to the use of the DACE C++ library is the relatively steep learning curve required to use it. As a C++ library, users of DACE need to be able to program in C++ and understand compiling and linking code, and the CMake build system.
These areas are often not covered in undergraduate studies, which can result in significant time spent for upskilling before any progress can be made on the research.
Julia is a relatively new language commonly used for numerical analysis and computational science, and is run similarly to scripting languages, such as Python, rather than compiled languages like C++.
As such, Julia is typically easier to learn and faster to develop code with when compared to compiled languages, but it can still achieve comparable performance. Creating a Julia interface to the DACE C++ library will enable easier access for students and researchers worldwide and increase research productivity.
What was done
NeSI Research Software Engineers Chris Scott and Alex Pletzer worked with the research group to develop a Julia interface for the DACE library. Different options for creating the Julia interface were compared, and CxxWrap.jl was chosen. The C++ code was extended to export the fundamental classes and functions from the C++ library to Julia. With every new release, this code is automatically precompiled for all the supported Julia platforms using Binary Builder and the Yggdrasil project. The DACE.jl Julia package was created to load the exported functionality from the C++ library. It was further extended to add compatibility with other Julia packages, such as DifferentialEquations.jl, enabling DACE to be used with the package’s suite of solvers, as well as other third-party Julia packages.
We have also started to implement the validation tests used when the C++ version was developed in Julia, and have compared running the same calculations with both C++ and Julia DACE and the alternative TaylorSeries.jl package, so we can be confident the Julia package is working correctly. We have not spent much time optimising performance at this point, although some initial benchmarks showed that performance was favourable compared to the TaylorSeries.jl package.
We now have a working Julia interface to DACE, which includes much of the core functionality. The research group is now looking forward to starting using the Julia library in their research. As usage ramps up we will identify any missing functionality or issues that need to be addressed and will also develop a better understanding of how performance compares to the C++ library and other Julia packages that provide similar functionality.
Main outcomes
- Create a Julia interface to the DACE C++ library using CxxWrap.jl
- Compatibility with other Julia packages, such as DifferentialEquations.jl, allowing us to leverage the power of the numerical analysis libraries found in the Julia ecosystem
- Creating the documentation for the Julia version of DACE: https://a-ev.github.io/DACE.jl/stable/
- Releasing an early version of DACE.jl to the Julia General registry, so that it can be installed easily by running “add DACE” from the Julia package manager
Researcher feedback
"This experience has been invaluable for my research group. Typically, this type of work would demand a significant time investment from my students and collaborators, producing future research potential but not immediate results. Consequently, despite its strategic importance, such activities are often postponed. Chris and Alex have delivered an interface that perfectly meets our needs. We are already reaping the benefits, with Alberto Fossà (UT Austin) developing advanced algorithms using it. This outstanding service has exceeded my expectations."
- Dr Roberto Armellin, Professor, Faculty of Engineering, Mechanical Engineering, University of Auckland
Do you want to bring your research to the next level? We can help. Send an email to support@nesi.org.nz to learn more about our Consultancy support or visit our Consultancy Service page.