WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
SolarRadiationPressureModel.h
/******************************************************************************
* Copyright (c) ATTX INC 2025. All Rights Reserved.
*
* This software and associated documentation (the "Software") are the 
* proprietary and confidential information of ATTX INC. The Software is 
* furnished under a license agreement between ATTX and the user organization 
* and may be used or copied only in accordance with the terms of the agreement.
* Refer to 'license/attx_license.adoc' for standard license terms.
*
* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION 
* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or 
* transmitted in any form or by any means, for any purpose, without the express 
* written permission of ATTX INC.
******************************************************************************/
/*
Solar Radiation Pressure model header file

Author: Sam Matez
*/
/*
Metadata for MS GUI:
imdata = {"displayname" : "Solar Radiation Pressure",
          "exclude" : False,
          "category" : "Environment"
}
aliases = {"S" : "Solar Flux",
           "C_r" : "Coeff. of Reflectivity",
           "A_srp" : "Spacecraft Area",
           "position_body_sun_f" : "Position",
           "v" : "Solar Intensity",
           "srp_force_body_f" : "SRP Force"
}
*/

#ifndef MODELS_SOLAR_RADIATION_PRESSURE_MODEL_H 
#define MODELS_SOLAR_RADIATION_PRESSURE_MODEL_H

// #include "frames/Body.h"
#include "frames/frameutils.h"
#include "simulation/Model.h"
#include "constants/unitutils.h"

namespace warptwin {

    /**
     * @brief   Solar Radiation Pressure Model
     * 
     * This model calculates the solar radiation pressure 
     * perturbation that acts on a body in orbit.
     * The methods and calculations in this model come from 
     * https://freeflyer.com/_help_Files/spherical_srp.htm 
     * 
     * Author: Sam Matez
     * Email: sam.matez@attx.tech
     * 
    */
    MODEL(SolarRadiationPressureModel)
    public:
        // Model params
        //         NAME                     TYPE                    DEFAULT VALUE
        START_PARAMS
            /** The solar flux , defaults to the mean solar flux at one astronomical unit (W/m^2) */
            SIGNAL(S,                       double,                 1361.0)
        END_PARAMS

        // Model inputs
        //         NAME                     TYPE                    DEFAULT VALUE
        START_INPUTS
            /** The body coefficient of reflectivity () */
            SIGNAL(C_r,                     double,                 1.0)
            /** The area of the body subject to solar radiation (the mean area that faces the sun). Defaults to 1 m^2 */
            SIGNAL(A_srp,                   double,                 1.0)
            /** The body position wrt the Sun in any generic frame. Defaults to 1 AU in meters with sun in X direction */
            SIGNAL(position_body_sun_f,     CartesianVector3,       CartesianVector3({warpos::AU_TO_METERS, 0.0, 0.0}))
            /** The current solar intensity on a scale of 0 to 1 where 0 is eclipse and 1 is direct sunlight */
            SIGNAL(v,                       double,                 1.0)
        END_INPUTS

        // Model Outputs
        //         NAME                     TYPE                    DEFAULT VALUE
        START_OUTPUTS
            /** The force acting on the body due to solar radiation pressure (N) in the smae generic frame as the input */
            SIGNAL(srp_force_body_f,      CartesianVector3,      CartesianVector3({0.0, 0.0, 0.0}))
        END_OUTPUTS

    protected:
        // Execute in protected
        int16 execute() override; 

        // Temporary vectors and variables to carry out our calculations
        double _r;
        double _multiplier;
        CartesianVector3 _unitpos_body_sun_f;
    };

}

#endif