Coverage for docs/source/examples/water_tank.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.4.0, created at 2024-01-07 22:15 -0500

1"Minimizes cylindrical tank surface area for a particular volume." 

2from gpkit import Variable, VectorVariable, Model 

3 

4M = Variable("M", 100, "kg", "Mass of Water in the Tank") 

5rho = Variable("\\rho", 1000, "kg/m^3", "Density of Water in the Tank") 

6A = Variable("A", "m^2", "Surface Area of the Tank") 

7V = Variable("V", "m^3", "Volume of the Tank") 

8d = VectorVariable(3, "d", "m", "Dimension Vector") 

9 

10# because its units are incorrect the line below will print a warning 

11bad_monomial_equality = M == V 

12 

13constraints = (A >= 2*(d[0]*d[1] + d[0]*d[2] + d[1]*d[2]), 

14 V == d[0]*d[1]*d[2], 

15 M == V*rho) 

16 

17m = Model(A, constraints) 

18sol = m.solve(verbosity=0) 

19print(sol.summary())