Closed zhangxiaoshuotttt closed 4 months ago
I will take a look a little bit later
Can you try Minput = model0.m.data[:]
. From the error log g::Vector, x:;Matrix
the vec
might not work properly
Yes, I just tested and @mloubout found the the source of the problem. But @zhangxiaoshuotttt you only need to set:
Minput = model0.m.data
That way it works
Hi @mloubout @kerim371 , I tried both of your advice but still have the same issue. By the way, I can get the gradient, but it seems like I can't get into the SPG process.
What version of JUDI and SlimOptim are you on?
Sorry, I forget about an important thing. The version is 3.3.8. By the way, to implement the PML condition, I use this version provided by Kerim. I use this version because the field data has a thin water layer(Only 80m). If I use version 3.3.10. Then, the simulated data has some waves reflected from boundaries.
Few comments
Since both @kerim371 and I can run SPG fine I would make sure that your versiobs are up to date so that we can help
I understand. I will try it immediately. Thank you very much.
As of shallow water, I've been running very shallow water (<30m) field data for a few month with 3.3.10 and with the opened field data PR and it works completely fine so not sure what issue you are facing.
Hi again,I have recently updated to JUDI 3.3.10 and have been running simulations with the updated code.
#### Parameters for model ######
n = (480, 300) # (x,y,z) or (x,z)
d = (5, 5)
o = (0., 0.)
seabed=80
seabedpoint=convert(Int64,seabed/d[1])
# Velocity [km/s]
v = ones(Float32,n) .+ 0.5f0
v0 = ones(Float32,n) .+ 0.5f0
v[:,seabedpoint:150] .= 2.2f0
v[:,150:end] .= 2.5f0
rho = (v0 .+ .5f0) ./ 2;
# Slowness squared [s^2/km^2]
m = (1f0 ./ v).^2
m0 = (1f0 ./ v0).^2
dm = vec(m0 - m)
# Setup model structure
model = Model(n, d, o, m)
model0 = Model(n, d, o, m0)
##############################
##############################
#### Parameters for Geometry ######
nxrec = 120
xrec = range(0f0, stop=(n[1]-1)*d[1], length=nxrec)
yrec = 0f0 # WE have to set the y coordiante to zero (or any number) for 2D modeling
zrec = range(80f0, step=0, length=nxrec)
# receiver sampling and recording time
timeD = 4000f0 # receiver recording time [ms]
dtD = 0.5f0 # receiver sampling interval [ms]
nsrc = 12
# Set up receiver structure
recGeometry = Geometry(xrec, yrec, zrec; dt=dtD, t=timeD, nsrc=nsrc)
xsrc = convertToCell(range(35f0, stop=(n[1]-5)*d[1], length=nsrc))
ysrc = convertToCell(range(0f0, stop=0f0, length=nsrc))
zsrc = convertToCell(range(20f0, step=0, length=nsrc))
# Set up source structure
srcGeometry = Geometry(xsrc, ysrc, zsrc; dt=dtD, t=timeD)
##############################
##############################
# setup wavelet
f0 = 0.01f0 # kHz
wavelet = ricker_wavelet(timeD, dtD, f0)
q = judiVector(srcGeometry, wavelet)
# Setup options
opt = Options(space_order=12,free_surface=true,limit_m=true,buffer_size = 20)
# Setup operators
Pr = judiProjection(recGeometry)
F = judiModeling(model; options=opt)
F0 = judiModeling(model0; options=opt)
Ps = judiProjection(srcGeometry)
J = judiJacobian(Pr*F0*adjoint(Ps), q)
dobs = Pr*F0*adjoint(Ps)*q
plot_sdata(dobs[6].data[1],(0.0005,10),cmap="RdBu",name="Water 80 with multiples",save=OutDir)
I have also been examining my simulated shot gather.
I have attempted to modify the buffer_size parameter from 0 to 3e3, but it appears to not be working well. Specifically, I have concerns about the effectiveness of the absorbing boundary. As a result, my shot gather is not as good as I would like it to be.
If the absorbing boundary works well, I may get the shot gather like this.
5m grid for a 10Hz wavelet is quite overkill the boundary layer is definitely gonna be short for such a setup, I would either augment my frequency, coarse the grid or add more boundary points to make sure there is enough wavelength in the 40 point boundary layer
I see. And I have tried it. It truly works. And it works. I forgot to et the nb
in the model. This was a careless mistake. Thank you for your patience and time.
Hi @mloubout @kerim371 , I have tried spg with new JUDI 3.3.10 with this new option, and I don't change other parameter, It still give me the same error. It's wired.
# JUDI options
global jopt = JUDI.Options(
IC = "fwi",
limit_m = true,
buffer_size = buffer_size,
optimal_checkpointing=false,
free_surface=true,
space_order=16)
Sorry I've been away from the devices.
The error mentionned above is most likely connected with the fact that some of the arguments are Vector
and other are Matrix
.
The first thing I would test is to check that all the variables (model, grad, Minput and other) have appropriate types (i.e. typeof
) and the size. Use reshape
when it is needed. Is your model0.m
is 1D array or it is 2D? Minput
1D or 2D?
I've tested your code and it was giving the error you mentionned in the beginning but then I've made changes that I said and the error disappeared.
Your JUDI.Options
seems to be fine.
My setup: devito: 4.8.2 JUDI: 3.9 SlimOptim: 0.2.3
Thank you for all of your advice @kerim371 @mloubout . I was able to identify the error - it was due to the type of my rho
, which was Float64
. To resolve the issue, I changed it to Float32
. Once this was done, the code worked perfectly. I appreciate your patience and the time you took to assist me. Thanks again!
Great, glad it got resolved. Could you open an issue so I don't forget there is a type mismatch that needs to be fixed.
Hello @mloubout @kerim371 ,
Please allow me to provide some details about the problems.
I am facing a strange issue while using SPG. Before using SPG, I attempted to use PGN and L-BFGS on my field data. As these methods worked fine, it seems that the field data is not the issue here.
However, when I tried to use SPG on field data, I encountered some errors. Before this, I tried the SPG on overthrust data, which worked well.
I have attached my scripts and the errors for your reference.
Here is the error![Screenshot from 2024-03-15 17-05-05](https://github.com/slimgroup/JUDI.jl/assets/84370046/9feaf310-8b9c-43f1-9ff6-db790aae4588)
After going through the error, I checked the original code and suspected that a particular line may be causing the issue.
I compared the model data output to the field data output and attempted to match their types, but the error persisted.![微信图片编辑_20240315171241](https://github.com/slimgroup/JUDI.jl/assets/84370046/8c7df8fe-e0ee-4b93-8731-4284078dde7e)