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.

65 lines
1.8 KiB

  1. /* rk4.h - Simulation of rocket flight */
  2. /* Copyright (C) 2000 */
  3. /* Antoine Lefebvre <antoine.lefebvre@polymtl.ca> */
  4. /* This program is free software; you can redistribute it and/or modify*/
  5. /* it under the terms of the GNU General Public License as published by*/
  6. /* the Free Software Foundation; either version 2 of the License, or */
  7. /* (at your option) any later version. */
  8. /* This program is distributed in the hope that it will be useful, */
  9. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  10. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  11. /* GNU General Public License for more details. */
  12. /* You should have received a copy of the GNU General Public License */
  13. /* along with this program; if not, write to the Free Software */
  14. /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
  15. #if !defined (rk4_h)
  16. #define rk4_h 1
  17. #include "c++rocket.h"
  18. extern int model_1(int neq, double time,
  19. double* z, double* dy,
  20. int ierr);
  21. extern int model_2(int neq, double time,
  22. double* z, double* dy,
  23. int ierr);
  24. typedef int (*ModelFunc_t) (int, double,
  25. double*, double*, int);
  26. extern "C" int rk4( int (*f)(int neq, double time,
  27. double *y, double *dy,
  28. int ierr),
  29. int neq, double step, double duration,
  30. double *ic, double **y );
  31. class rk4_solver
  32. {
  33. private:
  34. void *md; // pointer to the model function
  35. int memory;
  36. double time;
  37. int neq;
  38. int length;
  39. double **ans;
  40. public:
  41. rk4_solver(Model_t model);
  42. ~rk4_solver();
  43. void print();
  44. void export_octave(char *filename);
  45. int solve(double *st, double duration, double step);
  46. };
  47. #endif