This documentation is not for the latest stable Salvus version.
%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 salvus.namespace as sn
print("Opening existing project.")
p = sn.Project(path=PROJECT_DIR)
Opening existing project.
p.viz.nb.domain()
p.events.list()
['event_0']
p.simulations.list()
['my_first_simulation']
HDF5
file named reference_data.h5
in the data directory.ASDF
or SEGY
describe their data with associated headers. We'll see how to add these types of data in a later tutorial, but in this case we are just reading in raw waveform traces with little to no meta information. Because of this we'll need to assist Salvus a little and tell the project to what events this raw data refers to.p.waveforms.add_external(
data_name="reference",
event="event_0",
data_filename="data/reference_data.h5",
)
p.viz.nb.waveforms()
to visualize seismograms in part 1. To compare the simulated seismograms to the reference data, we just need to pass a list instead of a single simulation name.p.viz.nb.waveforms(
["EXTERNAL_DATA:reference", "my_first_simulation"],
receiver_field="displacement",
)
abp = sn.AbsorbingBoundaryParameters(
reference_velocity=3000.0,
number_of_wavelengths=3.5,
reference_frequency=15.0,
)
sc = p.entities.get(
entity_type="simulation_configuration", entity_name="my_first_simulation"
)
p += sn.SimulationConfiguration(
name="simulation_2",
max_frequency_in_hertz=sc.max_frequency_in_hertz,
elements_per_wavelength=sc.elements_per_wavelength,
model_configuration=sc.model_configuration,
event_configuration=sc.event_configuration,
absorbing_boundaries=abp,
)
+=
or add_to_project
to add new entities to the project.p.visualizations.nb.simulation_setup(
simulation_configuration="simulation_2",
events=p.events.list(),
)
[2024-03-15 09:01:29,812] INFO: Creating mesh. Hang on.
<salvus.flow.simple_config.simulation.waveform.Waveform object at 0x7f5e30432d90>
p.simulations.launch(
ranks_per_job=2,
site_name=SALVUS_FLOW_SITE_NAME,
events=p.events.list(),
simulation_configuration="simulation_2",
)
[2024-03-15 09:01:31,418] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150901628852_16abf5c77e@local
1
p.simulations.query(block=True)
True
p.viz.nb.waveforms(
["EXTERNAL_DATA:reference", "simulation_2"], receiver_field="displacement"
)
sc.event_configuration.wavelet.plot()
max_frequency_in_hertz
parameter, or the elements_per_wavelength
parameter, noting the increase or decrease in simulation time as you go.p += sn.SimulationConfiguration(
name="simulation_3",
max_frequency_in_hertz=sc.max_frequency_in_hertz,
elements_per_wavelength=2.0,
model_configuration=sc.model_configuration,
event_configuration=sc.event_configuration,
absorbing_boundaries=abp,
)
p.simulations.launch(
ranks_per_job=2,
site_name=SALVUS_FLOW_SITE_NAME,
events=p.events.list(),
simulation_configuration="simulation_3",
)
[2024-03-15 09:01:34,751] INFO: Creating mesh. Hang on. [2024-03-15 09:01:34,912] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150901922657_670b4aa0a5@local
1
p.simulations.query(block=True)
True
p.viz.nb.waveforms(
["EXTERNAL_DATA:reference", "simulation_3"],
receiver_field="displacement",
)
elements_per_wavelength
parameter and pay the extra simulation cost. As with many things, it is a fine balance between science, experience, and art.