COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
physicsclass.h
Go to the documentation of this file.
1 /********************************************************************
2 * Copyright (C) 2015 by Interstel Technologies, Inc.
3 * and Hawaii Space Flight Laboratory.
4 *
5 * This file is part of the COSMOS/core that is the central
6 * module for COSMOS. For more information on COSMOS go to
7 * <http://cosmos-project.com>
8 *
9 * The COSMOS/core software is licenced under the
10 * GNU Lesser General Public License (LGPL) version 3 licence.
11 *
12 * You should have received a copy of the
13 * GNU Lesser General Public License
14 * If not, go to <http://www.gnu.org/licenses/>
15 *
16 * COSMOS/core is free software: you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public License
18 * as published by the Free Software Foundation, either version 3 of
19 * the License, or (at your option) any later version.
20 *
21 * COSMOS/core is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * Refer to the "licences" folder for further information on the
27 * condititons and terms to use this software.
28 ********************************************************************/
29 
30 #ifndef PHYSICSCLASS_H
31 #define PHYSICSCLASS_H
32 
33 #include "support/configCosmos.h"
34 #include "support/jsondef.h"
35 #include "support/convertlib.h"
36 #include "support/timelib.h"
37 #include "physics/nrlmsise-00.h"
38 #include "support/datalib.h"
39 
40 
41 namespace Cosmos
42 {
43  namespace Physics
44  {
45 
46  class Structure
47  {
48  public:
50 
51  enum Type
52  {
53  U1,
54  U1X,
55  U1Y,
61  U2,
62  U2X,
63  U2Y,
65  U3,
66  U3X,
67  U3Y,
69  U6,
70  U6X,
71  U6Y,
73  U12,
77  };
78 
80  {
81  None = 0,
82  X,
83  Y,
85  };
86 
87  Structure(physicsstruc *physp) : newphys{physp}
88  {
89 
90  }
91 
92  int32_t Setup(Type type);
93  int32_t add_u(double x, double y, double z, ExternalPanelType type);
94  int32_t add_cuboid(string name, Vector size, double depth, Quaternion orientation, Vector offset);
95  int32_t add_face(string name, Vector point0, Vector point1, Vector point2, Vector point3, double depth, uint8_t external=1, float pcell=.85, Quaternion orientation=Math::Quaternions::eye(), Vector offset=Vector());
96  int32_t add_face(string name, Vector size, Quaternion orientation, Vector offset);
97  int32_t add_triangle(Vector pointa, Vector pointb, Vector pointc, double depth, bool external=true, float pcell=.85);
98  int32_t add_vertex(Vector point);
99 
100  private:
102 
103  };
104 
106  {
107  public:
108  double dt;
109  double dtj;
114 
115  enum Type
116  {
117  None = 0,
118  PositionInertial = 10,
119  PositionIterative = 11,
120  PositionGaussJackson = 12,
121  AttitudeInertial = 20,
122  AttitudeIterative = 21,
123  AttitudeLVLH = 22,
124  Thermal = 30,
125  Electrical = 40
126  };
128 
129  Propagator(locstruc *locp, physicsstruc *physp, double idt) : newloc{locp}, newphys{physp}
130  {
131  dt = 86400.*((locp->utc + (idt / 86400.))-locp->utc);
132  dtj = dt / 86400.;
133  }
134 
135  int32_t Increment(double nextutc);
136 
137  private:
138  };
139 
141  {
142  public:
144  : Propagator{ locp, physp, idt }
145  {
146  type = PositionInertial;
147  }
148 
149  int32_t Init();
150  int32_t Propagate();
151 
152  private:
153  };
154 
156  {
157  public:
159  : Propagator{ locp, physp, idt }
160  {
161  type = PositionIterative;
162  }
163 
164  int32_t Init();
165  int32_t Propagate();
166 
167  private:
168  };
169 
171  {
172  public:
173  uint16_t order;
174 
175  GaussJacksonPositionPropagator(locstruc *locp, physicsstruc *physp, double idt, uint16_t iorder)
176  : Propagator{ locp, physp, idt }, order { iorder }
177  {
178  type = PositionGaussJackson;
179  Setup(iorder);
180  }
181  int32_t Setup(uint16_t order);
182  int32_t Init(vector<tlestruc> lines);
183  int32_t Init(vector<locstruc> locs);
184  int32_t Init();
185  int32_t Converge();
186  int32_t Propagate();
187 
188  private:
189 
190  struct gjstruc
191  {
192  vector <double> a;
193  vector <double> b;
200  };
201 
202  vector< vector<int32_t> > binom;
203  vector<double> c;
204  vector<double> gam;
205  vector< vector<double> > beta;
206  vector<double> q;
207  vector<double> lam;
208  vector< vector<double> > alpha;
209  double dtsq;
210  uint16_t order2;
211  vector<gjstruc> step;
212  };
213 
215  {
216  public:
218  : Propagator{ locp, physp, idt }
219  {
220  type = AttitudeInertial;
221  }
222 
223  int32_t Init();
224  int32_t Propagate();
225 
226  private:
227  };
228 
230  {
231  public:
233  : Propagator{ locp, physp, idt }
234  {
235  type = AttitudeIterative;
236  }
237 
238  int32_t Init();
239  int32_t Propagate();
240 
241  private:
242  };
243 
245  {
246  public:
247  LVLHAttitudePropagator(locstruc *locp, physicsstruc *physp, double idt)
248  : Propagator{ locp, physp, idt }
249  {
250  type = AttitudeLVLH;
251  }
252 
253  int32_t Init();
254  int32_t Propagate();
255 
256  private:
257  };
258 
260  {
261  public:
262  ThermalPropagator(locstruc *locp, physicsstruc *physp, double idt, float itemperature)
263  : Propagator{ locp, physp, idt }, temperature{itemperature}
264  {
265  type = AttitudeLVLH;
266  newphys->temp = temperature;
268  newphys->radiation = SIGMA * pow(temperature, 4.);
269  for (trianglestruc& triangle : newphys->triangles)
270  {
271  triangle.temp = temperature;
272  triangle.heat = triangle.temp * (triangle.mass * triangle.hcap);
273  }
274  }
275  int32_t Init(float temp);
276  int32_t Propagate();
277 
278  float temperature;
279  };
280 
282  {
283  public:
284  ElectricalPropagator(locstruc *locp, physicsstruc *physp, double idt, float ibattery_charge)
285  : Propagator{ locp, physp, idt }, battery_charge{ibattery_charge}
286  {
287  type = AttitudeLVLH;
288  }
289 
290  int32_t Init(float bp);
291  int32_t Propagate();
292 
294  };
295 
296  class State
297  {
298  public:
303  double dt;
304  double dtj;
309 
314 
317 
320  vector<tlestruc> tle;
321 
324 
325  State();
326  int32_t Init(Propagator *posprop, Propagator *attprop, Propagator *thermprop, Propagator *elecprop);
327  int32_t Init(Structure::Type stype, Propagator::Type ptype, Propagator::Type atype, Propagator::Type ttype, Propagator::Type etype, locstruc *loc, physicsstruc *phys, double idt, vector<tlestruc> lines);
328  int32_t Increment(double nextutc);
329  };
330 
331 
332  double Msis00Density(posstruc pos,float f107avg,float f107,float magidx);
333  Vector GravityAccel(posstruc pos, uint16_t model, uint32_t degree);
334  int32_t GravityParams(int16_t model);
335  double Nplgndr(uint32_t l, uint32_t m, double x);
336 
337  int32_t PosAccel(locstruc* loc, physicsstruc* physics);
338  int32_t AttAccel(locstruc* loc, physicsstruc* physics);
339  int32_t PhysSetup(physicsstruc *phys);
340  int32_t PhysCalc(locstruc* loc, physicsstruc *phys);
341 
342 
343  } //end of namespace Physics
344 } // end of namespace Cosmos
345 
346 #endif // PHYSICSCLASS_H
vector< tlestruc > tle
Definition: physicsclass.h:320
double Msis00Density(posstruc pos, float f107avg, float f107, float magidx)
Calculate atmospheric density.
Definition: physicsclass.cpp:1589
locstruc * newloc
Definition: physicsclass.h:111
Definition: agentclass.cpp:54
vector< vector< int32_t > > binom
Definition: physicsclass.h:202
vector< double > a
Definition: physicsclass.h:192
Definition: physicsclass.h:75
Definition: physicsclass.h:69
physicsstruc * newphys
Definition: physicsclass.h:49
Definition: physicsclass.h:53
double Nplgndr(uint32_t l, uint32_t m, double x)
physicsstruc oldphys
Definition: physicsclass.h:301
vector< vector< double > > alpha
Definition: physicsclass.h:208
locstruc loc
Definition: physicsclass.h:199
Type type
Definition: physicsclass.h:101
y
Definition: inputfile.py:6
float radiation
Definition: jsondef.h:3428
int32_t add_u(double x, double y, double z, ExternalPanelType type)
Definition: physicsclass.cpp:92
Definition: physicsclass.h:55
physicsstruc * newphys
Definition: physicsclass.h:113
Propagator(locstruc *locp, physicsstruc *physp, double idt)
Definition: physicsclass.h:129
3 element generic row vector
Definition: vector.h:53
IterativeAttitudePropagator(locstruc *locp, physicsstruc *physp, double idt)
Definition: physicsclass.h:232
locstruc oldloc
Definition: physicsclass.h:110
vector< double > c
Definition: physicsclass.h:203
Definition: physicsclass.h:244
GaussJacksonPositionPropagator * gjposition
Definition: physicsclass.h:308
ThermalPropagator * thermal
Definition: physicsclass.h:316
Definition: physicsclass.h:66
int32_t add_vertex(Vector point)
Definition: physicsclass.cpp:227
vector< gjstruc > step
Definition: physicsclass.h:211
Definition: physicsclass.h:71
Definition: physicsclass.h:59
Propagator::Type ttype
Definition: physicsclass.h:315
float battery_charge
Definition: physicsclass.h:293
Definition: physicsclass.h:82
Definition: physicsclass.h:72
int32_t Setup(Type type)
Definition: physicsclass.cpp:7
InertialPositionPropagator(locstruc *locp, physicsstruc *physp, double idt)
Definition: physicsclass.h:143
Definition: physicsclass.h:64
rvector sb
Definition: physicsclass.h:197
vector< vector< double > > beta
Definition: physicsclass.h:205
int32_t add_face(string name, Vector point0, Vector point1, Vector point2, Vector point3, double depth, uint8_t external=1, float pcell=.85, Quaternion orientation=Math::Quaternions::eye(), Vector offset=Vector())
Definition: physicsclass.cpp:159
float mass
mass in Kg
Definition: jsondef.h:3303
Definition: physicsclass.h:214
ThermalPropagator(locstruc *locp, physicsstruc *physp, double idt, float itemperature)
Definition: physicsclass.h:262
Definition: physicsclass.h:67
int32_t AttAccel(locstruc *loc, physicsstruc *phys)
Attitude acceleration.
Definition: physicsclass.cpp:1411
Definition: physicsclass.h:281
Physics Simulation Structure.
Definition: jsondef.h:3411
Definition: convertdef.h:733
locstruc * newloc
Definition: physicsclass.h:300
Data Management header file.
rvector tau
Definition: physicsclass.h:198
locstruc oldloc
Definition: physicsclass.h:299
double dt
Definition: physicsclass.h:108
int32_t PosAccel(locstruc *loc, physicsstruc *phys)
Position acceleration.
Definition: physicsclass.cpp:1477
Propagator::Type ptype
Definition: physicsclass.h:305
float temp
Definition: jsondef.h:3426
Definition: physicsclass.h:140
GaussJacksonPositionPropagator(locstruc *locp, physicsstruc *physp, double idt, uint16_t iorder)
Definition: physicsclass.h:175
Type
Definition: physicsclass.h:115
Definition: physicsclass.h:229
int32_t add_cuboid(string name, Vector size, double depth, Quaternion orientation, Vector offset)
Definition: physicsclass.cpp:147
Definition: jsondef.h:3275
vector< double > lam
Definition: physicsclass.h:207
IterativePositionPropagator(locstruc *locp, physicsstruc *physp, double idt)
Definition: physicsclass.h:158
float hcap
Definition: jsondef.h:3424
Definition: physicsclass.h:68
InertialAttitudePropagator * inattitude
Definition: physicsclass.h:311
Propagator::Type etype
Definition: physicsclass.h:318
static uint16_t model
Definition: add_radio.cpp:19
Definition: physicsclass.h:65
double dtsq
Definition: physicsclass.h:209
rvector sa
Definition: physicsclass.h:196
double dt
Definition: physicsclass.h:303
Definition: physicsclass.h:73
Structure::Type stype
Definition: physicsclass.h:322
Headers and definitions common to all COSMOS.
convertlib include file A library providing functions for conversion between the various position and...
string name
Definition: cubesat2obj.cpp:6
Definition: physicsclass.h:63
Propagator::Type atype
Definition: physicsclass.h:310
Definition: physicsclass.h:74
Definition: physicsclass.h:81
Definition: physicsclass.h:56
vector< double > gam
Definition: physicsclass.h:204
ExternalPanelType
Definition: physicsclass.h:79
IterativePositionPropagator * itposition
Definition: physicsclass.h:307
Definition: physicsclass.h:155
Definition: physicsclass.h:83
Structure(physicsstruc *physp)
Definition: physicsclass.h:87
x
Definition: inputfile.py:6
IterativeAttitudePropagator * itattitude
Definition: physicsclass.h:312
timelib include file A library providing functions for handling various types of time.
double dtj
Definition: physicsclass.h:304
Definition: physicsclass.h:46
int32_t GravityParams(int16_t model)
Definition: physicsclass.cpp:1726
uint16_t order
Definition: physicsclass.h:173
Definition: physicsclass.h:61
double dtj
Definition: physicsclass.h:109
Definition: physicsclass.h:54
LVLHAttitudePropagator(locstruc *locp, physicsstruc *physp, double idt)
Definition: physicsclass.h:247
Structure * structure
Definition: physicsclass.h:323
float heat
Definition: jsondef.h:3427
Definition: physicsclass.h:58
physicsstruc * newphys
Definition: physicsclass.h:302
float temperature
Definition: physicsclass.h:278
float mass
Definition: jsondef.h:3425
InertialAttitudePropagator(locstruc *locp, physicsstruc *physp, double idt)
Definition: physicsclass.h:217
Definition: physicsclass.h:70
int32_t PhysSetup(physicsstruc *phys)
Definition: physicsclass.cpp:1369
vector< double > q
Definition: physicsclass.h:206
Definition: physicsclass.h:76
Definition: physicsclass.h:62
Quaternion eye(double scale)
Definition: vector.cpp:2661
Definition: physicsclass.h:60
vector< double > b
Definition: physicsclass.h:193
uint16_t order2
Definition: physicsclass.h:210
float heat
Energy content in Joules.
Definition: jsondef.h:3291
LVLHAttitudePropagator * lvattitude
Definition: physicsclass.h:313
Definition: physicsclass.h:296
Type
Definition: physicsclass.h:51
InertialPositionPropagator * inposition
Definition: physicsclass.h:306
Definition: physicsclass.h:105
ElectricalPropagator(locstruc *locp, physicsstruc *physp, double idt, float ibattery_charge)
Definition: physicsclass.h:284
int32_t add_triangle(Vector pointa, Vector pointb, Vector pointc, double depth, bool external=true, float pcell=.85)
Definition: physicsclass.cpp:207
Vector Class.
Definition: vector.h:672
#define SIGMA
SI Stefan-Boltzmann constant.
Definition: convertdef.h:51
float hcap
Heat Capacity in Joules / (Kg Kelvin)
Definition: jsondef.h:3293
NRLMSISE-00 Extended Support header file.
Definition: physicsclass.h:57
rvector ss
Definition: physicsclass.h:195
float temp
Temperature in Kelvin.
Definition: jsondef.h:3305
Definition: convertdef.h:876
physicsstruc oldphys
Definition: physicsclass.h:112
Definition: physicsclass.h:259
Type type
Definition: physicsclass.h:127
Vector GravityAccel(posstruc pos, uint16_t model, uint32_t degree)
Spherical harmonic gravitational vector.
Definition: physicsclass.cpp:1650
ElectricalPropagator * electrical
Definition: physicsclass.h:319
vector< trianglestruc > triangles
Definition: jsondef.h:3452
Definition: physicsclass.h:84
int32_t PhysCalc(locstruc *loc, physicsstruc *phys)
Definition: physicsclass.cpp:1315