Code Monkey home page Code Monkey logo

openmotor's Introduction

openMotor

Logo

Overview

openMotor is an open-source internal ballistics simulator for rocket motor experimenters. The software estimates a rocket motor's chamber pressure and thrust based on propellant properties, grain geometry, and nozzle specifications. It uses the Fast Marching Method to determine how a propellant grain regresses, which allows the use of arbitrary core geometries.

Current Features:

  • Metric and imperial units
  • Support for common grain geometries such as BATES, Finocyl, Star and more
  • Loading custom grain geometry from DXF files
  • A propellant editor that allows the user to enter the properties of as many propellants as they wish
  • The grain editor displays how a grain will regress to cut down on the guesswork involved in tweaking geometry
  • ENG file exporting
  • Burnsim importing and exporting
  • A UI that supports saving and loading designs along with undo and redo

Planned Features:

  • Erosive burning simulation
  • Detailed output of every calculated parameter at any time and position along the motor

The calculations involved were sourced from Rocket Propulsion Elements by George Sutton and from Richard Nakka's website.

Screenshot

Download

You can download the latest version for your system here. From there, just unzip the file and run it. Alternatively, you can run it from source code to get the latest features.

Building from Source

The program is currently being developed using python 3.10. The dependencies are outlined in requirements.txt, the main ones include PyQt6, matplot, numpy, scipy, scikit-fmm, and scikit-image. Because the PyQt6 bindings are used for the GUI, Qt6 must also be installed.

The easiest way to build/run from source code is to clone the repository and install the required dependencies into a virtual enviornment:

$ git clone https://github.com/reilleya/openMotor
$ cd openMotor
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt

If you are using a version of python that does not have a prebuilt version of one of the dependencies, the pip command above might fail with an error like:

Failed building wheel for scikit-fmm
skfmm/fmm.cpp:4:10: fatal error: Python.h: No such file or directory

The fix is to install python3-dev or the equivalent with your system package manager.

UI Files:

openMotor uses Qt Designer to lay out the GUI, which generates .ui files describing the user interface. We use pyuic5 to compile these files into Python source code which is then included in the program as ordinary source code.

Because these autogenerated files are not committed to the source tree, you must build them by running:

$ python setup.py build_ui

Note that if you make changes to the UI using the .ui forms, you must re-build using the same command.

Once everything is set up, you can start openMotor by running: python main.py

Note: On some systems, Python 2 and 3 are installed simultaneously, so you may have to specify which version to run when creating the venv. After the venv has been activated, the programs python and pip are aliased to the python runtime specific for your venv, so use those (instead of pip3 and python3, on e.g. Debian Linux)

Data Files

openMotor uses YAML for data storage. Motor files have the extension .ric to differentiate them, but internally they are YAML and can be edited in a text editor if desired. The recommended MIME type for these files is application/vnd.openmotor+yaml.

The remaining user information, like propellant data and preferences, is stored in plain YAML files in <AppData>\Local\openMotor on Windows, /Users/<username>/Library/Application Support/openMotor on Mac OS, and /home/<username>/.local/share/openMotor on Linux.

License

openMotor is released under the GNU GPL v3 license. The source code is distributed so you can build cool stuff with it, and so you don't have to trust the calculations are being done correctly. Check for yourself (and file an issue ticket!) if you doubt the results.

Contributing

As openMotor is open source, one of the goals of the project is to have as many eyes on the code as possible. I believe this is the best way to avoid bugs and also the easiest way to get new features added to the software. If you have ideas on how to improve the program or find an error, please open an issue ticket for discussion or file a pull request if possible.

openmotor's People

Contributors

astrochuck avatar aushe02 avatar bencoman avatar plengkeek avatar quigleyj97 avatar reilleya avatar stefanor avatar tomashubelbauer avatar tuxxi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openmotor's Issues

Detailed report

Add some way for the user to view all information generated by the simulation. This is already relevant because there is currently no way to view mass flux as a function of length, though that number is being generated. Because you are now looking at a variable as a function of both time and position, the problem is in three dimensions and becomes harder to show on a simple graph. I'm picturing a separate window opening up (or maybe a different mode for the graph widget) that shows the desired value as a function of length at a time that is set with a slider below the graph. The graph should update instantly when the slider moves and images of each grain regressed to the appropriate level should be displayed.

Pressure transients

Do some research into loosening the assumption that pressure is at steady state. It would be cool to (optionally) simulate things like startup pressure from a known igniter or burst disk, and also to estimate how pressure drops off after all propellant has been consumed.

Build scripts

Formalize the windows .spec file, and get a Mac build working

Tools menu framework

There should be a system for developing the large number of tools that are anticipated. Opening a dialog to enter a number, marking the motor as modified, and handling errors should all be provided so the individual tools don't have to do much more than actually apply their desired change.

Nozzle preview

It would be nice to view a cross section of the nozzle in the motor editor, especially once more parameters are added with #47.

CSV exporting

Allow the user to export a CSV file of simulation data including whichever fields they want.

Propellant loading menu

Instead of printing something when loading an existing propellant that differs from the library, there should be some dialog that allows the user to choose what to do.

Refactor + design patterns

Ideas for things we should consider refactoring:

  • main.py: This is a given, we need to extract MainWindow and isolate code that doesn't include UI into a different class, maybe application or something.

  • Folder Structure: This is related to the discussion in #56 about where to store default values. Often python projects or packages will have a package for the "overall" project, which can contain code or data common to all sub-modules. If we choose this refactor, our codebase would look like this:

.
+-- _openMotor
|    +-- _ui
|    +-- _motor
+-- main.py
+-- ... etc

This will solve the current issues with circular imports.
Another benefit to this is that we can add new modules, for example the thermo module for Cantera chemical equilibrium which I am planning to tackle soon (maybe post 0.4.0?). This also allows us to post openMotor as a package on pyPI so people can use our libraries and APIs programmatically.

  • Style: We should follow PEP 8 style guide wherever possible. We don't have to follow all of it, for example snake_case everywhere is not necessary IMHO, but we should at least consider:

    • class names should be UpperCamelCase
    • line length <= 120 chars (?)
    • two newlines between each class definition
    • .. and more!
      We can use an auto-formatter for this if you feel inclined, Black is pretty good.
  • Docstrings: We should try to include docstrings wherever possible, especially in the fmm code and motorlib. UI docstrings are not as crucial but they help.

  • Everything listed in #53, but especially C* and per-motor settings.

More suggestions please! We don't need to tackle everything at once, this is just ideas for now.

Propellant loading issues

It seems that the system for detecting that a motor file uses an existing propellant isn't comparing them correctly. It almost always detects that the propellant in the loaded file is different from the propellant in the library, causing the file to be unsaved immediately on opening.

Fix FMM grain shutdown spikes

Near shutdown, FMM grains tend to spike up as their contours close when they are very close to the casting tube. Try changing the clean function slightly, or coming up with a new strategy to exclude these points.

Configurable alerts

Each motor file (or preferences?) should have a set of associated limits for pressure, mass flux, etc that generate alerts if they are passed.

File versioning

The program should be able to tell if a file was generated in a past version and migrate its contents to the current specification for the file, if possible. This applies for motors, propellants, and preferences.

Custom grain

Allow the user to import a DXF or image or something to define the core geometry of a custom propellant grain.

General Info and data files for comparison

Hi Andrew,

I posted the following on the Rocketry Forum and have moved it to here. Hopefully that is ok.

I haven't used GitHub before, so bear with me. How do I set the issue type?

I've put together Zip file which contains my IREC team's characterization testing. A couple of notes:

  • ProPEP 3 was used to determine propellant characterics - A&N etc.
  • Their goal is a 98 mm 10 - 20 % N with a smoke grain.

The zip file contains the following:

    1. *.txt - static test data. File name is the throat in 64's
    1. *.bsx - Burnsim files - Propellant is 2019 IREC Blue
    1. *.ric - openMotor files - Propellant is 2019 IREC Blue
    1. 76mm Characterization Tests.xlsx - Test data. Average and Maximum Pressure calculated and burn time.
    1. 98 2nd Static Test.bsx - Burnsim for next static test
    1. 98 2nd Static Test.ric - openMotor for next static test
    1. 98 2nd Static Test with smoke grain.bsx - Takes into account the 1" propellant delay grain
    1. 98 2nd Static Test with smoke grain.ric - Takes into account the 1" propellant delay grain
    1. 2019 IREC Test data.MTD2 - ProPEP3 - average pressure is used calculate A&N

General notes for the above

  • For the static test burns, openMotor and Burnsim are close and compare well to the test data.
  • However, they do differ in the total impulse and calculated thrust/force.
  • Since I used average pressure to calculate A&N etc, Burnsim and openMotor max pressure matches the average pressure. Curious, do you use max or average pressure to calculate A&N?
  • I believe this motor is a little on the erosive side.

IREC Test Data.zip

Ben

Grain burnout

Grains that are shorter than their web do not have the correct shutdown condition.

Area spike at startup

The first surface area call returns a value that is ~5% too large, leading to a KN/pressure/thrust spike that almost resembles erosive burning.

About dialog

Add an "about" dialog that shows the logo, current version, and license information.

Propellant editor button cut off

image

This apparently has something to do with UI scaling on Gnome. Will likely be fixed when the left menu bar is made larger to accommodate a duplicate button for #45.

Erosivity simulation

Implement some model for erosivity. This will probably require more information from the user and be somewhat slow, so it should be optional. It will require grains to be sliced along the motor's major axis and for each slice to have a separate regression rate. It will still be easy to calculate volume and area with the "sliced grains", but performance will be bad for FMM grains due to how many contours will need to be calculated. This will require a lot of testing.

Grain visualizer

There should be a widget that takes in a perforated grain and displays the generated geometry. It should also be able to display the grain's regression pattern. The UI should be minimal as it will be used on the grain editing screen.

Add exception handling to file reading and writing

Though the file menu usually saves the user from this kind of error, it is possible to crash the program by trying to write to a read only file. There should be a popup to tell the user something went wrong.

Mac redraw issues

It seems that other UI elements may need manual repaints to get them to redraw on OSX. The grain table is one example, and any others should be found. Try to find a solution at a higher level before just throwing a repaint into every update function.

Image Exporting

Allow the user to export an image of the thrust/pressure/kn curve, and maybe add support for statistics to be overlaid on it.

List geometry alerts in grain editor

I really like the designer and how the Face etc are updated in real time as you change the various design parameters.

I've been doing some testing of the grain editor with the latest build.

  • End Burner - Doesn't display the tab showing Face/Regression/Area Graph. Should it?

  • Errors- If you have any errors in the grain design, the errors are caught and reported when your "run" the sim. I believe it would be more user friendly if grain errors were displayed when the clicks on the Apply button.

  • Add Grain button - When you click on "Add grain" it looks like the grain is added to the grid then the grain editor is displayed. If I cancel w/o editing or realize I picked the wrong grain type and wanted to cancel and not add the grain, the grain is still listed in the grid. Is it possible to first display the grain editor and then add the grain to grid when the user selects "Apply". Cancel would not add the grain.

Ben

Remove "default" motor

The program should start up to a blank slate. The propellant selector should have a "-" option for when the current motor has None set as its propellant, and this should mesh well with deletion of the current propellant. This is also a good time to revisit all of the motor editor stuff and add some signals instead of calling the setup____ functions everywhere.

Show peak mass flux location

Until the detailed graph of stats is available, it is not currently possible to tell where the calculated peak mass flux is. There should be a field after the value itself that tells which grain it was found in.

Example:
Peak Mass Flux: 1.2 lb/(in^2*s) (Grain 4)

Make BATES a perforated grain

The geometry calculations should not change for performance reasons, but it should be able to be displayed on the grain visualizer and reuse code for mass flux.

Suggested updates to simulation

Ideas:

  • Simulation settings (Ambient pressure, nozzle efficiency, burnout threshhold, erosive burning toggle, etc...) should be saved per-file, yet also have configurable defaults for new motors (a la OpenRocket).
  • Same as above, with configurable simulation alerts
  • Update UI to include "run simulation" button

Potentially breaking changes:

  • Replace T with C* (keep molar mass as its used in nozzle exit calculations?), or, just add C* and use that wherever appropriate in the simulation.

@reilleya thoughts on each of these? I will add changes to the erosive burning branch

Improved nozzle calculations

Change how thrust is calculated. Calculations should take into account details like convergent/divergent section angles and throat length to reduce dependence on the "efficiency" that thrust is currently scaled by.

Simulation exceptions

The simulation should detect error conditions like mass flow attempting to go through an endburning grain. If an error is encountered, the simulation should stop and tell the user what is wrong. There could also be user-configurable errors for limits like case max pressure and erosive mass flux being exceeded.

Duplicate a previously entered grain

Provide the ability to duplicate a selected grain. If the user has selected a previously entered grain, pressing the "Add" button would add the grain.

Tools->Set->KN

These tools should allow the user to enter a desired KN (either initial or peak) that the nozzle throat will be adjusted to meet.

Modified RIC file will not load

I'm using the unpacked version as start up time is a lot quicker.

Instead of reentering everything, I created the propellant "2019 IREC Blue" and modified each of the simulation files (ric) as follows:

  1. Added "data:" as the first line
  2. Indented all lines with 2 spaces
  3. Appended the following
    type: !!python/object/apply:uilib.fileIO.fileTypes [3]
    version: !!python/tuple [0, 1, 0]

For some reason or other, the attached sim file will not load. Program aborts w/o any kind of a message. All of the other modified sim files load and execute correctly.

Still haven't figured out how to assign an "Issue".

Can't upload *.ric files directly. Had to change the extension to "txt". Is there anyway to attach ric files w/o changing the extension?

#24 does not load.txt

Burnsim importing and exporting

Add support for importing motors from burnsim files, and also support the creation of burnsim files using motors built in openmotor.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.