reilleya / openMotor

An open-source internal ballistics simulator for rocket motor experimenters
GNU General Public License v3.0
361 stars 71 forks source link

Automatic Motor Optimization #204

Open mvccogo opened 1 year ago

mvccogo commented 1 year ago

It would be interesting to have an option in the "Tools" dropdown list to automatically find a suitable motor given the parameters proposed by the user. I've done a similar thing using scipy.optimize, and some of you may be familiar with Matlab's fminsearch/fmincon.

The parameters given as constraints are:

The parameters given as input/goals are:

The parameters given as bounds are:

The output design parameters are:

Python code as a concept:

def optimize_for_impulse():
    constraint = [{'type' : 'ineq', 'fun' : restraint_mean_pressure},              
                  {'type' : 'ineq', 'fun' : restraint_port_ratio},                    
                  {'type' : 'ineq', 'fun' : restraint_peak_pressure},               
                  {'type' : 'ineq', 'fun' : restraint_kn_variation},                  
                  {'type' : 'ineq', 'fun' : restraint_mass_flux}]                     
    bounds = ((0.005, 0.01), (0.05, 0.225), (0.003, 0.015))                    
    it = 0
    while (True):
        initial_guess = [random.uniform(0.005, 0.03664*0.6), random.uniform (0.1, 0.225), random.uniform(0.005, 0.015)]
        a = optimize.minimize(optimize_total_impulse, initial_guess, bounds=bounds, constraints=constraint ) 
        if a.success and a.fun < 10:
            return a.x, it
        elif it > 500:
            print("No suitable configuration was found in ", it, "iterations.")
            break
        it += 1
reilleya commented 1 year ago

This would be fun to play around with! I still use openMotor fairly often but I don't have too much time to work on it. I would be able to find time to review a PR for this if you/someone sent one in, or will keep it in mind for when I someday start on a v0.6.0 if not.

mvccogo commented 1 year ago

Sure, no problem. I'm also short on time, but I thought we should have an issue dedicated to this. I'll try building oM first, get familiar with the program then take a stab at it later on. Thanks, Andrew.

benrussell11 commented 1 year ago

I used OM all of the time. Spaceport America teams are also using it. This option would be great to have. I know I would use it.

For the 2023 cup, my team is working on designing a booster and sustainer for a 6” 2-stage with an on the pad weight in the 90 lb. range. Interesting to say the least.

Ben Russell

From: Matheus V. C. Cogo @.> Sent: Wednesday, December 14, 2022 9:40 PM To: reilleya/openMotor @.> Cc: Subscribed @.***> Subject: Re: [reilleya/openMotor] Automatic Motor Optimization (Issue #204)

Sure, no problem. I'm also short on time, but I thought we should have an issue dedicated to this. I'll try building oM first, get familiar with the program then take a stab at it later on. Thanks, Andrew.

— Reply to this email directly, view it on GitHub https://github.com/reilleya/openMotor/issues/204#issuecomment-1352481624 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AL4HO6BSWA7XCNPY4YUBSRLWNKAHTANCNFSM6AAAAAAS3PIZQE . You are receiving this because you are subscribed to this thread. https://github.com/notifications/beacon/AL4HO6HJOL5NWJCNVPDDVLTWNKAHTA5CNFSM6AAAAAAS3PIZQGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSQTU5VQ.gif Message ID: @. @.> >