# Add velocity perturbation ## Add velocity perturbation onto gll data format file The program of `sem_model_addpert.f90` provide functions to add velocity perturbation to points with Gaussian spatial filtering. The program read all GLL points and then calculate the distance between perturbation points and GLL points to determine amplitudes of the Gaussian filter. :::{math} g(d) = \exp{-\frac{d^2}{2\sigma^2}} ::: Where the {math}`d` is this distance. {math}`\sigma` is the Gaussian factor in meter. The core algorithm is shown as ```fortran do ipt=1,npts ! Number of perturbation points do ispec=1,nspec do k=1,NGLLZ do j=1,NGLLY do i=1,NGLLX iglob = ibool(i,j,k,ispec) ! calculate distance dist(ipt)=dsqrt((x(ipt)-dble(xstore(iglob)))**2 & +(y(ipt)-dble(ystore(iglob)))**2 & +(z(ipt)-dble(zstore(iglob)))**2) gaus=exp(-1*dist(ipt)*dist(ipt)/2/sigma/sigma) vstore_new(i,j,k,ispec)=vstore(i,j,k,ispec)*(1+pert*gaus) dlnvs_gaus(i,j,k,ispec)=pert*gaus enddo enddo enddo enddo enddo ``` ### Compilation Compile `sem_model_addpert.f90` with `mpif90`. ``` mpif90 -O3 -traceback -o sem_model_addpert sem_model_addpert.f90 exit_mpi.f90 read_basin_topo_bathy_file.f90 utm_geo.f90 ``` ### Run with `mpirun` To add a 6% perturbation with ```bash model_dir=model_2layers topo_dir=OUTPUT_FILES/DATABASES_MPI cat > gaus01.dat << eof 60000.0 0.0 -20000.0 eof dvs=0.06 sigma=3000 mpirun -np 4 $prog gaus01.dat $topo_dir $model_dir vs $dvs $sigma ``` ## Virtualization of GLL data format ### Convert binary file to npz I revise code of `auxiliaries/project_and_combine_vol_data_on_regular_grid.f90` for converting materials form the GLL format to npz format. ```bash data_filename=vs indir=model_pert/ outdir=output_vtk/ cat > fd_proj_grid.txt <