Category Archives: Design & Engineering

WLF Curve Fitting

A short script to fit a W-L-F model to experimental data. This is flaky, depending on the input guesses and convergence is poor. We simply stop the convergence at the point we have an acceptable fit. This is not robust!


options(scipen = 10)
aT <- structure(list(Temp.F = c(64.4, 86, 104, 122, 149, 176, 203,
230, 257, 284, 311), aT = c(16.7, 1.76, 1, 0.358, 0.00965, 0.000722,
0.000000308, 0.0000000733, 0.00000000357, 0.000000000202, 0.0000000000191
)), .Names = c("Temp.F", "aT"), class = "data.frame", row.names = c(NA,
-11L))
at.nls<-nls(log(aT) ~ ((-C1*(Temp.F-104))/(C2+(Temp.F-104))),
data = aT,
start = list(C1 = 100, C2 = 202),
trace = 1,
# weights = c(10,rep(1,length(aT)-1)),
nls.control(maxiter = 3,
tol = 1e-16,
minFactor = 1/1000000000024,
warnOnly = TRUE))
plot(log(aT$aT)~aT$Temp.F)
lines(predict(at.nls)~aT$Temp.F)
C1 <- summary(at.nls)$coefficients[[1]]
C2 <- summary(at.nls)$coefficients[[2]]
plot((aT$aT)~aT$Temp.F, log = "y", ylim = c(1e-20,100), xlim = c(0,500))
lines(exp(predict(at.nls))~aT$Temp.F)
curve(exp((-C1*(x-104))/(C2+(x-104))), add = TRUE)

Average of multiple curves

This R script is useful for creating average curves of experimental material property data. it simply breaks the multiple curve data into discrete chunks and averages the values within each chunk. The size of the window is customizable. Additionally, it also generates a lowess fit for the resultant dataset, applying additional smoothing if desired.


# R Script to compute an average curve from material test data
options(digits = 5)

# Read raw data (data should be in 2 colums) and sort by x-value.
# Data should be offset to the origin and all but a single 0,0 point should be included)
Data <- read.csv("Z:/Christopher/15/141531/Materials/Planar_23.csv", header=FALSE)
Data.sort <- Data[order(Data$V1),]

# Define the number of samples to generate
points <- 19
samples <- floor((length(Data.sort$V1)-1)/points)

# Initialize the matrix (we assume that the )
Result <- matrix(nrow = points, ncol = 2)
Result[1,] <- c(0,0)

# Loop over the data computing the average of groups of data points
# defined by the width of the sample window
i <- 1
x <- 1
for(x in 2:points){
V1 <- V2 <- 0.0
for(y in 1:samples){
V1 <- V1 + Data.sort[y+i,1]
V2 <- V2 + Data.sort[y+i,2]
}
i<-i+samples
Result[x,] <- c(V1/samples,V2/samples)
}

# Plot the raw data and the averaged curve in red
plot(Data.sort, pch = 1)
lines(Result, col = "red", lwd = 3)

# Create a lowess smoothed curve and plot in blue.
# This is helpful to remove noise in the average especially with a
# large number of sampled points
Smooth <- (lowess(Result, f = .3))
lines(Smooth, col = "blue", lwd = 3)

# Perform some data manipulation and export as tab delimited text files
Smooth<-(do.call(rbind, lapply(Smooth, unlist)))
Smooth[,1] <- c(0,0)
write(t(Result), file = "Planar_23_avg.txt", ncolumns = 2, sep = "\t")
write(Smooth, file = "Planar_23_smth.txt", ncolumns = 2, sep = "\t")

Rplot

QFD: House of Quality Template

Running around the web, I could not find a quality HOQ template that was not locked, protected, or complete for my needs. So I decided to create one and share it. The attached template is created in Excel 2007 and does not contain any macros or VB code. Nothing is locked or protected, and it can be resized at will (though this may require a little cleanup afterwards). Drop down lists are generated using the Data Validation tool, in-cell charts through the use of the REPT function, cell highlighting using conditional formatting and the line charts are simple excel graphs, updated automatically, that are aligned with the cells.

Click on the picture for a larger image. You can download the MS Excel 2007 template here and the OOo 3.1.1 template here.

I place this template into the public domain. Feel free to use, modify, redistribute, etc. Though if you do find it useful, let me know.


Caveat lector — All work and ideas presented here may not be accurate and should be verified before application.