Trixi.jl
Trixi.jl is a numerical simulation framework for conservation laws written in Julia. A key objective for the framework is to be useful to both scientists and students. Therefore, next to having an extensible design with a fast implementation, Trixi.jl is focused on being easy to use for new or inexperienced users, including the installation and postprocessing procedures. Its features include:
1D, 2D, and 3D simulations on line/quad/hex/simplex meshes
High-order accuracy in space and time
Arbitrary floating-point precision
Discontinuous Galerkin methods
Kinetic energy-preserving and entropy-stable methods based on flux differencing
Entropy-stable shock capturing
Positivity-preserving limiting
Subcell invariant domain-preserving (IDP) limiting
Advanced limiting strategies
Positivity-preserving limiting
Subcell invariant domain-preserving (IDP) limiting
Entropy-bounded limiting
Compatible with the SciML ecosystem for ordinary differential equations
CFL-based and error-based time step control
Custom explicit time integration schemes
Maximized linear stability via paired explicit Runge-Kutta methods
Relaxation Runge-Kutta methods for entropy-conservative time integration
Native support for differentiable programming
Forward mode automatic differentiation via ForwardDiff.jl
Automatic Jacobian sparsity detection via SparseConnectivityTracer.jl
Periodic and weakly-enforced boundary conditions
Multiple governing equations:
Compressible Euler equations
Compressible Navier-Stokes equations
Magnetohydrodynamics (MHD) equations
Multi-component compressible Euler and MHD equations
Linearized Euler and acoustic perturbation equations
Hyperbolic diffusion equations for elliptic problems
Lattice-Boltzmann equations (D2Q9 and D3Q27 schemes)
Shallow water equations via TrixiShallowWater.jl
Several scalar conservation laws (e.g., linear advection, Burgers' equation, LWR traffic flow)
Multi-physics simulations
Shared-memory parallelization via multithreading
Multi-node parallelization via MPI
Visualization and postprocessing of the results
Installation
If you have not yet installed Julia, please follow the instructions for your operating system. Trixi.jl works with Julia v1.10 and newer. We recommend using the latest stable release of Julia.
For users
Trixi.jl and its related tools are registered Julia packages. Hence, you can install Trixi.jl, the visualization tools Trixi2Vtk, and Plots.jl as well as the time integration sub-packages of OrdinaryDiffEq.jl, by executing the following commands in the Julia REPL:
You can copy and paste all commands to the REPL including the leading julia>
prompts - they will automatically be stripped away by Julia. The package OrdinaryDiffEq.jl and its sub-packages provide time integration schemes used by Trixi.jl, while Plots.jl can be used to directly visualize Trixi.jl's results from the REPL.
Note on package versions: If some of the examples for how to use Trixi.jl do not work, verify that you are using a recent Trixi.jl release by comparing the installed Trixi.jl version from
to the latest release. If the installed version does not match the current release, please check the [Troubleshooting](@ref old-release) section.
The commands above can also be used to update Trixi.jl. A brief list of notable changes to Trixi.jl is available in the Changelog
.
[For developers](@id for-developers)
If you plan on editing Trixi.jl itself, you can download Trixi.jl locally and use the code from the cloned directory:
If you installed Trixi.jl this way, you always have to start Julia with the --project
flag set to your run
directory, e.g.,
if already inside the run
directory.
The advantage of using a separate run
directory is that you can also add other related packages (see below, e.g., for time integration or visualization) to the project in the run
folder and always have a reproducible environment at hand to share with others.
Since the postprocessing tool Trixi2Vtk.jl typically does not need to be modified, it is recommended to install it as a normal package. Likewise, you can install Plots.jl and sub-packages of OrdinaryDiffEq.jl as ordinary packages. To achieve this, use the following REPL commands:
Note that the postprocessing tools Trixi2Vtk.jl and Plots.jl are optional and can be omitted.
Example: Installing Trixi.jl as a package
Please note that the playback speed is set to 3x, thus the entire installation procedure lasts around 45 seconds in real time (depending on the performance of your computer and on how many dependencies had already been installed before).
Usage
In the Julia REPL, first load the package Trixi.jl
Then start a simulation by executing
Please be patient since Julia will compile the code just before running it. To visualize the results, load the package Plots
and generate a heatmap plot of the results with
This will open a new window with a 2D visualization of the final solution:
The method trixi_include(...)
expects a single string argument with the path to a Trixi.jl elixir, i.e., a text file containing Julia code necessary to set up and run a simulation. To quickly see Trixi.jl in action, default_example()
returns the path to an example elixir with a short, two-dimensional problem setup. A list of all example elixirs packaged with Trixi.jl can be obtained by running get_examples()
. Alternatively, you can also browse the examples/
subdirectory. If you want to modify one of the elixirs to set up your own simulation, download it to your machine, edit the configuration, and pass the file path to trixi_include(...)
.
Example: Running a simulation with Trixi.jl
If this produces weird symbols or question marks in the terminal on your system, you are probably using Mac OS with problematic fonts. In that case, please check the [Troubleshooting](@ref font-issues) section.
Note on performance: Julia uses just-in-time compilation to transform its source code to native, optimized machine code at the time of execution and caches the compiled methods for further use. That means that the first execution of a Julia method is typically slow, with subsequent runs being much faster. For instance, in the example above the first execution of trixi_include
takes about 20 seconds, while subsequent runs require less than 60 milliseconds.
Performing a convergence analysis
To automatically determine the experimental order of convergence (EOC) for a given setup, execute
This will run a convergence test with the elixir default_example()
, using four iterations with different initial refinement levels. The initial iteration will use the elixir unchanged, while for each subsequent iteration the initial_refinement_level
parameter is incremented by one. Finally, the measured l^2
and l^\infty
errors and the determined EOCs will be displayed like this:
An example with multiple variables looks like this:
Showcase of advanced features
The presentation From Mesh Generation to Adaptive Simulation: A Journey in Julia, originally given as part of JuliaCon 2022, outlines how to use Trixi.jl for an adaptive simulation of the compressible Euler equations in two spatial dimensions on a complex domain. More details as well as code to run the simulation presented can be found at the reproducibility repository for the presentation.
Referencing
If you use Trixi.jl in your own research or write a paper using results obtained with the help of Trixi.jl, please cite the following articles:
In addition, you can also refer to Trixi.jl directly as
[Authors](@id authors-index-md)
Trixi.jl was initiated by Michael Schlottke-Lakemper (University of Augsburg, Germany) and Gregor Gassner (University of Cologne, Germany). Together with Hendrik Ranocha (Johannes Gutenberg University Mainz, Germany), Andrew Winters (Linköping University, Sweden), Jesse Chan (Rice University, US), and Andrés Rueda-Ramírez (Polytechnic University of Madrid (UPM), Spain), they are the principal developers of Trixi.jl. The full list of contributors can be found under Authors.
License and contributing
Trixi.jl is licensed under the MIT license (see License). Since Trixi.jl is an open-source project, we are very happy to accept contributions from the community. Please refer to Contributing for more details. Note that we strive to be a friendly, inclusive open-source community and ask all members of our community to adhere to our [Code of Conduct](@ref code-of-conduct). To get in touch with the developers, join us on Slack or create an issue.
Participating research groups
Participating research groups in alphabetical order:
Applied and Computational Mathematics, RWTH Aachen University 🇩🇪
Applied Mathematics, Department of Mathematics, University of Hamburg 🇩🇪
Division of Applied Mathematics, Department of Mathematics, Linköping University 🇸🇪
Computational and Applied Mathematics, Rice University 🇺🇸
High-Performance Computing, Institute of Software Technology, German Aerospace Center (DLR) 🇩🇪
High-Performance Scientific Computing, University of Augsburg 🇩🇪
Numerical Mathematics, Institute of Mathematics, Johannes Gutenberg University Mainz 🇩🇪
Numerical Simulation, Department of Mathematics and Computer Science, University of Cologne 🇩🇪
Acknowledgments
This project has benefited from funding by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) through the following grants:
Excellence Strategy EXC 2044-390685587, Mathematics Münster: Dynamics-Geometry-Structure.
Research unit FOR 5409 "Structure-Preserving Numerical Methods for Bulk- and Interface Coupling of Heterogeneous Models (SNuBIC)" (project number 463312734).
Individual grant no. 528753982.
This project has benefited from funding from the European Research Council through the ERC Starting Grant "An Exascale aware and Un-crashable Space-Time-Adaptive Discontinuous Spectral Element Solver for Non-Linear Conservation Laws" (Extreme), ERC grant agreement no. 714487.
This project has benefited from funding from Vetenskapsrådet (VR, Swedish Research Council), Sweden through the VR Starting Grant "Shallow water flows including sediment transport and morphodynamics", VR grant agreement 2020-03642 VR.
This project has benefited from funding from the United States National Science Foundation (NSF) under awards DMS-1719818 and DMS-1943186.
This project has benefited from funding from the German Federal Ministry of Education and Research (BMBF) through the project grant "Adaptive earth system modeling with significantly reduced computation time for exascale supercomputers (ADAPTEX)" (funding id: 16ME0668K).
This project has benefited from funding by the Daimler und Benz Stiftung (Daimler and Benz Foundation) through grant no. 32-10/22.
Trixi.jl is supported by NumFOCUS as an Affiliated Project.