|
| 1 | +.. _adding_example_code_tidymess: |
| 2 | + |
| 3 | +Adding a C++ N-Body Code to AMUSE |
| 4 | +================================= |
| 5 | + |
| 6 | +In this tutorial, we will create an interface from scratch for the |
| 7 | +TIdal DYnamics of Multi-body ExtraSolar Systems code, or ``TIDYMESS``, |
| 8 | +written by Dr. Tjarda Boekholt and Dr. Alexandre Correia. This code |
| 9 | +implements detailed tidal forces into an N-body code to track the deformation |
| 10 | +of bodies. This community code has already been implemented into AMUSE so you |
| 11 | +can follow along this tutorial. |
| 12 | + |
| 13 | +Getting Started |
| 14 | +=============== |
| 15 | + |
| 16 | +This tutorial assumes you have a working amuse or amuse development build, |
| 17 | +preferrably in seperated environment (virtualenv, venv or conda etc). |
| 18 | +Please ensure that amuse is setup correctly, this can be verified by running the |
| 19 | +``amusifier`` . |
| 20 | + |
| 21 | +.. code-block:: bash |
| 22 | +
|
| 23 | + > amusifier --help |
| 24 | +
|
| 25 | +Naming our project |
| 26 | +~~~~~~~~~~~~~~~~~~ |
| 27 | +Amuse naming conventions typically follows PascalCase, so we will name our project Tidymess. |
| 28 | + |
| 29 | +Creating the initial directory structure |
| 30 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 31 | +To start, we need to create the directory structure for ``Tidymess``, along with the |
| 32 | +necessary files to build our interface. The fastest method to setup the directory is |
| 33 | +by using the ``amusifier`` script with ``--mode=dir``. |
| 34 | + |
| 35 | +Since ``TIDYMESS`` is a native C++ code with no other dependencies, we will specify |
| 36 | +``--type=c``, but the ``amusifier`` can also build the interface directory for |
| 37 | +``f90`` and ``python`` codes. |
| 38 | + |
| 39 | +.. code-block:: bash |
| 40 | +
|
| 41 | + > amusifier --type=c --mode=dir Tidymess |
| 42 | +
|
| 43 | +Having run the ``amusifier``, we now have our new directory in ``amuse/src/amuse_tidymess``. |
| 44 | +There should be all the required folders for building our interface, as well as a few code |
| 45 | +stubs to expand upon. |
| 46 | + |
| 47 | +Building the code |
| 48 | +================= |
| 49 | +Before we start working on the interface, we should try and install and compile ``TIDYMESS`` |
| 50 | +inside of ``AMUSE``. |
| 51 | + |
| 52 | +Defining dependencies |
| 53 | +~~~~~~~~~~~~~~~~~~~~~ |
| 54 | +The ``AMUSE`` build system needs to know what packages and libraries our project depends on. |
| 55 | +Navigate to ``amuse_tidymess/packages/amuse_tidymess.amuse_deps``, which is where we define every |
| 56 | +dependency we will need. By default it will look like: |
| 57 | + |
| 58 | +.. code-block:: text |
| 59 | +
|
| 60 | + c c++ fortran java python cmake install download mpi openmp cuda opencl x11 opengl blas lapack gsl gmp mpfr fftw hdf5 netcdf4 |
| 61 | +
|
| 62 | +Since ``TIDYMESS`` is a standalone C++ code, we can simplify our dependencies to: |
| 63 | + |
| 64 | +.. code-block:: text |
| 65 | +
|
| 66 | + c c++ |
0 commit comments