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

Divergence-free reconstruction of B field #141

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

lkotipal
Copy link
Contributor

@lkotipal lkotipal commented Feb 4, 2021

Implements reconstruction and interpolation of magnetic field from face-average values in Analysator. Based on Balsara's paper.

Not thoroughly tested or ready to merge yet.

@markusbattarbee
Copy link
Contributor

Suggested improvements:

  • wrapper to calculate the reconstructed cell-centre values for a) single celll b) list of cellids c) whole mesh
  • Where possible, try to use numpy array operations instead of loops - e.g. doing three nested loops for a single cell and then putting that within three nested loops for three spatial dimensions is going to be really slow

Copy link
Contributor

@ykempf ykempf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lkotipal could you post some metric or figure to "convince" us that this works?

More generally, how do we want to verify this, is someone taking the paper in one hand and this script in the other, do we trust a comparison to e.g. Bvol, other ideas?

scripts/divergenceless_reconstruction.py Outdated Show resolved Hide resolved
scripts/divergenceless_reconstruction.py Outdated Show resolved Hide resolved
import numpy as np
from scipy.special import legendre
from time import perf_counter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding a comment near the top to shortly explain what this does including the paper's reference, so that someone looking at this code knows where it comes from.

@lkotipal
Copy link
Contributor Author

I've only managed to do simple tests so far to check that the field is in the right ballpark. I suppose the best metric would be to integrate the field over the cell to check that the volumetric average matches?

@ykempf
Copy link
Contributor

ykempf commented Feb 25, 2021

Sure, you can do that. You could check that it converges if you take 1 centre value, the corners, 3³, 4³ etc. Sounds like a good idea, but probably not worth the hassle of doing a more proper integration scheme just for this test.

@alhom
Copy link
Contributor

alhom commented Jun 20, 2023

This will require an interface to chunk production-size FSGrid variables at least when calculating abc, otherwise there will be OOMs.

@ykempf
Copy link
Contributor

ykempf commented Jun 20, 2023

How general should that be? We're bound to hit OOM elsewhere in future fsgrid data processing I'm pretty sure. And/or do you already have sth up your sleeve?

@alhom
Copy link
Contributor

alhom commented Jun 20, 2023

I have a dumb decomposition that has ugly boundary effects.. and this is a case where neighbor information is also used, so this case even needs a bit of a halo. Numpy.split also only does 1D split for now.. manual 3D numpy views to be used here?

from time import perf_counter
# Code for testing divergenceless_resconstruction.py

f = pt.vlsvfile.VlsvReader('/wrk/users/lkotipal/TEST/bulk.0000057.vlsv')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this is now outdated, of course

Copy link
Contributor Author

@lkotipal lkotipal Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uses argv[1] now

@markusbattarbee
Copy link
Contributor

@lkotipal wanna implement the requested changes and deprecated directory stuff here? Perhaps we could even get this merged at some point.

@alhom
Copy link
Contributor

alhom commented Aug 5, 2024

I suggest moving the reconstruction part to pyCalculations, keeping the test script under scripts (or should it be under examples?)

Have you Leo done a diff wrt. fg_b_vol values with the test now?

@lkotipal lkotipal marked this pull request as draft August 7, 2024 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants