groupeLIAMG / ttcr

Codes to do raytracing for geophysical applications
GNU General Public License v3.0
85 stars 34 forks source link

bad allocation #61

Closed cumttc closed 1 year ago

cumttc commented 1 year ago

Dear author,

I encountered an error and crash when using cell_slowness in RayInvr grid computation. My grid settings are as follows: ######## python

grid setting

XGridlength=500 YGridlength=700 ZGridlength=10 x = np.arange(0.00, 5000.00+XGridlength,XGridlength) y = np.arange(0.00, 7000.00+YGridlength,YGridlength) z = np.arange(50.00, 850.00+ZGridlength,ZGridlength)

method setting

cpu_threads = multiprocessing.cpu_count() grid=rg.Grid3d(x,y,z,cell_slowness=True,method='SPM',n_threads=cpu_threads) grid.set_slowness(1.0/V) tt, rays = grid.raytrace(src, rcv, return_rays=True) ######## The velocity model V has the same shape (10,10,80) as the grid. But this crash only happens when using cell_slowness. Node slowness works fine under the same condition.

I have tried checking the validity of V, reducing grid size, using single thread, but the problem remains. Please advise what could be the potential causes and how I can fix this. Any suggestions would be greatly appreciated.

Let me know if any other details are needed to reproduce the problem. Thanks for the great library!

Best regards,

bernard-giroux commented 1 year ago

Make sure that when using cell_slowness, you V array has a size equal to the number of cells, not the number of nodes.

cumttc commented 1 year ago

Hello, I would like to know what are the conditions for the error "bad allocation"? I often encounter this error when using "cell_slowness=True". You told me before that the V.size should be the same as the grid number, I have noticed this and I check it often. The problem I'm having now is that the grid can be created normally with "cell_slowness=True" and when solving "tt, rays = grid.raytrace(src, rcv, return_rays=True) "bad allocation" when solving "tt, rays = grid.raytrace(src, rcv, return_rays=True)".

cumttc commented 1 year ago

xshape = grid.shape[0] yshape = grid.shape[1] zshape = grid.shape[2] V= np.empty(zshape) ....... V=np.tile(V,xshape*yshape) slowness=1/V

cumttc commented 1 year ago

tt, rays = grid.raytrace(src, rcv, return_rays=True) After my testing, this error is reported when return_rays=True, while it is not reported when only counting walks and not paths

bernard-giroux commented 1 year ago

Please look at methods get_number_of_cells and get_number_of_nodes, and make sure you understand the difference. You should also have a look at https://ttcrpy.readthedocs.io/en/latest/model_discretization.html#assigning-velocity-slowness