Py-SPHViewer 2.0

Banner Image

Py-SPHViewer 2 is not publicly available at the moment, but it is being released for testing purposes and specific collaborations. The package is written in C and relies heavily on the Smoothed Mesh Library (SMESHL), which places particles on a grid using an Adaptive Mesh Refinement (AMR) method. This efficient library allows Py-SPHViewer 2.0 to be orders of magnitude faster than its predecessor.

This enables the rapid generation of images representing the entire density field of large cosmological volumes at unprecedented resolutions, effectively mitigating aliasing.

Notable differences of the publicly-available version of Py-SPHViewer 2.0 compared to Py-SPHViewer include: (1) the code is more than 100 times faster while delivering comparable results; (2) support for periodic boundary conditions; (3) lack of perspective projection; and (4) the library is serial, leaving parallelism implementation to the user as needed.

Getting Started

If you already have the package installed on your system, the tutorials below will give you a good overview of how to use Py-SPHViewer 2.0. If you haven’t installed the package yet, you can just read the Installation instructions I’ve included below.

Tutorials

Installation Instructions

Py-SPHViewer 2.0 is currently distributed in two steps. The first step is a python wrapper, and the second is a shared library compiled for various operating systems and architectures. Windows is not currently supported.

Install the Python Wrapper (Py-SPHViewer 2.0)

To install the python wrapper, run the following command in your terminal:

pip install py-sphviewer2

To check if the library was installed correctly, you can find the library using this command:

pip list | grep sphviewer2

For sphviewer2 to work, you also need the Smooth Mesh Library, which you can download and install following the instructions below:

Download the Smoothed Mesh Library

Currently, only a selected number of users are allowed to use the library. If you are one of them, you can download the appropriate library for your system here:

Platform Architecture Link
Ubuntu 24.04.1 LTS x86 64-bit Download
MacOS (Sonoma 14.5) x86/arm 64-bit Download

Instruction for MacOS

Ensure you download the correct library for your system.

To make the shared library widely accessible across your macOS system, you have two options:

  1. Move the file to a standard library location (Requires root permissions):
    • You can move the file libsmeshl.dylib to /usr/local/lib. This is the easiest option but requires root permissions. If this solution does not fit your needs, you can try the following:
  2. Set the DYLD_LIBRARY_PATH environment variable:
    • If you want to keep your .dylib file in a custom directory, you can set the DYLD_LIBRARY_PATH environment variable to include that directory. Follow the instructions below:
    1. Place the .dylib file in your custom directory (e.g., ~/my_libs).

    2. Set the environment variable:

      • Open your terminal and edit your shell profile file (e.g., .bash_profile, .zshrc, etc., depending on the shell you use):
        nano ~/.zshrc  # for Zsh
        
      • Add the following line:
        export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:~/my_libs
        
      • Save and exit the editor, then run:
        source ~/.zshrc
        

        This will ensure the path is included every time you open a new terminal session.

Finally, ensure that the permissions of the .dylib file are set correctly to allow reading. You can check and change permissions with:

chmod 755 /usr/local/lib/libsmeshl.dylib

Potential Issues

On macOS, you might encounter the following warning: “libsmeshl.dylib” cannot be opened because the developer cannot be verified..This is due to macOS’s Gatekeeper and System Integrity Protection (SIP) security mechanisms, which are in place to ensure that only trusted and signed software runs on the system. At your own risk, you can bypass this and use the libsmeshl.dylib following these steps:

1. Allow the App/Library to Run from Security Preferences:

After the initial security block, you can go to System Settings to allow the blocked .dylib.

  1. Open System Settings > Privacy & Security > Security.
  2. You should see a message at the bottom saying:

    libsmeshl.dylib was blocked from use because it is not from an identified developer.”

  3. Click on Allow Anyway.
  4. Try using the library again.
  5. It is possible that you see a final warning. Click in Open and that should allow you to use the library in the future.

The steps might vary depending on the OS version, but if in doubt, Google might help you resolve the issue.

Instruction for Ubuntu

If you are using an Ubuntu system, you will want to download the appropriate library file. Follow these instructions to make the shared library widely accessible across your Ubuntu system:

1: Download the Library

Ensure you download the correct version of libsmeshl.so for your architecture.

2: Move the Library to a Standard Location

You have two options for making the library accessible system-wide:

  1. Move the file to the standard library path (Requires root permissions):
    • You can move the file libsmeshl.so to /usr/local/lib. This is the simplest method. Open a terminal and run:
      sudo mv /path/to/libsmeshl.so /usr/local/lib/
      
  2. Use a custom directory:
    • If you prefer to keep your .so file in a custom directory, you can set the LD_LIBRARY_PATH environment variable to include that directory. Follow the instructions below:
    1. Place the .so file in your custom directory (e.g., ~/my_libs).

    2. Set the environment variable:

      • Open your terminal and edit your shell profile file (e.g., .bashrc, .bash_profile, or .profile, depending on your shell configuration):
        nano ~/.bashrc  # for Bash
        
      • Add the following line:
        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/my_libs
        
      • Save and exit the editor, then run:
        source ~/.bashrc
        

        This will ensure that the path is included every time you open a new terminal session.

3: Update the Library Cache

If you moved the library to /usr/local/lib, you may need to update the library cache. Run the following command:

sudo ldconfig

4: Check Permissions

Finally, ensure that the permissions of the .so file are set correctly to allow reading. You can check and change permissions with:

sudo chmod 755 /usr/local/lib/libsmeshl.so