Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
ac995e6
modified surface_density function to compute surface densities of gas…
j-f-gonzalez Jul 24, 2025
41331f3
Merge branch 'ttricco:main' into stokes-refactor
FathimaCSgithub Nov 25, 2025
da04fc2
stokes in new folder
Nov 25, 2025
09d55d3
simplify vstack
Nov 27, 2025
4ce7fa7
adding missing functions
Nov 27, 2025
0f1040c
moved dim
Nov 27, 2025
9f84606
new func for stokes number specifically
Nov 27, 2025
dc2b2c6
minor flake8
Nov 28, 2025
5661a78
rename sgrain
Nov 28, 2025
7e2a66b
flake8 and 1 line removal
Nov 28, 2025
c1d7475
renaming and commenting neighbour finding code
Dec 1, 2025
8c5ae4b
removing redundancy
FathimaCSgithub Dec 1, 2025
5ebe742
index
Dec 2, 2025
5803ff1
index
FathimaCSgithub Dec 2, 2025
c0557c5
comments
FathimaCSgithub Dec 2, 2025
7719d98
gas neighbour func
Dec 3, 2025
7fb9106
split into funcs
Dec 8, 2025
1e01716
comments explaining logic
Dec 8, 2025
98efbfa
comments dust locations
Dec 8, 2025
c338716
barebones unit test
FathimaCSgithub Dec 8, 2025
f9e1738
unit test fir inverting locations
FathimaCSgithub Dec 8, 2025
a7eab6c
init
Dec 8, 2025
ac51d41
test biug fix
FathimaCSgithub Dec 8, 2025
8ed9f23
bug fix
FathimaCSgithub Dec 8, 2025
02f82cc
update docs and docstrings
ttricco Dec 9, 2025
7cf74cf
update __all__
ttricco Dec 9, 2025
5498405
Merge pull request #140 from ttricco/docs_update
ttricco Dec 9, 2025
a8f1a58
create ptmass module and optimize classify sinks
ttricco Dec 10, 2025
fcbebd6
moved kernel unit tests into their own directory
ttricco Dec 10, 2025
6e9e1d3
fix init
ttricco Dec 10, 2025
07d4ec8
phantom writing type hint fixes
ttricco Dec 11, 2025
6a33ce4
error checks + type hints in phantom ev reader
ttricco Dec 11, 2025
45ae417
cleaner handling of rot_origin in _rotate_data
ttricco Dec 11, 2025
07b9f75
type hints, docstrings, cleaner code
ttricco Dec 11, 2025
4e1cbf6
Add ptmass docs and tidy API docs rst
ttricco Dec 11, 2025
74ee8b4
Merge pull request #141 from ttricco/minor_refactoring
ttricco Dec 11, 2025
0d38a0e
version 1.3.0
ttricco Dec 15, 2025
b4af4e2
handle no vtk in Python 3.8 on Mac ARM
ttricco Dec 15, 2025
28b3272
version 1.3.1
ttricco Dec 15, 2025
56a2156
readme update
ttricco Dec 15, 2025
37495e1
Fix phantom apr mass column miscalculation when apr_level >= 7
chunliangmu Mar 30, 2026
2637fad
add support for Wendland kernels
y-lapeyre Apr 20, 2026
2f4acfb
Merge pull request #146 from y-lapeyre/shamrock/update_reader
ttricco Apr 27, 2026
990bf49
Merge pull request #144 from chunliangmu/phantom_apr_bugfix
ttricco Apr 27, 2026
e96bb7c
(surface density) changed the returned sigma to accommodate if there …
becnealon Jul 7, 2026
1ad07f3
migrate to 3.10+ type hints
ttricco Jul 12, 2026
de04404
Merge pull request #147 from becnealon/main
ttricco Jul 27, 2026
47fe697
Merge branch 'main' into pr121
ttricco Jul 28, 2026
17f6330
tidy reading of ndust numbers from params
ttricco Jul 28, 2026
eb27a64
warn if surface density is computed from multiple particle types
ttricco Jul 28, 2026
bc7c5a9
unit test of surface density with multiple itypes
ttricco Jul 28, 2026
69da412
unit tests of one fluid surface density
ttricco Jul 28, 2026
811bf60
Merge pull request #121 from j-f-gonzalez/main
ttricco Jul 28, 2026
9c6c741
bug fix, had gas/dust density calc swapped + unit tests
ttricco Jul 28, 2026
6243504
lint
ttricco Jul 28, 2026
323aab7
Merge pull request #150 from ttricco/calc_one_fluid_quantity_fix
ttricco Jul 28, 2026
7821181
update from np.trapz to trapezoid
ttricco Jul 28, 2026
51fc87a
Merge pull request #151 from ttricco/np_trapezoid
ttricco Jul 28, 2026
9b7724b
lint
ttricco Aug 11, 2026
4fe15c8
Merge branch 'main' into modernize_type_hints
ttricco Aug 11, 2026
97fc583
lint
ttricco Aug 11, 2026
44409d1
consistency between type hints and docstrings
ttricco Aug 12, 2026
e8054d9
adhere to numpy docstring format guide
ttricco Aug 12, 2026
eeb2aab
update reqs to numpy and pandas 2.0
ttricco Aug 12, 2026
6bb9480
type hint cleaning
ttricco Aug 12, 2026
30aa826
type hint lint
ttricco Aug 12, 2026
c56d74a
flake8 lint
ttricco Aug 12, 2026
a42fb8a
fix typo
ttricco Aug 12, 2026
df15134
Merge pull request #153 from ttricco/modernize_type_hints
ttricco Aug 12, 2026
6a3cc2f
Merge branch 'main' into pr137
ttricco Aug 12, 2026
fea2cb6
refactor stokes_number calculation and create unit test
ttricco Aug 14, 2026
39c1321
check different kernels in unit test
ttricco Aug 14, 2026
af0b027
add option to use Kwok correction or not
ttricco Aug 20, 2026
76bf6f9
Merge branch '2f-stokes' into stokes-refactor
ttricco Aug 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
Sarracen
========

A Python library for smoothed particle hydrodynamics (SPH) analysis and visualization.
A Python library for smoothed particle hydrodynamics (SPH) analysis and
visualization.

About
-----

Sarracen is built upon the pandas, Matplotlib and NumPy libraries. It can load SPH particle data into a pandas DataFrame object that has been extended to allow for rendering of particle data and interpolation of particles to fixed grids. Additionally, this allows for access to the rich landscape of Python scientific and statistical libraries. All SPH functions offer multi-threaded CPU and CUDA implementations. Our intended application is for astrophysical SPH data.
Sarracen is built upon the pandas, Matplotlib and NumPy libraries. It can load
SPH particle data into a pandas DataFrame object that has been extended to
allow for rendering of particle data and interpolation of particles to fixed
grids. Additionally, this allows for access to the rich landscape of Python
scientific and statistical libraries. All SPH functions offer multi-threaded
CPU and CUDA implementations. Our intended application is for astrophysical SPH
data.

Installation
------------

The latest stable release and associated dependencies can be installed from PyPi:
The latest stable release and associated dependencies can be installed from
PyPi:

pip install sarracen

This is the recommended way to install Sarracen.

To install the latest development snapshot, install using this GitHub repository. Either clone the repository and add it to your path so that it can be imported, or install directly through pip:
To install the latest development snapshot, install using this GitHub
repository. Either clone the repository and add it to your path so that it can
be imported, or install directly through pip:

pip install git+https://github.com/ttricco/sarracen.git

Documentation
-------------

Sarracen's documentation is hosted online at [https://sarracen.readthedocs.io](https://sarracen.readthedocs.io).
Sarracen's documentation is hosted online at
[https://sarracen.readthedocs.io](https://sarracen.readthedocs.io).

The documentation contains examples and full API references.

Contributing
------------
Expand All @@ -35,22 +48,27 @@ Contributions are welcomed and appreciated. Here are some ways to get involved:
- Improving the documentation or providing examples.
- Writing code to add optimizations or new features.

Please use the [GitHub issue tracker](https://github.com/ttricco/sarracen/issues) to raise any bugs or to submit feature
requests. If something does not work as you might expect, please let us know. If there are features that you feel are
missing, please let us know.
Please use the [GitHub issue tracker](https://github.com/ttricco/sarracen/issues) to raise any bugs or to submit
feature requests. If something does not work as you might expect, please let us
know. If there are features that you feel are missing, please let us know.

Code submissions should be submitted as a pull request. Make sure that all existing unit tests successfully pass, and
please add any new unit tests that are relevant. Documentation changes should also be submitted as a pull request.
Code submissions should be submitted as a pull request. Make sure that all
existing unit tests successfully pass, and please add any new unit tests that
are relevant. Documentation changes should also be submitted as a pull request.

If you are stuck or need help, [raising an issue](https://github.com/ttricco/sarracen/issues) is a good place to start.
This helps us keep common issues in public view. Feel free to also [email](mailto:tstricco@mun.ca) with questions.
If you are stuck or need help,
[raising an issue](https://github.com/ttricco/sarracen/issues) is a good place
to start. This helps us keep common issues in public view. Feel free to also
[email](mailto:tstricco@mun.ca) with questions.

Please note that we adhere to a [code of conduct](CODE_OF_CONDUCT.md).

Citation
--------

Please cite the paper if you use Sarracen within your work. Sarracen is published with the Journal of Open Source Software (DOI: [10.21105/joss.05263](https://doi.org/10.21105/joss.05263)).
Please cite the paper if you use Sarracen within your work. Sarracen is
published with the Journal of Open Source Software (DOI:
[10.21105/joss.05263](https://doi.org/10.21105/joss.05263)).

```
@ARTICLE{Sarracen,
Expand Down
59 changes: 46 additions & 13 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,41 @@ API Reference
File reading
------------

Sarracen can read all general file formats supported by pandas (csv, notably).
Sarracen's design goal is to read data from multiple SPH codes while preserving
full functionality. All the general file formats supported by pandas (csv,
notably) work within Sarracen.

For SPH codes, Sarracen supports reading the native binary format of the `Phantom
SPH code <https://phantomsph.bitbucket.io>`_. Raise an issue on our GitHub if you
would like Sarracen to be able to read the file format for other SPH codes (or
make a pull request!).
For SPH codes, Sarracen supports reading the native binary format of the
`Phantom code <https://phantomsph.bitbucket.io>`_, the `Gasoline code
<https://gasoline-code.com/>`_, and the `Shamrock code
<https://shamrock-code.github.io/>`_.

Raise an issue on our GitHub if you would like Sarracen to be able to read the
file format for other SPH codes (or make a pull request!).

.. autosummary::
:toctree: api/

read_csv
read_phantom
read_marisa
read_gradsph
read_gasoline
read_gradsph
read_marisa
read_phantom
read_phantom_ev
read_shamrock
read_shamrock_vtk


File writing
------------

Sarracen can write native binary Phantom dump files. SarracenDataFrames can
also be dumped to .csv using pandas functionality.

.. autosummary::
:toctree: api/

write_phantom


SarracenDataFrame
Expand All @@ -51,6 +70,7 @@ Extra Quantities
:nosignatures:

SarracenDataFrame.calc_density
SarracenDataFrame.calc_one_fluid_quantities
SarracenDataFrame.centre_of_mass

Rendering
Expand All @@ -73,10 +93,11 @@ Interpolation
SarracenDataFrame.sph_interpolate


Kernels
-------
sarracen.kernels
----------------

The default smoothing kernel is the cubic spline. Additional smoothing kernels are included within Sarracen.
The default smoothing kernel is the cubic spline. Additional smoothing kernels
are included within the kernels module.

.. autosummary::
:toctree: api/
Expand All @@ -86,8 +107,8 @@ The default smoothing kernel is the cubic spline. Additional smoothing kernels a
kernels.QuinticSplineKernel


Disc
----
sarracen.disc
-------------

Accretion disc analysis routines are in the disc module.

Expand All @@ -99,3 +120,15 @@ Accretion disc analysis routines are in the disc module.
disc.angular_momentum
disc.scale_height
disc.honH


sarracen.ptmass
---------------

Analysis routines related to point masses and sink particles are in the ptmass
module.

.. autosummary::
:toctree: api/

ptmass.classify_bound_particles
93 changes: 73 additions & 20 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,107 @@ Contributions are welcomed and appreciated. Here are some ways to get involved:
- Improving the documentation or providing examples.
- Writing code to add optimizations or new features.

Please use the `GitHub issue tracker <https://github.com/ttricco/sarracen/issues>`_ to raise any bugs or to submit feature
requests. If something does not work as you might expect, please let us know. If there are features that you feel are
missing, please let us know.
Please use the `GitHub issue tracker
<https://github.com/ttricco/sarracen/issues>`_ to raise any bugs or to submit
feature requests. If something does not work as you might expect, please let us
know. If there are features that you feel are missing, please let us know.

Code submissions should be submitted as a pull request. Make sure that all existing unit tests successfully pass, and
please add any new unit tests that are relevant. Documentation changes should also be submitted as a pull request.
Code submissions should be submitted as a pull request. Make sure that all
existing unit tests successfully pass, and please add any new unit tests that
are relevant. Documentation changes should also be submitted as a pull request.

If you are stuck or need help, `raising an issue <https://github.com/ttricco/sarracen/issues>`_ is a good place to start.
This helps us keep common issues in public view. Feel free to also `email <mailto:tstricco@mun.ca>`_ with questions.

Please note that we adhere to a `code of conduct <https://github.com/ttricco/sarracen/blob/main/CODE_OF_CONDUCT.md>`_.
If you are stuck or need help, `raising an issue
<https://github.com/ttricco/sarracen/issues>`_ is a good place to start. This
helps us keep common issues in public view. Feel free to also `email
<mailto:tstricco@mun.ca>`_ with questions.

Please note that we adhere to a `code of conduct
<https://github.com/ttricco/sarracen/blob/main/CODE_OF_CONDUCT.md>`_.

Developer Guidelines
--------------------

There are several guiding principles to the development of Sarracen that we follow.
There are several guiding principles to the development of Sarracen that we
follow.

1. **Simple, intuitive API.**

A low barrier of entry for new users is important to us. This is why we model off of common scientific libraries, as we expect our users to be familiar with these tools. The naming of functions and their arguments should be clear, follow standard patterns, and avoid unnecessary complexity.
A low barrier of entry for new users is important to us. This is why we
model off of common scientific libraries, as we expect our users to be
familiar with these tools. The naming of functions and their arguments
should be clear, follow standard patterns, and avoid unnecessary
complexity.

2. **Efficiency.**

Performance is important. A simple guiding principle is to leverage built-in pandas or NumPy functions when possible.
Performance is important. A simple guiding principle is to leverage
built-in pandas or NumPy functions when possible.

3. **Pure Python.**

Sarracen is developed entirely in Python, without mixing in other code extensions such as Cython. Code efficiency is important, but we prioritize the maintainability and portability afforded by a pure Python codebase.
Sarracen is developed entirely in Python, without mixing in other code
extensions such as Cython. Code efficiency is important, but we prioritize
the maintainability and portability afforded by a pure Python codebase.

4. **Unit tested.**

We use pytest to comprehensively test Sarracen. Any new code added should come with an associated set of unit tests. System testing is important, but unit tests ensure the long-term correctness and reliability of Sarracen.
We use pytest to comprehensively test Sarracen. Any new code added should
come with an associated set of unit tests. System testing is important, but
unit tests ensure the long-term correctness and reliability of Sarracen.

5. **Avoid code lint.**

We use flake8 to conform to Python style guides. Avoiding lint might not help write good code, but it can help avoid writing bad code. Our aim is to reduce technical debt to help ensure consistency and readability across the codebase.
We use flake8 to conform to Python style guides. Avoiding lint might not
help write good code, but it can help avoid writing bad code. Our aim is to
reduce technical debt to help ensure consistency and readability across the
codebase.

If you have a new code addition or a change to existing code that you would like to submit, start by making a pull request (PR) on GitHub.

Pull Requests
-------------

All changes to Sarracen's code base are made through Pull Requests. Start by forking Sarracen on GitHub. Add your changes to your repository on your GitHub account (optionally on a development branch on your account). Then use GitHub to open a new Pull Request. Add details about your change, and resolve any issues found by the automated GitHub actions.
If you have a new code addition or a change to existing code that you would
like to submit, start by making a pull request (PR) on GitHub.

All changes to Sarracen's code base are made through Pull Requests. Start by
forking Sarracen on GitHub. Add your changes to your repository on your GitHub
account (optionally on a development branch on your account). Then use GitHub
to open a new Pull Request. Add details about your change, and resolve any
issues found by the automated GitHub actions.

GitHub Actions
Code Lint
--------------

Code commits use GitHub actions to automatically check for code lint.
Sarracen uses ``flake8`` to follow Python style guides on naming conventions,
code structure, and formatting. This is sometimes annoying, but adopting a
single style is beneficial.

Sarracen also uses type hints across the code base. Python
is not a typed language, but type hints help to avoid bugs and make intent
clear.

You can run flake8 on your local codebase as follows:

.. code-block::

pip install flake8
flake8 sarracen

You can also run flake8 on specific directories or files, rather than the whole
codebase. A list of specific errors per file with line numbers will be returned.

GitHub actions will automatically run flake8 on pull requests.

If the automated linter finds lint errors in your code, then go to the
``Checks`` tab on the PR. Expand the section "Super-linter" marked by the red
X, and then expand the PYTHON_FLAKE8 section. This will give you the output
from flake8, such as the specific lines of code and their associated lint
errors.

In the example below, the specific flake8 errors are given on lines 261, 262,
and 263 of the output. These point out that there is an undefined variable,
no blank lines after class or function declaration, and that there was no
newline at the end of the file. Yes, we do care about having a newline at the
end of the file.

If the automated linter finds lint errors in your code, check the details by going into the action's job details. Expand the section "Super-linter" marked by the red X, and then expand the PYTHON_FLAKE8 section. This will give you the output from flake8, such as the specific lines of code and their associated lint errors.
.. image:: contributing/flake8.png
Binary file added docs/contributing/flake8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
Examples
========

Below you will find a handful of examples of typical Sarracen usage. More
documentation is always appreciated!

.. toctree::
:maxdepth: 1
:caption: Contents:
Expand Down
28 changes: 28 additions & 0 deletions docs/examples/dustydisc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ The host star is 1 solar mass. It has two orbiting Jupiter mass planets at 10 an

The star and planets are modeled using sink particles. The gas and dust modeled using two species of particles. The analysis below is after 25 orbits of the outer planet.

Reading the Data
----------------

In a Jupyter notebook, or other interactive Python environment,

>>> # A sample analysis of the Orszag-Tang vortex at t=0.5.
Expand Down Expand Up @@ -41,6 +44,9 @@ In Phantom, gas particles are ``itype=1`` and dust particles ``itype=7``. There

Sarracen supports pandas style slicing. For example, to get a SarracenDataFrame of just the gas particles, one could use ``sdf[sdf.itype==1]``.

Visualization
-------------

Cross-sectional renderings of the gas and dust components of the disc are below.

>>> sdf[sdf.itype == 1].render('rho', xlim=(-40, 40), ylim=(-40, 40), log_scale=True, xsec=0.0)
Expand All @@ -62,3 +68,25 @@ Sarracen's render function returns a Matplotlib Axes object (and can accept one

.. image:: dustydisc/dustydisc-gas-sinks.png
:width: 400


Analysis
--------

Sarracen can calculate the surface density profile of the disc.

>>> import seaborn as sns
>>>
>>> sigma, bins = sarracen.disc.surface_density(sdf, r_out=80, retbins=True)
>>>
>>> ax = sns.lineplot(x=bins, y=sigma)
>>> ax.set_yscale('log')

.. image:: dustydisc/dustydisc-surface-density.png
:width: 450

Notice the two dips at the locations at the planets.

There are several more useful analysis routines in the ``disc`` module of
Sarracen.

Loading
Loading