Comment
Author: Admin | 2025-04-27
Pump we need to perform some unit conversions. The electricity consumption is currently expressed in W while the energy added to the water is currently expressed in Btu/timestep. To make this unit conversion we use the ratio 1 W = 3.412142 Btu/hr, then convert Btu/hr to Btu/s and multiply by the 10 seconds per timestamp. This gives the code:Data['P_Elec (Btu/10s)'] = Data['P_Elec (W)'] * (3.412142/60/60) * 10The COP is by definition the amount of heat added to the water divided by the amount of electricity consumed. Thus, we can calculate it with:Data['COP (-)'] = Data['Change in Stored Energy (Btu)'] / Data['P_Elec (Btu/10s)']Generating RegressionsNow we have a table showing the COP as a function of the water temperature at each of the three specified COPs. But we can do better than that. Wouldn’t it be nice to have a function we can use to calculate the COP so we can just enter the water temperature and identify the COP accordingly?NumPy provides the tools to make this easy. We can use the NumPy function “polyfit” to identify the coefficients of a regression describing the COP as a function of the water temperature. It’s a flexible function, allowing you to control the shape of the curve by specifying the order of the function at the end. Since the COP of a heat pump as a function of temperature is a parabolic curve, we need a second order regression for this example. Thus, the following line identifies the coefficients: Coefficients = np.polyfit(Data[‘Average Tank Temperature (deg F)’], Data[‘COP (-)’], 2)We can use the NumPy “poly1d” function to create a regression using those coefficients with:Regression = np.poly1d(Coefficients)Now you can identify the COP of the heat pump at a specified water temperature using this regression. Remember the regression is only generated for a specific air temperature, so only estimate the COP using the regression for the correct air temperature. (Creating a 2-d performance map is the ultimate goal of this tutorial, but we aren’t there yet.)We can identify the COP at a specified water temperature by calling the function and using the water temperature as an input. For instance, if you want to find the COP when the water temperature is 72 °F, you can enter:COP_72 = Regression(72.0)Regression RefresherWhat Is Linear Regression?How Do I Save Python Data Analysis Results?The data can be saved using the same techniques we’ve been using. We need to: Ensure that a folder for analyzed results is available. Create a new file name that clearly states what the file contains. Save the data. In this case we want to save the data to a new file called “Analyzed.” It should be in the same data folder and used to show the results of
Add Comment