Based on the original Rocket Workbench on SourceForge in CVS at: https://sourceforge.net/projects/rocketworkbench
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
2.3 KiB

  1. #ifndef __state_h__
  2. #define __state_h__
  3. typedef double real;
  4. typedef real scalar_t;
  5. typedef real vector_t[3];
  6. typedef real matrix_t[3][3];
  7. typedef enum
  8. {
  9. _CONSTANT,
  10. _FUNCTION,
  11. _TABLE
  12. } val_t;
  13. typedef enum
  14. {
  15. ALT,
  16. MACH,
  17. AOA,
  18. TIME
  19. } parameter_t;
  20. typedef struct _function
  21. {
  22. char *name;
  23. val_t type;
  24. /* if type is _CONSTANT */
  25. float constant_value;
  26. /* if type is _TABLE */
  27. int n_point;
  28. parameter_t independant_var;
  29. float *x, *y;
  30. /* if type is _FUNCTION */
  31. char *function;
  32. } function_t;
  33. typedef struct state
  34. {
  35. int s; /* active stage */
  36. scalar_t m; /* mass of the rocket */
  37. scalar_t g; /* gravitational acceleration */
  38. scalar_t Ix;
  39. scalar_t Iy;
  40. scalar_t Iz;
  41. /* */
  42. scalar_t alt;
  43. scalar_t aoa;
  44. scalar_t mach;
  45. /* aerodynamic coefficients */
  46. scalar_t Cd;
  47. scalar_t CL;
  48. scalar_t CB;
  49. scalar_t Cspin;
  50. scalar_t Cmoment;
  51. scalar_t Cdamping;
  52. scalar_t D; /* Diameter of the rocket */
  53. scalar_t A; /* reference area (m^2) */
  54. scalar_t C; /* reference distance */
  55. /* aerodynamic forces */
  56. vector_t Faero; /* (X, Y, Z) */
  57. /* moments */
  58. vector_t Maero; /* (L, M, N) */
  59. /* engine forces and moments */
  60. vector_t Feng;
  61. vector_t Meng;
  62. /* component of centripetal acceleration in F_B */
  63. scalar_t Cx;
  64. scalar_t Cy;
  65. scalar_t Cz;
  66. /* earth angular velocity in F_B */
  67. scalar_t pE;
  68. scalar_t qE;
  69. scalar_t rE;
  70. /* relative angular velocity of F_B to F_V */
  71. scalar_t P;
  72. scalar_t Q;
  73. scalar_t R;
  74. matrix_t L_BV;
  75. matrix_t L_VB;
  76. } state_t;
  77. typedef struct engine
  78. {
  79. float propellant_mass;
  80. float dry_mass;
  81. function_t thrust;
  82. float c;
  83. float mass_flow;
  84. float start_time;
  85. float burn_time;
  86. float drop_time;
  87. float position[3];
  88. float direction[3];
  89. } engine_t;
  90. typedef struct rocket_properties
  91. {
  92. float dry_mass;
  93. function_t Ix;
  94. function_t Iy;
  95. function_t Iz;
  96. function_t Cd;
  97. function_t CL;
  98. function_t CB;
  99. float Cspin;
  100. float Cmoment;
  101. float Cdamping;
  102. float Diameter;
  103. float active_time;
  104. int n_engine;
  105. engine_t *engines;
  106. } rocket_properties_t;
  107. typedef struct rocket
  108. {
  109. int n_stage;
  110. rocket_properties_t *stage_properties;
  111. state_t state;
  112. } rocket_t;
  113. typedef struct solution
  114. {
  115. float duration;
  116. float dt;
  117. float precision;
  118. } solution_t;
  119. #endif /* __state_h__ */