ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
SphericalHarmonicsGravityModel.h
1/******************************************************************************
2* Copyright (c) ATTX LLC 2024. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, LLC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX, LLC.
15******************************************************************************/
16/*
17Solar Radiation Pressure model header file
18
19Author: Sam Matez
20*/
21
22#ifndef MODELS_SPHERICAL_HARMONICS_GRAVITY_MODEL_H
23#define MODELS_SPHERICAL_HARMONICS_GRAVITY_MODEL_H
24
25#include <string>
26
27#include "core/macros.h"
28#include "simulation/Model.h"
29#include "utils/sphericalharmonicsutils.h"
30#include "locations.h"
31#include "utils/planetdefaults.h"
32
33namespace modelspace {
34
35 /**
36 * @brief Spherical Harmonics Model
37 *
38 * Implements spherical harmonic gravity up to an 18x18 field based on the implementation
39 * in the 42 simulation:
40 * https://github.com/ericstoneking/42/blob/4be580d8defc968da97d937ce09ef107c07860cb/Kit/Source/envkit.c#L82
41 *
42 * Author: Sam Matez
43 * Email: sam.matez@attx.tech
44 *
45 */
47 public:
48 // Model params
49 // NAME TYPE DEFAULT VALUE
51 /** The filename for the file that contains the coefficients for spherical
52 * harmonic calculation. These coefficients should be un-normalized, as the
53 * model applies a Neumann normalization to the loaded coefficients. */
54 SIGNAL(filename, std::string, modelspaceDir() + "data/WGS84/WGS84.txt")
55 /** This is the gravitational parameter of our parent planet. Defaults to
56 * Earth's gravitational parameter for ease of use */
57 SIGNAL(mu, double, clockwerk::earth_wgs84.mu)
58 /** This is the radius of our parent planet. Defaults to Earth's radius, in meters for ease of use */
59 SIGNAL(r_planet, double, clockwerk::earth_wgs84.semimajor_axis)
60 /** The coefficient n which represents the variations in gravitational field in the latitudinal direction */
61 SIGNAL(n, int, 0)
62 /** The coefficient m which represents the variations in gravitational field in the longitudinal direction.
63 * must be less than or equal to l */
64 SIGNAL(m, int, 0)
65 /** This is the mass of the body, which will be multiplied by our force
66 * to get the force calculation... TODO to replace this with accel methods */
67 SIGNAL(body_mass, double, 1.0)
69
70 // Model inputs
71 // NAME TYPE DEFAULT VALUE
73 /** The body position wrt the planet in a planet-centered, planet fixed frame (m) */
76
77 // Model Outputs
78 // NAME TYPE DEFAULT VALUE
80 /** This is the acceleration due to gravity calculated in the same reference frame as pos_body__f */
83
84 // Model-specific implementations of startup and derivative
85 SphericalHarmonicsGravityModel() : Model() {}
86 SphericalHarmonicsGravityModel(Model &pnt, int schedule_slot=DERIVATIVE, const std::string &m_name="spherical_harmonics_gravity")
87 : Model(pnt, schedule_slot, m_name) {}
88 SphericalHarmonicsGravityModel(SimulationExecutive &e, int schedule_slot=DERIVATIVE, const std::string &m_name="spherical_harmonics_gravity")
89 : Model(e, schedule_slot, m_name) {}
90 virtual ~SphericalHarmonicsGravityModel() {}
91
92 protected:
93 int start();
94 int execute();
95
96 // Pre-calculated parameters
97 double _K;
98
99 // Variables to hold gravity coefficients
100 double _c[NMAX_SPHERICAL_HARMONICS+1][NMAX_SPHERICAL_HARMONICS+1];
101 double _s[NMAX_SPHERICAL_HARMONICS+1][NMAX_SPHERICAL_HARMONICS+1];
102
103 // Local variable to hold force in the spherical frame
104 CartesianVector3D _accel_grav__spherical;
105
106 // Local variables for lla coordinates
107 double _lat;
108 double _lon;
109 double _alt;
110
111 // Local variable for magnitude of position vector
112 double _r_pos;
113
114 // Local variable to hold colatitude
115 double _colatitude;
116
117 // Local variables for rotation back to pcpf
118 double _sth;
119 double _cth;
120 double _sph;
121 double _cph;
123
124 };
125
126}
127
128#endif
Base model class for derived implementation.
Definition Model.h:56
Model()
Default constructor for the task object for simplicity. Note: Masks some functionality and should not...
Definition Model.cpp:21
Implementation of the executive class for simulation.
Definition SimulationExecutive.h:63
Spherical Harmonics Model.
Definition SphericalHarmonicsGravityModel.h:46
int start()
Function to perform task startup activities (step once after creation)
Definition SphericalHarmonicsGravityModel.cpp:28
int execute()
Function to execute the task. All math and calculations should be here.
Definition SphericalHarmonicsGravityModel.cpp:59
#define SIGNAL(NAME, TYPE, INITIAL_VALUE)
Definition macros.h:87
#define START_PARAMS
Definition macros.h:96
#define CartesianVector3D
Definition macros.h:54
#define END_OUTPUTS
Definition macros.h:90
#define END_PARAMS
Definition macros.h:98
#define START_OUTPUTS
Definition macros.h:88
#define END_INPUTS
Definition macros.h:94
#define START_INPUTS
Definition macros.h:92
Class to propagate CR3BP dynamics in characteristic units.
Definition ConfigurationWriter.cpp:18
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > pos_body_planet__pcpf
Definition SphericalHarmonicsGravityModel.h:74
clockwerk::DataIO< clockwerk::CartesianVector< double, 3 > > grav_force__f
Definition SphericalHarmonicsGravityModel.h:81
clockwerk::DataIO< double > body_mass
Definition SphericalHarmonicsGravityModel.h:67
clockwerk::DataIO< int > n
Definition SphericalHarmonicsGravityModel.h:61
clockwerk::DataIO< double > mu
Definition SphericalHarmonicsGravityModel.h:57
clockwerk::DataIO< double > r_planet
Definition SphericalHarmonicsGravityModel.h:59
clockwerk::DataIO< std::string > filename
Definition SphericalHarmonicsGravityModel.h:54
clockwerk::DataIO< int > m
Definition SphericalHarmonicsGravityModel.h:64