Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault when using the ExternalField block in 3D #668

Closed
mlyto opened this issue Nov 17, 2023 · 21 comments
Closed

Segmentation fault when using the ExternalField block in 3D #668

mlyto opened this issue Nov 17, 2023 · 21 comments
Labels

Comments

@mlyto
Copy link

mlyto commented Nov 17, 2023

Dear developers,

I'm running tests with the ExternalField block for various field configurations.
While this works well in 1D, I experienced a segmentation fault in 3D tests. For example, when I use analytical solutions for a 3D Gaussian beam to set the laser in this way. The same field solution installed at the boundary of the simulation box works correctly.

This is what I see in the slurm file

Initial fields setup

     Applying external fields at time t = 0

[nia1230:54934:0:54934] Caught signal 11 (Segmentation fault: address not mapped to object at address 0x231)
[nia1230:54960:0:54960] Caught signal 11 (Segmentation fault: address not mapped to object at address 0xa1)
[nia0151:253841:0:253841] Caught signal 11 (Segmentation fault: address not mapped to object at address 0x241)
[nia0151:253826:0:253826] Caught signal 11 (Segmentation fault: address not mapped to object at address 0xa1)
[nia0151:253844:0:253844] Caught signal 11 (Segmentation fault: address not mapped to object at address 0x231)
[nia1230:54954:0:54954] Caught signal 11 (Segmentation fault: address not mapped to object at address 0x231)
[nia0151:253840:0:253840] Caught signal 11 (Segmentation fault: address not mapped to object at address 0x231)
[nia1230:54961:0:54961] Caught signal 11 (Segmentation fault: address not mapped to object at address 0x31)

@mlyto mlyto added the bug label Nov 17, 2023
@beck-llr
Copy link
Contributor

Hi
Did you make sure your simulation starts if you comment the ExternalField block ?

@mlyto
Copy link
Author

mlyto commented Nov 17, 2023

Hi,
Yes, if I comment the ExternalField block, the simulation starts and I see in the slurm file

Initial fields setup

     Applying external fields at time t = 0
     Applying prescribed fields at time t = 0
     Applying antennas at time t = 0

@beck-llr
Copy link
Contributor

Ok, can you share how you define your external fields please ?

@mlyto
Copy link
Author

mlyto commented Nov 17, 2023

I use different configurations, here is the simplest one - just with the 3D paraxial Gaussian beam in vacuum. I'm not sure if I also need to set profiles for components equal to 0, but after many crashed I also added these functions (didn't help)


def myExternal_Ex(x,y,z):
    efield_x = myEx(c_double((- t0) * T_r), c_double((x - Lsim[0]/2.) * L_r), c_double((y - Lsim[1]/2.) * L_r), c_double((z - Lsim[2]/2.) * L_r),
                    c_double(lambda0), c_double(w0), c_double(fwhm * T_r))
    return efield_x * E0 / E_r

def myExternal_Ey(x,y,z):
    return 0

def myExternal_Ez(x,y,z):
    return 0

def myExternal_Bx(x,y,z):
    return 0

def myExternal_By(x,y,z):
    bfield_y = myBy(c_double((0.5*dt - t0) * T_r), c_double((x - Lsim[0]/2.) * L_r), c_double((y - Lsim[1]/2.) * L_r), c_double((z - Lsim[2]/2.) * L_r),
                    c_double(lambda0), c_double(w0), c_double(fwhm * T_r))
    return bfield_y * B0 / B_r

def myExternal_Bz(x,y,z):
    return 0

ExternalField(
    field = "Ex",
    profile = myExternal_Ex
)

ExternalField(
    field = "Ey",
    profile = myExternal_Ey
)

ExternalField(
    field = "Ez",
    profile = myExternal_Ez
)

ExternalField(
    field = "Bx",
    profile = myExternal_Bx
)

ExternalField(
    field = "By",
    profile = myExternal_By
)

ExternalField(
    field = "Bz",
    profile = myExternal_Bz
)

P.S: edited by beck-llr just to make the code a bit more readable.

@beck-llr
Copy link
Contributor

You don't have to set other components to 0.

Can you reproduce the issue if you set efield_x=0 and bfield_y=0 instead of myEx and myBy which are not defined in the piece of code you shared ?

@mlyto
Copy link
Author

mlyto commented Nov 17, 2023

Yes, I just tried it - it crashes even with efield_x=0 and bfield_y=0

@beck-llr
Copy link
Contributor

Ok that looks bad indeed :-)
Thanks for reporting we'll try to have a look asap.
Are you using the latest version of the code ? If not try it out. If yes, try to roll back to 4.8 if you're in a hurry.

@mlyto
Copy link
Author

mlyto commented Nov 17, 2023

I run my codes on a supercomputer. This version I uploaded a year ago.

@mlyto
Copy link
Author

mlyto commented Nov 17, 2023

Update: In version 5.0 I have the same problem with the ExternalField block (previous version was 4.7)
Also, now when I run the job, there is an info.shelf file in the directory. This was not the case in the previous version, what is this file for?

@mccoys
Copy link
Contributor

mccoys commented Nov 18, 2023

Please try to use external fields on a smaller case. This is too check whether it is a memory issue.

The new file serves as a storage for simulation information. Happi uses it to obtain information about the configuration

@mlyto
Copy link
Author

mlyto commented Nov 18, 2023

It works in 1D. What do you mean by "smaller case"? Smaller simulation box size? This one isn't big 24x24x32 (in lambda)

If possible, one more question wrt info.shelf file. Does it mean that updated happi doesn't work with the old simulation results since it requires info.shelf?

@mccoys
Copy link
Contributor

mccoys commented Nov 18, 2023

By smaller case i mean something occupying les memory. Like less particles or lower resolution.

The new happi falls back to the previous approach if it can't find the file

@mlyto
Copy link
Author

mlyto commented Nov 19, 2023

Thank you for your explanation about happi.

As to ExternalField block, the test case I reported was related to vacuum, so no particles at all, and the number of cells 384x384x512, which is pretty low wrt my simulation for plasma with Laser or Prescribed field blocks.

@mccoys
Copy link
Contributor

mccoys commented Nov 19, 2023

Can you provide a case that crashes?

@mlyto
Copy link
Author

mlyto commented Nov 19, 2023

vac_ext_zeros.txt
It's a Python file, I just can't attach it as a .py

If I comment all ExternalField blocks it works (with all zero results), however if all block are uncommented I get
Caught signal 11 (Segmentation fault: address not mapped to object at address 0x361) ...

@beck-llr
Copy link
Contributor

Thanks for sharing. I was able to reproduce your problem. There seems to be something off with the E fields (it works for the B fields). We'll look into it and let you know asap.

@mlyto
Copy link
Author

mlyto commented Nov 20, 2023

Thank you.

@beck-llr
Copy link
Contributor

I've pushed a fix in our local repository. We'll try to make it available to you tomorrow. Thanks again for reporting and doing all the tests !

@mlyto
Copy link
Author

mlyto commented Nov 20, 2023

Thank you again!

@beck-llr
Copy link
Contributor

The last commit should fix your issue. Please confirm and close the issue if it does.

@mlyto
Copy link
Author

mlyto commented Nov 21, 2023

Thank you for fixing this issue. Now it works.

@mlyto mlyto closed this as completed Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants