def born_rec_w(model, weight, wavelet, rec_coords, space_order=8, isic=False): """ Linearized (Born) modeling of a point source for a model perturbation (square slowness) dm with an extended source Parameters ---------- model: Model Physical model weight: Array Spatial distriubtion of the extended source wavelet: Array Source signature rec_coords: Array Coordiantes of the receiver(s) space_order: Int (optional) Spatial discretization order, defaults to 8 isic : Bool Whether or not to use ISIC imaging condition Returns ---------- Array Shot record """ rec, _, _ = born(model, None, rec_coords, wavelet, save=False, ws=weight, space_order=space_order, isic=isic) return rec.data
def born_rec(model, src_coords, wavelet, rec_coords, space_order=8, free_surface=False, isic=False): """ Linearized (Born) modeling of a point source for a model perturbation (square slowness) dm. Parameters ---------- model: Model Physical model src_coords: Array Coordiantes of the source(s) wavelet: Array Source signature rec_coords: Array Coordiantes of the receiver(s) space_order: Int (optional) Spatial discretization order, defaults to 8 free_surface: Bool (optional) Whether or not to use a free surface isic : Bool Whether or not to use ISIC imaging condition Returns ---------- Array Shot record """ rec, _ = born(model, src_coords, rec_coords, wavelet, save=False, space_order=space_order, free_surface=free_surface, isic=isic) return rec.data
# Source f1 = 0.008 src = RickerSource(name='src', grid=model.grid, f0=f1, time=time_axis) src.coordinates.data[0, :] = np.array(model.domain_size) * 0.5 src.coordinates.data[0, -1] = 20. # Receiver for observed data rec_t = Receiver(name='rec_t', grid=model.grid, npoint=301, ntime=nt) rec_t.coordinates.data[:, 0] = np.linspace(0., 3000., num=301) rec_t.coordinates.data[:, 1] = 20. # Linearized data print("Forward J") dD_hat, u0l, _ = born(model, src.coordinates.data, rec_t.coordinates.data, src.data, save=True) # Forward print("Forward") _, u0, _ = forward(model, src.coordinates.data, rec_t.coordinates.data, src.data, save=True) # gradient print("Adjoint J") dm_hat, _ = gradient(model, dD_hat, rec_t.coordinates.data, u0)
rank = comm.Get_rank() size = comm.size ######################################################################################### # Source wavelet tn = 1000. dt_shot = model.critical_dt nt = int(tn / dt_shot) time_s = np.linspace(0, tn, nt) wavelet = Ricker(0.015, time_s) ######################################################################################### # Devito operator d_obs = born(model, src_coords, rec_coords, wavelet, save=False)[0] u0 = forward(model, src_coords, rec_coords, wavelet, save=True, t_sub=8)[1] grad_dist = gradient(model, d_obs, d_obs.coordinates, u0, isic=False)[0] if rank > 0: # Send result to master comm.send(model.m.local_indices, dest=0, tag=10) comm.send(grad_dist.data, dest=0, tag=11) else: # Master # Initialize full array grad = np.empty(shape=model.m.shape_global, dtype='float32') grad[model.m.local_indices] = grad_dist.data # Collect gradients