convexengineering / gplibrary

Useful subsystem models
MIT License
10 stars 11 forks source link

(in progress) playing around with materials library #17

Open whoburg opened 8 years ago

whoburg commented 8 years ago

@bqpd, this isn't working quite yet, but could you take a quick look at what I'm trying to do? I thought it might be really clean to implement a material property look-up table as a model, but turns out this is awkward because it requires adding constraints when all I really want is the variable values (for now at least).

whoburg commented 8 years ago

More commits welcome if you want to run with this...

bqpd commented 8 years ago

Two options:

whoburg commented 8 years ago

Using substitutions sounds great. If I create a ColumnBuckling and an Aluminum6061:

from materials import Aluminum6061
from structures import ColumnBuckling
alum = Aluminum6061()
colb = ColumnBuckling()

... then how do I substitute alum.constants into colb? I tried passing substitutions=alum.constants into ColumnBuckling.__init__, but I got a TypeError: setup() takes exactly 1 argument (2 given).

bqpd commented 8 years ago

That sounds like a GPkit which hasn't been updated to use the substitutions arg...

whoburg commented 8 years ago

Ah -- you're correct. Fixed that. It looks like the substitution doesn't happen quite as intended though -- is the E_ColumnBucklingAluminum6061 expected?

In [1]: from materials import Aluminum6061

In [2]: from structures import ColumnBuckling

In [3]: alum = Aluminum6061()

In [4]: colb = ColumnBuckling(substitutions=alum.constants)

In [5]: colb
Out[5]:
gpkit.ColumnBuckling(# minimize
    F_ColumnBuckling**-1 [1/lbf],
[   # subject to
    9.87*E_ColumnBuckling*I_ColumnBuckling*K_ColumnBuckling**-2*L_ColumnBuckling**-2 [GPa*m**2] >= F_ColumnBuckling [lbf],
],
    substitutions={E_ColumnBucklingAluminum6061: 69, rho_ColumnBucklingAluminum6061: 2.7, sigma_{y}_ColumnBucklingAluminum6061: 55, I_ColumnBuckling: 1e-09, K_ColumnBuckling: 2.0, L_ColumnBuckling: 1})

In [6]: colb.solve()
E_ColumnBuckling has no upper bound
Using solver 'cvxopt'
Solving for 2 variables.
whoburg commented 8 years ago

(it's perfectly possible I'm using substitutions wrong -- let me know if there's a better way to get the desired behavior).

bqpd commented 8 years ago

Ack, no, this is expected. And right now merging doesn't cover substitutions, otherwise I'd just recommend you merge them...