ModelSpace
Documentation for ModelSpace models and classes.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
/******************************************************************************
* Copyright (c) ATTX LLC 2024. All Rights Reserved.
*
* This software and associated documentation (the "Software") are the 
* proprietary and confidential information of ATTX, LLC. 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, LLC.
******************************************************************************/
/*
Solar panel model header file

Author: Alex Jackson
*/
/*
Metadata for MS GUI:
imdata = {"displayname" : "Solar Panel",
          "exclude" : False,
          "category" : "Power"
}
aliases = {"mass" : "Mass",
           "solar_irr" : "Solar Flux",
           "panel_eff" : "Solar Panel Efficiency",
           "panel_area" : "Solar Panel Area",
           "panel_normal__body" : "Panel Normal Vector",
           "sun_frame_ptr" : "Sun Frame",
           "r_sun" : "Solar Radius",
           "planet_frame_ptr" : "Planet Frame",
           "r_planet" : "Planet Radius",
           "body_frame_ptr" : "Body Frame",
           "power" : "Power",
           "vis_frac" : "Visible Fraction",
           "panel_body_fixed" : "Body Fixed Panel"
}
*/

#ifndef MODELS_POWER_SOLAR_PANEL_MODEL_H
#define MODELS_POWER_SOLAR_PANEL_MODEL_H 

#include "simulation/Model.h"
#include "models/environment/OccultationModel.h"
#include "models/support/EffectiveSolarAreaModel.h"
#include "models/power/SolarPanelPowerModel.h"
#include "models/states/FrameStateSensorModel.h"

namespace modelspace {

    /**
     * @brief   Solar panel model
     * 
     * This model defines a solar panel model that accounts for eclipse, pointing, size, and efficiency. This is a combination
     * of the Solar Panel Power, Occultation, and Effective Solar Area moddels to aide in ease of use.
     * Author: Alex Jackson
     * Email: alex.jackson@attx.tech 
    */
    MODEL(SolarPanelModel)  
    public:
        
        // Model params
        //         NAME                     TYPE                    DEFAULT VALUE
        START_PARAMS
            /** The mass of the solar panel in kg. Default is massless */
            SIGNAL(mass,                    double,                 0.0)
            /** The solar irradiance at the location of interest in power per area (the default is in W/m^2)*/
            SIGNAL(solar_irr,               double,                 1361.0)
            /** The solar panel efficiency on a scale of 0 to 1 where 0 is 0 percent efficiency and 1 is 100 percent efficiency */
            SIGNAL(panel_eff,               double,                 0.28)
            /** The area of the solar panel. */
            SIGNAL(panel_area,              double,                 1.0)
            /** The solar panel normal vector in the body frame. This is used to describe the orientation of the 
            * solar panel wrt to the body frame (default is the x axis ) */
            SIGNAL(panel_normal__body,      CartesianVector3,       CartesianVector3({1.0,0.0,0.0}))
            /** The inertial Sun frame */
            SIGNAL(sun_frame_ptr,           Frame*,                 nullptr)
            /** Sun radius in m */
            SIGNAL(r_sun,                   double,                 695700000.0)
            /** The parent frame which the body frame is orbiting */
            SIGNAL(planet_frame_ptr,        Frame*,                 nullptr)
            /** Planet radius in m (default is Earth radius) */
            SIGNAL(r_planet,                double,                 cfspp::earth_wgs84.eq_radius)
            /** Body frame of the spacecraft*/
            SIGNAL(body_frame_ptr,          Frame*,                 nullptr)
            /** Whether the solar panel should remain body fixed and perform effective area calculations (true/default),
             *  or should assume effective solar area is always 100% of panel size for a simpler calculation (false) */
            SIGNAL(panel_body_fixed,        int,                    true)
        END_PARAMS

        // Model inputs
        //         NAME                     TYPE                    DEFAULT VALUE
        START_INPUTS
        
        END_INPUTS
 
        // Model outputs
        //         NAME                     TYPE                    DEFAULT VALUE
        START_OUTPUTS
            /** The power generated by the panel in watts*/
            SIGNAL(power,                   double,                 0.0)
            /** Fraction of two spherical representations of objects that are visible from the point
             * of view of the observer. 0 is fully occulted, 1 is not occulted, 0-1 is 
             * visible fraction of observed object. */
            SIGNAL(vis_frac,                double,                 1.0)
        END_OUTPUTS

    protected:
        int16 start() override;
        int16 execute() override; 
        // Occultation model used internally
        OccultationModel _oc;
        // The frame state sensor for relative states between spacecraft and sun
        FrameStateSensorModel _fss_sc_s;
        // Effective solar area model used internally
        EffectiveSolarAreaModel _esa;
        // Solar panel power model used for internal calculations
        SolarPanelPowerModel _spp;
    };

}

#endif