Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions materials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Material library"""
from gpkit import Model, Variable


class Material(Model):
# todo: what should be common?
pass


class Aluminum6061(Material):
def setup(self):
rho = Variable(r"\rho", 2.70, "g/cm^3", "density")
E = Variable("E", 69, "GPa", "Young's modulus")
sigma_y = Variable(r"\sigma_{y}", 55, "MPa", "yield stress")
# the objective and constraints are completely arbitrary.
# use case is accessing Variables (and their associated values)
return rho, [sigma_y <= E]


if __name__ == "__main__":
pass
25 changes: 25 additions & 0 deletions structures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from numpy import pi
from gpkit import Model, Variable


class ColumnBuckling(Model):
"""Euler column buckling, from https://en.wikipedia.org/wiki/Buckling

For both ends pinned (hinged, free to rotate), K = 1.0.
For both ends fixed, K = 0.50.
For one end fixed and the other end pinned, K ~= 0.699.
For one end fixed and the other end free to move laterally, K = 2.0.
"""
def setup(self):
F = Variable("F", "lbf", "vertical load on column")
E = Variable("E", "GPa", "modulus of elasticity")
I = Variable("I", 1e-9, "m^4", "area moment of inertia")
L = Variable("L", 1, "m", "unsupported length of column")
K = Variable("K", 2.0, '-', "column effective length factor")
return 1/F, [F <= pi**2*E*I / (K*L)**2]


if __name__ == "__main__":
from materials import Aluminum6061
M = ColumnBuckling().merge(Aluminum6061())
M.solve()