ADFWI.model
ADFWI.model.base
- class ADFWI.model.base.AbstractModel(ox: float, oz: float, nx: int, nz: int, dx: float, dz: float, free_surface: bool | None = False, abc_type: str | None = 'PML', abc_jerjan_alpha: float | None = 0.0053, nabc: int | None = 20, device='cpu', dtype=torch.float32)[source]
Bases:
Module
Abstract model class for FWI models
- Parameters:
ox (float) – Origin of the model in x-direction (m)
oz (float) – Origin of the model in z-direction (m)
dx (float) – Grid size in x-direction (m)
dz (float) – Grid size in z-direction (m)
nx (int) – Number of grid points in x-direction
nz (int) – Number of grid points in z-direction
free_surface (bool, optional) – Flag for free surface, default is False
abc_type (str, optional) – The type of absorbing boundary condition: PML, Jerjan, and other
abc_jerjan_alpha (float, optional) – The attenuation factor for Jerjan boundary condition
nabc (int, optional) – Number of absorbing boundary cells, default is 20
device (str, optional) – The running device
dtype (dtype, optional) – The dtypes for PyTorch variable, default is torch.float32
- constrain_range(value, min_value, max_value) Tensor [source]
Constrain the value to the range [min_value, max_value] by using the torch.clamp function
- abstract forward(*args, **kwargs) Tuple[Tensor, Tensor, Tensor] [source]
Forward method of the model class that outputs the elastic parameters of lambda, mu, and buoyancy required for the wave equation propagator.
- training: bool
ADFWI.model.acoustic_model
- class ADFWI.model.acoustic_model.AcousticModel(ox: float, oz: float, nx: int, nz: int, dx: float, dz: float, vp: array | Tensor | None = None, rho: array | Tensor | None = None, vp_bound: Tuple[float, float] | None = None, rho_bound: Tuple[float, float] | None = None, vp_grad: bool | None = False, rho_grad: bool | None = False, auto_update_rho: bool | None = True, auto_update_vp: bool | None = False, water_layer_mask: array | Tensor | None = None, free_surface: bool | None = False, abc_type: str | None = 'PML', abc_jerjan_alpha: float | None = 0.0053, nabc: int | None = 20, device='cpu', dtype=torch.float32)[source]
Bases:
AbstractModel
Acoustic Velocity model with parameterization of vp and rho.
- Parameters:
ox (float) – Not used. The origin coordinates of the model in the x-direction (meters).
oz (float) – Not used. The origin coordinates of the model in the z-direction (meters).
nx (int) – Not used. The number of grid points in the x-direction.
nz (int) – Not used. The number of grid points in the z-direction.
dx (float) – The grid spacing in the x-direction (meters).
dz (float) – The grid spacing in the z-direction (meters).
vp (Optional[Union[np.array, Tensor]], default=None) – P-wave velocity model with shape (nz, nx).
rho (Optional[Union[np.array, Tensor]], default=None) – Density model with shape (nz, nx).
vp_bound (Optional[Tuple[float, float]], default=None) – The lower and upper bounds for the P-wave velocity model.
rho_bound (Optional[Tuple[float, float]], default=None) – The lower and upper bounds for the density model.
vp_grad (Optional[bool], default=False) – Indicates whether the gradient of the P-wave velocity model is required.
rho_grad (Optional[bool], default=False) – Indicates whether the gradient of the density model is required.
auto_update_rho (Optional[bool], default=True) – Whether to automatically update the density model during inversion.
auto_update_vp (Optional[bool], default=False) – Whether to automatically update the P-wave velocity model during inversion.
water_layer_mask (Optional[Union[np.array, Tensor]], default=None) – A mask for the water layer (not updated), if applicable.
free_surface (Optional[bool], default=False) – Indicates whether a free surface is present in the model.
abc_type (Optional[str], default='PML') – The type of absorbing boundary condition used in the model. Options: ‘PML’ or ‘Jerjan’.
abc_jerjan_alpha (Optional[float], default=0.0053) – The attenuation factor for the Jerjan boundary condition.
nabc (Optional[int], default=20) – The number of grid cells dedicated to the absorbing boundary.
device (str, default='cpu') – The device on which to run the model (‘cpu’ or ‘cuda’).
dtype (torch.dtype, default=torch.float32) – The data type for PyTorch tensors.
- training: bool
ADFWI.model.elastic_model
- class ADFWI.model.elastic_model.AnisotropicElasticModel(ox: float, oz: float, nx: int, nz: int, dx: float, dz: float, vp: array | Tensor | None = None, vs: array | Tensor | None = None, rho: array | Tensor | None = None, eps: array | Tensor | None = None, gamma: array | Tensor | None = None, delta: array | Tensor | None = None, vp_bound: Tuple[float, float] | None = None, vs_bound: Tuple[float, float] | None = None, rho_bound: Tuple[float, float] | None = None, eps_bound: Tuple[float, float] | None = None, gamma_bound: Tuple[float, float] | None = None, delta_bound: Tuple[float, float] | None = None, vp_grad: bool | None = False, vs_grad: bool | None = False, rho_grad: bool | None = False, eps_grad: bool | None = False, gamma_grad: bool | None = False, delta_grad: bool | None = False, free_surface: bool | None = False, anisotropic_type: str | None = 'vti', abc_type: str | None = 'PML', abc_jerjan_alpha: float | None = 0.0053, nabc: int | None = 20, auto_update_rho: bool | None = False, auto_update_vp: bool | None = False, water_layer_mask: array | Tensor | None = None, device='cpu', dtype=torch.float32)[source]
Bases:
AbstractModel
- This model defines an anisotropic elastic velocity model for VTI (Vertical Transverse Isotropy) or HTI (Horizontal Transverse Isotropy) using the primary parameters:
P-wave velocity (vp)
S-wave velocity (vs)
Density (rho)
Anisotropic parameters epsilon (eps), gamma, and delta
- Parameters:
ox (float) – Origin of the model in the x-direction (m)
oz (float) – Origin of the model in the z-direction (m)
nx (int) – Number of grid points in the x-direction
nz (int) – Number of grid points in the z-direction
dx (float) – Grid size in the x-direction (m)
dz (float) – Grid size in the z-direction (m)
vp (Optional[Union[np.array, Tensor]], optional) – P-wave velocity model with shape (nz, nx), default is None
vs (Optional[Union[np.array, Tensor]], optional) – S-wave velocity model with shape (nz, nx), default is None
rho (Optional[Union[np.array, Tensor]], optional) – Density model with shape (nz, nx), default is None
eps (Optional[Union[np.array, Tensor]], optional) – Anisotropic parameter epsilon for VTI/HTI model, default is None
gamma (Optional[Union[np.array, Tensor]], optional) – Anisotropic parameter gamma for VTI/HTI model, default is None
delta (Optional[Union[np.array, Tensor]], optional) – Anisotropic parameter delta for VTI/HTI model, default is None
vp_bound (Optional[Tuple[float, float]], optional) – Lower and upper bounds for the P-wave velocity model, default is None
vs_bound (Optional[Tuple[float, float]], optional) – Lower and upper bounds for the S-wave velocity model, default is None
rho_bound (Optional[Tuple[float, float]], optional) – Lower and upper bounds for the density model, default is None
eps_bound (Optional[Tuple[float, float]], optional) – Lower and upper bounds for epsilon, default is None
gamma_bound (Optional[Tuple[float, float]], optional) – Lower and upper bounds for gamma, default is None
delta_bound (Optional[Tuple[float, float]], optional) – Lower and upper bounds for delta, default is None
vp_grad (Optional[bool], optional) – Flag to compute the gradient of the P-wave velocity model, default is False
vs_grad (Optional[bool], optional) – Flag to compute the gradient of the S-wave velocity model, default is False
rho_grad (Optional[bool], optional) – Flag to compute the gradient of the density model, default is False
eps_grad (Optional[bool], optional) – Flag to compute the gradient of epsilon, default is False
gamma_grad (Optional[bool], optional) – Flag to compute the gradient of gamma, default is False
delta_grad (Optional[bool], optional) – Flag to compute the gradient of delta, default is False
free_surface (Optional[bool], optional) – Flag to include a free surface, default is False
anisotropic_type (Optional[str], optional) – Type of anisotropic model (‘vti’, ‘hti’, etc.), default is ‘vti’
abc_type (Optional[str], optional) – Type of absorbing boundary condition, options include ‘PML’, ‘Jerjan’, etc., default is ‘PML’
abc_jerjan_alpha (Optional[float], optional) – Attenuation factor for Jerjan boundary condition, default is 0.0053
nabc (Optional[int], optional) – Number of absorbing boundary cells, default is 20
auto_update_rho (Optional[bool], optional) – Whether to automatically update the density model during inversion, default is False
auto_update_vp (Optional[bool], optional) – Whether to automatically update the P-wave velocity model during inversion, default is False
water_layer_mask (Optional[Union[np.array, Tensor]], optional) – Mask for the water layer (not updated), if applicable, default is None
device (str, optional) – Device for running the model (‘cpu’ or ‘cuda’), default is ‘cpu’
dtype (torch.dtype, optional) – Data type for PyTorch tensors, default is torch.float32
- training: bool
- class ADFWI.model.elastic_model.IsotropicElasticModel(ox: float, oz: float, nx: int, nz: int, dx: float, dz: float, vp: array | Tensor | None = None, vs: array | Tensor | None = None, rho: array | Tensor | None = None, vp_bound: Tuple[float, float] | None = None, vs_bound: Tuple[float, float] | None = None, rho_bound: Tuple[float, float] | None = None, vp_grad: bool | None = False, vs_grad: bool | None = False, rho_grad: bool | None = False, free_surface: bool | None = False, abc_type: str | None = 'PML', abc_jerjan_alpha: float | None = 0.0053, nabc: int | None = 20, auto_update_rho: bool | None = True, auto_update_vp: bool | None = False, water_layer_mask: array | Tensor | None = None, device='cpu', dtype=torch.float32)[source]
Bases:
AbstractModel
Isotropic Elastic Velocity model with parameterization of vp, vs, and rho.
- Parameters:
ox (float) – Origin of the model in x-direction (m)
oz (float) – Origin of the model in z-direction (m)
nx (int) – Number of grid points in x-direction
nz (int) – Number of grid points in z-direction
dx (float) – Grid size in x-direction (m)
dz (float) – Grid size in z-direction (m)
vp (Optional[Union[np.array, Tensor]], optional) – P-wave velocity model with shape (nz, nx), default is None
vs (Optional[Union[np.array, Tensor]], optional) – S-wave velocity model with shape (nz, nx), default is None
rho (Optional[Union[np.array, Tensor]], optional) – Density model with shape (nz, nx), default is None
vp_bound (Optional[Tuple[float, float]], optional) – The lower and upper bounds for the P-wave velocity model, default is None
vs_bound (Optional[Tuple[float, float]], optional) – The lower and upper bounds for the S-wave velocity model, default is None
rho_bound (Optional[Tuple[float, float]], optional) – The lower and upper bounds for the density model, default is None
vp_grad (Optional[bool], optional) – A flag to indicate if the gradient of the P-wave velocity model is needed, default is False
vs_grad (Optional[bool], optional) – A flag to indicate if the gradient of the S-wave velocity model is needed, default is False
rho_grad (Optional[bool], optional) – A flag to indicate if the gradient of the density model is needed, default is False
free_surface (Optional[bool], optional) – A flag to indicate the presence of a free surface in the model, default is False
abc_type (Optional[str], optional) – The type of absorbing boundary condition used in the model, options include ‘PML’, ‘Jerjan’, etc., default is ‘PML’
abc_jerjan_alpha (Optional[float], optional) – The attenuation factor for the Jerjan boundary condition, default is 0.0053
nabc (Optional[int], optional) – The number of grid cells dedicated to the absorbing boundary, default is 20
auto_update_rho (Optional[bool], optional) – Whether to automatically update the density model during inversion, default is True
auto_update_vp (Optional[bool], optional) – Whether to automatically update the P-wave velocity model during inversion, default is False
water_layer_mask (Optional[Union[np.array, Tensor]], optional) – A mask for the water layer (not updated), if applicable, default is None
device (str, optional) – The device on which to run the model, options are ‘cpu’ or ‘cuda’, default is ‘cpu’
dtype (torch.dtype, optional) – The data type for PyTorch tensors, default is torch.float32
- training: bool
ADFWI.model.parameters
- ADFWI.model.parameters.elastic_moduli_for_TI(CC, anisotropic_type='VTI')[source]
For Transverse isotropy case, only 5 independent components: C11, C13, C33, C44, C66, and C12 = C11 - 2*C66.
- Parameters:
CC (list of torch.Tensor) – List containing the 21 elastic moduli parameters: [C11, C12, C13, …, C66].
anisotropic_type (str, optional) – Type of anisotropy. Can be ‘VTI’ for vertical transverse isotropy (default) or ‘HTI’ for horizontal transverse isotropy.
- Returns:
CC – Modified list of elastic moduli with the corresponding anisotropic structure applied, depending on anisotropic_type.
- Return type:
list of torch.Tensor
- ADFWI.model.parameters.elastic_moduli_for_isotropic(CC)[source]
For isotropy case, only 2 independent components. The matrix of elastic moduli is simplified as:
- Parameters:
CC (list of torch.Tensor) – List containing the 21 elastic moduli parameters: [C11, C12, C13, …, C66].
- Returns:
CC – Modified list of elastic moduli with the isotropic assumption applied.
- Return type:
list of torch.Tensor
- ADFWI.model.parameters.elastic_moduli_init(nz, nx, device, dtype=torch.float32)[source]
Initialize the 21 independent elastic parameters for a full anisotropic medium. The function initializes the following 21 independent elastic parameters for a full anisotropic medium.
- Parameters:
nz (int) – The number of grid points in the z-direction.
nx (int) – The number of grid points in the x-direction.
device (str) – The device to place the tensors on (‘cpu’ or ‘cuda’).
dtype (torch.dtype, optional) – The data type of the tensors. Default is torch.float32.
- Returns:
A list containing the 21 independent elastic parameters, each as a tensor. The parameters are in the following order: [C11, C12, C13, C14, C15, C16, C22, C23, C24, C25, C26, C33, C34, C35, C36, C44, C45, C46, C55, C56, C66].
- Return type:
list of torch.Tensor
- ADFWI.model.parameters.elastic_moduli_to_thomsen(C11, C13, C33, C44, C66, rho)[source]
Transform Elastic Moduli to Thomsen parameters.
- Parameters:
C11 (torch.Tensor) – Elastic Moduli, C11.
C13 (torch.Tensor) – Elastic Moduli, C13.
C33 (torch.Tensor) – Elastic Moduli, C33.
C44 (torch.Tensor) – Elastic Moduli, C44.
C66 (torch.Tensor) – Elastic Moduli, C66.
rho (torch.Tensor) – Density.
- Returns:
alpha_thomsen (torch.Tensor) – P-wave velocity (vp).
beta_thomsen (torch.Tensor) – S-wave velocity (vs).
eps_thomsen (torch.Tensor) – Anisotropy parameter (eps).
delta_thomsen (torch.Tensor) – Anisotropy parameter (delta).
gamma_thomsen (torch.Tensor) – Anisotropy parameter (gamma).
- ADFWI.model.parameters.parameter_staggered_grid(mu, b, C44, C55, C66, nx, nz)[source]
Staggered mesh settings for model parameters.
This function calculates the staggered grid values for different model parameters: shear modulus (mu), buoyancy (b), and elastic moduli (C44, C55, C66) based on the grid size (nx, nz) and applies an averaging method for staggered grids.
- Parameters:
mu (torch.Tensor) – Shear modulus, also known as Lame constant.
b (torch.Tensor) – Buoyancy, the inverse of density.
C44 (torch.Tensor) – Elastic modulus C44, describing shear waves.
C55 (torch.Tensor) – Elastic modulus C55, another shear modulus term.
C66 (torch.Tensor) – Elastic modulus C66, also related to shear waves.
nx (int) – Number of grid points in the X direction (horizontal axis).
nz (int) – Number of grid points in the Z direction (vertical axis).
- Returns:
bx (torch.Tensor) – Staggered grid for buoyancy (b) in the X-axis.
bz (torch.Tensor) – Staggered grid for buoyancy (b) in the Z-axis.
muxz (torch.Tensor) – Staggered grid for shear modulus (mu).
C44 (torch.Tensor) – Staggered grid for C44 (shear modulus term).
C55 (torch.Tensor) – Staggered grid for C55 (shear modulus term).
C66 (torch.Tensor) – Staggered grid for C66 (shear modulus term).
- ADFWI.model.parameters.thomsen_init(vp, vs, rho, eps, delta, gamma, device, dtype=torch.float32)[source]
Initialize the Thomsen parameters.
- Parameters:
vp (array_like) – P-wave velocity model.
vs (array_like) – S-wave velocity model.
rho (array_like) – Density model.
eps (array_like) – Anisotropic parameter epsilon.
delta (array_like) – Anisotropic parameter delta.
gamma (array_like) – Anisotropic parameter gamma.
device (str) – The device to place the tensors on (‘cpu’ or ‘cuda’).
dtype (torch.dtype, optional) – Data type of the tensors, default is torch.float32.
- Returns:
vp (torch.Tensor) – P-wave velocity as a tensor.
vs (torch.Tensor) – S-wave velocity as a tensor.
rho (torch.Tensor) – Density as a tensor.
eps (torch.Tensor) – Anisotropic epsilon parameter as a tensor.
delta (torch.Tensor) – Anisotropic delta parameter as a tensor.
gamma (torch.Tensor) – Anisotropic gamma parameter as a tensor.
- ADFWI.model.parameters.thomsen_to_elastic_moduli(alpha_thomsen, beta_thomsen, rho, eps_thomsen, delta_thomsen, gamma_thomsen)[source]
Transform Thomsen parameters to Elastic Moduli for Transverse Isotropy. For Transverse isotropy case, only 5 independent components are used: C11, C13, C33, C44, C66. Additionally, C12 is calculated as C11 - 2*C66.
- Parameters:
alpha_thomsen (torch.Tensor) – P-wave velocity (vp).
beta_thomsen (torch.Tensor) – S-wave velocity (vs).
rho (torch.Tensor) – Density.
eps_thomsen (torch.Tensor) – Anisotropy parameter (eps).
delta_thomsen (torch.Tensor) – Anisotropy parameter (delta).
gamma_thomsen (torch.Tensor) – Anisotropy parameter (gamma).
- Returns:
C11 (torch.Tensor) – Elastic Moduli, C11.
C13 (torch.Tensor) – Elastic Moduli, C13.
C33 (torch.Tensor) – Elastic Moduli, C33.
C44 (torch.Tensor) – Elastic Moduli, C44.
C66 (torch.Tensor) – Elastic Moduli, C66.
- ADFWI.model.parameters.vs_vp_to_Lame(vp, vs, rho)[source]
Transform P-wave and S-wave velocities along with density to the Lame constants.
- Parameters:
vp (torch.Tensor) – P-wave velocity along the respective axis.
vs (torch.Tensor) – S-wave velocity along the respective axis.
rho (torch.Tensor) – Density.
- Returns:
mu (torch.Tensor) – Lame constant (shear modulus).
lamu (torch.Tensor) – Lame constant (lambda).
lam (torch.Tensor) – Lambda constant (lambda - 2 * mu).
b (torch.Tensor) – Buoyancy, which is the inverse of density (1 / rho).