psvWave.fdModel
- class psvWave.fdModel(configuration_file_path: str)
Class to simulate P-SV wave phyiscs and its adjoint state.
- Parameters
configuration_file_path – Path to the desired configuration.
- adjoint_simulate(i_shot: int, verbose: bool, omp_threads_override: int)
Adjoint simulate the wavefield for a given shot. This additionally correlates the adjoint wavefields for this shot with those stored in the snapshots to calculate the sensitivity kernel in Lamé’s parameters.
- Parameters
i_shot (int) – Integer representing which shot will be simulated.
verbose (bool) – Boolean controlling the verbosity of the simulation.
omp_threads_override (int) – Integer determining the amounts of threads that will be used. Defaults to the environment variable if not passed / 0.
- calculate_l2_adjoint_sources()
Calculate the adjoint sources corresponding to the L2 misfit w.r.t. the observed data.
- calculate_l2_misfit()
Calculate L2 misfit for simulated waveforms w.r.t. observed data.
- copy() psvWave.fdModel
Returns a copy of the object, duplicating all members.
- property dt
Time discretization
- property dx
Horizontal discretization
- property dz
Vertical discretization
- forward_simulate(i_shot: int, store_fields: bool = True, verbose: bool = False, output_wavefields: bool = False, omp_threads_override: int = 0)
Run forward simulations for a given ‘shot’.
- Parameters
i_shot (int) – Integer representing which shot will be simulated.
store_fields (int) – Boolean controlling whether or not wavefields are stored, defaults to True.
verbose (bool) – Boolean controlling the verbosity of the simulation.
output_wavefields (boolean) – Boolean controlling whether or not wavefields are written to disk.
omp_threads_override (int) – Integer determining the amounts of threads that will be used. Defaults to the environment variable if not passed / 0.
- property free_parameters
Total free parameters in the model, vp, vs, rho combined.
- get_coordinates()
- get_extent()
- get_gradient_vector() numpy.ndarray
Returns the computed gradient vector. Should be retreived only after all the following functions are run:
set_model_vector()
, to set a new model for which to calculate the gradient.For each shot,
forward_simulate()
, to simulate the forward wavefields.calculate_l2_misfit()
to calculate the L2 misfit of the synthetic waveforms w.r.t. the data.calculate_l2_adjoint_sources()
to calculate the adjoint sources corresponding to the current model.calculate_l2_adjoint_sources()
to calculate the adjoint sources corresponding to the current model.adjoint_simulate()
to simulate the adjoint (backward) wavefield.reset_kernels()
to empty the current kernels.For each shot
adjoint_simulate()
to simulate the adjoint (backward) wavefield exactly once. Simulating one of the shots twice will result in incorrect kernels.map_kernels_to_velocity()
to map the sensitivities in Lamé’s parameters (lambda, mu, rho) to velocity (vp, vs, rho).
- Returns
Current gradient vector.
- Return type
numpy.ndarray
- get_kernels()
- get_model_vector() numpy.ndarray
Get the current model in the model as a numpy vector, flattened.
- Returns
Current model vector containing P-wave speed, S-wave speed, and density.
- Return type
numpy.ndarray
- get_observed_data()
- get_parameter_fields()
- get_receivers(in_units: bool, include_absorbing_boundary_as_index: bool) Tuple[numpy.ndarray, numpy, ndarray]
Get the receiver array coordinates either in meters or grid indices.
- Parameters
in_units (bool) – Boolean controlling if the returned coordinates are physical distance from origin or grid indices.
include_absorbing_boundary_as_index (bool) – Boolean controlling whether or not to place the origin at the edge of the absording boundary or within it.
- Returns
A tuple of 2 numpy.ndarray’s for horizontal and vertical coordinate, each of shape (n_receivers, 1).
- Return type
Tuple[numpy.ndarray, numpy,ndarray]
- get_snapshots() Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]
Get snapshots of all the dynamical fields generated across all the shots.
- get_sources()
- get_synthetic_data()
- load_vector(relative_path: str, verbose: bool) numpy.ndarray
Loads a vector of shape (free_parameters, 1) from a text file. Read in precision real_simulation.
- map_kernels_to_velocity()
Transform sensitivity kernels in Lamé parametrization (lambda, mu, rho) to velocity parametrization (vp, vs, rho).
- property misfit
Current misfit in the model.
This value is updated after
calculate_l2_misfit()
is run.
- property n_shots
Number of shots
- property n_sources
Number of sources across shots. Does not indicate how many per shot.
- property np_boundary
- property nt
Total time points
- property nx
Total horizontal points, including boundary layer
- property nx_free_parameters
- property nx_inner
- property nx_inner_boundary
- property nz
Total vertical points, including boundary layer
- property nz_free_parameters
- property nz_inner
- property nz_inner_boundary
- parameters = ['$v_p$', '$v_s$', '$\\rho$']
- plot_data(data: Tuple[numpy.ndarray, numpy.ndarray], exagerration=5.0)
- plot_domain(axis=None, shot_to_plot=None)
- plot_fields(fields=None, axes=None, shot_to_plot=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, vmin=[None, None, None], vmax=[None, None, None])
- plot_model_vector(m, axes=None, shot_to_plot=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, vmin=[None, None, None], vmax=[None, None, None])
- plot_observed_data(exagerration=5.0)
- plot_synthetic_data(exagerration=5.0)
- reset_kernels()
Reset kernel accumulators to zero. Important for adjoint simulations, as they simply keep accumulating wavefield correlations across shots and iterations otherwise. Making this manual allows for flexibility (e.g. different misfit per shot).
- set_model_vector(m: numpy.ndarray)
Update the model (vp, vs, rho) in the class.
- Parameters
m (numpy.ndarray) – vector of shape (free_parameters, 1).
- set_observed_data()
- set_parameter_fields()
- set_synthetic_data()
- property snapshot_interval
The interval of timesteps between snapshots.
- property snapshots
The total amount of snapshots per shot.
- units = ['$m/s$', '$m/s$', '$kg/m^3$']
- property which_source_to_fire_in_which_shot
Which source fires in which shot.