AmirMardan / PyFWI

This repository is for PyFWI, a Python package for seismic FWI and reservoir monitoring (time-lapse FWI)
https://pyfwi.readthedocs.io/en/latest/
GNU General Public License v3.0
60 stars 12 forks source link

Example: Mostly NaN values in d_obs #14

Closed m-weigand closed 4 months ago

m-weigand commented 4 months ago

Hi, thank you very much for freely publishing your code! I would like to assess pyFWI for use in teaching. Unfortunately, I was not able to run any of the provided examples and am wondering if you can provide any hints on how to debug the issue?

I'm running a Debian Linux (bookworm) system with cpu-only opencl-bindings (I modified wave_propagation.py accordingly to prevent errors similar to the other reported issues).

pyopencl is at version 2024.1.5 and reports a opencl version of 3.0:

In [5]: cl.get_cl_header_version()
Out[5]: (3, 0)

In [6]: cl.VERSION
Out[6]: (2024, 2, 6)

Printing d_obs right after running the (unmodified) example fwi_example_surface.ipynb yields:

W.nt before calling forward modelling 1050
{'taux': array([[ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,
         0.0000000e+00,  0.0000000e+00,  0.0000000e+00],
       [ 1.3551305e-08, -2.4419445e-05, -7.3146715e-05, ...,
        -9.8132311e-09, -3.7813452e-10,  6.5853427e-11],
       [           nan,            nan,            nan, ...,
                   nan,            nan,            nan],
       ...,
       [           nan,            nan,            nan, ...,
                   nan,            nan,            nan],
       [           nan,            nan,            nan, ...,
                   nan,            nan,            nan],
       [           nan,            nan,            nan, ...,
                   nan,            nan,            nan]], dtype=float32), 'tauz': array([[ 0.0000000e+00,  0.0000000e+00,  0.0000000e+00, ...,
         0.0000000e+00,  0.0000000e+00,  0.0000000e+00],
       [ 1.3551305e-08, -2.4419445e-05, -7.3146715e-05, ...,
        -9.8132311e-09, -3.7813452e-10,  6.5853427e-11],
       [           nan,            nan,            nan, ...,
                   nan,            nan,            nan],
       ...,
       [           nan,            nan,            nan, ...,
                   nan,            nan,            nan],
       [           nan,            nan,            nan, ...,
                   nan,            nan,            nan],
       [           nan,            nan,            nan, ...,
                   nan,            nan,            nan]], dtype=float32)}

I suppose this is an issue of my system, but I am a little bit at loss how to debug this. Any help would be greatly appreciated! Thanks

AmirMardan commented 4 months ago

Hi, I believe this happens because the used frequency, temporal sampling rate (dt), and spatial sampling rate (dh) do not respect CFL criteria. I assume if you visualize the wave propagation W.forward_modeling(model, show=True) you will see that the wave propagates initially and after a few steps, the kernel generates only nan. So, I suggest working on these three parameters, dh, dt, fdom.

m-weigand commented 4 months ago

I'm sorry for not getting back to you. To be honest, I first need to do some more reading before I can get back to this. I tried systematically varying dh, dt, fdom, but got no usable results. Thanks again for your time!

Lujiang-ECUST commented 4 days ago

Hi, I believe this happens because the used frequency, temporal sampling rate (dt), and spatial sampling rate (dh) do not respect CFL criteria. I assume if you visualize the wave propagation W.forward_modeling(model, show=True) you will see that the wave propagates initially and after a few steps, the kernel generates only nan. So, I suggest working on these three parameters, dh, dt, fdom.

HI,thank you very much for freely publishing your code! I want to apply Pyfwi to the ultrasonic frequency band, when I set the time sampling rate(dt), spatial sampling rate (dh), and frequency fdom inside the inpa as the following parameters, inpa = {

'ns':1,  # Number of sources
'sdo': 4,  # Order of FD
'fdom': 5e6,  # Central frequency of source
'dh':114e-6,  # Spatial sampling rate
'dt': 1e-8,  # Temporal sampling rate
'acq_type': 1,  # Type of acquisition (0: crosswell, 1: surface, 2: both)
't': 3.4e-6,  # Length of operation
'npml': 40,  # Number of PML
'pmlR': 1e-5,  # Coefficient for PML (No need to change)
'pml_dir': 2,  # type of boundary layer
'device': 1, # The device to run the program. Usually 0: CPU 1: GPU
# 'seimogram_shape': '3d',
'rec_dis':1,
# 'tv':{'lambda_weight':0.2, 'ax':0.2, 'az':0.2, }
# prior_model'
'fn':5E6*20

}

the maximum speed of the velocity model I used is 6300m/s, and the minimum speed is 5800m/s. After my theoretical calculations, I am sure that this set of parameter satisfies the CFL condition as well as the stability condition for staggered finite difference convergence, but it never works correctly. I would be grateful if you could provide me with the correct set of inpa parameters for this model and frequency.