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

Psi4 Fix #4647

Merged
merged 1 commit into from
Feb 3, 2023
Merged

Psi4 Fix #4647

merged 1 commit into from
Feb 3, 2023

Conversation

AlexCarpenter46
Copy link
Contributor

Proposed changes

This PR is to fix the visualization issues I've been seeing with Psi4. Made x_hat and y_hat orthonormal to r_hat at every point, was previously was not aware that this was required, I assumed x_hat and y_hat were the cartesian basis vectors.

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.

nilsdeppe
nilsdeppe previously approved these changes Jan 27, 2023
Copy link
Contributor

@geoffrey4444 geoffrey4444 left a comment

Choose a reason for hiding this comment

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

Nice fix! Looks reasonable to me. Just some minor suggestions...you can squash immediately

@@ -96,9 +96,6 @@ void test_psi_4(const RealDataType& used_for_size_real,
auto inertial_coords =
make_with_random_values<tnsr::I<RealDataType, 3, Frame::Inertial>>(
nn_generator, nn_distribution, used_for_size_real);
for (size_t i = 0; i < 3; ++i) {
inertial_coords.get(i)[0] = 0.0;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I get that this test as it was written doesn't work anymore...but might it be possible for you to contrive an example that does give a zero denominator after the Gram-Schmidt orthonormalization? No big deal to me if not, but I would have thought you could work out what e.g. y_hat is for the 0th point before normalization, then modify it so that its magnitude is in fact zero?

Copy link
Contributor

Choose a reason for hiding this comment

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

If this isn't something quick to do, then I wouldn't sweat it

src/PointwiseFunctions/GeneralRelativity/Psi4.cpp Outdated Show resolved Hide resolved
@@ -69,27 +71,62 @@ void psi_4(const gsl::not_null<Scalar<ComplexDataVector>*> psi_4_result,
inverse_spatial_metric, cov_deriv_extrinsic_curvature, r_hat,
inverse_projection_tensor, projection_tensor, projection_up_lo, 1.0);

auto& x_coord = get<::Tags::TempI<0, 3, Frame>>(temp_buffer);
// Gram-Schmidt x_hat
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify comment: state something like Gram-Schmidt x_hat, i.e. make x_hat a unit vector orthogonal to r_hat


Variables<tmpl::list<::Tags::TempI<0, 3, Frame, ComplexDataVector>,
::Tags::TempI<1, 3, Frame, ComplexDataVector>>>
y_hat_buffer{get<0>(inertial_coords).size()};

// Grad-Schmidt y_hat
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify comment: state something like Gram-Schmidt y_hat, i.e. make y_hat a unit vector orthogonal to r_hat and x_hat

::Tags::Tempii<1, 3, Frame>, ::Tags::TempIj<0, 3, Frame>,
::Tags::TempII<0, 3, Frame>>>
Variables<
tmpl::list<::Tags::TempScalar<0>, ::Tags::TempScalar<1>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just so I understand, can you please explain to me why you need the additional temporaries?

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 think the additional TempScalar can be safely removed, however the additional TempI's are needed since TempI<0 = r_hat, TempI<1 = x_coord then changed to y_coord when not needed anymore, TempI<2 = x_hat and finally TempI<3 = y_hat_not_complex. I carry out the computation for y_hat in non-complex DataVector form for easier computation and then switch it to a ComplexDataVector later on.

@AlexCarpenter46
Copy link
Contributor Author

I'm not sure why a test was cancelled or timed out

@nilsdeppe nilsdeppe merged commit 21cab78 into sxs-collaboration:develop Feb 3, 2023
@nilsvu nilsvu added the bugfix label Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants