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

Add BnsInitialData System #6054

Merged

Conversation

isaaclegred
Copy link
Contributor

Proposed changes

This PR adds the system for generating BNS Irrotational Initial data. To do this, an elliptic system is introduced to solve for the velocity potential using the framework of Baumgarte + Shapiro Ch. 15. The background consists of a matter profile which is not yet implemented (as it is contained in the initial data).

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

Further comments

@isaaclegred
Copy link
Contributor Author

@nilsvu whenever you get a chance!

@nilsvu nilsvu self-requested a review June 4, 2024 19:24
src/Elliptic/Systems/IrrotationalBns/FirstOrderSystem.hpp Outdated Show resolved Hide resolved
* formulated as a set of coupled first-order PDEs.
*
* \details This system formulates the Irrotational Bns HSE equations for the
* velocity potential \f$\Phi\f$. For a background matter distribution (given
Copy link
Member

Choose a reason for hiding this comment

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

(optional) note that you can write standard latex $\Phi$ and \begin{align}...\end{align}; you don't need those \f.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh huh, that makes things easier. I'll start doing that from now on

src/Elliptic/Systems/IrrotationalBns/FirstOrderSystem.hpp Outdated Show resolved Hide resolved
src/Elliptic/Systems/IrrotationalBns/Equations.cpp Outdated Show resolved Hide resolved
::tenex::update(source_for_potential,
(*source_for_potential)() +
flux_for_potential(ti::I) *
(log_deriv_of_lapse_over_specific_enthalpy(ti::i) -
Copy link
Member

Choose a reason for hiding this comment

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

Does this include the factor of \rho as well in D_i \ln(\alpha\rho / h)?

Also I think the Christoffels should be added, not subtracted? The equation is -\partial_i F^i + S = f please check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it does include the factor of \rho, I'll change the variable name to make that obvious but maybe we can condense it in the future.

Hm, I would think the Christoffel should be be subtracted, we have the equation which looks like -D_i F^i + S_flat = f and then we expand the term D_i F^i = \partial_i F^i + Gamma^i_{ij}F^j so -Gamma^i_{ij} F^j gets added to the sources

Copy link
Member

Choose a reason for hiding this comment

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

Yes you're right it should be subtracted, but the other term as well if I did the math correctly

src/Elliptic/Systems/IrrotationalBns/IrrotationalBns.hpp Outdated Show resolved Hide resolved
src/Elliptic/Systems/IrrotationalBns/Tags.hpp Outdated Show resolved Hide resolved
* \f]
*/
template <typename DataType>
struct AuxiliaryVelocity : db::SimpleTag {
Copy link
Member

Choose a reason for hiding this comment

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

You can delete this tag, and also some or all of the tags below this (at least for now).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So basically If I deleted these now they would get added back in when the executable is added?

Copy link
Member

Choose a reason for hiding this comment

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

You can keep the ones you surely will need, like the Euler constant. But e.g. the FixedSources tag you don't need because there's already one in DataStructures/DataBox/Prefixes.hpp.

Comment on lines 31 to 32
// The constant term on the RHS is nonlinear with respect to the
// operator, so the linearized form of the RHS is zero.
Copy link
Member

Choose a reason for hiding this comment

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

"The term on the RHS is constant w.r.t. the variables, so the linearized form of the RHS is zero."

class Neumann : public elliptic::BoundaryConditions::BoundaryCondition<3> {
/// Impose StarSurface boundary conditions
/// \f[
/// n_i F^i = \frac{1}{\sqrt{\partial_i \rho \partial_j \rho \gamma^{ij}}
Copy link
Member

Choose a reason for hiding this comment

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

This should be just n_i F^i = C/square(alpha) B^i n_i, right?

set_number_of_grid_points(n_dot_auxiliary_velocity, *velocity_potential);
get(*n_dot_auxiliary_velocity) = 0.0;
tenex::evaluate<>(n_dot_auxiliary_velocity,
-euler_enthalpy_constant / square(lapse()) *
Copy link
Member

Choose a reason for hiding this comment

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

I think the minus sign is incorrect?

@@ -47,6 +47,8 @@ void fluxes_on_face(
const tnsr::I<DataVector, 3>& face_normal_vector,
const tnsr::II<DataVector, 3>& rotational_shift_stress,
const Scalar<DataVector>& velocity_potential) {
// potential optimization : precompute the produce of the `face_normal`
Copy link
Member

Choose a reason for hiding this comment

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

produce -> product

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🥦 -> ✖️ 👍

Copy link
Member

Choose a reason for hiding this comment

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

ping

source_for_potential,
(*source_for_potential)() +
flux_for_potential(ti::I) *
(log_deriv_lapse_times_density_over_specific_enthalpy(ti::i) -
Copy link
Member

Choose a reason for hiding this comment

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

I think both of these terms should have a minus sign. Please check.

Copy link
Member

Choose a reason for hiding this comment

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

still a minus sign to fix (unless I got the math wrong)

* velocity potential \f$\Phi\f$. For a background matter distribution (given
* by the specific enthalpy h) and a background metric \f$\gamma_{ij}\f$.
* The velocity potential is defined by \f$D_i \Phi = h u_i\f$ with \f$u_i\f$
(the spatial part of) the four velocity
Copy link
Member

Choose a reason for hiding this comment

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

fix this line (and more below that don't start with *)

*
* The system can be formulated in terms of these fluxes and sources (see
* `elliptic::protocols::FirstOrderSystem`):
*
*
* \f{align*}
* D_i F^i + S = f
Copy link
Member

@nilsvu nilsvu Jun 13, 2024

Choose a reason for hiding this comment

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

-\partial_i F^i + S = f (note the minus sign and \partial_i). This means some minus signs in the equations below need to be fixed too.

* F^i_{v_j} &= u \delta^i_j \\
* S_{v_j} &= v_j \\
* f_{v_j} &= 0 \text{.}
* F^i &= h u^i - \frac{B^j h u_j}{\alpha^2}B^i \\
Copy link
Member

Choose a reason for hiding this comment

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

h u^i -> \partial_i \phi to make clear that the flux depends on the gradient of the potential

@isaaclegred
Copy link
Contributor Author

I think everything should be done except removing the "flat" things. I'll do that in a separate commit after squashing all of this because I plan on keeping it around on a branch just in case it becomes useful for checking that the executable is working
.

Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

You can squash everything

source_for_potential,
(*source_for_potential)() +
flux_for_potential(ti::I) *
(log_deriv_lapse_times_density_over_specific_enthalpy(ti::i) -
Copy link
Member

Choose a reason for hiding this comment

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

still a minus sign to fix (unless I got the math wrong)

*
* \f{align*}
* F^i &= D_i \phi - \frac{B^j D_j \phi}{\alpha^2}B^i \\
* S &= -F^iD_i \left( \ln \frac{\alpha \rho}{h}\right) -\Gamma^i_{ij}F^j \\
Copy link
Member

@nilsvu nilsvu Jun 14, 2024

Choose a reason for hiding this comment

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

Can you add spin terms already? This probably also means we should name the executable something other than "irrotational".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to have the irrotational case merged first, at that point it should be straightforward to extend to the spin case but also at that point things stop being "exact". I'd like to go through the sources and understand what's going on and write up notes before I add that though.

The minus sign is my bad I have confused myself thoroughly with signs.

Copy link
Member

Choose a reason for hiding this comment

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

Ok that's fine. Probably still we should not name things "irrotational", don't you think? That seems confusing once we add the spin terms (and we don't want to rename everything later).

@isaaclegred isaaclegred force-pushed the BNSInitialDataSystems branch 2 times, most recently from d7efda3 to a3d4259 Compare June 18, 2024 00:56
HEADERS
Equations.hpp
FirstOrderSystem.hpp
Geometry.hpp
Copy link
Member

Choose a reason for hiding this comment

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

remove Geometry.hpp

@@ -47,6 +47,8 @@ void fluxes_on_face(
const tnsr::I<DataVector, 3>& face_normal_vector,
const tnsr::II<DataVector, 3>& rotational_shift_stress,
const Scalar<DataVector>& velocity_potential) {
// potential optimization : precompute the produce of the `face_normal`
Copy link
Member

Choose a reason for hiding this comment

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

ping

src/Elliptic/Systems/IrrotationalBns/Equations.cpp Outdated Show resolved Hide resolved
src/Elliptic/Systems/IrrotationalBns/Equations.hpp Outdated Show resolved Hide resolved
src/Elliptic/Systems/IrrotationalBns/Tags.hpp Outdated Show resolved Hide resolved
const double euler_enthalpy_constant = 1.0;
apply_neumann_boundary_condition<false>(
make_not_null(&n_dot_auxilliary_velocity));
CHECK(get(n_dot_auxilliary_velocity) ==
Copy link
Member

Choose a reason for hiding this comment

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

You aren't actually comparing to the Python implementation I think?

tests/Unit/Elliptic/Systems/IrrotationalBns/Test_Tags.cpp Outdated Show resolved Hide resolved
*
* \f{align*}
* F^i &= D_i \phi - \frac{B^j D_j \phi}{\alpha^2}B^i \\
* S &= -F^iD_i \left( \ln \frac{\alpha \rho}{h}\right) -\Gamma^i_{ij}F^j \\
Copy link
Member

Choose a reason for hiding this comment

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

Ok that's fine. Probably still we should not name things "irrotational", don't you think? That seems confusing once we add the spin terms (and we don't want to rename everything later).

@isaaclegred
Copy link
Contributor Author

@nilsvu I renamed everything to BnsInitialData in order to make it more general. Also fixed up comments.

Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

You can squash everything

/*!
* Impose StarSurface boundary conditions:
* \f[
* n_i F^i = \frac{C}{\alpha^2} B^i n_i.
Copy link
Member

Choose a reason for hiding this comment

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

Question: Since this is a Neumann boundary condition, it leaves the freedom for a constant offset in \Phi. I think the equations also leave this freedom. Have you thought about how to fix this freedom?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't, I would think a reasonable choice would be that Phi should be zero at the center of the star or something like that, we probably can't set Phi=0 at the surface because I'm almost sure it's not "equipotential"

@isaaclegred isaaclegred force-pushed the BNSInitialDataSystems branch 2 times, most recently from 5b4b7e0 to 5a3fd8a Compare June 27, 2024 18:29
nilsvu
nilsvu previously approved these changes Jun 28, 2024
Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

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

Just have to appease CI :)

@isaaclegred isaaclegred force-pushed the BNSInitialDataSystems branch 2 times, most recently from 393e308 to 7af735e Compare July 5, 2024 16:41
@nilsvu nilsvu changed the title Add IrrotationalBns System Add BnsInitialData System Jul 5, 2024
@nilsvu nilsvu merged commit b085f46 into sxs-collaboration:develop Jul 5, 2024
21 of 22 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