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

Gravity for elliptical loops #147

Open
jwreep opened this issue Jun 11, 2021 · 4 comments
Open

Gravity for elliptical loops #147

jwreep opened this issue Jun 11, 2021 · 4 comments

Comments

@jwreep
Copy link
Member

jwreep commented Jun 11, 2021

I'd like to incorporate a function to create the gravity function for elliptical loops. I've written a function for the current paper to take in loop length, and a relative x and y (semi-major and semi-minor axis):

def calc_ellipse_gravity(loop_length: u.cm, x, y):

For example, if the semi-major axis is vertical, with a height twice as large as width, x=1, and y=2.

@wtbarnes, what do you think about that format? Is there already a function for writing out the initial.amr.gravity file?

A more general possibility would be to allow the semi-major axis to be at any angle, rather than just 0 or 90 degrees . . . I'd have to think about how to implement that.

@wtbarnes
Copy link
Member

So I think the best way to proceed here would be to have functions for generating particular loop geometries and then have a single function that calculates field-aligned gravity for any geometry, e.g. https://github.com/wtbarnes/synthesizAR/blob/69256ce3ffe12a6347df102187e49713594eb627/synthesizAR/loop.py#L169-L182

Then, we could just have a function that generates the geometry for an elliptical loop. As an example for what this could look like, here's my code for generating semi-circular loop coordinates: https://github.com/wtbarnes/synthesizAR/blob/69256ce3ffe12a6347df102187e49713594eb627/synthesizAR/models/geometry.py#L13-L69

This all could actually be really useful outside of just the context of HYDRAD too...

Is there already a function for writing out the initial.amr.gravity file?

I don't think we need to write the initial.amr.gravity file. In pydrad, the input looks like,

config['general']['poly_fit_gravity'] = {
        'order': 6,  # order of the fit
        'domains': [0, 1],  # domain edges
        'x': s,  # field-aligned coordinate from 0 to L
        'y': g,  # field-aligned gravity as a function of s
} 

specifying this dictionary will write out a file ''poly_fit.gravity' which HYDRAD will then pick up and use to write the initial.amr.gravity file. All of this also applies to the magnetic field: just replace "gravity" with "magnetic_field" and 'y' is B as a function of s.

@sjbradshaw
Copy link

sjbradshaw commented Jun 16, 2021 via email

@wtbarnes
Copy link
Member

wtbarnes commented Jun 16, 2021

Another approach would be to use the new piece-wise polynomial fitting class that I wrote a little while back. You can calculate gravity for whatever loop geometry you choose and then do a piece-wise fit, with each set of polynomial coefficients stored in the .gravity file, which HYDRAD then uses. This is the approach that would be used to calculate gravity (and magnetic field strength) for an extrapolated magnetic field, for example.

I believe this is what pydrad is already doing. I just simplified the inputs so that a user only has to specify the profiles and doesn't have to worry about doing the polynomial fits "by hand." The coefficients that go into the .gravity file are calculated here

def _fit_poly_domains(self, name, unit):
and then it lets HYDRAD do the rest.

@sjbradshaw
Copy link

sjbradshaw commented Jun 16, 2021 via email

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

No branches or pull requests

3 participants