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

B=0 field output in magnetostatic mode #5242

Open
jwestern opened this issue Sep 10, 2024 · 8 comments · May be fixed by #5289
Open

B=0 field output in magnetostatic mode #5242

jwestern opened this issue Sep 10, 2024 · 8 comments · May be fixed by #5289
Assignees
Labels
component: magnetostatic magneticstatic solver question Further information is requested

Comments

@jwestern
Copy link
Contributor

jwestern commented Sep 10, 2024

I get zero magnetic field in the field output running with the magnetostatic solver on.

I'm running in electromagnetostatic mode via PICMI. I setup the solver like this:

solver = picmi.ElectrostaticSolver(
    grid=grid,
    method='Multigrid',
    required_precision=1e-6,
    warpx_self_fields_verbosity = 0,
    warpx_magnetostatic=True,
)

And I install the field diagnostic like this:

field_diag = picmi.FieldDiagnostic(write_dir = f'./diags/{diagdire}',
                                       warpx_file_prefix = 'field',
                                       grid = grid,
                                       period=100,
                                       warpx_openpmd_backend='h5',
                                       warpx_format='openpmd',
                                       data_list=['B', 'E', 'J', 'rho'])
    sim.add_diagnostic(field_diag)

This happens with both GPU and CPU runs.

Does anyone know what's going on? Let me know if other details are needed, such as the creation of grid or sim.

@ax3l ax3l added question Further information is requested component: magnetostatic magneticstatic solver labels Sep 16, 2024
@roelof-groenewald
Copy link
Member

Hi @jwestern. That is strange. Could you please provide a bit more information about the simulation:

  • what geometry do you use (1d, 1d, 3d, rz)?
  • are you seeing zero values for all B-field components?
  • do you get non-zero current values?
  • do you get non-zero E-field values?

@clarkse
Copy link
Member

clarkse commented Sep 17, 2024

@jwestern could you share an input deck or reproducer so we can take a look at it? Can you share what sort of current source you have? Particle injection?

@jwestern
Copy link
Contributor Author

jwestern commented Sep 17, 2024

  • what geometry do you use (1d, 1d, 3d, rz)? 3D
  • are you seeing zero values for all B-field components? Yes
  • do you get non-zero current values? Yes
  • do you get non-zero E-field values? Yes

@clarkse I'll work on a reproducer. The issue arises either with particles initialized at t=0 or with injection over time.

The runtime is slower with magnetostatic mode on, suggesting there is extra work being done. But the field diagnostic output gives B=0.

@jwestern
Copy link
Contributor Author

jwestern commented Sep 17, 2024

@clarkse @roelof-groenewald Here's a reproducer PICMI .py file (I had to rename is .txt in order to attach):

zeroB_reproducer.txt

@clarkse
Copy link
Member

clarkse commented Sep 18, 2024

@clarkse @roelof-groenewald Here's a reproducer PICMI .py file (I had to rename is .txt in order to attach):

zeroB_reproducer.txt

@jwestern Thank you for sending this over. There appears to be an issue with how the B field is calculated from A when not using an embedded boundary. As a work around you can compile with EB support. There is an example in Examples/Tests/magnetostatic_eb that still passes CI. You can probably adapt it to have a box EB for now. I will look at fixing the bug soon so you don't need to use an embedded boundary.

@jwestern
Copy link
Contributor Author

@clarkse great, thank you! I'll wait for the bug fix, because compiling with EB support reduces the reliability of the Poisson solve to a level where I cannot use it.

@roelof-groenewald
Copy link
Member

Thanks for tracking down the issue @jwestern and @clarkse.

@jwestern there's a WIP PR that actually fixes this bug (see #5175) but I won't have time in the next few weeks to finish up that PR. If you wanted to you could take a look at how the issue is fixed in that PR and maybe cherry-pick those parts to create an intermediate PR focused on just fixing this bug (without all the other refactoring done in the WIP PR).

@clarkse
Copy link
Member

clarkse commented Sep 18, 2024

@jwestern I think this PR should fix your problem.
#5289

You can try to pull it and run your case. There was a bug how the functor for computing B from A was being constructed and the centering coefficients used were uninitialized when not using momentum-conserving field gathering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: magnetostatic magneticstatic solver question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants