Initial commit of "Rocket Workbench".
Taken from sources in CVS at:
https://sourceforge.net/projects/rocketworkbench/
Sources extracted in two steps:
1. Pull entire project tree into a subdir "rwb" via "rsync":
rsync -a a.cvs.sourceforge.net::cvsroot/rocketworkbench/ rwb/.
2. Export sources:
export CVSROOT=$(pwd)/rwb
SUBDIRS="analyser cpropep cpropep-web CVSROOT data libcompat libcpropep libnum libsimulation libthermo prop rocketworkbench rockflight"
mkdir rwbx; cd rwbx
cvs export -D now ${SUBDIRS}
After this (and some backups for safety), the directory content was
added to a Git repo:
git init .
git add *
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#ifndef const_h
|
||||
#define const_h
|
||||
|
||||
/* molar gaz constant in J/(mol K)*/
|
||||
#define R 8.31451
|
||||
|
||||
/* earth gravitational acceleration */
|
||||
#define Ge 9.80665
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef conversion_h
|
||||
#define conversion_h
|
||||
|
||||
|
||||
/* pressure units */
|
||||
enum
|
||||
{
|
||||
ATM,
|
||||
PSI,
|
||||
BAR,
|
||||
KPA
|
||||
};
|
||||
|
||||
/* Transform calories to joules */
|
||||
#define CAL_TO_JOULE 4.1868
|
||||
|
||||
/* Transform pound/(cubic inch) to gram/(cubic centimeter) */
|
||||
#define LBS_IN3_TO_G_CM3 27.679905
|
||||
|
||||
/* Transform different pressure units */
|
||||
|
||||
#define ATM_TO_PA 101325.0
|
||||
#define ATM_TO_PSI 14.695949
|
||||
#define ATM_TO_BAR 1.01325
|
||||
|
||||
#define BAR_TO_PSI 14.503774
|
||||
|
||||
#define BAR_TO_ATM 0.98692327
|
||||
#define PSI_TO_ATM 0.068045964
|
||||
#define KPA_TO_ATM 0.0098692327
|
||||
|
||||
/* Length */
|
||||
|
||||
#define M_TO_CM 100.0
|
||||
#define M_TO_IN 39.370079
|
||||
|
||||
#define IN_TO_M 0.0254
|
||||
|
||||
/* Surface */
|
||||
|
||||
#define M2_TO_CM2 10000.0
|
||||
#define M2_TO_IN2 1550.0031
|
||||
|
||||
/* Volume */
|
||||
|
||||
#define M3_TO_CM3 1000000.0
|
||||
#define M3_TO_IN3 61023.744
|
||||
|
||||
/* Mass flow */
|
||||
|
||||
#define KG_S_TO_LB_S 2.2046226
|
||||
|
||||
|
||||
/* force */
|
||||
|
||||
/* newton to pound-force */
|
||||
#define N_TO_LBF 0.22480894
|
||||
#define LBF_TO_N 4.4482216
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef derivative_h
|
||||
#define derivative_h
|
||||
|
||||
#include "equilibrium.h"
|
||||
|
||||
int derivative(equilibrium_t *e);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,156 @@
|
||||
#ifndef equilibrium_h
|
||||
#define equilibrium_h
|
||||
/* equilibrium.h - Calculation of Complex Chemical Equilibrium */
|
||||
/* $Id: equilibrium.h,v 1.1 2000/10/13 19:24:31 antoine Exp $ */
|
||||
/* Copyright (C) 2000 */
|
||||
/* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
|
||||
/* Mark Pinese <pinese@cyberwizards.com.au> */
|
||||
/* */
|
||||
/* Licensed under the GPLv2 */
|
||||
|
||||
#include "compat.h"
|
||||
#include "type.h"
|
||||
|
||||
#define GRAM_TO_MOL(g, sp) g/propellant_molar_mass(sp)
|
||||
|
||||
#define _min(a, b, c) __min( __min(a, b), c)
|
||||
#define _max(a, b, c) __max( __max(a, b), c)
|
||||
|
||||
extern int global_verbose;
|
||||
|
||||
|
||||
/***************************************************************
|
||||
FUNCTION PROTOTYPE SECTION
|
||||
****************************************************************/
|
||||
|
||||
int set_verbose(equilibrium_t *e, int v);
|
||||
|
||||
/************************************************************
|
||||
FUNCTION: This function search for all elements present in
|
||||
the composition and fill the list with the
|
||||
corresponding number.
|
||||
|
||||
PARAMETER: e is of type equilibrium_t and hold the information
|
||||
about the propellant composition.
|
||||
|
||||
COMMENTS: It fill the member element in equilibrium_t
|
||||
|
||||
DATE: February 6, 2000
|
||||
|
||||
AUTHOR: Antoine Lefebvre
|
||||
**************************************************************/
|
||||
int list_element(equilibrium_t *e);
|
||||
int reset_element_list(equilibrium_t *e);
|
||||
|
||||
int list_product(equilibrium_t *e);
|
||||
|
||||
/***************************************************************
|
||||
FUNCTION: This function initialize the equilibrium structure.
|
||||
The function allocate memory for all the structure
|
||||
it need. It is important to call dealloc_equilibrium
|
||||
after.
|
||||
|
||||
AUTHOR: Antoine Lefebvre
|
||||
|
||||
DATE: February 27, 2000
|
||||
****************************************************************/
|
||||
int initialize_equilibrium(equilibrium_t *e);
|
||||
|
||||
|
||||
/***************************************************************
|
||||
FUNCTION: Dealloc what have been allocated by
|
||||
initialize_equilibrium
|
||||
***************************************************************/
|
||||
int dealloc_equilibrium(equilibrium_t *e);
|
||||
|
||||
int reset_equilibrium(equilibrium_t *e);
|
||||
|
||||
int copy_equilibrium(equilibrium_t *dest, equilibrium_t *src);
|
||||
|
||||
int compute_thermo_properties(equilibrium_t *e);
|
||||
|
||||
/***************************************************************
|
||||
FUNCTION: Set the state at which we want to compute the
|
||||
equilibrium.
|
||||
|
||||
PARAMETER: e is a pointer to an equilibrium_t structure
|
||||
T is the temperature in deg K
|
||||
P is the pressure in atm
|
||||
|
||||
AUTHOR: Antoine Lefebvre
|
||||
****************************************************************/
|
||||
int set_state(equilibrium_t *e, double T, double P);
|
||||
|
||||
|
||||
/***************************************************************
|
||||
FUNCTION: Add a new molecule in the propellant
|
||||
|
||||
PARAMETER: e is a pointer to the equilibrium_t structure
|
||||
sp is the number of the molecule in the list
|
||||
mol is the quantity in mol
|
||||
|
||||
AUTHOR: Antoine Lefebvre
|
||||
****************************************************************/
|
||||
int add_in_propellant(equilibrium_t *e, int sp, double mol);
|
||||
|
||||
/***************************************************************
|
||||
FUNCTION: Return the stochiometric coefficient of an element
|
||||
in a molecule. If the element isn't present, it return 0.
|
||||
|
||||
COMMENTS: There is a different function for the product and for the
|
||||
propellant.
|
||||
|
||||
AUTHOR: Antoine Lefebvre
|
||||
****************************************************************/
|
||||
int product_element_coef(int element, int molecule);
|
||||
//int propellant_element_coef(int element, int molecule);
|
||||
|
||||
|
||||
|
||||
/***************************************************************
|
||||
FUNCTION: This function fill the matrix in function of the data
|
||||
store in the structure equilibrium_t. The solution
|
||||
of this matrix give corresction to initial estimate.
|
||||
|
||||
COMMENTS: It use the theory explain in
|
||||
"Computer Program for Calculation of Complex Chemical
|
||||
Equilibrium Compositions, Rocket Performance, Incident
|
||||
and Reflected Shocks, and Chapman-Jouguet Detonations"
|
||||
by Gordon and McBride
|
||||
|
||||
AUTHOR: Antoine Lefebvre
|
||||
****************************************************************/
|
||||
|
||||
|
||||
//#ifdef TRUE_ARRAY
|
||||
//int fill_equilibrium_matrix(double *matrix, equilibrium_t *e, problem_t P);
|
||||
int fill_matrix(double *matrix, equilibrium_t *e, problem_t P);
|
||||
//#else
|
||||
//int fill_equilibrium_matrix(double **matrix, equilibrium_t *e, problem_t P);
|
||||
//int fill_matrix(double **matrix, equilibrium_t *e, problem_t P);
|
||||
//#endif
|
||||
|
||||
|
||||
/****************************************************************
|
||||
FUNCTION: This function compute the equilibrium composition at
|
||||
at specific pressure/temperature point. It use fill_matrix
|
||||
to obtain correction to initial estimate. It correct the
|
||||
value until equilibrium is obtain.
|
||||
|
||||
AUTHOR: Antoine Lefebvre
|
||||
******************************************************************/
|
||||
int equilibrium(equilibrium_t *equil, problem_t P);
|
||||
|
||||
|
||||
double product_molar_mass(equilibrium_t *e);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
#ifndef performance_h
|
||||
#define performance_h
|
||||
|
||||
#include "compat.h"
|
||||
#include "return.h"
|
||||
|
||||
#include "equilibrium.h"
|
||||
#include "derivative.h"
|
||||
|
||||
|
||||
int frozen_performance(equilibrium_t *e, exit_condition_t exit_type,
|
||||
double value);
|
||||
int shifting_performance(equilibrium_t *e, exit_condition_t exit_type,
|
||||
double value);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#ifndef print_h
|
||||
#define print_h
|
||||
|
||||
#include "type.h"
|
||||
|
||||
#include "equilibrium.h"
|
||||
#include "derivative.h"
|
||||
#include "performance.h"
|
||||
|
||||
#define PROPELLANT_NAME(sp) (propellant_list + sp)->name
|
||||
|
||||
extern FILE * errorfile;
|
||||
extern FILE * outputfile;
|
||||
|
||||
int print_error_message(int error_code);
|
||||
|
||||
/***************************************************************
|
||||
FUNCTION: Print the information of a specie in the thermo_list
|
||||
|
||||
PARAMETER: an integer corresponding to the molecule
|
||||
|
||||
AUTHOR: Antoine Lefebvre
|
||||
***************************************************************/
|
||||
int print_propellant_info(int sp);
|
||||
int print_thermo_info(int sp);
|
||||
|
||||
|
||||
/*************************************************************
|
||||
FUNCTION: Print the content of the respective list with the
|
||||
number which refer to the molecule
|
||||
|
||||
AUTHOR: Antoine Lefebvre
|
||||
modification by Mark Pinese
|
||||
**************************************************************/
|
||||
int print_thermo_list(void);
|
||||
int print_propellant_list(void);
|
||||
|
||||
/*************************************************************
|
||||
FUNCTION: Print the list of condensed species in the product
|
||||
|
||||
PARAMETER: a structure of tupe product_t
|
||||
|
||||
AUTHOR: Antoine Lefebvre
|
||||
**************************************************************/
|
||||
int print_condensed(product_t p);
|
||||
|
||||
|
||||
|
||||
/*************************************************************
|
||||
FUNCTION: Print the list of gazeous species in the product
|
||||
|
||||
PARAMETER: a structure of tupe product_t
|
||||
|
||||
AUTHOR: Antoine Lefebvre
|
||||
**************************************************************/
|
||||
int print_gazeous(product_t p);
|
||||
|
||||
int print_product_composition(equilibrium_t *e, short npt);
|
||||
|
||||
int print_product_properties(equilibrium_t *e, short npt);
|
||||
|
||||
int print_propellant_composition(equilibrium_t *e);
|
||||
|
||||
//int print_derivative_results(deriv_t *d);
|
||||
//int print_performance_information(performance_t *p);
|
||||
|
||||
int print_performance_information(equilibrium_t *e, short npt);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef RETURN_H
|
||||
#define RETURN_H
|
||||
|
||||
/* Codes used in some functions by Antoine Lefebvre */
|
||||
#define SUCCESS 0
|
||||
#define ERROR -1
|
||||
|
||||
/*
|
||||
Return codes
|
||||
Mark Pinese 24/4/2000
|
||||
*/
|
||||
|
||||
#define ERR_MALLOC -1
|
||||
#define ERR_FOPEN -2
|
||||
#define ERR_EOF -3
|
||||
#define ERR_NOT_ALLOC -4
|
||||
#define ERR_TOO_MUCH_PRODUCT -5
|
||||
#define ERR_EQUILIBRIUM -6
|
||||
#define ERR_AERA_RATIO -7
|
||||
#define ERR_RATIO_TYPE -8
|
||||
|
||||
#endif /* !defined(RETURN_H) */
|
||||
@@ -0,0 +1,161 @@
|
||||
#ifndef type_h
|
||||
#define type_h
|
||||
|
||||
#define MAX_PRODUCT 400 /* Maximum species in product */
|
||||
#define MAX_ELEMENT 15 /* Maximum different element */
|
||||
#define MAX_COMP 20 /* Maximum different ingredient in
|
||||
composition */
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
/****************************************************************
|
||||
TYPE: Enumeration of the possible state of a substance
|
||||
*****************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
GAS,
|
||||
CONDENSED,
|
||||
STATE_LAST
|
||||
} state_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TP, /* assign temperature and pressure */
|
||||
HP, /* assign enthalpy and pressure */
|
||||
SP /* assign entropy and pressure */
|
||||
} problem_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SUBSONIC_AREA_RATIO,
|
||||
SUPERSONIC_AREA_RATIO,
|
||||
PRESSURE
|
||||
} exit_condition_t;
|
||||
|
||||
|
||||
/********************************************
|
||||
Note: Specific impulse have unit of m/s
|
||||
Ns/kg = (kg m / s^2) * (s / kg)
|
||||
= (m / s)
|
||||
|
||||
It is habitual to found in literature
|
||||
specific impulse in units of second.
|
||||
It is in reality Isp/g where g is
|
||||
the earth acceleration.
|
||||
**********************************************/
|
||||
typedef struct _performance_prop
|
||||
{
|
||||
double ae_at; /* Exit aera / Throat aera */
|
||||
double a_dotm; /* Exit aera / mass flow rate (m/s/atm) */
|
||||
double cstar; /* Characteristic velocity */
|
||||
double cf; /* Coefficient of thrust */
|
||||
double Ivac; /* Specific impulse (vacuum) */
|
||||
double Isp; /* Specific impulse */
|
||||
|
||||
} performance_prop_t;
|
||||
|
||||
|
||||
/***************************************************************
|
||||
TYPE: Hold the composition of a specific propellant
|
||||
ncomp is the number of component
|
||||
molecule[ ] hold the number in propellant_list corresponding
|
||||
to the molecule
|
||||
coef[ ] hold the stochiometric coefficient
|
||||
|
||||
NOTE: It should be great to allocate the memory of the array in
|
||||
function of the number of element
|
||||
|
||||
DATE: February 6, 2000
|
||||
****************************************************************/
|
||||
typedef struct _composition
|
||||
{
|
||||
short ncomp; /* Number of different component */
|
||||
short molecule[MAX_COMP]; /* Molecule code */
|
||||
double coef[MAX_COMP]; /* Moles of molecule */
|
||||
double density; /* Density of propellant */
|
||||
} composition_t;
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
TYPE: Hold the composition of the combustion product. The molecule
|
||||
are separate between their different possible state.
|
||||
|
||||
NOTE: This structure should be initialize with the function
|
||||
initialize_product.
|
||||
|
||||
DATE: February 13, 2000
|
||||
******************************************************************/
|
||||
typedef struct _product
|
||||
{
|
||||
bool element_listed; /* true if element have been listed */
|
||||
bool product_listed; /* true if product have been listed */
|
||||
bool isequil; /* true if equilibrium is ok */
|
||||
|
||||
/* coefficient matrix for the gases */
|
||||
unsigned short A[MAX_ELEMENT][MAX_PRODUCT];
|
||||
|
||||
short n_element; /* n. of different element */
|
||||
short element[MAX_ELEMENT]; /* element list */
|
||||
short n[STATE_LAST]; /* n. of species for each state */
|
||||
short n_condensed; /* n. of total possible condensed */
|
||||
short species[STATE_LAST][MAX_PRODUCT]; /* possible species in each state */
|
||||
double coef[STATE_LAST][MAX_PRODUCT]; /* coef. of each molecule */
|
||||
|
||||
} product_t;
|
||||
|
||||
/* Structure to hold information during the iteration procedure */
|
||||
typedef struct _iteration_var
|
||||
{
|
||||
double n; /* mol/g of the mixture */
|
||||
double ln_n; /* ln(n) */
|
||||
double sumn; /* sum of all the nj */
|
||||
double delta_ln_n; /* delta ln(n) in the iteration process */
|
||||
double delta_ln_T; /* delta ln(T) in the iteration process */
|
||||
double delta_ln_nj[MAX_PRODUCT]; /* delta ln(nj) in the iteration process */
|
||||
double ln_nj[MAX_PRODUCT]; /* ln(nj) nj are the individual mol/g */
|
||||
|
||||
} iteration_var_t;
|
||||
|
||||
/**********************************************
|
||||
Hold information on equilibrium properties once
|
||||
it have been compute
|
||||
|
||||
June 14, 2000
|
||||
***********************************************/
|
||||
typedef struct _equilib_prop
|
||||
{
|
||||
double P; /* Pressure (atm) */
|
||||
double T; /* Temperature (K) */
|
||||
double H; /* Enthalpy (kJ/kg) */
|
||||
double U; /* Internal energy (kJ/kg) */
|
||||
double G; /* Gibbs free energy (kJ/kg) */
|
||||
double S; /* Entropy (kJ/(kg)(K)) */
|
||||
double M; /* Molar mass (g/mol) */
|
||||
double dV_P; /* (d ln(V) / d ln(P))t */
|
||||
double dV_T; /* (d ln(V) / d ln(T))p */
|
||||
double Cp; /* Specific heat (kJ/(kg)(K)) */
|
||||
double Cv; /* Specific heat (kJ/(kg)(K)) */
|
||||
double Isex; /* Isentropic exponent (gamma) */
|
||||
double Vson; /* Sound speed (m/s) */
|
||||
} equilib_prop_t;
|
||||
|
||||
|
||||
typedef struct _new_equilibrium
|
||||
{
|
||||
bool equilibrium_ok; /* true if the equilibrium have been compute */
|
||||
bool properties_ok; /* true if the properties have been compute */
|
||||
bool performance_ok; /* true if the performance have been compute */
|
||||
|
||||
//temporarily
|
||||
double entropy;
|
||||
|
||||
iteration_var_t itn;
|
||||
composition_t propellant;
|
||||
product_t product;
|
||||
equilib_prop_t properties;
|
||||
performance_prop_t performance;
|
||||
|
||||
} equilibrium_t;
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user