Skip to main content

collresolve is a library designed to provide collision analysis and handling for N-body codes.

The library has interfaces for the following languages:

  • C/C++
  • Fortran
  • Python

Installation

C/C++/Fortran

The installation of the C/C++/Fortran library using the standard ./configure, make and make install commands.

The repository does not provide the configure script. If installing directly from the repository, the file must be created first. The easiest way to do this is executing autoreconf --install command which will create the configure script and its dependencies. This command requires the GNU autoconf tool. In this situation, the commands to execute are:

autoreconf --install
./configure
make
make install

As for other packages, you may want to execute ./configure --help to see which options are available and tune that command to your needs, e.g. by changing the location where the library will be installed using the --prefix=PATH option.

Linking

If the library has been installed in a non-standard part, then the paths to the header files and library object files must be provided to the compiler and linker calls. Hereafter, we assume that the base location of the library is PREFIX, which is the value of the --prefix argument to ./configure call.

The public interface of the library for the C/C++ languages is provided in the collresolve.h file. In case the path must be provided, then the argument -IPREFIX/include must be added to the compiler commands of files that make use of collresolve.h.

To use the library, the argument -lcollresolve is to be provided to the linking command. In case the library is in a non-standard directory, the path can be provided using -LPREFIX/lib argument.

The Fortran interface is tailored to use with the mercury package.

Python

From a checkout of the repository, the Python module can be easily built and installed by the executing the following commands:

python setup.py build
python setup.py install

In case the library is to be installed for the current user only, then the --user argument can be provided to the install command.

This will put the Python module in a location where is it readily available. No further action is needed.

Usage

To use most of the library, a configuration object must be created and set first. The configuration object contains essential parameters for the calls, such as the collision model to determine the outcome of collisions and the unit system in use. The object must not be accessed directly, but the functions collresolve_conf_* should be used instead to alter its state.

Python

An example of usage of the library is provided in the example.py file.

Mercury

To use the library with the mercury, the following modifications to the code of the latter are needed. When compiling the code, the additional flags described above to link the executable to the library are required.

In the mce_coll subroutine, near the end, in lieu of the part

c
c Do the collision (inelastic merger)
      call mce_merg (jcen,i,j,nbod,nbig,m,xh,vh,s,stat,elost,
     %         nsetup)

the code should be changed to something like

      if (opt(2).eq.2 .and. i.gt.1 .and. j.gt.1) then
        model = 4
        nres = 2

        regime = collresolve_resolve(model, m(i) / K2, m(j) / K2,
     %     rphys(i), rphys(j), xh(:,i), xh(:,j), vh(:,i), vh(:,j), nres,
     %     mres, rres, pres, vres)

        if (regime .lt. 0) then
          ! An error occurred
          ! Do not do anything.
        else if (mres(1) .lt. 1.d-3 / (1047.d0 * 317.8d0)) then
          stat(i) = -2
          stat(j) = -2
          xh(:,j) = -xh(:,j)
          vh(:,j) = -vh(:,j)
        else if (mres(2) .lt. 1.d-3 / (1047.d0 * 317.8d0)) then
          m(i) = mres(1) * K2
          rphys(i) = rres(1)
          xh(:,i) = pres(:,1)
          vh(:,i) = vres(:,1)
          stat(j) = -2
          xh(:,j) = -xh(:,j)
          vh(:,j) = -vh(:,j)
        else
          m(i) = mres(1) * K2
          m(j) = mres(2) * K2
          rphys(i) = rres(1)
          rphys(j) = rres(2)
          xh(:,i) = pres(:,1)
          xh(:,j) = pres(:,2)
          vh(:,i) = vres(:,1)
          vh(:,j) = vres(:,2)
        end if
      else
c
c Do the collision (inelastic merger)
        call mce_merg (jcen,i,j,nbod,nbig,m,xh,vh,s,stat,elost,
     %         nsetup)
      end if

with the following new variables at the beginning of the subroutine

      real*8 mres(3),rres(3),pres(3,3),vres(3,3)
      integer nres,model,regime,collresolve_resolve

There are a few items to be noted with the above code:

  • The library is only called when the flag about using the "fragmentation" mode in the parameters file is enabled. This allows to easily perform comparison run with mercury's standard merging algorithm with having to re-compile the code.
  • The value of the model variable should be adjusted to which model the library is to use to resolve the collisions. The possible values are given in the collresolve_model enummeration in collresolve.h. The value provided in this code snippet, 4, tells the library to use Cambioni et al. (2019) model.
  • It implements a minimum mass cutoff for the remnants, with a value to 1/1000 of an Earth mass (the factor 1047 * 317.8 being the conversion to solar mass that Mercury uses as the mass unit).

While the above codes sets the correct radii on return, these will be ignored in a standard version of the mercury package. In effect, this will assume a constant density for each body. In case the model 4 (Cambioni et al. 2019) is used, a further modification is needed so that the bodies have a consistent radius with the bodies that were used to generate the model. To achieve this, the code setting the physical radius in mce_init should be changed from rphys(j)=hill(j)/a(j)*(temp/rho(j))**THIRD to rphys(j) = collresolve_radius(4, m(j) / K2) while adding real*8 collresolve_radius in the definitions of that subroutine. This will make mercury use the library's mass-radius relation for all bodies (both at the beginning of the simulation and after a collision), except for the central body. In effect, this makes the d parameter in the input file useless.

License

The library is licensed under version 2.0 of the Apache License, see the LICENSE file for the full terms and conditions.

Citations

If you use this library in a scientific work that lead to publication, we would like you to acknowledge the following article:

  • Emsenhuber, A., Cambioni S., Asphaug, E., Gabriel, T. S. J., Schwartz, S. R., and Furfaro, R. (2020). Realistic On-the-fly Outcomes of Planetary Collisions. II. Bringing Machine Learning to N-body Simulations. The Astrophysical Journal, 891(1), 6. doi:10.3847/1538-4357/ab6de5 bib:2020ApJ...891....6E

If you use the LS2012 model, you should also cite:

If you use the SL2012 model, you should also cite the same publication as for LS2012, and:

If you use the C2019 model, you should also cite:

  • Cambioni, S., Asphaug, E., Emsenhuber, A., Gabriel, T. S. J., Furfaro, R., and Schwartz, S. R. (2019). Realistic On-the-fly Outcomes of Planetary Collisions: Machine Learning Applied to Simulations of Giant Impacts. The Astrophysical Journal, 875(1), 40. doi:10.3847/1538-4357/ab0e8a bib:2019ApJ...875...40C

Metadata

Release files for collresolve 1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for collresolve 1.3
File Size Uploaded
collresolve-1.3.tar.gz 64.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for collresolve 1.3
File
collresolve-1.3-cp39-cp39-manylinux1_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.5+ x86-64 Details
collresolve-1.3-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details
collresolve-1.3-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
collresolve-1.3-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details

Total release size: 464.3 kB

Release files / collresolve-1.3.tar.gz

Download URL collresolve-1.3.tar.gz
Size 64.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bd511c211ead2d1cf0ea62691e2a63cdfecbbe38dc8add954e42f8272cb81439
BLAKE2b-256 checksum
How to use checksums
4d2345d543fc4204cd4ac1a7f7be78e4489d1f6600c7a9bcd6d72631a6f249ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / collresolve-1.3-cp39-cp39-manylinux1_x86_64.whl

Download URL collresolve-1.3-cp39-cp39-manylinux1_x86_64.whl
Size 100.1 kB
Tags CPython 3.9 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
012fe44c8462d1fdfb9ebaf5a12fada909bec38b766c238539ff9d1a0e49bc72
BLAKE2b-256 checksum
How to use checksums
616f348c81c2a36e0b58bce06701fb8821e76f88c23ca8b7d405c79a1326a94d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / collresolve-1.3-cp38-cp38-manylinux1_x86_64.whl

Download URL collresolve-1.3-cp38-cp38-manylinux1_x86_64.whl
Size 100.4 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
315d06f4d99503062c7f6c6c7c7291b19050300599230d3189f4ad744e8e67f7
BLAKE2b-256 checksum
How to use checksums
6f698eaeda11c5b174a2f2c1d10c0eba34b178fb9f2514b353a2554fdfed7afc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / collresolve-1.3-cp37-cp37m-manylinux1_x86_64.whl

Download URL collresolve-1.3-cp37-cp37m-manylinux1_x86_64.whl
Size 99.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
ab4f93c2ecd27222dfccd2c281aa17e99405bfbf3f66c27d11b452b48cce8b31
BLAKE2b-256 checksum
How to use checksums
de07b6ea2e9bdbe8ea424057ddb6f140ff7b4f3046ae811697a4e4239838e82b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / collresolve-1.3-cp36-cp36m-manylinux1_x86_64.whl

Download URL collresolve-1.3-cp36-cp36m-manylinux1_x86_64.whl
Size 99.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
9780c705010e2c3ebaf66fa03152c596d693562ea1964e2dee1f9ea644dfcc0f
BLAKE2b-256 checksum
How to use checksums
d39cb675e8c9a7cb70954499b20107a3838eb0d3889a264ca8c4f05819fc73b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

1.3 This release

5 release files

1.2

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page