NDF-Poli-USP / spyro

Wave propagators for seismic domains with application to full waveform inversion.
GNU General Public License v3.0
34 stars 15 forks source link

shot_record pdfs when running marmousi model #115

Open acse-yw11823 opened 4 days ago

acse-yw11823 commented 4 days ago

Hello, I was successfully running the script located in the /paper folder named run_fwi_2d.py. However, I noticed that the output files in the shots folder are identical. For instance, shot_number_1.pdf is exactly the same as shot_number_30.pdf.

I am using MacOS and executing the script in the terminal with the command python run_fwi_2d.py. Does anyone know why this might be happening? I would really appreciate any insight.

The code is the following:

import os
os.environ["OMP_NUM_THREADS"] = "1"

from firedrake import File
import spyro

model = {}

model["opts"] = {
    "method": "KMV",  # either CG or KMV
    "quadrature": "KMV",  # Equi or KMV
    "degree": 5,  # p order
    "dimension": 2,  # dimension
}
model["parallelism"] = {
    "type": "automatic",
}
model["mesh"] = {
    "Lz": 3.5,  # depth in km - always positive
    "Lx": 17.0,  # width in km - always positive
    "Ly": 0.0,  # thickness in km - always positive
    "meshfile": "meshes/marmousi_exact.msh",
    "initmodel": "not_used.hdf5",
    "truemodel": "velocity_models/marmousi_exact.hdf5",
}
model["BCs"] = {
    "status": True,  # True or false
    "outer_bc": "non-reflective",  # None or non-reflective (outer boundary condition)
    "damping_type": "polynomial",  # polynomial, hyperbolic, shifted_hyperbolic
    "exponent": 2,  # damping layer has a exponent variation
    "cmax": 4.5,  # maximum acoustic wave velocity in PML - km/s
    "R": 1e-6,  # theoretical reflection coefficient
    "lz": 0.9,  # thickness of the PML in the z-direction (km) - always positive
    "lx": 0.9,  # thickness of the PML in the x-direction (km) - always positive
    "ly": 0.0,  # thickness of the PML in the y-direction (km) - always positive
}
model["acquisition"] = {
    "source_type": "Ricker",
    "num_sources": 40,
    "source_pos": spyro.create_transect((-0.01, 1.0), (-0.01, 15.0), 40),
    "frequency": 5.0,
    "delay": 1.0,
    "num_receivers": 500,
    "receiver_locations": spyro.create_transect((-0.10, 0.1), (-0.10, 17.0), 500),
}
model["timeaxis"] = {
    "t0": 0.0,  # Initial time for event
    "tf": 5.00,  # Final time for event
    "dt": 0.00025,
    "amplitude": 1,  # the Ricker has an amplitude of 1.
    "nspool": 100,  # how frequently to output solution to pvds
    "fspool": 99999,  # how frequently to save solution to RAM
}
comm = spyro.utils.mpi_init(model)
mesh, V = spyro.io.read_mesh(model, comm)
vp = spyro.io.interpolate(model, mesh, V, guess=False)
if comm.ensemble_comm.rank == 0:
    File("true_velocity.pvd", comm=comm.comm).write(vp)
sources = spyro.Sources(model, mesh, V, comm)
receivers = spyro.Receivers(model, mesh, V, comm)
wavelet = spyro.full_ricker_wavelet(
    dt=model["timeaxis"]["dt"],
    tf=model["timeaxis"]["tf"],
    freq=model["acquisition"]["frequency"],
)
p, p_r = spyro.solvers.forward(model, mesh, comm, vp, sources, wavelet, receivers)
spyro.plots.plot_shots(model, comm, p_r, vmin=-1e-3, vmax=1e-3)
spyro.io.save_shots(model, comm, p_r)

The shot_number_31.pdf is like the following:

Screenshot 2024-07-01 at 16 21 03

The shot_number_3.pdf is like the following:

Screenshot 2024-07-01 at 16 22 17
Olender commented 1 day ago

Can you experiment changing vmin=-1e-3, vmax=1e-3 values? Look at the max and minimum value of p_r and set it for the pdf.

acse-yw11823 commented 1 day ago

Thanks for reply! I will try now!

Sent from Outlook for iOShttps://aka.ms/o0ukef


From: Alexandre Olender @.> Sent: Wednesday, July 3, 2024 10:16:03 PM To: NDF-Poli-USP/spyro @.> Cc: Wu, Yifan @.>; Author @.> Subject: Re: [NDF-Poli-USP/spyro] shot_record pdfs when running marmousi model (Issue #115)

This email from @.*** originates from outside Imperial. Do not click on links and attachments unless you recognise the sender. If you trust the sender, add them to your safe senders listhttps://spam.ic.ac.uk/SpamConsole/Senders.aspx to disable email stamping for this address.

Can you experiment changing vmin=-1e-3, vmax=1e-3 values? Look at the max and minimum value of p_r and set it for the pdf.

— Reply to this email directly, view it on GitHubhttps://github.com/NDF-Poli-USP/spyro/issues/115#issuecomment-2207314658, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BDENNF4ROWHX5C6H5I7N4H3ZKRSZHAVCNFSM6AAAAABKFZ675KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBXGMYTINRVHA. You are receiving this because you authored the thread.Message ID: @.***>

acse-yw11823 commented 1 day ago

Hello, I have implemented the method you suggested, adjusting the vmin and vmax parameters. However, I have not observed any significant changes in the visualization of the shot record. Additionally, I found that the data in shot_record_1.dat is identical to that in shot_record_11.dat. Could this issue be related to using serial execution instead of parallel?

Furthermore, there is no difference in the results even when I specify different source_num values in the forward function. For instance, both of the following calls yield the same results:

p, p_r_10 = spyro.solvers.forward(model, mesh, comm, vp, sources, wavelet, receivers, source_num = 10)

and thefollowing will give the same result

p, p_r_1 = spyro.solvers.forward(model, mesh, comm, vp, sources, wavelet, receivers, source_num = 1)

Do you have any idea about this result? Many thanks for your time!!

Olender commented 1 day ago

Could this issue be related to using serial execution instead of parallel?

Yes, currently we support using a number of cores that is a multiple of the number of sources (e.g., with 4 sources, you can use 4, 8, 16, 32, and so on). Each source is essentially a separate forward problem that utilizes spatial parallelism internally. We are also working on an enhancement (issue #105) to add the capability of running multiple shots in serial.

acse-yw11823 commented 1 day ago

[like] Wu, Yifan reacted to your message:


From: Alexandre Olender @.> Sent: Thursday, July 4, 2024 2:08:16 PM To: NDF-Poli-USP/spyro @.> Cc: Wu, Yifan @.>; Author @.> Subject: Re: [NDF-Poli-USP/spyro] shot_record pdfs when running marmousi model (Issue #115)

This email from @.*** originates from outside Imperial. Do not click on links and attachments unless you recognise the sender. If you trust the sender, add them to your safe senders listhttps://spam.ic.ac.uk/SpamConsole/Senders.aspx to disable email stamping for this address.

Could this issue be related to using serial execution instead of parallel?

Yes, currently we support using a number of cores that is a multiple of the number of sources (e.g., with 4 sources, you can use 4, 8, 16, 32, and so on). Each source is essentially a separate forward problem that utilizes spatial parallelism internally. We are also working on an enhancement (issue #105https://github.com/NDF-Poli-USP/spyro/issues/105) to add the capability of running multiple shots in serial.

— Reply to this email directly, view it on GitHubhttps://github.com/NDF-Poli-USP/spyro/issues/115#issuecomment-2209091011, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BDENNFZC2XF3IMQDNPBEGCDZKVJNBAVCNFSM6AAAAABKFZ675KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBZGA4TCMBRGE. You are receiving this because you authored the thread.Message ID: @.***>