Skip to content

Conversation

jo11he
Copy link
Collaborator

@jo11he jo11he commented Sep 21, 2025

Feature branch implementing user option to subtract mean tidal forcing from solid body tide model.

Unit test implemented only in unitTestEnvironmentModelSetup.cpp, not unitTestGravityFieldVariations.cpp.
Unit test for partials is pending.

@DominicDirkx DominicDirkx changed the base branch from master to develop_10 September 22, 2025 07:52
@DominicDirkx DominicDirkx changed the base branch from develop_10 to develop September 25, 2025 13:44
@DominicDirkx
Copy link
Member

@jo11he I closed the other issue for this, since it was for pre-1.0 consistency, which we don't need anymore :)

I think we can merge this PR once there's a unit test that the mean tide is properly subtracted during the estimation as well. Do you have one already?

const int maximumDegree,
const int maximumOrder );
const int maximumOrder,
std::map< int, std::vector< double > > meanCosineForcing = { {0, {0.0}} },
Copy link
Member

Choose a reason for hiding this comment

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

Instead of initializing a specific map, initialize to empty map std::map< int, std::vector< double > >( ), which will not allocate needless memory (and makes the check for whether mean tides are added easier)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed.


// if cosine mean forcing terms are empty map (default), set map values to zero
if (meanForcingCosineTerms.empty()){
for (const auto& [key, vec] : loveNumbers_) {
Copy link
Member

Choose a reason for hiding this comment

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

The const auto& [key, vec] requires C++17, which is not (yet) the default of Tudat compilation, could you modify this?

void setMeanForcingCosineTerms( const std::map<int, std::vector<double>>& newCosineTerms ) {

// Check same number of keys
assert(newCosineTerms.size() == meanForcingCosineTerms_.size() && "Error when setting meanForcingCosineTerms in BasicSolidBodyGravityFieldVariationSettings. Keys of newCosineTerms argument must match with existing love number keys.");
Copy link
Member

Choose a reason for hiding this comment

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

Use exceptions (like you already have) instead of assert

}


void massageMeanTermsIfDefault(std::map< int, std::vector< double > >& input, const std::map< int, std::vector< std::complex< double > > >& loveNumbersReference) {
Copy link
Member

Choose a reason for hiding this comment

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

This is now done 'in the loop', allocating memory each time step. I think this can be checked and done once (?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this comment refers to the call to massageMeanTermsIfDefault?

This function is only called in std::pair< Eigen::MatrixXd, Eigen::MatrixXd > calculateSolidBodyTideSingleCoefficientSetCorrectionFromAmplitude( ), which is the overload using const std::map< int, std::vector< std::complex< double > > > loveNumbers as input. This function is only called in the unit tests.

As such, it does not go through any "preparations", it is just called out of the blue, for a given state of the environment (so also not "in-the-loop"). Without the "preparations" it is also impossible to adjust the format of the 0.0 meanTidalForcing defaults to the format of the loveNumbers input, which can be of arbitrary std::map< int, std::vector< std::complex< double > > > format. Therefore, this adjustment needs to be made inside the body of this function.

In short, I think this function was never intended to be used by a user, not even the C++ user in propagation, only as a facilitator in unit tests.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, no need to change this

}
}

} else {
Copy link
Member

Choose a reason for hiding this comment

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

why not do this in a single piece of code, rather than the if/else?

@DominicDirkx
Copy link
Member

@jo11he I added a couple of comments into the code, and extended the tests for the Love number partials. There are some failures in the test that indicate some things are not yet as they should be:

  • The partials pass perfectly well for parameters k2, k3 with and without the mean forcing (in this setting, the mode sets k20=k21=k22 and k30=k31=k32=k33)
  • The partials fail for separate k20, k21, k22, k30, k31, k32, k33
  • The partials fail for the mode-coupled Love numbers (the model Marc developed with couplings between response/forcing at different degree/order)

The last one is particular strange, since it these Love number partials should not be affected at all by your code. I did very little investigation, so it's also possible that the problem is in the test, not the functionality :)

@DominicDirkx
Copy link
Member

UPDATE: I have not found the error, but I have a good lead. On of the parameter where the partials go wrong is set up (on purpose, and after 10 years it's paying off by finding a bug!) as:

[k22,k20,k21]

when I modify this to setting it up as

[k20,k21,k22]

it all works fine

Since the same is done for the mode-coupled Love number partials, I suspect this PR incorrectly modified a book-keeping aspect in the parameter/partial.

To be investigated further :)

@jo11he
Copy link
Collaborator Author

jo11he commented Oct 14, 2025

I'm on it

@DominicDirkx DominicDirkx force-pushed the feature/interface_for_mean_tidal_potential_100 branch from f5b3026 to 12acb9a Compare October 16, 2025 17:57
@jo11he
Copy link
Collaborator Author

jo11he commented Oct 17, 2025

I think this is looking good now!

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