def __init__(self, shots, shape, origin, spacing, m0, dm, noise=0.0, device='cpu', sequential=False): super(wave_solver, self).__init__() self.forward_born = ForwardBorn() self.noise = noise self.device = device self.dm = dm self.spacing = spacing epsilon = np.sqrt(noise)*np.random.randn(shots.shape[0], shots.shape[1], shots.shape[2]) self.shots = shots + epsilon self.model0 = Model(shape=shape, origin=origin, spacing=spacing, vp=1/np.sqrt(m0), nbpml=40) self.T = self.mute_top(dm, mute_end=10, length=5) t0 = 0. tn = 1500.0 dt = self.model0.critical_dt nt = int(1 + (tn-t0) / dt) self.time_range = np.linspace(t0,tn,nt) self.f0 = 0.030 self.nsrc = 205 self.nsimsrc = 205 self.src = RickerSource(name='src', grid=self.model0.grid, f0=self.f0, time=self.time_range, npoint=self.nsimsrc) self.src.coordinates.data[:,0] = np.linspace(0, self.model0.domain_size[0], num=self.nsimsrc) self.src.coordinates.data[:,-1] = 2.0*spacing[1] nrec = 410 self.rec = Receiver(name='rec', grid=self.model0.grid, npoint=nrec, ntime=nt) self.rec.coordinates.data[:, 0] = np.linspace(0, self.model0.domain_size[0], num=nrec) self.rec.coordinates.data[:, 1] = 2.0*spacing[1] self.seq_src_idx = 0 self.sequential = sequential
if iteration == 1: x = np.zeros(shape=shape, dtype='float32') else: x = array_get( bucket, variable_path + 'chunk_1/' + variable_name + str(iteration - 1)) if num_chunks > 1: for chunk in range(1, num_chunks): x_chunk = array_get( bucket, variable_path + 'chunk_' + str(chunk + 1) + '/' + variable_name + str(iteration - 1)) x = np.concatenate((x, x_chunk), axis=0) x = x.reshape(shape[0], shape[1], order='F') # Set up model structures model = Model(shape=shape, origin=origin, spacing=spacing, vp=np.sqrt(1 / m0)) # Time axis t0 = 0. dt_comp = model.critical_dt nt_comp = int(1 + (tn - t0) / dt_comp) + 1 time_comp = np.linspace(t0, tn, nt_comp) # Source f0 = 0.020 src_coordinates = np.empty((1, ndims)) src_coordinates[0, 0] = sx src_coordinates[0, 1] = sz # Receiver for predicted data nrec = len(gx)
if np.isscalar(vel): return .9 * vel * np.ones(shape, dtype=np.float32) out = np.copy(vel) nz = shape[-1] for a in range(5, nz - 6): if len(shape) == 2: out[:, a] = np.sum(vel[:, a - 5:a + 5], axis=1) / 10 else: out[:, :, a] = np.sum(vel[:, :, a - 5:a + 5], axis=2) / 10 return out # Set up model structures rho0 = smooth10(rho, shape) model = Model(shape=shape, origin=origin, spacing=spacing, vp=v, rho=rho0) # Smooth background model v0 = smooth10(v, shape) dm = (1 / v)**2 - (1 / v0)**2 model0 = Model(shape=shape, origin=origin, spacing=spacing, vp=v0, dm=dm, rho=rho0) # Constant background model v_const = np.empty(shape, dtype=np.float32) v_const[:, :] = 1.5 dm_const = (1 / v)**2 - (1 / v_const)**2
from PyModel import Model from checkpoint import DevitoCheckpoint, CheckpointOperator from pyrevolve import Revolver import matplotlib.pyplot as plt from JAcoustic_codegen import forward_modeling, adjoint_born # Model shape = (101, 101) spacing = (10., 10.) origin = (0., 0.) v = np.empty(shape, dtype=np.float32) v[:, :51] = 1.5 v[:, 51:] = 2.5 v0 = np.empty(shape, dtype=np.float32) v0[:, :] = 1.5 model = Model(shape=shape, origin=origin, spacing=spacing, vp=v) model0 = Model(shape=shape, origin=origin, spacing=spacing, vp=v0) # Time axis t0 = 0. tn = 1000. dt = model.critical_dt nt = int(1 + (tn - t0) / dt) time = np.linspace(t0, tn, nt) # Source f0 = 0.010 src = RickerSource(name='src', grid=model.grid, f0=f0, time=time) src.coordinates.data[0, :] = np.array(model.domain_size) * 0.5 src.coordinates.data[0, -1] = 20.
shape = (120, 120, 120) spacing = (10, 10, 10) origin = (0., 0., 0.) nrec = 101 # Velocity v = np.empty(shape, dtype=np.float32) v[:, :, :55] = 1.5 v[:, :, 55:] = 3.0 v0 = ndimage.gaussian_filter(v, sigma=5) m = (1. / v)**2 m0 = (1. / v0)**2 dm = m - m0 # Set up model structures model = Model(shape=shape, origin=origin, spacing=spacing, vp=v, nbpml=30) model0 = Model(shape=shape, origin=origin, spacing=spacing, vp=v0, dm=dm, nbpml=30) # Time axis t0 = 0. tn = 1200. num_wavefields = int(tn / 4) mem = ((model.shape[0] + 2 * model.nbpml) * (model.shape[1] + 2 * model.nbpml) * (model.shape[2] + 2 * model.nbpml) * num_wavefields / subsampling_factor * 8) / 1024**3
# Velocity v = np.empty(shape, dtype=np.float32) v[:, :51] = 1.5 v[:, 51:] = 1.5 v0 = np.empty(shape, dtype=np.float32) v0[:, :] = 1.5 # Density rho = np.empty(shape, dtype=np.float32) rho[:, :51] = 1.0 rho[:, 51:] = 2.0 rho0 = np.empty(shape, dtype=np.float32) rho0[:, :] = 1.0 # Set up model structures model = Model(shape=shape, origin=origin, spacing=spacing, vp=v, rho=rho) model0 = Model(shape=shape, origin=origin, spacing=spacing, vp=v0, rho=rho0) # Time axis t0 = 0. tn = 1000. dt = model.critical_dt nt = int(1 + (tn - t0) / dt) time = np.linspace(t0, tn, nt) # Source f0 = 0.010 src = RickerSource(name='src', grid=model.grid, f0=f0, time=time) src.coordinates.data[0, :] = np.array(model.domain_size) * 0.5 src.coordinates.data[0, -1] = 20.
# Model shape = (301, 301) spacing = (10., 10.) origin = (0., 0.) v1 = np.empty(shape, dtype=np.float32) v1[:, :51] = 1.5 v1[:, 51:] = 3.5 # Density rho = np.empty(shape, dtype=np.float32) rho[:, :51] = 1.0 rho[:, 51:] = 2.0 # Set up model structures model1 = Model(shape=shape, origin=origin, spacing=spacing, vp=v1, rho=rho) def smooth10(vel, shape): if np.isscalar(vel): return .9 * vel * np.ones(shape, dtype=np.float32) out = np.copy(vel) nz = shape[-1] for a in range(5, nz - 6): if len(shape) == 2: out[:, a] = np.sum(vel[:, a - 5:a + 5], axis=1) / 10 else: out[:, :, a] = np.sum(vel[:, :, a - 5:a + 5], axis=2) / 10 return out