Version:

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.

2-D Global Gradients without SalvusProject

This tutorial demonstrates how to compute gradients in a 2-D global Earth model only using SalvusFlow and SalvusMesh. This is useful in cases where you want full control and individual runs are small enough that there is no advantage to use the persistent on-disc storage SalvusProject provides.
Copy
# Global site name for all runs
import os

SALVUS_FLOW_SITE_NAME = os.environ.get("SITE_NAME", "local")
%matplotlib inline

from salvus.mesh.simple_mesh import basic_mesh
from salvus.flow import simple_config
from salvus.flow import api
import salvus.namespace as sn

import json
import h5py
import matplotlib.pyplot as plt
import numpy as np
import obspy
import pathlib
import typing
# Print all available 1-D Earth models. You can of course
# provide your own.
from salvus.mesh.models_1D import model

model.get_builtin_models()
['prem_iso',
 'iasp91',
 'prem_ani_no_crust',
 'prem_iso_one_crust',
 'csem',
 'prem_ani_one_crust',
 'mars_sohl',
 'prem_crust20_global',
 'prem_iso_no_crust',
 'prem_ani',
 'VPREMOON',
 'prem_crust20_cont',
 'VPREMOON_noLVL',
 'prem_ani_ocean',
 'prem_crust20_ocean',
 'ak135',
 'ak135f',
 'Moon_Weber2011']
# The most important settings are collected here.
PERIOD = 100.0

# A good idea as the gradients are always computed
# relative to the input parameterization. This will
# just result in a much smoother looking gradient.
# Planet will also be actually round.
TENSOR_ORDER = 4

# Probably up this a bit for any final results but works
# just fine for testing purposes.
ELEMENTS_PER_WAVELENGTH = 1.0

# No latitude in 2-D. Receiver always at the surface.
SRC_LONGITUDE = 0.0
SRC_DEPTH_KM = 100.0
REC_LONGITUDE = 135.0

# It will by default select a window around this phase.
PHASE = "Pdiff"

Step 1: Build Mesh

m = basic_mesh.Circular2D()

m.basic.model = "prem_ani_no_crust"
m.basic.min_period_in_seconds = PERIOD
m.basic.elements_per_wavelength = ELEMENTS_PER_WAVELENGTH
m.advanced.tensor_order = TENSOR_ORDER

m