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

Problems with magnetostatic solver test input file #5444

Open
clarkse opened this issue Nov 7, 2024 Discussed in #5425 · 3 comments · May be fixed by #5476
Open

Problems with magnetostatic solver test input file #5444

clarkse opened this issue Nov 7, 2024 Discussed in #5425 · 3 comments · May be fixed by #5476
Assignees
Labels
bug: affects latest release Bug also exists in latest release version bug Something isn't working component: boundary PML, embedded boundaries, et al. component: magnetostatic magneticstatic solver

Comments

@clarkse
Copy link
Member

clarkse commented Nov 7, 2024

Discussed in #5425

Originally posted by BCatGA October 29, 2024
Hi,

I would like to use the "warpx_magnetostatic=True" option for the Electrostatic solver so I have been running the WarpX Test input file "inputs_test_rz_magnetostatic_eb_picmi.py" to figure out how it works. In this RZ simulation, there is an electron beam of radius 0.1 m going down a pipe (embedded boundary) of radius 0.2 m. The domain is rmax=0.25 m X zmax=1 m, and there are 128 cells in the both the radial and axial directions. The input file is setup to run the simulation for only 1 time step, so it can calculate the electric and magnetic fields.

When I run the input file with Python the simulation converges. But I found that convergence is very sensitive to changes in the pipe radius (say, from 0.2 to 0.21 m) when "warpx_magnetostatic=True", but not when "warpx_magnetostatic=False". I figured out that this sensitivity goes away when I make the cells square (reducing nr to 32 for rmax = 0.25). In that case, I can put the pipe radius right on the domain boundary and the simulation will converge, as long as I make the boundary conditions at rmax the same as the pipe boundary condition (dirichlet,1V).

But that begs the question, why do I need the pipe as an embedded boundary? Why not just remove it and treat the outer boundary as the pipe by setting dirichlet boundary conditions with a constant voltage? However, when I do that, the multigrid solver converges but I get multiple segmentation faults and the simulation crashes. And again, if I set "warpx_magnetostatic=False" everything runs fine.

So, my questions are:

  1. Why is the convergence of the multi-grid solver so sensitive to the pipe radius when the cells aren't square?
  2. Why does the simulation generate segmentation faults if the pipe/embedded boundary is removed?
  3. Why do these problems occur when warpx_magnetostatic is True but not when it is False?

Thanks for your help,
Brian

I have reproduced this problem and am converting it to an issue.

@clarkse clarkse added bug Something isn't working bug: affects latest release Bug also exists in latest release version component: boundary PML, embedded boundaries, et al. component: magnetostatic magneticstatic solver labels Nov 7, 2024
@clarkse clarkse self-assigned this Nov 7, 2024
roelof-groenewald pushed a commit that referenced this issue Nov 11, 2024
#5446)

…ch is currently hard coded, and adding assert to force EB being enabled
in order to avoid a seg fault in AMReX when computing the gradient
solution.

This PR partially addresses
#5444. This PR adds
semi-coarsening in 3D and then adds an assert to keep the magnetostatic
solver from being run without an EB. This is required since in AMReX
MLMG->getGradSolution will segfault when not using an EB.

It should also be noted that
#5175 will use a different scheme
around the embedded boundaries to compute gradients, and will likely
mitigate these issues.

A work around in RZ to use the outer edge is to enable the embedded
boundary and set the boundary radius larger than the outer grid radius.
This works like it would without an embedded boundary and can be used
until either the refactor or the bugfix in AMReX for getGradSolution.

---------

Signed-off-by: S. Eric Clark <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@RemiLehe RemiLehe reopened this Nov 13, 2024
@RemiLehe
Copy link
Member

@clarkse
From offline discussions with @roelof-groenewald @WeiqunZhang, it seems that AMReX-Codes/amrex#4226 fixes the fact that the magnetostatic solver did not work when EB where not defined. Would it make sense to revert this part of your PR:
https://github.com/ECP-WarpX/WarpX/pull/5446/files#diff-8b02ba33dc4d7b58f462f3cb54b564e1532fc0f9aacf952e07562d57a36fcd11R71

@clarkse
Copy link
Member Author

clarkse commented Nov 19, 2024

@clarkse From offline discussions with @roelof-groenewald @WeiqunZhang, it seems that AMReX-Codes/amrex#4226 fixes the fact that the magnetostatic solver did not work when EB where not defined. Would it make sense to revert this part of your PR: https://github.com/ECP-WarpX/WarpX/pull/5446/files#diff-8b02ba33dc4d7b58f462f3cb54b564e1532fc0f9aacf952e07562d57a36fcd11R71

I will remove the assert and submit a new PR today.

@clarkse clarkse linked a pull request Nov 20, 2024 that will close this issue
@clarkse
Copy link
Member Author

clarkse commented Nov 20, 2024

@RemiLehe I have removed the offending asserts in #5476

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: affects latest release Bug also exists in latest release version bug Something isn't working component: boundary PML, embedded boundaries, et al. component: magnetostatic magneticstatic solver
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants