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,2 @@
|
||||
ROOT = ../../..
|
||||
include $(ROOT)/config/presrc.mk
|
||||
@@ -0,0 +1,3 @@
|
||||
ROOT = ../../../..
|
||||
include $(ROOT)/config/makedef
|
||||
include $(ROOT)/config/exesrc.mk
|
||||
@@ -0,0 +1,181 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libcpropep/include/conversion.h"
|
||||
|
||||
#include "liblrd/include/lrd.h"
|
||||
|
||||
int load_input(char *filename, design_param_t *d, liquid_propellant_t *p)
|
||||
{
|
||||
int section = 0;
|
||||
|
||||
FILE *fd;
|
||||
|
||||
double sp;
|
||||
|
||||
char buffer[128], keyword[64], num[10], qt[10], unit[10];
|
||||
|
||||
char *bufptr;
|
||||
|
||||
fd = fopen(filename, "r");
|
||||
|
||||
if (fd == NULL)
|
||||
return -1;
|
||||
|
||||
while ( fgets(buffer, 128, fd) != NULL )
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
case 0:
|
||||
|
||||
if (buffer[0] == ' ' || buffer[0] == '\n' || buffer[0] == '\0' ||
|
||||
buffer[0] == '#')
|
||||
{
|
||||
section = 0;
|
||||
break;
|
||||
}
|
||||
else if (strncmp(buffer, "Propellant", 10) == 0)
|
||||
{
|
||||
section = 1;
|
||||
}
|
||||
else if (strncmp(buffer, "Parameter", 9) == 0)
|
||||
{
|
||||
section = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unknown keyword 1.\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
if (buffer[0] == '+')
|
||||
{
|
||||
sscanf(buffer, "%s %s", keyword, num);
|
||||
bufptr = keyword + 1;
|
||||
|
||||
sp = atof(num);
|
||||
|
||||
if (strcmp(bufptr, "oxidant") == 0)
|
||||
{
|
||||
p->oxidant = (int) sp;
|
||||
}
|
||||
else if (strcmp(bufptr, "fuel") == 0)
|
||||
{
|
||||
p->fuel = (int) sp;
|
||||
}
|
||||
else if (strcmp(bufptr, "o/f") == 0)
|
||||
{
|
||||
p->o_f_ratio = sp;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unknown keyword 2.\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (buffer[0] == '#')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (buffer[0] == ' ' || buffer[0] == '\n' || buffer[0] == '\0')
|
||||
{
|
||||
section = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
if (buffer[0] == '+')
|
||||
{
|
||||
sscanf(buffer, "%s %s %s", keyword, num, unit);
|
||||
bufptr = keyword + 1;
|
||||
|
||||
sp = atof(num);
|
||||
|
||||
if (strcmp(bufptr, "chamber_pressure") == 0)
|
||||
{
|
||||
if (strcmp(unit, "atm") == 0)
|
||||
{
|
||||
d->chamber_pressure = sp;
|
||||
}
|
||||
else if (strcmp(unit, "psi") == 0)
|
||||
{
|
||||
d->chamber_pressure = sp * PSI_TO_ATM;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unknown unit.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
else if (strcmp(bufptr, "thrust") == 0)
|
||||
{
|
||||
if (strcmp(unit, "N") == 0)
|
||||
{
|
||||
d->thrust = sp;
|
||||
}
|
||||
else if (strcmp(unit, "lbf") == 0)
|
||||
{
|
||||
d->thrust = sp * LBF_TO_N;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unknown unit.\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (strcmp(bufptr, "L*") == 0)
|
||||
{
|
||||
if (strcmp(unit, "m") == 0)
|
||||
{
|
||||
d->Lstar = sp;
|
||||
}
|
||||
else if (strcmp(unit, "in") == 0)
|
||||
{
|
||||
d->Lstar = sp * IN_TO_M;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unknown unit.\n");
|
||||
}
|
||||
}
|
||||
else if (strcmp(bufptr, "Dc/Dt") == 0)
|
||||
{
|
||||
d->Dc_Dt = sp;
|
||||
}
|
||||
else if (strcmp(bufptr, "theta") == 0)
|
||||
{
|
||||
d->theta = sp;
|
||||
}
|
||||
else if (strcmp(bufptr, "r_rt") == 0)
|
||||
{
|
||||
d->R_Rt = sp;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unknown keyword 3.\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (buffer[0] == '#')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (buffer[0] == ' ' || buffer[0] == '\n' || buffer[0] == '\0')
|
||||
{
|
||||
section = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef lrd_load_h
|
||||
#define lrd_load_h
|
||||
|
||||
#include "liblrd/include/lrd.h"
|
||||
|
||||
int load_input(char *filename, design_param_t *d, liquid_propellant_t *p);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "libthermo/include/load.h"
|
||||
#include "libcpropep/include/print.h"
|
||||
#include "libthermo/include/thermo.h"
|
||||
|
||||
#include "lrd_load.h"
|
||||
#include "liblrd/include/lrd.h"
|
||||
|
||||
#define THERMO_FILE "../../data/thermo.dat"
|
||||
#define PROPELLANT_FILE "../../data/propellant.dat"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
liquid_propellant_t p;
|
||||
design_param_t param;
|
||||
motor_t motor_frozen,
|
||||
motor_shifting;
|
||||
|
||||
equilibrium_t *frozen,
|
||||
*shifting;
|
||||
|
||||
|
||||
load_input("input.lr", ¶m, &p);
|
||||
|
||||
/* Initialisation of cpropep lib */
|
||||
errorfile = stdout;
|
||||
outputfile = stdout;
|
||||
|
||||
if (load_thermo (THERMO_FILE) < 0)
|
||||
{
|
||||
printf("Error loading thermodynamic data file.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (load_propellant (PROPELLANT_FILE) < 0)
|
||||
{
|
||||
printf("Error loading propellant data file.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
frozen = (equilibrium_t *) malloc (sizeof(equilibrium_t) * 3);
|
||||
shifting = (equilibrium_t *) malloc (sizeof(equilibrium_t) * 3);
|
||||
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
initialize_equilibrium(frozen + i);
|
||||
initialize_equilibrium(shifting + i);
|
||||
}
|
||||
|
||||
add_in_propellant(frozen, p.fuel, GRAM_TO_MOL(10.0, p.fuel));
|
||||
add_in_propellant(frozen, p.oxidant, GRAM_TO_MOL(10.0 * p.o_f_ratio, p.oxidant));
|
||||
|
||||
copy_equilibrium(shifting, frozen);
|
||||
|
||||
printf("Liquid-fuel rocket engine design (lrd).\n\n");
|
||||
|
||||
LRD_print_propellant_info(&p);
|
||||
LRD_print_design_criteria(¶m);
|
||||
|
||||
frozen->properties.P = param.chamber_pressure;
|
||||
equilibrium(frozen, HP);
|
||||
frozen_performance(frozen, PRESSURE, 1);
|
||||
|
||||
LRD_compute_caracteristics(frozen, ¶m, &motor_frozen, &p);
|
||||
|
||||
shifting->properties.P = param.chamber_pressure;
|
||||
equilibrium(shifting, HP);
|
||||
shifting_performance(shifting, PRESSURE, 1);
|
||||
|
||||
LRD_compute_caracteristics(shifting, ¶m, &motor_shifting, &p);
|
||||
|
||||
LRD_print_design_information(&motor_frozen, &motor_shifting);
|
||||
|
||||
printf("\nFrozen equilibrium caracteristics.\n\n");
|
||||
print_product_properties(frozen, 3);
|
||||
print_performance_information(frozen, 3);
|
||||
print_product_composition(frozen, 3);
|
||||
|
||||
printf("\nShifting equilibrium caracteristics.\n\n");
|
||||
print_product_properties(shifting, 3);
|
||||
print_performance_information(shifting, 3);
|
||||
print_product_composition(shifting, 3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
LIB = -lcpropep -lthermo -lnum -llrd -lm
|
||||
PROG = lrd
|
||||
OBJS = main.o lrd_load.o
|
||||
Reference in New Issue
Block a user