Skip to content

Instantly share code, notes, and snippets.

@jstults
jstults / octet_volfrac_array.py
Created December 21, 2012 14:11
generate octet truss array with varying member radius, and generate a part based on a variable density solution from ToPy
#
# http://www.variousconsequences.com/2012/12/octet-truss-for-topology-optimization.html
#
import scipy as sp
import cPickle
import octet
if __name__ == "__main__":
import os
@jstults
jstults / octet.py
Created December 21, 2012 14:16
functions for generating mged (BRLCAD) commands to make octet truss primitives
#
# http://www.variousconsequences.com/2012/12/octet-truss-for-topology-optimization.html
#
import scipy as sp
class rcc_shape():
def __init__(self, name, origin, height, radius):
self.name = name
self.origin = origin
self.height = height
@jstults
jstults / multi_scatter.R
Created January 21, 2013 19:44
example of small multiple scatter plots and marginal densities in R
ninputs = 3 # across the columns
noutputs = 2 # down the rows
iin = c(1,2,3) # indices for the inputs
jout = c(4,5) # indices for the ouputs
# example data frame:
npoints = 2**14
data.set = data.frame(X1=rnorm(npoints), X2=rnorm(npoints), X3=rnorm(npoints))
data.set = transform(data.set, X4=X1*X2+0.1*X3**2, X5=2*X2+X1+0.1*X3**2)
# the width/height are set by \showthe\columnwidth \textheight in latex
@jstults
jstults / ofat.R
Created February 2, 2013 14:27
why one-factor-at-a-time testing is a bad idea
#
# why one-factor-at-a-time testing is a bad idea
# http://www.variousconsequences.com/2013/02/no-interactions-ofat-is-still-bad-idea.html
#
library(AlgDesign)
library(xtable)
# full factorial of 6 factors at 2 levels:
fullfac = gen.factorial(levels=c(2,2,2,2,2,2), center=TRUE)
# D-optimal fraction, 32 runs:
dx.1 = optFederov(~(X1+X2+X3+X4+X5+X6)^2, data=fullfac, nTrials=32, nullify=2, maxIteration=64, nRepeats=200)
@jstults
jstults / octet_truss.py
Created June 25, 2013 00:47
octet truss cubes with two levels of hierarchical organization to improve the speed of the union operation
import scipy as sp
import itertools as it
class rcc_shape():
def __init__(self, name, origin, height, radius):
self.name = name
self.origin = origin
self.height = height
self.radius = radius
def mged_string(self):
@jstults
jstults / framev.tpd
Created December 7, 2013 20:27
ToPy Problem Definition (tpd) for topology optimization of a Prusa Mendel frame vertex Based on this one: http://www.thingiverse.com/thing:5094/
[ToPy Problem Definition File v2007]
#
# Author: Joshua Stults
# a 2d cross-section for a Prusa Mendal RepRap frame vertex
#
PROB_TYPE : comp
PROB_NAME : framev
ETA : 0.5 # reciprocal approx.
DOF_PN : 2
@jstults
jstults / solidvoid.py
Created December 7, 2013 20:32
script to process 1-bit pngs that define solid and void regions for ToPy topology optimization problems
# read in black & white pngs and create PASV_ELEM and ACTV_ELEM lists
# for topy input decks
#
# void.png: black pixels indicate regions that should be void
# solid.png: black pixels indicate regions that should be solid
#
from PIL import Image
solidim = Image.open("solid.png")
voidim = Image.open("void.png")
@jstults
jstults / brkt.dxf
Last active August 29, 2015 14:03
3-in Tack Strip Bracket TopOpt
0
SECTION
2
HEADER
9
$ACADVER
1
AC1014
9
$HANDSEED
@jstults
jstults / pure-bending.tpd
Last active December 16, 2017 22:55
Pure bending ToPy problem definition
[ToPy Problem Definition File v2007]
# Author: Josh Stults
# pure bending topology optimization on a 640x720 domain
PROB_TYPE : comp
PROB_NAME : pure-bend
ETA : exp
DOF_PN : 2
VOL_FRAC : 0.3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.