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

Dipole grid for the ions #160

Merged
merged 48 commits into from
Dec 20, 2024
Merged

Conversation

abukowski21
Copy link
Collaborator

@abukowski21 abukowski21 commented Dec 18, 2024

Dipole grid for the ions

Don't see an issue for this... But this PR modifies/overhauls the dipole grid for the ions.

Within edu/example/dipole/ there is a Python file which will generate
plots from this new grid. It is helpful to experiment with that to see how
the grid is affected by different parameters

The methodology in that file is pretty outdated, but the locations are
OK. If requested, I can update that file to use the same methods to
what's being put into src/init_mag_grid.cpp.

Going to go through a little explanation here, since the code is complicated.

  • Inputs are min_alt, min_apex, LatMax, LatStretch, dAltStretch, and of course, the number of cells in each direction
    • min_alt defines the minimum altitude of the cell centers
    • min_apex is the altitude of the lowest field line. This controls the minimum latitude.
    • LatMax sets, roughly, the maximum latitude field lines are traced from. It's not exact because things are complicated.
      • When the user requests a single longitude dimension, field lines are traced from about halfway between LatMax and min_alt. I set the dLat to ~1 degree, same with longitude.
    • LatStretch is not currently used. So it can only be set to one, otherwise the code will complain and change it to 1. LatStretch=1 corresponds to linear spacing of base latitudes and eventually this will control the spacing of the base latitudes.
    • dAlt stretch controls how points are laid down along magnetic field lines. Values much less than one put more points at lower altitudes, and values closer to one put more points higher. I like the look of ~0.2.

I can document more and/or include some more plotting scripts that show what things are doing, if anyone wants.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change that fixes an issue) kinda: there's no issue for this, but it is an "issue"
  • Breaking change (fix or feature that would cause existing functionality
    to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • 1D, 2D, 3D, with a large number of possible resolutions.
    • They all work as expected
    • There are some configurations that put corners on the pole. This does not (yet) raise errors. But those points just don't exist
  • I checked orthogonality, expected locations, conversions to geographic.... everything I can think of.
    • They all work as I would expect now
    • That's why this took so long
    • Running on one core causes some weird things to happen, which I'll make issues for.

Test configuration

gcc 13.3.0 on WSL2 (Ubuntu) on a Windows machine. Ran on Linux too with gcc 13.2.0.

Checklist:

  • [N/A] Make sure you are merging into the develop (not master) branch
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • [N/A] Add a note to CHANGELOG.md, summarizing the changes

(It's not used yet)
4/3, not 3/3. taking (normalized) 2/3 step each time,
-> the ghost cells aren't in yet though.

changes to grid.cpp will support any variation of the dipole grid, from dipole to dipole6. Any number, really.
rearrange where inputs are checked too.
latitudes are backwards now???
it's weird to do it this way, but it works
and a comment describing what's going on.
- clean up comments & report statements (typos)
- lay down baselats in the same order as geo grid, make interpolation easier later!
- the order stuff was placed was weird.
- correct comments too
forgot to commit this earlier. Scale the exp_q_dist by nAlts, not nAlts/2

We can also switch to q_Start (and 0), instead of q_s and q_N
in an effort to try and figure out why its wrong...
…l vars

if a var within a function has the same name as a global & it changes the value, let's just be really clear it's only the **local** var that should be changed.
found a couple unused variables, and some that shared names w others
holy crap this was hard to find. Dipole looks (mostly) good now
> this is "bad github practice" but there were some changes that got forgotten in previous commits. whoops. it's all going to the same place anyways, as they say :)
This could break old input files, watch out!

Seems ok on my end though...
…n mag_grid

also move a couple functions around

Just cleanin' up the code a bit
holy crap this has been a week of hunting the smallest bugs and chasing down the most miniscule of errors

Dipole looks great now, for realz this time. Works in 1 & 3 dimensions

This commit makes baselats_down a global var, and changes how the corners are put in. There are no longer any zeros, nans, etc.

note, some configurations of the grid *can* result in nan's at the poles, but these are rare

- code beforte this commit would have the last field line shifted one q-step lower than it should be. this makes everything even & makes sure the centers and corners are lined up.
whoops. aether doesn't need this lol
@abukowski21
Copy link
Collaborator Author

Um just did a merge commit with the web editor. I hope it's right. If the checks pass, then this should be good to go!

@abukowski21 abukowski21 changed the title Promised it would be done today, and it is. Dipole grid for the ions Dec 20, 2024
@abukowski21 abukowski21 marked this pull request as ready for review December 20, 2024 01:04
@aaronjridley aaronjridley merged commit b429fe2 into AetherModel:develop Dec 20, 2024
3 checks passed
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.

2 participants