This documentation is not for the latest stable Salvus version.

This tutorial is presented as Python code running inside a Jupyter Notebook, the recommended way to use Salvus. To run it yourself you can copy/type each individual cell or directly download the full notebook, including all required files.

Lamb's problem

Part 3 - Visualization and extensions

In this part, we'll take a look at other output options, visualize the entire wavefield and start exploring other types of sources and receivers.
%matplotlib inline
# This notebook will use this variable to determine which
# remote site to run on.
import os

SALVUS_FLOW_SITE_NAME = os.environ.get("SITE_NAME", "local")
PROJECT_DIR = "project"
import pathlib
import numpy as np
import shutil
import salvus.namespace as sn

print("Opening existing project.")
p = sn.Project(path=PROJECT_DIR)
Opening existing project.
We want to rerun simulation_3, but with volumetric output. In addition to displacement, let's also output the spatial gradient of the displacement field, so we can compute derived quantities like the divergence or curl afterwards.
Because we change the desired output, we need to delete the old data first. To this end, we query the output directory and delete it in the cell below
        "volume_data": {
            "sampling_interval_in_time_steps": 10,
            "fields": ["displacement", "gradient-of-displacement"],
[2021-07-09 22:17:24,467] INFO: Submitting job ...
Uploading 1 files...

🚀  Submitted [email protected]local_cuda
And that's it! The simulations are off and running. SalvusFlow will take care of abstracting the machine archcitecture, and SalvusProject will take care of saving all the output data into the correct location, copying it from any remote machines as necessary. We can get the current status of the simulations by calling query_simulations() as below.
The jupyter widgets are great to get a glimpse of many entities. However, more advanced visualization requires external tools such as Paraview.
Meshes and wavefield data are read and written as HDF5 files. The HDF5 library allows us to performantly access single files in parallel, as well as allowing for the portable sharing of such files. To see a visual representation of what's in these files we recommend using Paraview.
Note that we strongly recommend to download Paraview from the official website -- the versions installed through Linux package management systems often do not come with the correct libraries installed.
Files are visualized in Paraview using the XDMF standard. This is why you'll see for every mesh, surface, or volume output file used by Salvus, an associated file with the same name but with a .xdmf file suffix.
You can query the internal folder where the output is stored with the following command.
# Uncomment the next line and paste the path from above
# !ls _paste_the_path_above_here
We see some log files, meta information, receiver data and volumetric output. The file volume_data_output_elastic_volume.xdmf is what we are after. It is this .xdmf file that should be opened in Paraview. When you do open such a file, you should see a dialogue box to select the correct reader. Make sure to select the XDMF Reader and not any of the Xdmf3Reader or Paraview will crash immediately :-/
Now, it's time to play around with Salvus.
How about adding a new event with a moment tensor point source and strain receivers? Have a look at the beginning of part one and try to create event_1 with newly defined source(s) and receivers.
You could also ramp up the frequency and send some simulations to a bigger machine. Once you have registered a site with SalvusFlow, you only need to adjust the site_name and the ranks_per_job in the launch function and Salvus will take care about the rest.