>> Rodney Roberts IS & Education Professional Homepage   >> Programming Tutorials And Downloads   >> Model Rockets & Boost/Gliders Programming







Science makes it known,
Engineering makes it work,
Art makes it beautiful.




 

Lazarus, Pascal, FORTRAN, and Model Rocket Parallel Stages

Rockets may use Serial Staging (or simply, Multi-Staging), Parallel Staging, or a combination of both.  Multi-Staging is used for a long continuous boost, Parallel Staging for a high initial boost.  Parallel Staging is a special case of Engine Clustering.  The rocket main body contains a single
engine, and the clustered engines are mounted in external "pods" (using hooks, pins or other method).  Parallel Stages are jettisoned at external engine burnout (which should occur before main engine burnout).  Parallel Stage Pods often have a recovery system, usually a streamer.  Rockets may have two to four Parallel Stages; beyond that ignition reliability and aerodynamic drag become issues.  On serial multi-stage rockets, Parallel Stages are mounted on the lowermost stage only.

missle30/missle31 is a Lazarus unit/sub-form to input a Parallel Stage Pod's design parameters, calculate its impact on Center of Pressure (cp) and Coefficient of Normal Force (C), etc.  missle30/missle31 is part of an actual Lazarus application (MRmain) using sub-forms to input and analyze a model rocket design.
    Simplifications:
  1. Parallel Stage Pod nose is conical shape of 1 caliber length
  2. May have 1 Isosceles Trapezoid shape fin of the same thickness as the last stage fins
  3. For cp and C calculations1,  Parallel Stage Pod treated as a Delta shape fin with equivalent planar area and added to last stage;
    for CD calculations2 treated as a simple fuselage with single fin.

    Files:3
  1. missle30.pas - Parallel Stage Lazarus unit source file (class name Tmissle31); contains user interface event procedures; calls units/Librarys listed below for calculations and other data processing; has  { public declarations }  - these can be accessed by other units by including missle30 in the uses statement of the interface section (as long as it does not cause a circular reference)
    missle30.lfm - Parallel Stage Sub-Form (shown below)
    pstage.gif - image depicting representative Parallel Stage Pod, displayed by sub-form
  2. NumRecGlbl.pas - Numerical Recipes4 global constants/variables/procedures Lazarus unit, reused in other Lazarus projects & Object Pascal Librarys; has rudimentary data validation functions
    genetyp.inc5 - include file developed from major rewrite of Dawkins8 Biomorphs (Free Pascal dawkins8.dll callable from both Pascal and D programs); contains useful CONSTant and TYPE declarations
    nrtyp.inc - Numerical Recipes include file; CONSTant and TYPE declarations, including unit dimension constants (engineering/scientific applications; as an example, length is a dimension, but it is measured in units of feet (ft) or meters (m);  unit dimension constants are single char data, some of which are 8-bit ASCII;  these are meant as indicators (or program control values);  can not output these direct in Windows without ASCII to UTF-8 conversion; used in procedure PSTGSCUOM (...), see below)
  3. MRcommon.pas - Model Rocket global constants/variables/procedures Lazarus unit; many functions/procedures are called by multiple sub-forms;  like the Object Pascal and FORTRAN Librarys listed below, significant amount of calculations and other data processing occur in this unit relative to the sub-form units; with this unit, the Librarys and references listed below, it is possible to write your own system. Refer to source file comments for global variables' descriptionMRcommon.pas is still being developed for future sub-forms
    missle.inc - include file used by MRcommon.pas, missle06.pas, and missle02.pas; rocket related CONSTant and TYPE declarations
    nrlazrs.pas - user written FORTRAN Numerical Recipes - Lazarus Interface6 Library of Object Pascal procedures (LIBRARY nrlazrs); uses include files genetyp.inc and nrtyp.inc; procedures called by MRcommon; not called directly/indirectly by missle30/missle31, called by untBT10 / FrmBT10 (see below); calls FORTRAN subroutines in sttstcs.dll (see below; Pascal calling FORTRAN subprograms is straight-forward; see Free Pascal Programmer's Guide Chapter 12, Programming shared libraries)
    nrlazrs.dll - nrlazrs.pas dynamic link library; compile with fpcdll.bat (link below) - invokes Free Pascal Compiler 2.6.4 with -WR switch (generate relocation code)
  4. missle13.pas - source code for Object Pascal Library missle13.dll; contains Write Thrust Points File, Parallel Stage Pod, and Drag Coefficient procedures; calls FORTRAN subroutines in mathproc.dll (see below), Pascal procedures in hwndio.dll (not called directly/indirectly by missle30/missle31), and missle02.dll; requires include file aero021.inc.    missle13.dll procedures have been successfully called by a D Windows program.
    missle06.pas - Object Pascal unit used by missle13.pas; uses include files nrtyp.inc and missle.inc; outputs Thrust Points File (also used by Object Pascal Windows program missle05.exe); some procedures called by function WRTPSTAGE (...) (see below)
    fnameIO.pas - Object Pascal unit used by missle06.pas and missle13.pas; uses include file genetyp.inc; Get File Open/Save Name (Object Pascal Windows programs only), File Open Status, and IOResult text message functions/procedures and variables
    missle13.dll - missle13.pas (including missle06.pas & fnameIO.pas) dynamic link library; compile with fpcdll.bat
  5. missle02.pas - source code for Object Pascal Library missle02.dll (rocket related functions/procedures); callable by Object Pascal command console programs, Object Pascal Windows programs, Lazarus, and indirectly D programs.  Uses include files genetyp.inc, nrtyp.inc, and missle.inc; UOM conversion, Error Message, compute rocket components' surface area, overall rocket cp/C and other functions/procedures; calls FORTRAN subroutines in mathproc.dll (see below);  refer to source file comments for variables' description
    missle02.dll - missle02.pas dynamic link library; compile with fpcdll.bat
  6. FORTRAN Subprograms (tir33.for and mathaux.for) extracted from mathproc.for - FORTRAN subroutines/functions to compute basic shapes' surface area and rocket components' cp and C; called by procedures in missle02.dll and missle13.dll
    mathproc.dll - mathproc.for dynamic link library; built using SilverFrost FTN95 Plato IDE
  7. sttstcs.for - Numerical Recipes FORTRAN statistical analysis and support subprograms; subroutines called by nrlazrs.dll; not used by missle30/missle31, used by untBT10 / FrmBT10 (see below)
    sttstcs.dll - sttstcs.for dynamic link library; built using SilverFrost FTN95 Plato IDE
  8. hwndio.pas - (not used by missle30/missle31, required for clean compile/link of missle02.pas and missle13.pas) collection of Object Pascal general purpose functions for Windows Edit Boxes I/O, field tabbing.



Parallel Stage Pod data can be entered after model rocket design data.
When entering data for a new Parallel Stage Pod, application will use model rocket's Units of Measure for Parallel Stage Pod Units of Measure.
When using an existing Parallel Stage Pod, if Parallel Stage Pod and model rocket use different Units of Measure, application will convert one or the other's Units of Measure.
User Interface

    File Commands:
  1. New
    Clears sub-form fields
  2. Open Parallel Stage File
    calls missle13.dll procedure RDPSTAGE (...), loads Parallel Stage Pod data (name, length, radius, fin measurements, mass, and units of measure) into unit MRcommon global variables;
    if Rocket and Parallel Stage Pod Units of Measure do not match, can convert rocket Units of Measure (unit MRcommon functions cnvrtLinearUom (...) and/or cnvrtMassUom (...)) OR Parallel Stage Pod Units of Measure (missle13.dll procedure PSTGSCUOM (...))
  3. Save Parallel Stage File
    Parallel Stage Pod dimensions must be entered/modified before enabled
    (calls missle13.dll function WRTPSTAGE (...), which calls procedures in unit missle06)
    writes Parallel Stage Pod dimensions to *.psp file
  4. Calculate
    Either Parallel Stage Pod dimensions must be entered or Open Parallel Stage File must be executed before enabled;
    calculates Parallel Stage Pod surface area, Delta Fin semispan for a fin with equivalent planar area (calls missle13.dll procedures PSTGSAREA (...) (uses nth stage fin thickness T and fin bevel angle BEVEL for Parallel Stage Pod fin thickness and fin bevel angle), PSTG2DELTA (...))
    Fin Edge Rear edge view of fin - root chord at left,
    tip chord at right
    Enables Load Parallel Stage into Design
  5. Load Parallel Stage into Design
    Both Command Calculate, determine rocket's cp and C with Form Missle10 (missle11) must be executed before enabled
    Revises rocket's cp and C to include Parallel Stage Pods on the nth stage (missle13.dll procedure CMPTCPPSP (...), mathproc.dll subroutine CPFINS (...), and missle02.dll procedure cmptCPfinal (...) are called)
    Displays Revised Coefficient Normal Force
    Displays Revised Center of Pressure
    Disables New, Open Parallel Stage File, and Calculate
    Enables Remove Parallel Stage from Design
  6. Remove Parallel Stage from Design
    Removes Parallel Stage Pods from rocket's nth stage cp and C calculations (calls missle02.dll procedure cmptCPfinal (...))
    Enables New, Open Parallel Stage File
  7. Close Form
    sets  ModalResult:=mrClose;
    returns control to main form


Help Commands:
Implemented as simple ShowMessage (...) calls

Sub-form fields uses Hints



MRmain is the main form, includes missle30 in the uses statement of the interface section.
(Also includes units/forms for Tare Mass and Engine Selection in addition to those mentioned elsewhere)

MRmain event procedure invoking missle30/missle31:

The ShowModal method transfers exclusive control to the sub-form.

DataLoad07 ( )  and  DataLoad05 ( )  are MRmain non-event procedures, UOM2text (...)  is a unit MRcommon procedure, and setMassUomComboBox ( )  is another MRmain non-event procedure.  These procedures are called in case missle30/missle31 opened an existing Parallel Stage Pod file and performed a Units of Measure conversion.

EdtNstage is a Number of Stages MRmain form field that is set to ReadOnly when Parallel Stages will be used.

Prior to MRmain enabling TMRmain.BtnParallelStgClick(...), model rocket design data must be entered (using either MRmain's menu command File, Open OR entering values in Form Design Data / Center of Pressure (Missle10/Missle11))  AND  execute Form Fin Shape / Area (Missle18/FrmFinShpArea) - fin shape, fin thickness, fin bevel angle, fin surface 'wetted' area (surface area 'scrubbed' by airflow, used in CD calculations)


    Compiling / Linking :7
  1. Compile and link FORTRAN mathproc.for
  2. Compile and link FORTRAN sttstcs.for
  3. Open a MS-DOS Command Prompt and use batch file fpcdll.bat to compile the Object Pascal files
    fpcdll hwndio
    fpcdll nrlazrs
    fpcdll missle02
    fpcdll missle13
  4. Start Lazarus
    New Project, Application
    Project, New Project from File
    select missle30.pas
    View Forms
    select missle31
    click button Toggle Form/Unit (displays form)
    add units NumRecGlbl.pas, MRcommon.pas
    can add untBT10 / FrmBT10  and  missle14 / FrmPayload  from  Lazarus Body Tubes Sub-forms
    and missle18 / FrmFinShpArea  (will also need Fins/Wings image files)
    to start building your own model rocket analysis software system if desired.




1. Barrowman, James. TIR-33 Calculating the Center of Pressure
When using two parallel stage pods, violates assumption 6; treating parallel stage pods as fins violates assumption 7 (several model rocket and rocket/glider designs use hollow body tubes for stabilizers).  The simplifications should at least yield order of magnitude accuracy, which is sometimes the best that can be done without excessively complex programming and/or wind tunnel testing.
While not directly related, Close Enough to Correct: Approximate Computing discusses "ease of programming and a desire to minimize the power and area of computation" in chip design, one of "Many classes of applications exhibit significant tolerance to inaccuracies in their computations."  These classes include image processing, multimedia applications, and machine learning.  Treating parallel stage pods as fins, along with Drag Coefficient estimation, can be considered as additional classes meeting this criteria.

2. Gregorek, Gerald M. TIR-11 Aerodynamic Drag of Model Rockets
Lazarus unit/sub-form missle24/missle25 (in development, calls missle13.pas procedures) will be used to estimate the Drag Coefficient (CD) for the entire rocket.  missle24/missle25 uses missle30/missle31 { public declarations } data.  Unit/sub-form missle18/FrmFinShpArea uses missle24/missle25 { public declarations } data.  The missle13.pas (link above) CD calculation procedures are being continuously refined; new versions will be uploaded often.

3. MRmain is a large project of over 25 source, include, and form files.  This list consists of the sub-form files, source files called by sub-form unit file, and their called source files.  Some source files (for example, mathproc.for and sttstcs.for) not available in their entirety for download because they contain subroutines published in Numerical Recipes and other sources (subroutine headers, with modifications if any, available at other pages on this site, by combining subroutine header with RETURN and END statements can at least build shell SUBROUTINE in FORTRAN source file for clean compile; the unmodified Numerical Recipes FORTRAN source code is available for purchase at Older Numerical Recipes book editions; C source code available at link below - warning - have not yet tried calling C from Lazarus).  These files are presented as learning tools and as a start in building your own mathproc.for, sttstcs.for, and model rocket analysis system.

4. Press, William H., Brian P. Flannery, Saul A Teukolsky, and William T. Vetterling (1986).  Numerical Recipes: The Art of Scientific Computing. New York : Press Syndicate of the University of Cambridge.  A student version (in English) of Numerical Recipes In 'C': The Art Of Scientific Computing, Second Edition, © 1988-1992 is available from the University of Trieste at no cost.

5. Rietman, Edward (1994).  Genesis Redux: Experiments Creating Artificial Life. Windcrest (McGraw-Hill).
The original Dawkins8 source consisted of one unit and one MS-DOS main program (without any modularity whatsoever).  Broke that down into two Windows callable .dll's (genecode.dll and dawkins8.dll) and one include file.  The main .dll is now very modular.

6. Have found when a Lazarus program's event procedure directly calls a FORTRAN subprogram, it may produce an Access Violation Exception when the event procedure exits, even though no calculation errors occurred.  This exception does not occur when called via a Free Pascal Library function/procedure.

7. This is a complex project demonstrating as much re-use as possible of Librarys from other projects, resulting in a large compile/link list and multiple .dlls.
For compatibility with other programs, using 32 bit compilers.


Any and all © copyrights, ™ trademarks, or other intellectual property (IP) mentioned here are the property of their respective owners. No infringment is intended.

Feel free to use any of the above in your project (without violating any intellectual property rights); please give credit (same idea as Copyleft).  The source code files available for download on these pages are enhanced (including error fixes) and tested periodically - check often for revised versions (some portions of source code still in beta).

Page best viewed with Mozilla FireFox 3.6.13 (or higher) and Safari 5.1.7. Avoid Smart Applications Speed Browser.

Web hosting provided by
 FREE WEB HOSTING. Award Space Web Hosting Free Web Hosting X10hosting Free Web Hosting. , &  GigaRocket Web Hosting


>> Rodney Roberts IS & Education Professional Homepage   >> Programming Tutorials And Downloads   >> Model Rockets & Boost/Gliders Programming