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,43 @@
|
||||
CXX = g++
|
||||
CC = gcc
|
||||
CXXFLAGS = -g -Wall
|
||||
CFLAG = -g -Wall
|
||||
|
||||
|
||||
LEXER = motor
|
||||
|
||||
CXXSRC = simulation.cc modeles.cc rocket.cc lsode.cc rk4.cc
|
||||
CXXOBJS = simulation.o modeles.o rocket.o lsode.o rk4.o
|
||||
|
||||
|
||||
COBJS = motor.yy.o
|
||||
|
||||
LIBNAME = librocket.a
|
||||
|
||||
.SUFFIXES: .cc
|
||||
|
||||
.cc.o:
|
||||
$(CXX) $(DEF) $(INCLUDE) $(CXXFLAGS) -c $*.cc -o $*.o
|
||||
|
||||
$(LIBNAME): $(CXXOBJS) $(COBJS)
|
||||
ar -r $@ $(CXXOBJS) $(COBJS)
|
||||
ranlib $@
|
||||
|
||||
$(COBJS): $(LEXER).yy.c
|
||||
$(CXX) $(CFLAG) -c $< -o $@
|
||||
|
||||
$(LEXER).yy.c: $(LEXER).l
|
||||
flex -o$(LEXER).yy.c $<
|
||||
|
||||
clean:
|
||||
rm -f *.o *~
|
||||
|
||||
clean-all: clean
|
||||
rm $(LIBNAME)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
1- There is a memory leak in the lexer. I don't find how to free the
|
||||
buffer that was allocated by flex...
|
||||
@@ -0,0 +1,51 @@
|
||||
/* c++rocket.h - Simulation of rocket flight */
|
||||
/* Copyright (C) 2000 */
|
||||
/* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
|
||||
|
||||
/* This program is free software; you can redistribute it and/or modify*/
|
||||
/* it under the terms of the GNU General Public License as published by*/
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (cxx_rocket_h)
|
||||
#define cxx_rocket_h 1
|
||||
|
||||
class simulation;
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#define MAXPROP 3 // Maximum number of stage on the rocket
|
||||
|
||||
// pointer to the actual simulation
|
||||
extern simulation *simptr;
|
||||
|
||||
extern const double R; // Perfect gaz constant
|
||||
extern const double g; // Earth gravitational accélération
|
||||
extern const double G; // universal gravitational constant
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AERO_MODEL,
|
||||
SIMPLE_MODEL,
|
||||
MODEL_LAST
|
||||
} Model_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include "lsode.h"
|
||||
//#include "simulation.h"
|
||||
#include "c++rocket.h"
|
||||
|
||||
//typedef int (* ModelFunc)(const int &, const double &, double *,
|
||||
// double *, int &);
|
||||
|
||||
char *error_msg(State s);
|
||||
|
||||
static int ModelNeq[MODEL_LAST] = { 7, 5 };
|
||||
|
||||
lsode::lsode(Model_t model) {
|
||||
|
||||
memory = 0;
|
||||
|
||||
neq = ModelNeq[model];
|
||||
//dy = new double*[7];
|
||||
time = 0.0;
|
||||
|
||||
itol = 1;
|
||||
rtol = 1.49012e-08;
|
||||
atol = 1.49012e-08;
|
||||
itask = 1;
|
||||
istate = 1;
|
||||
iopt = 0;
|
||||
|
||||
rwork = new double[20+16*neq];
|
||||
lrw = 20+16*neq;
|
||||
iwork = new int[20];
|
||||
liw = 20;
|
||||
mf = 10;
|
||||
state = new double[neq];
|
||||
|
||||
if (!rwork) {
|
||||
cout << "Allocation error\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
switch (model)
|
||||
{
|
||||
case AERO_MODEL:
|
||||
md = model_1;
|
||||
break;
|
||||
case SIMPLE_MODEL:
|
||||
md = model_2;
|
||||
break;
|
||||
default:
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
lsode::~lsode() {
|
||||
|
||||
if (memory) {
|
||||
for (int j = 0; j < neq; j++)
|
||||
delete [] dy[j];
|
||||
delete dy;
|
||||
}
|
||||
|
||||
delete [] state;
|
||||
delete [] iwork;
|
||||
delete [] rwork;
|
||||
cout << "Freeing memory...\n" ;
|
||||
}
|
||||
|
||||
int lsode::solve(double *st, double duration, double step)
|
||||
{
|
||||
reset();
|
||||
|
||||
if (memory) {
|
||||
for (int j = 0; j < neq; j++)
|
||||
delete [] dy[j];
|
||||
delete dy;
|
||||
|
||||
memory = 0;
|
||||
}
|
||||
|
||||
length = (int)rint(duration/step);
|
||||
|
||||
// on alloue la memoire
|
||||
dy = new double*[neq];
|
||||
for (int j = 0; j < neq; j++)
|
||||
dy[j] = new double[length];
|
||||
|
||||
memory = 1; // pour indiquer que l'on a alloue la memoire
|
||||
|
||||
// on simule et on remplie l'array
|
||||
for (int i = 0; i < length; i++) {
|
||||
tout = i*step;
|
||||
|
||||
|
||||
lsode_((ModelFunc_t)md, neq, st, time, tout, itol, rtol, atol,
|
||||
itask, istate, iopt, rwork, lrw, iwork, liw, NULL, mf);
|
||||
|
||||
for (int j = 0; j < neq ; j++)
|
||||
dy[j][i] = st[j];
|
||||
|
||||
if (istate < 0) // if any error, stop the simulation
|
||||
{
|
||||
cout << "ERROR: " << error_msg ((State)istate) << endl;
|
||||
cout << i << " points out of " << length << " were found."
|
||||
<< endl;
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cout << "Simulation completed successfully." << endl;
|
||||
cout << length << " " << "points computed" << endl;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
void lsode::reset()
|
||||
{
|
||||
tout = 0.0; // restart the simulation at 0
|
||||
time = 0.0; // restart the time at 0
|
||||
istate = 1; // should reset the istate
|
||||
}
|
||||
|
||||
void lsode::print() {
|
||||
for (int i = 0; i < length; i++) {
|
||||
for (int j = 0; j < neq; j++) {
|
||||
cout << dy[j][i] << "\t";
|
||||
}
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lsode::get_data(double** a)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
for (int j = 0; j < neq; j++)
|
||||
a[j][i] = dy[j][i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char *error_msg(State s)
|
||||
{
|
||||
switch (s)
|
||||
{
|
||||
case TOO_MUCH_WORK:
|
||||
return "Excess work done on this call (perhaps wrong mf).";
|
||||
break;
|
||||
|
||||
case TOO_MUCH_ACC:
|
||||
return "Excess Accuracy Requested (Tolerances too small).";
|
||||
break;
|
||||
|
||||
case ILLEGAL_INPUT:
|
||||
return "Illegal input detected.";
|
||||
break;
|
||||
|
||||
case ERR_FAILURE:
|
||||
return "Repeated error test failures.";
|
||||
break;
|
||||
|
||||
case CONV_FAILURE:
|
||||
return "Repeated convergence failures.";
|
||||
break;
|
||||
|
||||
case ERROR_WEIGHT:
|
||||
return "Error weight became zero during problem.";
|
||||
break;
|
||||
|
||||
case EXIT_IN_FUNCTION:
|
||||
return "Exit requested in ode function.";
|
||||
break;
|
||||
|
||||
default:
|
||||
return "Unrecognize error state.";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
#if !defined (lsode_h)
|
||||
#define lsode_h 1
|
||||
|
||||
#include "c++rocket.h"
|
||||
|
||||
extern int model_1(const int& neq, const double& time,
|
||||
double* z, double* dy,
|
||||
int& ierr);
|
||||
|
||||
extern int model_2(const int& neq, const double& time,
|
||||
double* z, double* dy,
|
||||
int& ierr);
|
||||
|
||||
extern "C" int lsode_ (int (*)(const int&, const double&,
|
||||
double*, double*, int&),
|
||||
int&, double*, double&, double&, int&,
|
||||
double&, double&, int&, int&, int&,
|
||||
double*, int&, int*, int&,
|
||||
int (*)(const int&, const double&,
|
||||
double*, const int&, const int&,
|
||||
double*, const int&),
|
||||
int&);
|
||||
|
||||
typedef int (*ModelFunc_t) (const int&, const double&,
|
||||
double*, double*, int&);
|
||||
|
||||
|
||||
class lsode
|
||||
{
|
||||
int memory; // est vrai si la memoire a ete alloue
|
||||
// ce sont des variables utilises par lsode_
|
||||
int neq;
|
||||
int length;
|
||||
|
||||
double **dy;
|
||||
|
||||
double time;
|
||||
double tout;
|
||||
int itol;
|
||||
double rtol;
|
||||
double atol;
|
||||
int itask;
|
||||
int istate;
|
||||
int iopt;
|
||||
double *rwork;
|
||||
int lrw;
|
||||
int *iwork;
|
||||
int liw;
|
||||
int mf;
|
||||
double *state;
|
||||
|
||||
void *md;
|
||||
|
||||
//int (*func)(const int&, const double&, double*, double*, int&)
|
||||
|
||||
void reset();
|
||||
|
||||
public:
|
||||
|
||||
lsode(Model_t model);
|
||||
~lsode();
|
||||
void print();
|
||||
void set_atol(double tol) { atol = tol; }
|
||||
void set_rtol(double tol) { rtol = tol; }
|
||||
|
||||
int solve(double *st, double duration, double step);
|
||||
|
||||
int get_length(void) { return length; };
|
||||
void get_data(double**);
|
||||
|
||||
int get_neq(void) { return neq; };
|
||||
};
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SUCCES = 2,
|
||||
TOO_MUCH_WORK = -1,
|
||||
TOO_MUCH_ACC = -2,
|
||||
ILLEGAL_INPUT = -3,
|
||||
ERR_FAILURE = -4,
|
||||
CONV_FAILURE = -5,
|
||||
ERROR_WEIGHT = -6,
|
||||
EXIT_IN_FUNCTION = -13
|
||||
} State;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
/* modeles.cc - Simulation of rocket flight */
|
||||
/* Copyright (C) 2000 */
|
||||
/* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
|
||||
|
||||
/* This program is free software; you can redistribute it and/or modify*/
|
||||
/* it under the terms of the GNU General Public License as published by*/
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <cmath>
|
||||
#include "simulation.h"
|
||||
|
||||
#include "c++rocket.h"
|
||||
|
||||
// modified arctan function
|
||||
double Atan(double x, double y);
|
||||
double coef(double v);
|
||||
double T(double time);
|
||||
double mass(double time);
|
||||
|
||||
|
||||
|
||||
int model_1(int neq, double time,
|
||||
double *z, double *dy, int ierr);
|
||||
|
||||
int model_2(int neq, double time,
|
||||
double* z, double* dy, int ierr);
|
||||
|
||||
|
||||
extern simulation *simptr;
|
||||
|
||||
/**********************************************************************
|
||||
MODEL_1: This model takes care of the principal aerodynamic effects
|
||||
that takes place in a rocket flight. The mathematical relation
|
||||
come from 'Mathematical theory of rocket flight' McGraw-Hill
|
||||
Book company. Author are J. Barkley Rosser, Robert R. Newton,
|
||||
George L. Gross.
|
||||
|
||||
COMMENTS: I will eventually explain the theory in some documentation
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
int model_1(int neq, double time,
|
||||
double *z, double *dy, int ierr)
|
||||
{
|
||||
|
||||
//double s = z[0]; not use
|
||||
double x = z[1]; // position in the x coordinate
|
||||
double y = z[2]; // position in the y coordinate
|
||||
double theta = z[3]; // angle about the horizontal
|
||||
double phi = z[4]; // angle of the rocket axis about the horizontal
|
||||
double v = z[5]; // speed
|
||||
double dphi = z[6]; // first derivative of phi
|
||||
|
||||
double h = sqrt(pow(x,2) + pow(y,2));
|
||||
double g = G*simptr->p_data[masse]/(pow(h,2));
|
||||
double delta = phi - theta;
|
||||
double rho = simptr->densiteatm(h - simptr->p_data[rayon]);
|
||||
double drag_correction = coef(v)/0.15;
|
||||
double Drag = -simptr->r_data[Kdrag]*(1+simptr->r_data[Kdd]*pow(delta,2))\
|
||||
*rho*pow(simptr->r_data[Diameter],2)*pow(v,2)*drag_correction;
|
||||
double Lift = simptr->r_data[Klift]*rho*pow(simptr->r_data[Diameter],2) * pow(v,2)*sin(delta - simptr->r_data[dlift]);
|
||||
double Spin = simptr->r_data[Kspin]*rho*pow(simptr->r_data[Diameter],3)*v*dphi;
|
||||
double Moment = -simptr->r_data[Kmoment]*rho*pow(simptr->r_data[Diameter],3)*pow(v,2)*sin(delta-simptr->r_data[dmoment]);
|
||||
double Damping = -simptr->r_data[Kdamping]*rho*pow(simptr->r_data[Diameter],4)*v*dphi;
|
||||
|
||||
|
||||
double thrust = T(time);
|
||||
double dmasse = 0; // mass flow
|
||||
|
||||
double angle = Atan(x, y);
|
||||
|
||||
dy[0] = v;
|
||||
dy[1] = v*cos(theta);
|
||||
dy[2] = v*sin(theta);
|
||||
dy[3] = (thrust* sin( delta - simptr->r_data[dt] ) - mass(time)*g*cos(theta + PI/2 - angle) + Lift + Spin*cos(delta))/(mass(time)*v); //dtheta
|
||||
dy[4] = dphi;
|
||||
dy[5] = (thrust*cos(delta-simptr->r_data[dt])-mass(time)*g*sin(theta+PI/2-angle) + Drag + Spin*sin(delta))/mass(time);
|
||||
dy[6] = (thrust*simptr->r_data[rcm_throat]*sin(simptr->r_data[dt]) + Moment + Damping - dmasse*dphi*(simptr->r_data[rcm_throat]*simptr->r_data[rcm_exit]-pow(simptr->r_data[k],2)))/(mass(time)*pow(simptr->r_data[k],2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
double Atan(double x, double y)
|
||||
{
|
||||
double angle;
|
||||
if ((x == 0)&&(y > 0))
|
||||
angle = PI/2;
|
||||
else if ((x == 0)&&(y < 0))
|
||||
angle = -PI/2;
|
||||
else if ((x > 0))
|
||||
angle = atan(y/x);
|
||||
else if ((x < 0))
|
||||
angle = PI + atan(y/x);
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
// table de variation des du coefficient de frottement en
|
||||
// fonction de la vitesse
|
||||
|
||||
// table of the drag coefficient variation with speed
|
||||
//
|
||||
double coef(double v)
|
||||
{
|
||||
static const int V[] = {0, 50, 100, 150, 200, 250, 300, 350, 400, 450,
|
||||
500, 550, 600, 650, 700, 750, 800, 850, 900, 950,
|
||||
1000, 1050, 1100, 1150, 1200};
|
||||
|
||||
static const double C[] = {0.15, 0.13, 0.125, 0.12, 0.135, 0.15, 0.2,
|
||||
0.3, 0.37, 0.39, 0.38, 0.37, 0.36, 0.35, 0.34,
|
||||
0.33, 0.32, 0.315, 0.31,0.305, 0.302, 0.3,
|
||||
0.299, 0.298, 0.297};
|
||||
|
||||
if (v > 1200)
|
||||
return 0.295;
|
||||
else {
|
||||
int b = (int)floor(v/50)+1;
|
||||
return ( (C[b+1]-C[b]) / (V[b+1]-V[b]) )*(v-V[b]) + C[b];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double mass(double time)
|
||||
{
|
||||
double trel = 0;
|
||||
double M = simptr->r_data[Mass];
|
||||
|
||||
if (simptr->n_prop() == 0)
|
||||
return M;
|
||||
|
||||
for (int i = 0; i < simptr->n_prop(); i++)
|
||||
M += simptr->prop[i].M(0);
|
||||
|
||||
|
||||
if (time < simptr->ta[0])
|
||||
return M;
|
||||
|
||||
M -= simptr->prop[0].M(0);
|
||||
for (int i = 0; i < simptr->n_prop(); i++)
|
||||
if (time < (simptr->tl[i]+simptr->ta[i]+simptr->prop[i].burntime+trel) )
|
||||
return (M + simptr->prop[i].M(time - trel - simptr->ta[i]));
|
||||
else
|
||||
{
|
||||
trel += simptr->ta[i] + simptr->tl[i] + simptr->prop[i].burntime;
|
||||
M -= simptr->prop[i].M(0);
|
||||
}
|
||||
|
||||
return simptr->r_data[Mass];
|
||||
}
|
||||
|
||||
|
||||
// give the thrust of the rocket in function of time, flight program and
|
||||
// motor that are loaded
|
||||
|
||||
double T(double time)
|
||||
{
|
||||
double trel = 0;
|
||||
if (simptr->n_prop() == 0)
|
||||
return 0.0;
|
||||
if (time < simptr->ta[0])
|
||||
return 0.0;
|
||||
for (int i = 0; i < simptr->n_prop(); i++) {
|
||||
if (time < (simptr->tl[i]+simptr->ta[i]+simptr->prop[i].burntime+trel) )
|
||||
return simptr->prop[i].T(time - trel - simptr->ta[i]);
|
||||
else
|
||||
trel += simptr->ta[i] + simptr->tl[i] + simptr->prop[i].burntime;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
MODEL_2: Simple model that do not take care of aerodynamic parameter
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int model_2(int neq, double time,
|
||||
double* z, double* dy, int ierr)
|
||||
{
|
||||
//double s = z[0];
|
||||
double x = z[1];
|
||||
double y = z[2];
|
||||
double theta = z[3];
|
||||
double v = z[4];
|
||||
|
||||
double h = sqrt(pow(x,2) + pow(y,2));
|
||||
double g = G*simptr->p_data[masse]/(pow(h,2));
|
||||
|
||||
double rho = simptr->densiteatm(h - simptr->p_data[rayon]);
|
||||
double drag_correction = coef(v)/0.15;
|
||||
double Drag = -simptr->r_data[Kdrag]*rho*pow(simptr->r_data[Diameter],2)*pow(v,2)*drag_correction;
|
||||
|
||||
|
||||
double thrust = T(time);
|
||||
//double dmasse = 0; //mass flow
|
||||
double angle = Atan(x, y);
|
||||
|
||||
dy[0] = v;
|
||||
dy[1] = v*cos(theta);
|
||||
dy[2] = v*sin(theta);
|
||||
dy[3] = (thrust - mass(time)*g*cos(theta+PI/2-angle) )/(mass(time)*v); //dtheta
|
||||
dy[4] = (thrust-mass(time)*g*sin(theta+PI/2-angle) + Drag )/mass(time);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/* motor.l - Simulation of rocket flight */
|
||||
/* Copyright (C) 2000 */
|
||||
/* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
|
||||
|
||||
/* This program is free software; you can redistribute it and/or modify*/
|
||||
/* it under the terms of the GNU General Public License as published by*/
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
%{
|
||||
|
||||
#define YY_DECL int motorscan(char *name, double *diameter, double *length, double *masse_totale, double *masse_poudre, double **thrust, int *ndata)
|
||||
|
||||
|
||||
double P[2][200];
|
||||
char bidon[32];
|
||||
int foo;
|
||||
int count;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
int tmp1, tmp2, tmp3;
|
||||
double dtmp1, dtmp2;
|
||||
|
||||
%}
|
||||
|
||||
%x body
|
||||
|
||||
|
||||
%%
|
||||
|
||||
<*>#+.*\n ; /* elimination of the character #, \t, \n, space, ; */
|
||||
^[ ]+ ;
|
||||
<*>^\t+ ;
|
||||
<*>\n ;
|
||||
<INITIAL>";"+.*\n ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
01.*[ ].* {
|
||||
sscanf(yytext, "%s%s%s", bidon, bidon, name);
|
||||
/*printf("%s\n", name);*/
|
||||
count = 0;
|
||||
}
|
||||
|
||||
07.*[ ].* {
|
||||
sscanf(yytext, "%s%s%lf", bidon, bidon, &dtmp1);
|
||||
diameter[0] = dtmp1*2.54/100;
|
||||
/*printf("%f\n", diameter[0]);*/
|
||||
}
|
||||
|
||||
08.*[ ].*[ ].* {
|
||||
sscanf(yytext, "%s%s%s%lf", bidon, bidon, bidon, &dtmp1);
|
||||
length[0] = dtmp1*2.54/100;
|
||||
/*printf("%f\n", length[0]);*/
|
||||
}
|
||||
|
||||
11.*[ ].*[ ].*[ ].* {
|
||||
sscanf(yytext, "%s%s%s%s%lf", bidon, bidon, bidon, bidon, &dtmp1);
|
||||
masse_poudre[0] = dtmp1/1000;
|
||||
/*printf("%f\n", masse_poudre[0]);*/
|
||||
}
|
||||
|
||||
12.*[ ].*[ ].*[ ].* {
|
||||
sscanf(yytext, "%s%s%s%s%lf", bidon, bidon, bidon, bidon, &dtmp1);
|
||||
masse_totale[0] = dtmp1/1000;
|
||||
/*printf("%f\n", masse_totale[0]);*/
|
||||
}
|
||||
|
||||
20.*[ ].*[ ].*[ ].* {
|
||||
sscanf(yytext, "%s%s%s%lf%lf", bidon, bidon, bidon, &P[0][count], &P[1][count]);
|
||||
count++;
|
||||
}
|
||||
|
||||
64.* {
|
||||
// allocate the memory
|
||||
thrust[0] = new double[count];
|
||||
thrust[1] = new double[count];
|
||||
|
||||
ndata[0] = count;
|
||||
|
||||
for (j = 0; j < count; j++)
|
||||
{
|
||||
thrust[0][j] = P[0][j];
|
||||
thrust[1][j] = P[1][j] * 4.448221615; //1lb X 9.80665 X 0.45359237 kg/lb
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[0-9]{2}.*[ ].* { /*garbage all other data*/
|
||||
}
|
||||
|
||||
|
||||
[A-Z0-9]+[ ]*[0-9]+[ ]*[0-9]+[ ]*[0-9]+[ ]*[0-9]+"."[0-9]+[ ]*[0-9]+"."[0-9]+[ ]*[A-Z0-9]+[ ]* {
|
||||
sscanf(yytext, "%s%d%d%d%lf%lf%s", name, &tmp1, &tmp2, &foo, masse_poudre, masse_totale, bidon);
|
||||
|
||||
diameter[0] = (double)tmp1/1000;
|
||||
length[0] = (double)tmp2/1000;
|
||||
|
||||
count = 0;
|
||||
BEGIN(body);
|
||||
}
|
||||
|
||||
<body>[0-9]+"."[0-9]+[ ]*[0-9]+"."[0-9]+[ ]* {
|
||||
sscanf(yytext, "%lf%lf", &P[0][count], &P[1][count]);
|
||||
count++;
|
||||
}
|
||||
|
||||
<body>";"+.*\n {
|
||||
|
||||
thrust[0] = new double[count];
|
||||
thrust[1] = new double[count];
|
||||
ndata[0] = count;
|
||||
for (i = 0; i < 2; i++)
|
||||
for (j = 0; j < count; j++)
|
||||
thrust[i][j] = P[i][j];
|
||||
BEGIN(INITIAL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
%%
|
||||
|
||||
int yywrap()
|
||||
{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/* rk4.cc - Simulation of rocket flight */
|
||||
/* Copyright (C) 2000 */
|
||||
/* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
|
||||
|
||||
/* This program is free software; you can redistribute it and/or modify*/
|
||||
/* it under the terms of the GNU General Public License as published by*/
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <fstream.h>
|
||||
|
||||
#include "rk4.h"
|
||||
#include "c++rocket.h"
|
||||
|
||||
|
||||
static int ModelNeq[MODEL_LAST] = { 7, 5 };
|
||||
|
||||
|
||||
rk4_solver::rk4_solver(Model_t model)
|
||||
{
|
||||
neq = ModelNeq[model];
|
||||
time = 0.0;
|
||||
memory = 0;
|
||||
|
||||
switch (model)
|
||||
{
|
||||
case AERO_MODEL:
|
||||
md = model_1;
|
||||
break;
|
||||
case SIMPLE_MODEL:
|
||||
md = model_2;
|
||||
break;
|
||||
default:
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rk4_solver::~rk4_solver()
|
||||
{
|
||||
if (memory) {
|
||||
for (int j = 0; j < length; j++)
|
||||
delete [] ans[j];
|
||||
delete ans;
|
||||
}
|
||||
cout << "Freeing memory...\n" ;
|
||||
}
|
||||
|
||||
int rk4_solver::solve(double *st, double duration, double step)
|
||||
{
|
||||
int i;
|
||||
|
||||
length = (int)rint(duration/step) + 1;
|
||||
|
||||
// memory allocation
|
||||
ans = new double*[length];
|
||||
for (int j = 0; j < length; j++)
|
||||
ans[j] = new double[neq];
|
||||
|
||||
memory = 1;
|
||||
|
||||
// fill the ans array
|
||||
rk4 ( (ModelFunc_t)md, neq, step, duration, st, ans, NULL);
|
||||
return length;
|
||||
}
|
||||
|
||||
// print the data to screen
|
||||
void rk4_solver::print()
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
for (int j = 0; j < neq; j++)
|
||||
{
|
||||
cout << ans[i][j] << "\t";
|
||||
}
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// export the data in filename with the format need by octave
|
||||
// for the function load. It will maybe work with matlab to
|
||||
// but i'm not sure
|
||||
void rk4_solver::export_octave(char *filename)
|
||||
{
|
||||
|
||||
ofstream out(filename);
|
||||
|
||||
out << "# Create by c++rocket" << endl;
|
||||
out << "# name: M" << endl;
|
||||
out << "# type: matrix" << endl;
|
||||
out << "# rows: " << length << endl;
|
||||
out << "# columns: " << neq << endl;
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
for (int j = 0; j < neq; j++)
|
||||
{
|
||||
out << ans[i][j] << " ";
|
||||
}
|
||||
out << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* rk4.h - Simulation of rocket flight */
|
||||
/* Copyright (C) 2000 */
|
||||
/* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
|
||||
|
||||
/* This program is free software; you can redistribute it and/or modify*/
|
||||
/* it under the terms of the GNU General Public License as published by*/
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (rk4_h)
|
||||
#define rk4_h 1
|
||||
|
||||
#include "c++rocket.h"
|
||||
|
||||
extern int model_1(int neq, double time,
|
||||
double* z, double* dy,
|
||||
int ierr);
|
||||
|
||||
extern int model_2(int neq, double time,
|
||||
double* z, double* dy,
|
||||
int ierr);
|
||||
|
||||
typedef int (*ModelFunc_t) (int, double,
|
||||
double*, double*, int);
|
||||
|
||||
extern "C" int rk4( int (*f)(int neq, double time,
|
||||
double *y, double *dy,
|
||||
int ierr),
|
||||
int neq, double step, double duration,
|
||||
double *ic, double **y );
|
||||
|
||||
class rk4_solver
|
||||
{
|
||||
|
||||
private:
|
||||
void *md; // pointer to the model function
|
||||
int memory;
|
||||
|
||||
double time;
|
||||
|
||||
int neq;
|
||||
int length;
|
||||
double **ans;
|
||||
|
||||
public:
|
||||
rk4_solver(Model_t model);
|
||||
~rk4_solver();
|
||||
|
||||
void print();
|
||||
void export_octave(char *filename);
|
||||
|
||||
int solve(double *st, double duration, double step);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,314 @@
|
||||
/* cpropep.c - Calculation of Complex Chemical Equilibrium */
|
||||
/* Copyright (C) 2000 */
|
||||
/* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
|
||||
|
||||
/* This program is free software; you can redistribute it and/or modify*/
|
||||
/* it under the terms of the GNU General Public License as published by*/
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <cmath>
|
||||
#include "c++rocket.h"
|
||||
#include "rocket.h"
|
||||
|
||||
|
||||
extern FILE* yyin; // file pointer for the file parser
|
||||
|
||||
// function generate by the flex lexer generator (motor.l)
|
||||
extern int motorscan(char *name, double *diameter,
|
||||
double *length, double *masse_totale,
|
||||
double *masse_poudre, double **thrust,
|
||||
int *ndata);
|
||||
|
||||
|
||||
simulation *simptr; // this is the pointer to the active simulation
|
||||
|
||||
const double G = 6.67259e-11; // universal gaz constant
|
||||
const double R = 8.3145; // perfect gaz constant
|
||||
const double g = 9.80665; // Earth gravitational constant
|
||||
|
||||
|
||||
|
||||
|
||||
// default value for the initialisation
|
||||
|
||||
static double rocket_default[PARA_ROCKET_LAST] = { 0.204,
|
||||
2,
|
||||
2.33,
|
||||
20.4,
|
||||
6.32,
|
||||
31.6,
|
||||
0,
|
||||
0,
|
||||
0.1143,
|
||||
16,
|
||||
1,
|
||||
1.1,
|
||||
0.229,
|
||||
0 };
|
||||
|
||||
|
||||
static double planete_default[PLANETE_DATA_LAST] = { 5.98e24,
|
||||
6370000 };
|
||||
|
||||
|
||||
static double atmosphere_default[ATM_DATA_LAST] = { 1.013e5,
|
||||
0.0289644,
|
||||
273.15 };
|
||||
|
||||
propulseur::~propulseur()
|
||||
{
|
||||
cout << "Destroying propulseur\n";
|
||||
if (!(ndata == 0))
|
||||
{
|
||||
delete [] thrust[0];
|
||||
delete [] thrust[1];
|
||||
delete [] thrust;
|
||||
}
|
||||
}
|
||||
|
||||
int propulseur::print_data(void)
|
||||
{
|
||||
if (!(check()))
|
||||
return -1;
|
||||
|
||||
cout << "Motor:\t\t\t" << name << endl;
|
||||
cout << "Diameter:\t\t" << diameter << " m" << endl;
|
||||
cout << "Length:\t\t" << length << " m" << endl;
|
||||
cout << "Mass de propergol:\t" << masse_poudre << " Kg" << endl;
|
||||
cout << "Total mass:\t\t" << masse_totale << " Kg" << endl;
|
||||
//cout << ndata << endl;
|
||||
cout << endl;
|
||||
cout << "Time (s)\t" << "Thrust (N)" << endl;
|
||||
for (int k = 0; k < ndata; k++)
|
||||
cout << thrust[0][k] << "\t\t" << thrust[1][k] << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int propulseur::load_data(char file[32])
|
||||
{
|
||||
FILE *file_in = NULL;
|
||||
if ((file_in = fopen(file, "r")) == NULL)
|
||||
{
|
||||
cout << "No such file or directory " << file << endl;
|
||||
return -1;
|
||||
}
|
||||
yyin = file_in;
|
||||
thrust = new double*[2];
|
||||
motorscan(name, &diameter, &length, &masse_totale,
|
||||
&masse_poudre, thrust, &ndata);
|
||||
|
||||
fclose(file_in);
|
||||
|
||||
burntime = thrust[0][ndata-1];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//#ifdef WITH_GTK
|
||||
//int propulseur::plot_data(void) {
|
||||
// cout << "I plot the data...\n";
|
||||
// return 0;
|
||||
//}
|
||||
//#endif
|
||||
|
||||
int propulseur::check(void)
|
||||
{
|
||||
if (ndata == 0)
|
||||
{
|
||||
cout << "No data loaded\n";
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
double propulseur::T(double time)
|
||||
{
|
||||
if (!(check()))
|
||||
return 0; // no thrust
|
||||
|
||||
double pousse;
|
||||
|
||||
// there is file with no data at time 0
|
||||
if (time < thrust[0][0])
|
||||
return (thrust[1][0]/thrust[0][0])*time;
|
||||
|
||||
// after the last data, the thrust is 0
|
||||
if (time > thrust[0][ndata-1])
|
||||
return 0;
|
||||
|
||||
// linear interpolation ( should be interesting
|
||||
// to add quadratic interpolation
|
||||
for (int i = 1; i < ndata; i++)
|
||||
if ((thrust[0][i] > time) && (thrust[0][i-1] <= time))
|
||||
{
|
||||
pousse = (thrust[1][i]-thrust[1][i-1])/
|
||||
(thrust[0][i]-thrust[0][i-1])*(time-thrust[0][i-1]) +
|
||||
thrust[1][i-1];
|
||||
}
|
||||
return pousse;
|
||||
}
|
||||
|
||||
double propulseur::M(double time)
|
||||
{
|
||||
if (!(check()))
|
||||
return 0;
|
||||
|
||||
if (time > burntime)
|
||||
return (masse_totale - masse_poudre);
|
||||
else
|
||||
return (masse_totale - time*(masse_totale-masse_poudre)/burntime);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
double propulseur::impulse(void)
|
||||
{
|
||||
if (!(check()))
|
||||
return -1;
|
||||
|
||||
double I = 0;
|
||||
|
||||
for (int i = 0; i < (ndata - 1); i++)
|
||||
I += (thrust[1][i]+thrust[1][i+1])*(thrust[0][i+1]-thrust[0][i])/2;
|
||||
|
||||
return I;
|
||||
}
|
||||
|
||||
double propulseur::favg(void)
|
||||
{
|
||||
if (check())
|
||||
return (impulse()/burntime);
|
||||
return -1;
|
||||
}
|
||||
|
||||
double propulseur::vg(void)
|
||||
{
|
||||
if (check())
|
||||
return impulse()/masse_poudre;
|
||||
return -1;
|
||||
}
|
||||
|
||||
double propulseur::isp(void)
|
||||
{
|
||||
if (check())
|
||||
return vg()/g;
|
||||
return -1;
|
||||
}
|
||||
|
||||
double propulseur::propellant_mass_fraction(void)
|
||||
{
|
||||
if (check())
|
||||
return masse_poudre/masse_totale;
|
||||
return -1;
|
||||
}
|
||||
|
||||
double propulseur::impulse_to_weight(void)
|
||||
{
|
||||
if (check())
|
||||
return impulse()/(masse_totale*g);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rocket::rocket(void)
|
||||
{
|
||||
nprop = 0;
|
||||
r_data = rocket_default;
|
||||
}
|
||||
|
||||
rocket::rocket(double *r)
|
||||
{
|
||||
nprop = 0;
|
||||
for (int i = 0; i < PARA_ROCKET_LAST; i++)
|
||||
r_data[i] = r[i];
|
||||
}
|
||||
|
||||
int rocket::set_propulseurs(int stage, char file[128])
|
||||
{
|
||||
if (stage > MAXPROP)
|
||||
return -1;
|
||||
if (!(stage == 1))
|
||||
if (prop[stage-2].ndata == 0) {
|
||||
cout << "Stage " << stage-1 << " not loaded.\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
prop[stage-1].load_data(file);
|
||||
nprop = stage;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
planete::planete(void)
|
||||
{
|
||||
p_data = planete_default;
|
||||
}
|
||||
|
||||
planete::planete(double *p)
|
||||
{
|
||||
for (int i = 0; i < PLANETE_DATA_LAST; i++)
|
||||
p_data[i] = p[i];
|
||||
}
|
||||
|
||||
planete::planete(double *p, double *a) : atmosphere(a)
|
||||
{
|
||||
for (int i = 0; i < PLANETE_DATA_LAST; i++)
|
||||
p_data[i] = p[i];
|
||||
}
|
||||
|
||||
|
||||
double planete::densiteatm(double altitude)
|
||||
{
|
||||
double d = (((a_data[pression_sol] * a_data[masse_molaire]) / (R*a_data[temperature]))* exp(( (a_data[masse_molaire]*G*p_data[masse])/(R*a_data[temperature]) ) * ( (1/(p_data[rayon] + altitude)) - (1/p_data[rayon]) ) ));
|
||||
return d;
|
||||
}
|
||||
|
||||
atmosphere::atmosphere(void)
|
||||
{
|
||||
a_data = atmosphere_default;
|
||||
}
|
||||
|
||||
|
||||
atmosphere::atmosphere(double* a)
|
||||
{
|
||||
for (int i = 0; i < ATM_DATA_LAST; i++)
|
||||
a_data[i] = a[i];
|
||||
}
|
||||
|
||||
flight_program::flight_program(void)
|
||||
{
|
||||
for (int i = 0; i < MAXPROP; i++)
|
||||
{
|
||||
ta[i] = 0;
|
||||
tl[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int flight_program::set_prog(int stage, double allumage, double largage)
|
||||
{
|
||||
if ( (stage < 1) || (stage > MAXPROP) )
|
||||
return -1;
|
||||
|
||||
ta[stage - 1] = allumage;
|
||||
tl[stage - 1] = largage;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
/* cpropep.c - Calculation of Complex Chemical Equilibrium */
|
||||
/* Copyright (C) 2000 */
|
||||
/* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
|
||||
|
||||
/* This program is free software; you can redistribute it and/or modify*/
|
||||
/* it under the terms of the GNU General Public License as published by*/
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (rocket_h)
|
||||
#define rocket_h 1
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "c++rocket.h"
|
||||
|
||||
// enumeration for data
|
||||
|
||||
typedef enum
|
||||
{
|
||||
pression_sol, // ground pressure in Pa
|
||||
masse_molaire, // molar mass of the atmosphere
|
||||
temperature, // temperature of the atmosphere
|
||||
ATM_DATA_LAST
|
||||
} AtmData;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
masse, // mass of the plenet in Kg
|
||||
rayon, // radius of the planet in m
|
||||
PLANETE_DATA_LAST
|
||||
} PlaneteData;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Kdrag, // drag coefficient
|
||||
Kdd, // Kd variation with delta
|
||||
Klift, // lift coefficient
|
||||
Kspin, // cross-spin coefficient
|
||||
Kmoment, // moment coefficient
|
||||
Kdamping, // damping coefficient
|
||||
dmoment, // restoring moment asymetry
|
||||
dlift, // lift asymetry
|
||||
Diameter, // diameter of the rocket in m
|
||||
Mass, // rocket mass in kg (without booster)
|
||||
rcm_throat, // distance between mass center and throat throat
|
||||
rcm_exit, // distance between mass center and 'exit area'
|
||||
k, // radius of geryration about a transverse axis in meter
|
||||
// this field should become a function of time
|
||||
dt, // angle of the thrust about the rocket axis
|
||||
PARA_ROCKET_LAST
|
||||
} ParaRocket;
|
||||
|
||||
// Classes ********************************************
|
||||
|
||||
class propulseur {
|
||||
|
||||
char name[32];
|
||||
double diameter;
|
||||
double length;
|
||||
|
||||
double masse_poudre;
|
||||
double masse_totale;
|
||||
double **thrust; // table of thrust in function of time
|
||||
int check(void); // function to verify if there is data loaded
|
||||
public:
|
||||
double burntime;
|
||||
int ndata; // number of point in **thrust
|
||||
int load_data(char*); // char* is the file name
|
||||
int print_data(void);
|
||||
|
||||
//#ifdef WITH_GTK
|
||||
//int plot_data(void); //plot a graph of the thrust as a fonction of time
|
||||
//#endif
|
||||
|
||||
propulseur(void) { ndata = 0; }
|
||||
~propulseur(void);
|
||||
|
||||
double T(double time); // thrust in function of time
|
||||
double M(double time); // mass in function of time
|
||||
|
||||
// to be verify
|
||||
double impulse(void); // total impulse of the motor
|
||||
double favg(void); // mean thrust of the motor
|
||||
|
||||
double vg(void); // gaz speed at the exit
|
||||
double isp(void); // specific impulse
|
||||
|
||||
double propellant_mass_fraction(void);
|
||||
double impulse_to_weight(void);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class rocket
|
||||
{
|
||||
int nprop; // nomber of stage
|
||||
|
||||
public:
|
||||
char name[32]; // name of the rocket
|
||||
|
||||
double r_data[PARA_ROCKET_LAST];
|
||||
class propulseur prop[MAXPROP];
|
||||
|
||||
// set a stage of the rocket (file is the path name of the data file)
|
||||
int set_propulseurs(int stage, char file[128]);
|
||||
int n_prop(void) { return nprop; }
|
||||
rocket(void);
|
||||
rocket(double *);
|
||||
~rocket() { cout << "Destroying rocket\n"; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class atmosphere
|
||||
{
|
||||
public:
|
||||
double a_data[ATM_DATA_LAST];
|
||||
atmosphere(void);
|
||||
atmosphere(double *);
|
||||
~atmosphere() { cout << "Destroying atmosphere\n";}
|
||||
};
|
||||
|
||||
|
||||
class planete : public atmosphere
|
||||
{
|
||||
public:
|
||||
double p_data[PLANETE_DATA_LAST];
|
||||
|
||||
double densiteatm(double); // g/cm^3
|
||||
|
||||
planete(void);
|
||||
planete(double *);
|
||||
planete(double *planete_data, double *atm_data);
|
||||
|
||||
~planete() { cout << "Destroying planete\n"; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class flight_program
|
||||
{
|
||||
public:
|
||||
double ta[MAXPROP]; //temps de l'allumage (depuis le largage du précédent)
|
||||
double tl[MAXPROP]; //temps du largage (après la fin de la combustion)
|
||||
|
||||
int set_prog(int stage, double allumage, double largage);
|
||||
|
||||
flight_program(void);
|
||||
~flight_program(void) { }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/* cpropep.c - Calculation of Complex Chemical Equilibrium */
|
||||
/* Copyright (C) 2000 */
|
||||
/* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
|
||||
|
||||
/* This program is free software; you can redistribute it and/or modify*/
|
||||
/* it under the terms of the GNU General Public License as published by*/
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <iostream.h>
|
||||
#include "simulation.h"
|
||||
|
||||
//extern int model_1(const int& neq, const double& time,
|
||||
// double* z, double* dy,
|
||||
// int& ierr);
|
||||
|
||||
extern simulation *simptr;
|
||||
|
||||
simulation::simulation(Model_t model) : rk4_solver(model)
|
||||
{
|
||||
simptr = this;
|
||||
sim_name = new char[128];
|
||||
//model = model_1;
|
||||
}
|
||||
|
||||
|
||||
simulation::~simulation()
|
||||
{
|
||||
//delete rocket.prop;
|
||||
delete sim_name;
|
||||
cout << "Destroying simulation\n";
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/* cpropep.c - Calculation of Complex Chemical Equilibrium */
|
||||
/* Copyright (C) 2000 */
|
||||
/* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
|
||||
|
||||
/* This program is free software; you can redistribute it and/or modify*/
|
||||
/* it under the terms of the GNU General Public License as published by*/
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#if !defined (simulation_h)
|
||||
#define simulation_h 1
|
||||
|
||||
#include <iostream>
|
||||
#include "c++rocket.h"
|
||||
#include "rocket.h"
|
||||
|
||||
#include "rk4.h"
|
||||
|
||||
|
||||
//extern int model_1(const int& neq, const double& time,
|
||||
// double* z, double* dy,
|
||||
// int& ierr);
|
||||
|
||||
|
||||
class simulation : public flight_program,
|
||||
public rocket,
|
||||
public planete,
|
||||
public rk4_solver
|
||||
//public lsode
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
char *sim_name;
|
||||
|
||||
simulation(Model_t model);
|
||||
|
||||
simulation(double* r, double* p, Model_t model ) :
|
||||
rocket(r), planete(p), rk4_solver(model) {
|
||||
cout << "Constructing simulation\n";
|
||||
}
|
||||
|
||||
simulation(double* r, double* p, double* a, Model_t model) :
|
||||
rocket(r), planete(p, a), rk4_solver(model) {
|
||||
cout << "Constructing simulation\n";
|
||||
}
|
||||
|
||||
~simulation(void);
|
||||
|
||||
|
||||
//int model_1(const int& neq, const double& time,
|
||||
// double* z, double* dy,
|
||||
// int& ierr);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%% generic configureation file for %%%%
|
||||
%%%% the ccmalloc memory profiler %%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
%-----------------------------------------------------------------%
|
||||
% COPY THIS FILE TO `.ccmalloc' in your project or home directory %
|
||||
%-----------------------------------------------------------------%
|
||||
|
||||
##############################################################################
|
||||
## (C) 1997-1998 Armin Biere, 1998 Johannes Keukelaar
|
||||
## $Id: .ccmalloc,v 1.1.1.1 2000/02/08 02:52:02 antoine Exp $
|
||||
##############################################################################
|
||||
|
||||
%%% `%' and `#' are comments !!!!!!!
|
||||
|
||||
% This file must be called `.ccmalloc' and is searched for in the
|
||||
% current directory and in the home directory of the user. If it
|
||||
% does not exist then the default values mentioned below are used.
|
||||
|
||||
% It is also the currently only available user manual ;-) So here
|
||||
% is a reading hint. First have a look at the short one line
|
||||
% descriptions of each option ...
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% with `file' the executable is specified [a.out]
|
||||
% ----------------------------------------------------------------------
|
||||
% This should not be necessary for Linux and Solaris because the proc
|
||||
% file system can be used to find argv[0].
|
||||
%
|
||||
% (the rest of this comment only applies to other OS)
|
||||
%
|
||||
% For other OS you should use this option unless the executable is
|
||||
% in the current directory or its name is `a.out'.
|
||||
%
|
||||
% If you do not specify this then ccmalloc tries to find an executable
|
||||
% in the current directory that matches the running program starting
|
||||
% with `a.out'. For this process it must call `nm' on each executable
|
||||
% file in the directory which may be time consuming. With this option
|
||||
% you can speed up this process.
|
||||
%
|
||||
% You can also specify absolute or relative path names. This is
|
||||
% necessary if you do not start your program from the current directory.
|
||||
% But you can also simply link or name your program to `a.out'.
|
||||
|
||||
%file FILE
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `log' specify the logfile [stderr]
|
||||
% ----------------------------------------------------------------------
|
||||
% The default is to use stderr. The argument to `log' is the name of
|
||||
% the file you want to write to. It can also be `stdout' or `-' which
|
||||
% sets stdout as logfile. If the logfile is stdout or stderr and is
|
||||
% connected to a terminal then the output is slightly different.
|
||||
%
|
||||
% For big programs the logfile can be really big. To reduce the size
|
||||
% you can use a small chain length (see `chain-length' below). The other
|
||||
% possibility is to use compressed logfiles. This can be done by
|
||||
% specifying a logfile name with a `.gz' (or a `.Z') suffix. This means
|
||||
% that gnuzip (resp. compress) is used to compress the output.
|
||||
|
||||
log c++rocket.log
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `logpid' specify the logfile
|
||||
% ----------------------------------------------------------------------
|
||||
% Can be used alternatively to the `log' command if you want to use
|
||||
% ccmalloc for debugging parallel applications where several copies of
|
||||
% the program you are debugging must be run simoultaneously. In this
|
||||
% case you can not use `log' because you do not want to write to the same
|
||||
% log file. Using `logpid' uses a file name ending with the <pid> of
|
||||
% the process which means the name is unique even if several copies of
|
||||
% your program are run simoultaneously.
|
||||
%
|
||||
% If you use the compressing suffixes then the <pid> is inserted before
|
||||
% the suffix (e.g. `logpid ccmalloc.log.gz' uses `ccmalloc.log.<pid>.gz'
|
||||
% as the name for the log file).
|
||||
|
||||
%logpid FILE
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `dont-log-chain' skip info about certain chains []
|
||||
% ----------------------------------------------------------------------
|
||||
% This command may be repeated any number of times. The argument to this
|
||||
% command is a comma-separated list of function-or-file-and-line
|
||||
% specifications. Garbage allocated from a callchain that contains this
|
||||
% subchain anywhere will _not_ be logged.
|
||||
%
|
||||
% The comma-separated list should not contain any spaces. E.g. not:
|
||||
% main, foo, bar
|
||||
% but:
|
||||
% main,foo,bar
|
||||
% A function-or-file-and-line specification is a string followed by an
|
||||
% optional colon and number, for example: main or main:14 or main.c or
|
||||
% main.c:15. Note that the string is compared with both the function and
|
||||
% the file name, if available. If main.c happens to be a function name,
|
||||
% that will cause a match (for that string at least).
|
||||
% Not specifying a line number will match any line number. If line number
|
||||
% information is not available, anything will match!
|
||||
% Not specifying a name (e.g. ,,,) will match an unknown function name.
|
||||
% Not giving any parameters at all, will match a chain containing at least
|
||||
% one unknown function.
|
||||
%
|
||||
% Note that if you say
|
||||
% dont-log-chain wrapper.c
|
||||
% _nothing_ will be logged...
|
||||
|
||||
%dont-log-chain
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `only-log-chain' skip info about other chains []
|
||||
% ----------------------------------------------------------------------
|
||||
% The obvious counterpart to dont-log-chain. In this case, only matching
|
||||
% chains will be reported. Non-matching chains will not be reported.
|
||||
% Can be repeated any number of times; if the chain matches any of the
|
||||
% instances, it will be reported.
|
||||
|
||||
%only-log-chain
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# This is the `flag' section #
|
||||
# #
|
||||
# `set FLAG' is the same as `set FLAG 1' #
|
||||
# #
|
||||
# The default values are those set below. If `silent' is disabled #
|
||||
# then you will find the banner in the log file (or it is listed on #
|
||||
# stdout or stderr). The banner describes the current settings of all #
|
||||
# these flags. #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% with `only-count' ccmalloc only counts garbage - no call chains [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% If only-count is set to one then only one additional pointer for
|
||||
% each allocated data is used and no call chain is generated. This is
|
||||
% the fasted and most space efficient mode ccmalloc can operate
|
||||
% in. In this mode you get at least the size of garbage produced.
|
||||
%
|
||||
% Note that `check-free-space' does not work at all with `only-count'
|
||||
% set and over writes (`check-overwrites') are only checked when
|
||||
% calling free.
|
||||
|
||||
%set only-count 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `load-dynlibs' load dynamic linked libraries into gdb [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% If your program is linked with dynamic libraries, function and file
|
||||
% name information is not available for addresses in those libraries,
|
||||
% unless you set `load-dynlibs' to 1.
|
||||
|
||||
%set load-dynlibs 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `keep-deallocated-data' does not recycle deallocated data [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% If you enable keep-deallocated-data then all data deallocated with
|
||||
% `free' (or `delete' in C++) is not given back to the free store
|
||||
% but stays associated with the call chain of its allocation. This is
|
||||
% very useful if your program does multiple deallocation of the
|
||||
% same data.
|
||||
|
||||
%set keep-deallocated-data 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `check-overwrites' detect overwrites [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% If you want to detect `off by n bytes' errors you should set
|
||||
% `checking-overwrites' to n/4 (on 32-Bit machines).
|
||||
%
|
||||
% ccmalloc inserts a boundary above allocated data. This boundary
|
||||
% consists of `check-overwrites' words. If your program writes to
|
||||
% this area then ccmalloc can detect this (see also check-start
|
||||
% and check-interval). `ccmalloc' also does checking for overwrites
|
||||
% at non word boundaries (e.g. strcpy(malloc(strlen("hello")),"hello");)
|
||||
|
||||
%set check-overwrites 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `check-underwrites' detect overwrites [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% same with writes below allocated data. You do not have to set this
|
||||
% option if you only want detect `off (below) by one' errors because
|
||||
% ccmalloc keeps a magic value just before the user data.
|
||||
|
||||
%set check-overwrites 0
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `check-free-space' can be used to find dangling pointers. [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% A very serious type of bug is to write on data that has already been
|
||||
% freed. If this happens the free space management of malloc is in
|
||||
% trouble and you will perhaps encounter non deterministic behaviour of
|
||||
% your program. To test this first enable `keep-deallocated-data' and
|
||||
% restart your program. If the problem goes away and ccmalloc does not
|
||||
% report anything then you should *also* enable `check-free-space'. Now
|
||||
% ccmalloc checks already deallocated data for corruption.
|
||||
%
|
||||
% Note that to perform this check `keep-deallocated-data' also must
|
||||
% be enabled and `only-count' disabled.
|
||||
|
||||
%set check-free-space 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `check-interval' can be used to speed up checks [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% If check-overwrite, check-underwrites or check-free-space is set then
|
||||
% the default is to do `write checks' when data is deallocated and
|
||||
% to do `free space checks' when reporting together with
|
||||
% `write checks' for garbage. When you want these checks to be
|
||||
% performed more often then you should set `check-interval' to a
|
||||
% positive number. This number is the interval between the number of
|
||||
% calls to free or malloc without performing the checks.
|
||||
|
||||
%set check-interval 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `check-start' can be used to speed up checks [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% The flag `check-start' delays the start of checks until the given
|
||||
% number of calls to free and malloc have occured. Together with
|
||||
% `check-interval' you can use a binary search to find an aproximation
|
||||
% when a corruption occured! If you simply set check-interval to 1 and
|
||||
% check-start to 0 then this will slow done your program too much.
|
||||
|
||||
%set check-start 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `silent' disables banner [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% If you don't want to see the banner of ccmalloc then set
|
||||
% `silent' to 1 (f.e. when logging to stderr)
|
||||
|
||||
%set silent
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `file-info' en/disables file and line number information [1]
|
||||
% ----------------------------------------------------------------------
|
||||
% If your program was compiled with debugging information (-g) then
|
||||
% ccmalloc can generate line number and file info for call chains opening
|
||||
% a pipe to gdb. For very big programs this method is slow. In this case
|
||||
% you can set `file-info' to zero and you will only get the function
|
||||
% names. For SunOS 4.3.1 `nm' does not `demangle' C++ identifiers
|
||||
% very well. So gdb is called instead but only if `file-info' is
|
||||
% not set to 0.
|
||||
|
||||
%set file-info 1
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `continue' if ccmalloc aborts when something weired happened [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% If the free function of ccmalloc is called with an argument that does
|
||||
% not make sense to ccmalloc or that has already been freed then you
|
||||
% probably want the program to stop at this point. This is also
|
||||
% the default behaviour. But you can force ccmalloc also to ignore
|
||||
% this if you set `continue' to 1. This flag also controls the behaviour
|
||||
% of ccmalloc when free space is found to be corrupted or a write
|
||||
% boundary has been overwritten.
|
||||
|
||||
%set continue 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `chain-length' is the length of the maximal call chain [0 = infinite]
|
||||
% ----------------------------------------------------------------------
|
||||
% You can restrict the length of call chains by setting `chain-length'
|
||||
% to a number greater than zero. If `chain-length' is zero (the default)
|
||||
% then chains are as long as possible (on a non x86 system only call
|
||||
% chains with a finite maximal length can be generated). For big
|
||||
% programs especially if keep-deallocated-data is enabled this can
|
||||
% reduce the size of the log file from over 100MB to several MB!
|
||||
|
||||
%set chain-length 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `print-addresses' of data [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% If you want to see the addresses of the allocated data (and
|
||||
% deallocated data if keep-deallocated-data is set to 1) set
|
||||
% `print-addresses' to 1.
|
||||
|
||||
%set print-addresses 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `print-on-one-line' shortens log file [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% The default is to print function names and file/line number info
|
||||
% on separate lines. With `print-on-one-line' set 1 all are printed
|
||||
% on one line.
|
||||
|
||||
%set print-on-one-line 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `additional-line' enlarges readability [1]
|
||||
% ----------------------------------------------------------------------
|
||||
% When printing call chains an empty line is printed between to
|
||||
% call points. Set `additional-line' to 0 to disable this feature.
|
||||
|
||||
%set additional-line 1
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% `statistics' enables more accurate profiling [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% Calculate number of allocations and deallocations and bytes also on
|
||||
% a per call chain basis. This uses 4 additional pointers for each
|
||||
% call chain.
|
||||
|
||||
%set statistics 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% set order for sorting of call chains [1] [1]
|
||||
% ----------------------------------------------------------------------
|
||||
% When printing the report to the log file the call chains are sorted by
|
||||
% default with respect to the largest accumulated garbage produced by
|
||||
% that call chain. This can be changed with setting `sort-by-wasted'
|
||||
% to 0. In this case they are sorted by the number of allocated bytes.
|
||||
% If you want the number of allocations (only possible if `statistics'
|
||||
% is enabled) as sorting criteria instead then set `sort-by-size' to 0.
|
||||
|
||||
%set sort-by-wasted 1
|
||||
%set sort-by-size 1
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% report library chains [0]
|
||||
% ----------------------------------------------------------------------
|
||||
% Some external libraries (like libg++) have memory leaks. On some
|
||||
% systems even a call to printf produces a leak. ccmalloc tries to
|
||||
% detect this (only heuristically!) and with this flag you can control
|
||||
% if leaks produced by such library calls are reported.
|
||||
%
|
||||
% Since version 0.2.1 some similar effect can be achieved by using
|
||||
% `dont-log-chain' with no argument.
|
||||
|
||||
%set library-chains 0
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% print debugging information [X] (compile time dependend)
|
||||
% ----------------------------------------------------------------------
|
||||
|
||||
%set debug X
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% align memory on 8 byte boundary [0] (no effect on SunOS or Solaris)
|
||||
% ----------------------------------------------------------------------
|
||||
|
||||
%set align-8-byte 0
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
|
||||
CXX = c++
|
||||
CC = gcc
|
||||
CXXFLAGS = -g -Wall
|
||||
CFLAG = -g -Wall
|
||||
|
||||
LIBS = -lm -lrocket -lnum -lcruft -lf2c -ldl
|
||||
LIBDIR = -L/usr/lib -L/usr/lib/octave-2.0.14.93 -L../ -L../../libnum/
|
||||
|
||||
|
||||
|
||||
INCLUDE += -I../ -I../../libnum/
|
||||
|
||||
SRC = c++rocket.cc
|
||||
OBJS = c++rocket.o #ccmalloc.o
|
||||
|
||||
PROG = c++rocket
|
||||
|
||||
|
||||
.cc.o:
|
||||
$(CXX) $(DEF) $(CXXFLAGS) $(INCLUDE) -c $*.cc -o $*.o
|
||||
|
||||
|
||||
$(PROG): $(OBJS)
|
||||
$(CXX) $(DEF) $(OBJS) $(LIBDIR) $(LIBS) -o $@
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *.o *~
|
||||
|
||||
clean-all: clean
|
||||
rm $(PROG)
|
||||
|
||||
.PHONY: clean
|
||||
@@ -0,0 +1,78 @@
|
||||
#include <iostream>
|
||||
#include <fstream.h>
|
||||
|
||||
#include "c++rocket.h"
|
||||
#include "rocket.h"
|
||||
#include "simulation.h"
|
||||
|
||||
//extern simulation *simptr;
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
simulation muty(AERO_MODEL);
|
||||
|
||||
simulation simple(SIMPLE_MODEL);
|
||||
|
||||
//simptr = &muty;
|
||||
|
||||
muty.set_propulseurs(1,"/home/antoine/debian/rocketsim-0.3/thrust/AEJ125.edx");
|
||||
muty.set_propulseurs(2,"/home/antoine/debian/rocketsim-0.3/thrust/AEJ180T.eng");
|
||||
// muty.set_propulseurs(3,"/home/antoine/debian/rocketsim-0.3/thrust/AEK250W.eng");
|
||||
|
||||
|
||||
muty.set_prog(0,0,0);
|
||||
|
||||
//cout << muty.tl[2] << endl;
|
||||
|
||||
//simptr = &muty;
|
||||
|
||||
double state[7] = {0, 0, 6370000, PI/3, PI/3, 100, 0};
|
||||
|
||||
double state2[5] = {0, 0, 6370000, PI/3, 1000};
|
||||
//lsode ode;
|
||||
//int flag = ode.solve(state, 10, 0.1);
|
||||
|
||||
|
||||
|
||||
muty.solve(state, 50, 0.01);
|
||||
|
||||
simple.solve(state2, 1, 0.001);
|
||||
|
||||
// cout << simptr->prop[0].impulse() << endl;
|
||||
// cout << simptr->prop[0].favg() << endl;
|
||||
// cout << simptr->prop[0].vg() << endl;
|
||||
// cout << simptr->prop[0].propellant_mass_fraction() << endl;
|
||||
// cout << simptr->prop[0].impulse_to_weight() << endl;
|
||||
// cout << simptr->prop[0].isp() << endl;
|
||||
|
||||
|
||||
|
||||
//simptr->prop[0].plot_data();
|
||||
|
||||
//for (int i = 0; i<MAXPROP; i++)
|
||||
// simptr->prop[i].print_data();
|
||||
|
||||
|
||||
//for (int i = 0; i < 40; i++)
|
||||
// cout << mass((double)i/2) << endl;
|
||||
|
||||
|
||||
//muty.print();
|
||||
//muty.export_octave("test");
|
||||
//simple.print();
|
||||
|
||||
//ode.print();
|
||||
//simptr->print();
|
||||
|
||||
|
||||
//cout << flag << endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user