Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Motor Optimization #204

Open
mvccogo opened this issue Dec 12, 2022 · 3 comments
Open

Automatic Motor Optimization #204

mvccogo opened this issue Dec 12, 2022 · 3 comments

Comments

@mvccogo
Copy link

mvccogo commented Dec 12, 2022

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:

  • Mean Pressure: average pressure developed after a simulation
  • Port ratio: set minimum Port/Throat ratio to reduce effects of erosive burning
  • Peak Pressure: peak pressure developed after a simulation
  • Kn variation: maximum allowed Kn variation throughout the burn
  • Maximum Mass Flux: reduce effects of erosive burning

The parameters given as input/goals are:

  • Total impulse

The parameters given as bounds are:

  • Min and Max outer diameter (BATES)
  • Min and Max inner diameter (BATES)
  • Min and Max length (BATES)

The output design parameters are:

  • Number of grains
  • Length of grains
  • Inner and outer diameter of grains
  • Nozzle configuration

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
Copy link
Owner

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
Copy link
Author

mvccogo commented Dec 15, 2022

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
Copy link

benrussell11 commented Dec 15, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants