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

fix divu when theta=0 or pi #2975

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

zhichen3
Copy link
Collaborator

@zhichen3 zhichen3 commented Oct 12, 2024

PR summary

When calculating vy, when $\theta = 0$ or $\theta = \pi$, sinc=0 which causes division by 0. But the numerator should cancel due to azimuthal symmetry. So numerator is 0. So set vy=0 when that happens.

Do it more precisely, expand out divergence in theta to be: $\frac{1}{r sin\theta} \frac{\partial (v sin\theta)}{\partial \theta}$ = $\frac{1}{r} \left(\frac{\Delta v}{\Delta \theta} + v cot\theta \right)$. Both $\Delta v = 0$ and $v = 0$ at $\theta = 0$, so we have $\frac{1}{r} \frac{cos \theta v}{sin \theta} = 0/0$. With l'hopital, we have $lim_{\theta \rightarrow 0} \frac{\partial(v cos \theta) / \partial \theta}{cos \theta } = 0$

PR motivation

PR checklist

  • test suite needs to be run on this PR
  • this PR will change answers in the test suite to more than roundoff level
  • all newly-added functions have docstrings as per the coding conventions
  • the CHANGES file has been updated, if appropriate
  • if appropriate, this change is described in the docs

@zingale zingale merged commit 7b80efd into AMReX-Astro:development Oct 14, 2024
26 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