cylinder_opt_example.py¶
Example 5 from: https://cims.nyu.edu/~kiryl/Calculus/Section_4.5–Optimization%20Problems/Optimization_Problems.pdf
A manufacturer needs to make a cylindrical can that will hold 1.5 liters of liquid. Determine the dimensions of the can that will minimize the amount of material used in its construction.
Minimize: area = 2*pi*r**2 + 2*pi*r*h Constraint: volume = pi*r**2*h/1000 = 1.5
- Optimal values:
- indep.r = 6.2035 cm indep.h = 12.407 cm cylinder.area = 725.396379 cm**2 cylinder.volume = 1.5 L
We’re going to model our cylinder in two different ways and show that we get the same result.
-
class
openmdao.examples.cylinder_opt_example.
Cylinder1
[source]¶ Bases:
openmdao.core.component.Component
This is one way to model our cylinder. We can define our own Component class that defines solve_nonlinear() and linearize() methods.
-
openmdao.examples.cylinder_opt_example.
Cylinder2
()[source]¶ This is another way to model our cylinder, by using an ExecComp that contains the equations for cylinder area and volume given radius and height.
-
openmdao.examples.cylinder_opt_example.
opt_cylinder1
()[source]¶ Perform the optimization using our Cylinder class.
-
openmdao.examples.cylinder_opt_example.
opt_cylinder2
()[source]¶ Perform the optimization using an ExecComp to model the cylinder.
-
openmdao.examples.cylinder_opt_example.
setup_opt
(cylinder)[source]¶ Creates a Problem, adds a model for the cylinder, and sets up the optimizer, design variables, and constraints.