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.

156 lines
5.1 KiB

  1. #ifndef equilibrium_h
  2. #define equilibrium_h
  3. /* equilibrium.h - Calculation of Complex Chemical Equilibrium */
  4. /* $Id: equilibrium.h,v 1.1.1.1 2001/07/20 03:19:06 antoine Exp $ */
  5. /* Copyright (C) 2000 */
  6. /* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
  7. /* Mark Pinese <pinese@cyberwizards.com.au> */
  8. /* */
  9. /* Licensed under the GPLv2 */
  10. #include "libcompat/include/compat.h"
  11. #include "type.h"
  12. #define GRAM_TO_MOL(g, sp) g/propellant_molar_mass(sp)
  13. #define _min(a, b, c) __min( __min(a, b), c)
  14. #define _max(a, b, c) __max( __max(a, b), c)
  15. extern int global_verbose;
  16. /***************************************************************
  17. FUNCTION PROTOTYPE SECTION
  18. ****************************************************************/
  19. int set_verbose(equilibrium_t *e, int v);
  20. /************************************************************
  21. FUNCTION: This function search for all elements present in
  22. the composition and fill the list with the
  23. corresponding number.
  24. PARAMETER: e is of type equilibrium_t and hold the information
  25. about the propellant composition.
  26. COMMENTS: It fill the member element in equilibrium_t
  27. DATE: February 6, 2000
  28. AUTHOR: Antoine Lefebvre
  29. **************************************************************/
  30. int list_element(equilibrium_t *e);
  31. int reset_element_list(equilibrium_t *e);
  32. int list_product(equilibrium_t *e);
  33. /***************************************************************
  34. FUNCTION: This function initialize the equilibrium structure.
  35. The function allocate memory for all the structure
  36. it need. It is important to call dealloc_equilibrium
  37. after.
  38. AUTHOR: Antoine Lefebvre
  39. DATE: February 27, 2000
  40. ****************************************************************/
  41. int initialize_equilibrium(equilibrium_t *e);
  42. /***************************************************************
  43. FUNCTION: Dealloc what have been allocated by
  44. initialize_equilibrium
  45. ***************************************************************/
  46. int dealloc_equilibrium(equilibrium_t *e);
  47. int reset_equilibrium(equilibrium_t *e);
  48. int copy_equilibrium(equilibrium_t *dest, equilibrium_t *src);
  49. int compute_thermo_properties(equilibrium_t *e);
  50. /***************************************************************
  51. FUNCTION: Set the state at which we want to compute the
  52. equilibrium.
  53. PARAMETER: e is a pointer to an equilibrium_t structure
  54. T is the temperature in deg K
  55. P is the pressure in atm
  56. AUTHOR: Antoine Lefebvre
  57. ****************************************************************/
  58. int set_state(equilibrium_t *e, double T, double P);
  59. /***************************************************************
  60. FUNCTION: Add a new molecule in the propellant
  61. PARAMETER: e is a pointer to the equilibrium_t structure
  62. sp is the number of the molecule in the list
  63. mol is the quantity in mol
  64. AUTHOR: Antoine Lefebvre
  65. ****************************************************************/
  66. int add_in_propellant(equilibrium_t *e, int sp, double mol);
  67. /***************************************************************
  68. FUNCTION: Return the stochiometric coefficient of an element
  69. in a molecule. If the element isn't present, it return 0.
  70. COMMENTS: There is a different function for the product and for the
  71. propellant.
  72. AUTHOR: Antoine Lefebvre
  73. ****************************************************************/
  74. int product_element_coef(int element, int molecule);
  75. /*int propellant_element_coef(int element, int molecule);*/
  76. /***************************************************************
  77. FUNCTION: This function fill the matrix in function of the data
  78. store in the structure equilibrium_t. The solution
  79. of this matrix give corresction to initial estimate.
  80. COMMENTS: It use the theory explain in
  81. "Computer Program for Calculation of Complex Chemical
  82. Equilibrium Compositions, Rocket Performance, Incident
  83. and Reflected Shocks, and Chapman-Jouguet Detonations"
  84. by Gordon and McBride
  85. AUTHOR: Antoine Lefebvre
  86. ****************************************************************/
  87. /*#ifdef TRUE_ARRAY*/
  88. /*int fill_equilibrium_matrix(double *matrix, equilibrium_t *e, problem_t P);*/
  89. int fill_matrix(double *matrix, equilibrium_t *e, problem_t P);
  90. /*#else*/
  91. /*int fill_equilibrium_matrix(double **matrix, equilibrium_t *e, problem_t P);*/
  92. /*int fill_matrix(double **matrix, equilibrium_t *e, problem_t P);*/
  93. /*#endif*/
  94. /****************************************************************
  95. FUNCTION: This function compute the equilibrium composition at
  96. at specific pressure/temperature point. It use fill_matrix
  97. to obtain correction to initial estimate. It correct the
  98. value until equilibrium is obtain.
  99. AUTHOR: Antoine Lefebvre
  100. ******************************************************************/
  101. int equilibrium(equilibrium_t *equil, problem_t P);
  102. double product_molar_mass(equilibrium_t *e);
  103. #endif