hpcsys-lab / simwave Goto Github PK
View Code? Open in Web Editor NEWSimulates the propagation of the acoustic wave using the finite difference method in 2D and 3D domains.
License: GNU General Public License v3.0
Simulates the propagation of the acoustic wave using the finite difference method in 2D and 3D domains.
License: GNU General Public License v3.0
The following code takes far longer than what I would expect (given my experience with FEM codes) to run 265 timesteps on my laptop takes about 183 seconds. It also produces a fairly strange shot record. Given a similar configuration with spyro, it takes about 10-20 seconds.
from pywave import *
# number of grid points (z,x)
shape = (2801, 13601)
spacing = (50.0, 50.0)
# propagation time (miliseconds)
time = 2000
velModel = Model(file="elastic-marmousi-model/model/MODEL_P-WAVE_VELOCITY_1.25m.segy")
# plot_velocity_model(velModel, show=True)
compiler = Compiler(cc="gcc", cflags="-O3 -shared")
extension = BoundaryProcedures(
nbl=(
(0, 50),
(50, 50),
),
boundary_condition=(
("NN", "ND"),
("ND", "ND"),
), # dirichlet on the left, right and bottom, neumann on the top
damping_polynomial_degree=3,
alpha=0.0001,
)
wavelet = Wavelet(frequency=5.0)
source = Source(kws_half_width=1, wavelet=wavelet)
source.add(position=(30, 6500))
receivers = Receiver(kws_half_width=1)
for i in range(1, 13601, 20):
receivers.add(position=(45, i))
setup = Setup(
velocity_model=velModel,
sources=source,
receivers=receivers,
boundary_config=extension,
spacing=spacing,
propagation_time=time,
jumps=1,
compiler=compiler,
space_order=2,
)
solver = AcousticSolver(setup=setup)
wavefields, rec, exec_time = solver.forward()
print(exec_time, flush=True)
plot_shotrecord(rec, show=True)
language=c
compilation fails because the code tries to import omp.h
header despite it not being used. Perhaps this could be avoided by putting this include in a pragma?So that the initial pressure, or initial "pressure velocity" can be non-zero
I am gonna refatorate some classes in order to improve the API.
Per Hicks (2002), the suggested default value for the radius width is actually r=4. The current default is 1.
Fix OpenMP parallelization in sources/receivers loop. The following line should execute in serial order:
offset_src_kws_index_z += (src_z_num_points + src_x_num_points);
$ python3 gradient_2D.py
Traceback (most recent call last):
File "gradient_2D.py", line 199, in <module>
recv_true = calculate_true_seimogram(velocity_model=tru_vel)
File "gradient_2D.py", line 130, in calculate_true_seimogram
solver = create_solver(saving_stride=0, velocity_model=velocity_model)
File "gradient_2D.py", line 64, in create_solver
space_model = SpaceModel(
File "/home/jaime/simwave-research/simwave/kernel/frontend/model.py", line 57, in __init__
self._velocity_model = self.interpolate(velocity_model)
File "/home/jaime/simwave-research/simwave/kernel/frontend/model.py", line 242, in interpolate
return self.dtype(interpolant((Z, X)))
File "/usr/local/lib/python3.8/dist-packages/scipy/interpolate/_rgi.py", line 336, in __call__
result = evaluate_linear_2d(self.values,
File "_rgi_cython.pyx", line 19, in scipy.interpolate._rgi_cython.__pyx_fused_cpdef
TypeError: No matching signature found
It works with scipy==1.9.2
Add an action to run the GPU execution tests.
Hi everyone:
I'm trying to run the examples files on my Windows PC. First of all the acoustic 2D and gets an error at 53 line
----> 53 space_model = SpaceModel(
simwave\kernel\frontend\model.py:57
---> 57 self._velocity_model = self.interpolate(velocity_model)
simwave\kernel\frontend\model.py:242
--> 242 return self.dtype(interpolant((Z, X)))
File _rgi_cython.pyx:19, in scipy.interpolate._rgi_cython.__pyx_fused_cpdef()
TypeError: No matching signature found
Then I tried to run this on Google Colab and get an error a this point
u_full, recv = solver.forward()
Exception: Compilation failed
I'm really interested on using this library for solving problems of seismic acquisition.
Let me know what am I doing wrong, I'll appreciate it.
simwave/simwave/kernel/frontend/source.py
Line 103 in b48b852
and not of the model's dtype
is this in meters or kilometers?
Doing a simulation with the same sources leads to different results depending on the order sources are added.
Using the 2d example from the example/ directory:
from pywave import *
import numpy as np
# shape of the grid
shape = (512, 512)
# spacing
spacing = (15.0, 15.0)
# propagation time
time = 1500
# Velocity model
vel = np.zeros(shape, dtype=np.float32)
vel[:] = 1500.0
vel[200:] = 2000.0
velModel = Model(ndarray=vel)
# Compiler
compiler = Compiler(cc="gcc", cflags="-O3 -shared")
# domain extension (damping + spatial order halo)
extension = BoundaryProcedures(
nbl=50,
boundary_condition=(("NN", "NN"), ("NN", "NN")),
damping_polynomial_degree=3,
alpha=0.0001,
)
# Wavelet
wavelet = Wavelet(frequency=5.0)
# Source
source = Source(kws_half_width=1, wavelet=wavelet)
source.add(position=(270, 240))
source.add(position=(255.5, 255.5))
# receivers
receivers = Receiver(kws_half_width=1)
for i in range(512):
receivers.add(position=(255.5, i))
setup = Setup(
velocity_model=velModel,
sources=source,
receivers=receivers,
boundary_config=extension,
spacing=spacing,
propagation_time=time,
jumps=0,
compiler=compiler,
space_order=2,
)
solver = AcousticSolver(setup=setup)
wavefields, rec, exec_time = solver.forward()
print(wavefields.shape)
if len(wavefields.shape) > 2:
count = 0
for wavefield in wavefields:
plot_wavefield(wavefield, file_name="arq-" + str(count))
count += 1
else:
plot_wavefield(wavefields)
print("Forward execution time: %f seconds" % exec_time)
plot_shotrecord(rec)
swapping lines 34 and 35 leads to different shot records:
Unfortunately the bug does not come from my latest pull request, as I generated these images in commit 0b1b157.
pywave
remains currently private?pywave
from the SEGY file format.I am gonna create a few scripts to generate a single C code version.
import numpy as np
from pywave import *
shape = (512, 512)
spacing = (15.0, 15.0)
time = 10000
vel = Data(shape=shape)
compiler = Compiler(program_version="sequential")
grid = Grid(shape=vel.shape())
src_points, src_values = get_source_points(
grid_shape=shape, source_location=(30, 255.5), half_width=4
)
rec_points = np.array([], dtype=np.uint)
rec_values = np.array([], dtype=np.float32)
for i in range(512):
points, values = get_source_points(
grid_shape=shape, source_location=(30, i), half_width=4
)
rec_points = np.append(rec_points, points)
rec_values = np.append(rec_values, values)
setup = Setup(
grid=grid,
velocity=vel,
origin=(255, 255.5),
spacing=spacing,
progatation_time=time,
frequency=5.0,
nbl=150,
compiler=compiler,
src_points_interval=src_points,
src_points_values=src_values,
rec_points_interval=rec_points,
rec_points_values=rec_values,
num_receivers=511,
)
solver = AcousticSolver(setup=setup)
wavefields, rec, exec_time = solver.forward()
print(wavefields.shape)
wavefields.shape has the size of only one snap? Shouldn't this save all timesnaps?
Dear @jaimesouza ,
Thanks for your contribution. I would like to know if I can use it in ultrasound wave propagation such as 2.5MHz frequency. If yes, do you have experience in the space model or the computational time. Thanks a lot!
At a minimum we need to demonstrate and have a unit test which verifies all implemented numerical methods are converging at the correct spatial order
for very high order methods, the cfl condition will need to be much more conservative than the stability criteria in order to satisfy the asymptotic regime criteria.
We may also think about higher order timestepping methods
-O3 -march=znver2 -mtune=znver2 -ffast-math -funroll-loops -ftree-loop-distribution
which is not always safe but is muito rapido nonetheless.
how could these be passed?
Hello,
I am wondering if you have some plans to develop FDTD solver for 2D and 3D full linear elastic equations (isotropic, or maybe VTI/full anisotropic case)? It will be a great help to have a verified open-source solved with a good PML realization.
See if the interpolation function is correct in terms of axis order.
Only floats. Otherwise nothing is actually evaluated, as can be seen by running this MWE:
from pywave import *
import numpy as np
# Set reference (numerical) model
c = 2000 * np.ones(shape=(512, 512), dtype=np.float32)
space_model = SpaceModel(
bbox=(0, 5110, 0, 5110), grid_spacing=(10, 10), velocity_model=c
)
time_model = TimeModel(space_model=space_model, tf=1)
source = Source(space_model, coordinates=[(2560, 2560)])
receiver = Receiver(space_model, coordinates=[(3500, 3500)])
ricker = RickerWavelet(10.0, time_model)
solver = Solver(space_model,
time_model=time_model,
sources=source,
receivers=receiver,
wavelet=ricker,
saving_jump=1)
# run the forward
u, rec = solver.forward()
nbl
in the function setup
? and likewise half-width
?Hello.
The package is great but I have some difficulties to use it.
The example given on the readme.md generate a solution with only one snapshot. How do I increase the number of snapshots ?
I would like to create a video of the evolution of the wave.
Thanks.
Hi,
Is there some example to create animations from simwave simulations ?
It would be helpful to have a "generalized source" that instead of acting at a single coordinate, is a field depending on the coordinate position. so instead of s = f(t), the source would be s = f(t) * g(x).
I've tried creating one source for each grid point, but the code get's very slow.
The application would be to test the convergence for the variable density case.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.