Colebrook-White
This commit is contained in:
parent
0a45ed3d6f
commit
c9a67f0347
@ -154,5 +154,38 @@ I_Planck <- function(wavelength, temp){
|
||||
|
||||
lam.vec <- seq(100,2000,len=70)
|
||||
plot(lam.vec, I_Planck(lam.vec,5778), type = "l", lty = 1,
|
||||
xlab="wavelength (nm)", ylab="Energy Density", main="Wavelength peaks for different T (K)")
|
||||
xlab="wavelength (nm)", ylab="Energy Density",
|
||||
main="Wavelength peaks for different T (K)")
|
||||
grid(NULL,NULL)
|
||||
|
||||
## Part 4: Colebrook-White
|
||||
# Solve
|
||||
implicitFF <- function(Re,ed,x.guess,tol=1e-6){
|
||||
if (Re<2000){
|
||||
f0 <- 16/Re
|
||||
} else {
|
||||
fun.4 <- function(x) {(-16*log10((ed/3.7)+(1.255/(Re*sqrt(x)))))^-2}
|
||||
fun.4.string <- "(-16*log10((ed/3.7)+(1.255/(Re*sqrt(x)))))^-2"
|
||||
fun.4.estimate <- findZeroRelax(fun.4,x.guess)
|
||||
f0 <- fun.4.estimate[1]
|
||||
}
|
||||
# Plot
|
||||
func.plot <- ggplot(data.frame(x=seq(0,2,.1)), aes(x)) +
|
||||
stat_function(fun=fun.4, aes(col=fun.4.string)) +
|
||||
geom_hline(aes(yintercept=0, col = "y=0"), show.legend=TRUE)+
|
||||
geom_vline(aes(xintercept=fun.4.estimate[1],
|
||||
col = "relaxation estimate"), show.legend=TRUE)+
|
||||
ggtitle("Zero Function") +
|
||||
xlab("x") + ylab("Zero Function") +
|
||||
theme(text = element_text(size=20), plot.title = element_text(hjust = 0.5))
|
||||
print(func.plot)
|
||||
return(f0)
|
||||
}
|
||||
|
||||
# 4a
|
||||
fa.estimate <- implicitFF(7000, 0.0001, 0.1)
|
||||
# 4b
|
||||
fb.estimate <- implicitFF(8000, 0.0001, 0)
|
||||
# 4c
|
||||
fc.estimate <- implicitFF(9000, 0.0001, 0)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user