dynInteg.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #include "dynInteg.h"
  2. void dynInteg1(double* dynRhs, double* path, double* x, double* u, double* p, cmscp_auxdata* auxdata) {
  3. // 有动力下惯性姿态角控制
  4. // x:状态变量:地心距、经度、纬度、速度、当地速度倾角、负的当地航迹方位角、质量、时间
  5. // u:相对发惯系的俯仰和偏航角
  6. double A0, lon0, B0, alpha, beta, nu, u1[4] = { 0 }, dynRhs0[8] = { 0 }, path0[5] = { 0 }, state[8] = { 0 };
  7. cmscp_scales* scales;
  8. scales = auxdata->scales;
  9. A0 = auxdata->launchA;
  10. lon0 = auxdata->launchLon;
  11. B0 = auxdata->launchB;
  12. // 有量纲化
  13. state[0] = x[0] * scales->length;
  14. state[1] = x[1];
  15. state[2] = x[2];
  16. state[3] = x[3] * scales->speed;
  17. state[4] = x[4];
  18. state[5] = x[5];
  19. state[6] = x[6] * scales->mass;
  20. state[7] = x[7] * scales->time;
  21. // 控制变量
  22. A_H2B1(&alpha, &beta, &nu,
  23. state[5], state[4], state[2], state[1], u[0], u[1], auxdata->gammaT0,
  24. A0, lon0, B0, state[7]);
  25. u1[0] = auxdata->thrust;
  26. u1[1] = alpha;
  27. u1[2] = beta;
  28. u1[3] = nu;
  29. // 动力学方程
  30. dynamics0(dynRhs0, path0, state, u1, auxdata);
  31. // 输出无量纲化参数
  32. // 动力学右手边项(有可能dynRhs和dynRhs0个数不一样,所以设置两个变量)
  33. if (dynRhs != NULL)
  34. {
  35. dynRhs[0] = dynRhs0[0] / scales->speed;
  36. dynRhs[1] = dynRhs0[1] * scales->time;
  37. dynRhs[2] = dynRhs0[2] * scales->time;
  38. dynRhs[3] = dynRhs0[3] / scales->acceleration;
  39. dynRhs[4] = dynRhs0[4] * scales->time;
  40. dynRhs[5] = dynRhs0[5] * scales->time;
  41. dynRhs[6] = dynRhs0[6] / scales->mass * scales->time;
  42. dynRhs[7] = dynRhs0[7];
  43. }
  44. // 路径约束函数值
  45. if (path != NULL) {
  46. path[0] = path0[0] / scales->length;//高度
  47. path[1] = path0[1] / (scales->density * scales->speed * scales->speed);//动压
  48. path[2] = path0[2];//过载
  49. path[3] = path0[3];//纵程角
  50. path[4] = path0[4];//横程角
  51. }
  52. }
  53. void dynInteg2(double* dynRhs, double* path, double* x, double* u, double* p, cmscp_auxdata* auxdata) {
  54. // 无动力下惯性姿态角控制
  55. // x:状态变量:地心距、经度、纬度、速度、当地速度倾角、负的当地航迹方位角、质量、时间
  56. // u:相对发惯系的俯仰和偏航角
  57. double A0, lon0, B0, u1[4] = { 0 }, dynRhs0[8] = { 0 }, path0[5] = { 0 }, state[8] = { 0 };
  58. cmscp_scales* scales;
  59. scales = auxdata->scales;
  60. A0 = auxdata->launchA;
  61. lon0 = auxdata->launchLon;
  62. B0 = auxdata->launchB;
  63. // 有量纲化
  64. state[0] = x[0] * scales->length;
  65. state[1] = x[1];
  66. state[2] = x[2];
  67. state[3] = x[3] * scales->speed;
  68. state[4] = x[4];
  69. state[5] = x[5];
  70. state[6] = x[6] * scales->mass;
  71. state[7] = x[7] * scales->time;
  72. // 动力学方程
  73. dynamics0(dynRhs0, path0, state, u1, auxdata);
  74. // 输出无量纲化参数
  75. // 动力学右手边项
  76. if (dynRhs!=NULL)
  77. {
  78. dynRhs[0] = dynRhs0[0] / scales->speed;
  79. dynRhs[1] = dynRhs0[1] * scales->time;
  80. dynRhs[2] = dynRhs0[2] * scales->time;
  81. dynRhs[3] = dynRhs0[3] / scales->acceleration;
  82. dynRhs[4] = dynRhs0[4] * scales->time;
  83. dynRhs[5] = dynRhs0[5] * scales->time;
  84. dynRhs[6] = dynRhs0[6] / scales->mass * scales->time;
  85. dynRhs[7] = dynRhs0[7];
  86. }
  87. // 路径约束函数值
  88. if (path != NULL) {
  89. path[0] = path0[0] / scales->length;//高度
  90. path[1] = path0[1] / (scales->density * scales->speed * scales->speed);//动压
  91. path[2] = path0[2];//过载
  92. path[3] = path0[3];//纵程角
  93. path[4] = path0[4];//横程角
  94. }
  95. }
  96. void dynInteg3(double* dynRhs, double* path, double* x, double* u, double* p, cmscp_auxdata* auxdata) {
  97. // 正常再入动力学模型,倾侧角为控制变量
  98. // x:状态变量:地心距、经度、纬度、速度、当地速度倾角、负的当地航迹方位角、质量、时间
  99. // u:倾侧角
  100. double A0, lon0, B0, u1[4] = { 0 }, dynRhs0[8] = { 0 }, path0[5] = { 0 }, state[8] = { 0 };
  101. cmscp_scales* scales;
  102. scales = auxdata->scales;
  103. A0 = auxdata->launchA;
  104. lon0 = auxdata->launchLon;
  105. B0 = auxdata->launchB;
  106. // 有量纲化
  107. state[0] = x[0] * scales->length;
  108. state[1] = x[1];
  109. state[2] = x[2];
  110. state[3] = x[3] * scales->speed;
  111. state[4] = x[4];
  112. state[5] = x[5];
  113. state[6] = x[6] * scales->mass;
  114. state[7] = x[7] * scales->time;
  115. // 控制变量
  116. u1[3] = u[0];
  117. // 动力学方程
  118. dynamics0(dynRhs0, path0, state, u1, auxdata);
  119. // 输出无量纲化参数
  120. // 动力学右手边项
  121. if (dynRhs != NULL)
  122. {
  123. dynRhs[0] = dynRhs0[0] / scales->speed;
  124. dynRhs[1] = dynRhs0[1] * scales->time;
  125. dynRhs[2] = dynRhs0[2] * scales->time;
  126. dynRhs[3] = dynRhs0[3] / scales->acceleration;
  127. dynRhs[4] = dynRhs0[4] * scales->time;
  128. dynRhs[5] = dynRhs0[5] * scales->time;
  129. dynRhs[6] = dynRhs0[6] / scales->mass * scales->time;
  130. dynRhs[7] = dynRhs0[7];
  131. }
  132. // 路径约束函数值
  133. if (path != NULL) {
  134. path[0] = path0[0] / scales->length;//高度
  135. path[1] = path0[1] / (scales->density * scales->speed * scales->speed);//动压
  136. path[2] = path0[2];//过载
  137. path[3] = path0[3];//纵程角
  138. path[4] = path0[4];//横程角
  139. }
  140. }