Skip to content

updateEnergyContributions calculation typo #1041

@MessiXiang

Description

@MessiXiang

Describe the bug

In file basilisk/src/simulation/dynamics/_GeneralModuleFiles/gravityEffector.cpp, function updateEnergyContributions calculates the potential energy contribution. But in line 299, there's probably a typo.

if (this->centralBody && !body->isCentralBody) // If there is a central body and it's not
                                                       // 'body'
{
    // potential of central body w/in current planet field. leads to
    // relative potential energy solution
    orbPotEnergyContr += body->gravityModel->computePotentialEnergy(r_PN_N - r_CN_N);
}
orbPotEnergyContr = body->gravityModel->computePotentialEnergy(
    r_cP_N); // Potential w/in current planet field

As shown above, the orbPotEnergyContr need to add all these energy up. However, it was given by body->gravityModel->computePotentialEnergy(r_cP_N) at last, which supposed to be +=

To reproduce

see above

Expected behavior

orbPotEnergyContr += body->gravityModel->computePotentialEnergy(
    r_cP_N); // Potential w/in current planet field

commit:
2b4dfec

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions