Skip to content

Matter: Port Matter classes (with unit tests) #94

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

Merged
merged 27 commits into from
Apr 30, 2025

Conversation

julianakwan
Copy link
Contributor

This PR completes my port of the Matter classes and closes #10 . It includes:

  • Porting MatterCCZ4
  • Porting the ScalarField and DefaultPotential classes
  • Porting the calculation of Weyl4_Re and Weyl4_Im for a Matter class
  • Porting the calculation of the energy density, the momentum density and the spatial stress energy density for Matter classes
  • Porting the calculation of the relaxation of chi (I didn't know it was going to be depreciated!)
  • Unit tests for the above
  • Renaming NewMatterConstraints to just MatterConstraints.
  • The removal of the Matter directory from the list of ignored files in .lint_ignore

@julianakwan julianakwan added the enhancement New feature or request label Mar 1, 2025
@julianakwan julianakwan self-assigned this Mar 1, 2025
Copy link

github-actions bot commented Mar 1, 2025

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/ChiRelaxation.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/MatterCCZ4RHS.impl.hpp
Source/Matter/MatterConstraints.impl.hpp
Source/Matter/MatterWeyl4.impl.hpp
Source/Matter/ScalarField.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@julianakwan julianakwan changed the title Enhancement/matter class fix Matter: Port Matter classes (with unit tests) Mar 3, 2025
Copy link

github-actions bot commented Mar 4, 2025

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/ChiRelaxation.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/MatterCCZ4RHS.impl.hpp
Source/Matter/MatterConstraints.impl.hpp
Source/Matter/MatterWeyl4.impl.hpp
Source/Matter/ScalarField.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

Copy link
Member

@mirenradia mirenradia left a comment

Choose a reason for hiding this comment

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

Thanks for this PR Juliana.

It looks pretty good but I have some comments. I know there are a fair few of them but I think most of them should be easy to resolve and the more complicated ones I will try and look at myself.

For the GRChombo HDF5 files you have generated for the tests, where is the code you used to create them? I couldn't find a relevant branch in the GRChombo repo.

I don't think the Tests/MatterWeyl4Test/GRChomboEMTensorTest.h5 file is needed/used so could you remove it as well?

Would you also be able to fix the commit history by applying the fixups?

/// 3 components for the momentum density: m_11, m_22, m_33
/// 6 components for the stress energy tensor (symmetric): s_11, s_12 etc.
static inline const amrex::Vector<std::string> extra_var_names = {
"m_11, m_22, m_33, s_11, s_12, s_13, s_22, s_23, s_33"};
Copy link
Member

Choose a reason for hiding this comment

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

Yes. We have always used Si and Sij but here that naming might be confusing. We could use J instead, so then it would be J1,J2,J3, S11, S12 etc. Maybe let's leave this for the naming tidy up as it would be best to be consistent throughout the code.

Copy link
Member

Choose a reason for hiding this comment

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

This would be good. I always found the passing of intervals in the constructor a bit ugly and confusing.

@julianakwan julianakwan force-pushed the enhancement/matter_class_fix branch from 5e527e5 to 2b7a3ce Compare March 19, 2025 22:19
Copy link

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ChiRelaxation.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@julianakwan julianakwan force-pushed the enhancement/matter_class_fix branch 2 times, most recently from 1c36aac to a44ef5d Compare April 9, 2025 13:51
Copy link

github-actions bot commented Apr 9, 2025

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ChiRelaxation.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

1 similar comment
Copy link

github-actions bot commented Apr 9, 2025

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ChiRelaxation.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@julianakwan julianakwan force-pushed the enhancement/matter_class_fix branch from 50c4e2b to dcf4ae8 Compare April 9, 2025 15:13
Copy link

github-actions bot commented Apr 9, 2025

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ChiRelaxation.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

Copy link

github-actions bot commented Apr 9, 2025

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@julianakwan
Copy link
Contributor Author

julianakwan commented Apr 9, 2025

Hi all - I think I have addressed everyone's comments now (and the lint checks have finally passed). Could you please review this PR again and double check that you are happy with everything?

Main changes are:

  • ChiRelaxation has been moved to a new branch enhancement/chi_relaxation
  • Names starting with Matter have been moved to ...WithMatter e.g. MatterCCZ4RHS is now CCZ4RHSWithMatter
  • Constructor classes involving the Matter object no longer require the Matter object to be passed as an argument because the object is now default constructed from the templated type.
  • Tests/Common/InitialData.hpp now has a function to initialize test scalar field and conjugate momentum values
  • I have applied the bugfix from GRChombo to the MovingPunctureGauge. Because it is a matter thing only, it is stored in it's own matter file MovingPunctureGaugeWithMatter.hpp

Copy link
Member

@mirenradia mirenradia left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes, Juliana. Just a couple more minor changes.

@julianakwan julianakwan force-pushed the enhancement/matter_class_fix branch from da3ee70 to 47a3a61 Compare April 15, 2025 11:53
Copy link

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@julianakwan julianakwan force-pushed the enhancement/matter_class_fix branch from 47a3a61 to 20562ea Compare April 15, 2025 12:14
@julianakwan julianakwan requested a review from mirenradia April 15, 2025 12:36
@julianakwan
Copy link
Contributor Author

Hi @mirenradia - I believe I have addressed all your comments now. Can you please take another look at this PR? Thanks!

This commit adds:
  - a set_up function to add the energy density, momemtum density
    and spatial stress-energy tensor as components of derive_lst
  - compute_mf a wrapper to the compute function which is called
    by AMReX whenever a derived variable needs to be calculated.
This commit will:
  - introduce a set_up function that adds "Weyl4_Re" and "Weyl4_Im"
    to the derive_lst for matter classes.
  - wrap the compute function inside compute_mf which is called by
    AMReX whenever the derived variable are needed.
This commit will:
  - introduce a set_up function for adding "Ham", "Mom1", "Mom2",
    and "Mom3" (or alternatively "Ham" and "Mom" normalized) to
    the derive_lst
  - introduce a compute_mf wrapper that will calculate the above
    whenever required by AMReX.
This commit will:
  - Call compute_mf to calculate derived varables
  - Refactor the HDF5 output to be consistent with the other unit
    tests (and update the relevent HDF5 files).
This commit will:
  - Pull out the test for rho from the MatterWeyl4 unit test into
    its own test case
  - Test the outputted values of rho calculated by EMTensor
    against values calculated by GRChombo
  - Test the outputted values of chi calculated by ChiRelaxation
    against values calculated by GRChombo
  - Add the GRChombo .h5 files for comparison
  - Add these two new test cases to the list in TestCases.hpp
This commit will:
  - Add an #if statement around HDF5 parts so they are not
    compiled if USE_HDF5=FALSE
  - Also, fix Lint errors
This commit will:
  - fix the bug in GRChombo with the gauge calculation in
    MatterCCZ4
This commit will:
  - Add the definition of phi and Pi to the common header file
  - Refactor the tests to use these definitions. I noticed that
    the BSSN Matter test and the chi relaxation test were using
    different initial conditions from the other so I had to
    update the HDF5 file outputs as well.
This commit will also:
  - Rename G_newton to G_Newton in the BSSN Matter test
This commit will:
  - Switch ordering of naming convention, so MatterCCZ4RHS becomes
    CCZ4RHSWithMatter, MatterConstraints becomes
    ConstraintsWithMatter, MatterWeyl4 becomes Weyl4WithMatter

Matter: Remove matter object from constructor

I forgot to remove the matter object in the constructor for
CCZ4RHSWithMatter!
There is now a separate branch for the ChiRelaxation class
This will update the naming convention of emtensor_t:
  - The trace of the spatial stress energy tensor is now trS
  - The spatial stress energy tensor itself is now S
  - The momentum vector is now j
@julianakwan julianakwan force-pushed the enhancement/matter_class_fix branch from 20562ea to 8c30fcb Compare April 17, 2025 12:44
Copy link

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

Copy link
Member

@KAClough KAClough left a comment

Choose a reason for hiding this comment

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

I am happy with this PR, I made two minor suggestions for you to consider @julianakwan but I don't feel strongly about them, so whatever you think! Let's get this merged and do the tidy up!

This will:
  - Remove the calculations of emtensor and add_matter_rhs without
    the potential and incorporate them into a single function
Copy link

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

julianakwan and others added 2 commits April 29, 2025 12:53
This will:
  - Remove the calculations of emtensor and add_matter_rhs without
    the potential and incorporate them into a single function
Now the choice of which components are stored is decided by the template
parameter em_tensor_parts.

The choice is more limited as we now assume that if you want the
momentum density, you will also want the energy density and similarly if
you want the stress tensor, you want everything else too.
Copy link

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@julianakwan
Copy link
Contributor Author

I have incorporated the changes to the EMTensor class from enhancements/matter_class_mr_suggest with some changes - I would prefer to call it EMTensorOptions rather than EMTensorParts as I think this is clearer. (We could also have EMTensorComputeOptions but this is a bit long). I didn't do the same for the ConstraintsWithMatter class because the Constraints parent class needs to be changed as well (which should be done in another PR).

@mirenradia
Copy link
Member

I have incorporated the changes to the EMTensor class from enhancements/matter_class_mr_suggest with some changes - I would prefer to call it EMTensorOptions rather than EMTensorParts as I think this is clearer. (We could also have EMTensorComputeOptions but this is a bit long). I didn't do the same for the ConstraintsWithMatter class because the Constraints parent class needs to be changed as well (which should be done in another PR).

I'm fine with this. I think @KAClough suggested EMTensorComponents. I think she also wanted to change the last option from all to allDensities. I'll let her respond but I'm otherwise happy to approve this PR.

@KAClough
Copy link
Member

KAClough commented Apr 30, 2025

I'm happy with EMTensorOptions - I didn't like Parts either. Options is nice as it shows you have options to pick! I would like to make it allDensities, thanks @mirenradia for remembering this. But we can also do that in the tidy up, it is not crucial. Let's merge this!

Copy link

This PR modifies the following files which are ignored by .lint-ignore:

Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@julianakwan julianakwan merged commit d632ffe into develop Apr 30, 2025
55 of 56 checks passed
@julianakwan julianakwan deleted the enhancement/matter_class_fix branch April 30, 2025 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port Matter classes
3 participants