Ejemplo n.º 1
0
from mpi4py import MPI

if __name__ == "__main__":

    comm = MPI.COMM_WORLD
    size = comm.Get_size()
    rank = comm.Get_rank()

    # Wrapper for handling parallelism over shots
    pwrap = ParallelWrapShot(comm=MPI.COMM_WORLD)

    if rank == 0:
        ttt = time.time()

    #   Load or generate true wave speed
    C, C0, m, d = marmousi(patch="mini_square")

    # Set up shots

    Nshots = size
    sys.stdout.write("{0}: {1}\n".format(rank, Nshots / size))

    shots = equispaced_acquisition(
        m, RickerWavelet(10.0), sources=Nshots, source_depth=20.0, receivers="max", parallel_shot_wrap=pwrap
    )

    # Define and configure the wave solver
    trange = (0.0, 3.0)

    solver = ConstantDensityAcousticWave(m, spatial_accuracy_order=6, trange=trange, kernel_implementation="cpp")
    size = comm.Get_size()
    rank = comm.Get_rank()

    print "size = %i and rank = %i"%(size, rank)

    pwrap = ParallelWrapShot(comm=comm)  
  
  

####### Here we set the wave speed

    WaveSpeed.add_lower_bound(1000.0)
    WaveSpeed.add_upper_bound(6500.0)
    
    x_lbc = PML(600.0,100.0); x_rbc = PML(600.0,100.0); z_lbc = PML(600.0,100.0); z_rbc = PML(600.0,100.0)
    C, C0, m, d = marmousi(patch='mini_square', x_lbc = x_lbc, x_rbc = x_rbc, z_lbc = z_lbc, z_rbc = z_rbc)

    n_nodes_x = m.x.n
    n_nodes_z = m.z.n
    
    dx = m.x.delta
    dz = m.z.delta
    
    x_min = d.x.lbound
    x_max = d.x.rbound
    z_min = d.z.lbound
    z_max = d.z.rbound    

    x_min_km = x_min/1000.0; x_max_km = x_max/1000.0; z_min_km = z_min/1000.0; z_max_km = z_max/1000.0 

    marmousi_baseline_true_2d    = np.reshape(C , (n_nodes_z, n_nodes_x), 'F')
Ejemplo n.º 3
0
# Std import block
import time
import copy

import numpy as np
import matplotlib.pyplot as plt

from pysit import *
from pysit.gallery import marmousi
from pysit.gallery import marmousi2

if __name__ == '__main__':
    #   Load or generate true wave speed
    C, C0, m, d = marmousi(patch='mini_square')
#   C, C0, m, d = marmousi2(patch='mini_square')

    # Set up shots
    shots = equispaced_acquisition(m,
                                   RickerWavelet(10.0),
                                   sources=1,
                                   source_depth=500.0,
                                   source_kwargs={},
                                   receivers='max',
                                   receiver_kwargs={},
                                   )

    # Define and configure the wave solver
    trange = (0.0, 3.0)

    solver = ConstantDensityAcousticWave(m,
                                         spatial_accuracy_order=6,
Ejemplo n.º 4
0
# Std import block
import time
import copy

import numpy as np
import matplotlib.pyplot as plt

from pysit import *
from pysit.gallery import marmousi
from pysit.gallery import marmousi2

if __name__ == '__main__':
    #   Load or generate true wave speed
    C, C0, m, d = marmousi(patch='mini_square')
    #   C, C0, m, d = marmousi2(patch='mini_square')

    # Set up shots
    shots = equispaced_acquisition(
        m,
        RickerWavelet(10.0),
        sources=1,
        source_depth=500.0,
        source_kwargs={},
        receivers='max',
        receiver_kwargs={},
    )

    # Define and configure the wave solver
    trange = (0.0, 3.0)

    solver = ConstantDensityAcousticWave(m,
Ejemplo n.º 5
0
    pwrap = ParallelWrapShot()

    if rank == 0:
        ttt = time.time()
        sys.stdout.write('Marmousi test \n')

    # Set up domain, mesh and velocity model
    m_param = {
        'patch': 'mini_square',
        #    'pixel_scale'           : 'mini',
        #    'initial_model_style'   : 'smooth_low_pass',
        #    'initial_config'        : {'freq':1/3000.},
    }

    C, C0, m, d = marmousi(patch=m_param['patch'])
    #    pixel_scale=m_param['pixel_scale'],
    #    initial_model_style=m_param['initial_model_style'],
    #    initial_config=m_param['initial_config'])

    if rank == 0:
        sys.stdout.write('patch = %s \n' % m_param['patch'])
        # sys.stdout.write('pixel_scale = %s \n' %m_param['pixel_scale'])
        # sys.stdout.write('initial_model_style = %s \n' %m_param['initial_model_style'])
        # sys.stdout.write('initial_config = %s \n' %m_param['initial_config'])

    # Set up shots
    zmin = d.z.lbound
    zmax = d.z.rbound
    zpos = 0.02 * 1.0
Ejemplo n.º 6
0
import os

import numpy as np
import matplotlib.pyplot as plt

from pysit import *
from pysit.gallery import marmousi
from pysit.gallery import marmousi2

if __name__ == '__main__':
    os.environ["OMP_NUM_THREADS"] = "14"
    #   Load or generate true wave speed we can add the compact operator
    #   flag it will speed up the resolution

    # uses a compact PML formulation
    C, C0, m, d = marmousi(patch='mini_square', compact=True)
    # C, C0, m, d = marmousi2(patch='mini_square', compact = True)
    # C, C0, m, d = marmousi(patch='mini_square')
    # C, C0, m, d = marmousi2(patch='mini_square')

    # Set up shots
    shots = equispaced_acquisition(
        m,
        RickerWavelet(10.0),
        sources=20,
        source_depth=500.0,
        source_kwargs={},
        receivers='max',
        receiver_kwargs={},
    )
Ejemplo n.º 7
0
from pysit.gallery import marmousi
import scipy.io as io
import os
import matplotlib.pyplot as plt
import time
import numpy as np
if __name__ == '__main__':
    # 生成默认的二维marmousi模型
    # 物理尺寸:横坐标-0~9200;纵坐标-0~3000;单位-m
    # 网格参数:横向网格数-460;纵向网格数-150;
    # 网格划分间隔-20;单位-m;横向网格点数-461;纵向网格点数-151
    # C-二维Marmousi模型各网格波速;C0-反演初始模型各网格波速;
    # m-网格对象,保存二维Marmousi模型的网格剖分信息;
    # d-物理模型对象,保存二维Marmousi模型的物理信息
    # initial_model_style-初始模型生成规则,可填参数constant、smooth_width、smooth_low_pass、gradient
    C, C0, m, d = marmousi(patch='mini_square',
                           initial_model_style='smooth_low_pass')
    # 绘制模型
    plt.figure()
    plt.subplot(2, 1, 1)
    vis.plot(C0, m)
    b1 = plt.colorbar()
    b1.set_label('Velocity (m/s)')
    plt.title('Initial Model')
    plt.xlabel('Length (m)')
    plt.ylabel('Depth (m)')
    plt.subplot(2, 1, 2)
    vis.plot(C, m)
    b2 = plt.colorbar()
    b2.set_label('Velocity (m/s)')
    plt.title('True Model')
    plt.xlabel('Length (m)')
Ejemplo n.º 8
0
import os

import numpy as np
import matplotlib.pyplot as plt

from pysit import *
from pysit.gallery import marmousi
from pysit.gallery import marmousi2

if __name__ == '__main__':
    os.environ["OMP_NUM_THREADS"] = "14"
    #   Load or generate true wave speed we can add the compact operator
    #   flag it will speed up the resolution
    
    # uses a compact PML formulation
    C, C0, m, d = marmousi(patch='mini_square', compact = True)
    # C, C0, m, d = marmousi2(patch='mini_square', compact = True)
    # C, C0, m, d = marmousi(patch='mini_square')
    # C, C0, m, d = marmousi2(patch='mini_square')

    # Set up shots
    shots = equispaced_acquisition(m,
                                   RickerWavelet(10.0),
                                   sources=20,
                                   source_depth=500.0,
                                   source_kwargs={},
                                   receivers='max',
                                   receiver_kwargs={},
                                   )

    # Define and configure the wave solver
from pysit.util.compute_tools import *
from pysit.gallery import marmousi
from pysit.gallery import marmousi2

from pysit.util.parallel import *

if __name__ == '__main__':
    # Set up parallel computing environment
    comm = MPI.COMM_WORLD
    size = comm.Get_size()
    rank = comm.Get_rank()

    pwrap = ParallelWrapShot()

    # Set up domain, mesh and velocity model
    C, C0, m, d = marmousi(pixel_scale='mini')
    if rank == 0:

        plt.figure()
        vis.plot(C, m)
        plt.show()

    comm.Barrier()

    m_shape = m._shapes[(False, True)]
    pmlx = PML(0.5, 1000)
    pmlz = PML(0.5, 1000)

    x_config = (d.x.lbound / 1000.0, d.x.rbound / 1000.0, pmlx, pmlx)
    z_config = (d.z.lbound / 1000.0, d.z.rbound / 1000.0, pmlz, pmlz)
Ejemplo n.º 10
0
    aux_info_copy = copy.deepcopy(aux_info)


    solver.model_parameters = joint_model.m_1
    gradient_m_1 = objective.compute_gradient(shots_1, joint_model.m_1, aux_info=aux_info_copy)
    objective_value_m_1 = aux_info_copy['objective_value'][1]    
        
    joint_data_obj = objective_value_m_0 + objective_value_m_1
    joint_data_gradient = JointPerturbation(gradient_m_0, gradient_m_1)

    return joint_data_obj, joint_data_gradient

if __name__ == '__main__':
    pixel_scale = [50.0, 50.0]
    
    C, C0, m, d = marmousi(patch='mini_square', pixel_scale=pixel_scale)

    shots = equispaced_acquisition(m,
                                   RickerWavelet(4.0),
                                   sources=3,
                                   source_depth=200.0,
                                   source_kwargs={},
                                   receivers='max',
                                   receiver_kwargs={},
                                   )

    trange = (0.0, 3.0)

    solver = ConstantDensityAcousticWave(m,
                                         spatial_accuracy_order=6,
                                         trange=trange,
Ejemplo n.º 11
0
# Std import block
import time
import copy

import numpy as np
import matplotlib.pyplot as plt

from pysit import *
from pysit.gallery import marmousi
from pysit.gallery import marmousi2

if __name__ == '__main__':
    #   Load or generate true wave speed
    C, C0, m, d = marmousi(patch='mini_square', pixel_scale='medium')
#   C, C0, m, d = marmousi2(patch='mini_square')

    # Set up shots
    shots = equispaced_acquisition(m,
                                   RickerWavelet(10.0),
                                   sources=1,
                                   source_depth=500.0,
                                   source_kwargs={},
                                   receivers='max',
                                   receiver_kwargs={},
                                   )

    # Define and configure the wave solver
    trange = (0.0, 3.0)

    solver = ConstantDensityAcousticWave(m,
                                         spatial_accuracy_order=2,