library(ggplot2) # Create a data frame with temperature of the cold reservoir values from 260 to 290 df <- data.frame(Tc = seq(260, 300)) # Calculate the corresponding Carnot COP values for a refrigeration system with a hot reservoir temperature of 308K df$COP1 <- 308 / (308 - df$Tc) # Scale the COP values by multiplying by 0.4 df$COP1 <- df$COP1 * 0.4 # Calculate the corresponding Carnot COP values for a refrigeration system with a hot reservoir temperature of 328K df$COP2 <- 328 / (328 - df$Tc) # Scale the COP values by multiplying by 0.4 df$COP2 <- df$COP2 * 0.4 # Create a line plot of the data p <- ggplot(df, aes(x = Tc)) + geom_line(aes(y = COP1), color = "steelblue") + geom_line(aes(y = COP2), color = "red") + theme(plot.margin = unit(c(0, 0, 0, 0), "cm")) + scale_y_continuous(limits = c(0,10), breaks=seq(0,10,by=1))+ scale_x_continuous(labels = function(x) round(x - 273, 1), breaks=seq(260,300, by=2))+ labs(x = "Temperature of Cold Reservoir (K)", y = "Carnot COP", title = "Carnot COP for a Refrigeration System with Hot Reservoir Temperature of 308K and 328K") # Save the plot as a PDF file named "cop.pdf" ggsave("cop.pdf", plot = p, width = 6, height = 4)