<commit_before>/*
 * Copyright (c) 2016 <NAME> (<EMAIL>)
 * Distributed under the MIT License.
 * See accompanying file LICENSE.md or copy at http://opensource.org/licenses/MIT
 */

#include <cstdlib>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cmath>
#include <limits>

#include <gsl/gsl_odeiv2.h>
#include <gsl/gsl_errno.h>

#include "NAOS/constants.hpp"
#include "NAOS/ellipsoidGravitationalAcceleration.hpp"
#include "NAOS/orbiterEquationsOfMotion.hpp"
#include "NAOS/rk4.hpp"
#include "NAOS/rk54.hpp"
#include "NAOS/basicMath.hpp"
#include "NAOS/basicAstro.hpp"
#include "NAOS/ellipsoidPotential.hpp"
#include "NAOS/misc.hpp"
#include "NAOS/gslIntegratorOrbiterAroundURE.hpp"

namespace naos
{

//! Equations of motion for spacecraft or particle around a uniformly rotating ellipsoid (URE)
/*!
 * function defining the equation of motion which will be used in the integrator routine of GSL
 *
 */

 int equationsOfMotion( double t, const double X[], double dXdt[], void *parameters )
 {
    ( void )( t );

    asteroidParameters param = *(asteroidParameters *) ( parameters );
    const double Ux = param.xGravAcceleration;
    const double Uy = param.yGravAcceleration;
    const double Uz = param.zGravAcceleration;
    const double Wz = param.zRotation;

    dXdt[ naos::xPositionIndex ] = X[ naos::xVelocityIndex ];
    dXdt[ naos::yPositionIndex ] = X[ naos::yVelocityIndex ];
    dXdt[ naos::zPositionIndex ] = X[ naos::zVelocityIndex ];
    dXdt[ naos::xVelocityIndex ] = Ux + 2.0 * Wz * X[ naos::yVelocityIndex ]
                                    + Wz * Wz * X[ naos::xPositionIndex ];
    dXdt[ naos::yVelocityIndex ] = Uy - 2.0 * Wz * X[ naos::xVelocityIndex ]
                                    + Wz* Wz * X[ naos::yPositionIndex ];
    dXdt[ naos::zVelocityIndex ] = Uz;
    return GSL_SUCCESS;
 }

//! Execute routine to compute orbiter/particle motion around a uniformly rotating ellipsoid (URE)
/*!
 * This routine will compute the motion of the orbiter or particle around an asteroid modelled as
 * a uniformly rotating triaxial ellipsoid. The routine is called in main for execution.
 * @sa ellipsoidGravitationalAcceleration.cpp, orbiterEquationsOfMotion.hpp, rk4.hpp
 *
 * @param[in] alpha                         largest semi axis of the ellipsoid<commit_msg>minor edit<commit_after>/*
 * Copyright (c) 2016 <NAME> (<EMAIL>)
 * Distributed under the MIT License.
 * See accompanying file LICENSE.md or copy at http://opensource.org/licenses/MIT
 */

#include <cstdlib>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cmath>
#include <limits>

#include <gsl/gsl_odeiv2.h>
#include <gsl/gsl_errno.h>

#include "NAOS/constants.hpp"
#include "NAOS/ellipsoidGravitationalAcceleration.hpp"
#include "NAOS/orbiterEquationsOfMotion.hpp"
#include "NAOS/rk4.hpp"
#include "NAOS/rk54.hpp"
#include "NAOS/basicMath.hpp"
#include "NAOS/basicAstro.hpp"
#include "NAOS/ellipsoidPotential.hpp"
#include "NAOS/misc.hpp"
#include "NAOS/gslIntegratorOrbiterAroundURE.hpp"

namespace naos
{

//! Equations of motion for spacecraft or particle around a uniformly rotating ellipsoid (URE)
/*!
 * function defining the equation of motion which will be used in the integrator routine of GSL
 *
 */

 int equationsOfMotion( double t, const double X[], double dXdt[], void *parameters )
 {
    ( void )( t );

    asteroidParameters param = *(asteroidParameters *) ( parameters );
    const double Ux = param.xGravAcceleration;
    const double Uy = param.yGravAcceleration;
    const double Uz = param.zGravAcceleration;
    const double Wz = param.zRotation;

    dXdt[ naos::xPositionIndex ] = X[ naos::xVelocityIndex ];
    dXdt[ naos::yPositionIndex ] = X[ naos::yVelocityIndex ];
    dXdt[ naos::zPositionIndex ] = X[ naos::zVelocityIndex ];
    dXdt[ naos::xVelocityIndex ] = Ux + 2.0 * Wz * X[ naos::yVelocityIndex ]
                                    + Wz * Wz * X[ naos::xPositionIndex ];
    dXdt[ naos::yVelocityIndex ] = Uy - 2.0 * Wz * X[ naos::xVelocityIndex ]
                                    + Wz * Wz * X[ naos::yPositionIndex ];
    dXdt[ naos::zVelocityIndex ] = Uz;
    return GSL_SUCCESS;
 }

//! Execute routine to compute orbiter/particle motion around a uniformly rotating ellipsoid (URE)
/*!
 * This routine will compute the motion of the orbiter or particle around an asteroid modelled as
 * a uniformly rotating triaxial ellipsoid. The routine is called in main for execution.
 * @sa ellipsoidGravitationalAcceleration.cpp, orbiterEquationsOfMotion.hpp, rk4.hpp
 *
 * @param[in] alpha                         largest semi axis of the ellipsoid
{'fraction_non_alphanumeric': 0.11206526406182911, 'fraction_numerical': 0.0055817947617003, 'mean_word_length': 3.6636636636636637, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4995950', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1505, 'n_words': 426}