def calc_perf(theta_0=360,
              plot=False,
              verbose=True,
              inertial=False,
              export_csv=True):
    t, torque, drag = foampy.load_all_torque_drag()
    _t, theta, omega = foampy.load_theta_omega(t_interp=t)
    reached_theta_0 = True
    if theta.max() < theta_0:
        theta_0 = 1
        reached_theta_0 = False
    # Compute tip speed ratio
    tsr = omega * R / U_infty
    # Compute mean TSR
    meantsr = np.mean(tsr[theta >= theta_0])
    if inertial:
        inertia = 3  # guess from SolidWorks model
        inertial_torque = inertia * fdiff.second_order_diff(omega, t)
        torque -= inertial_torque
    # Compute power coefficient
    power = torque * omega
    cp = power / (0.5 * rho * area * U_infty**3)
    meancp = np.mean(cp[theta >= theta_0])
    # Compute drag coefficient
    cd = drag / (0.5 * rho * area * U_infty**2)
    meancd = np.mean(cd[theta >= theta_0])
    if export_csv:
        df = pd.DataFrame()
        df["theta_deg"] = theta
        df["tsr"] = tsr
        df["cp"] = cp
        df["cd"] = cd
        df.to_csv("processed/perf.csv", index=False)
    if verbose:
        print("Performance from {:.1f}--{:.1f} degrees:".format(
            theta_0, theta.max()))
        print("Mean TSR = {:.3f}".format(meantsr))
        print("Mean C_P = {:.3f}".format(meancp))
        print("Mean C_D = {:.3f}".format(meancd))
    if plot:
        plt.close('all')
        plt.plot(theta[5:], cp[5:])
        plt.title(r"$\lambda = %1.1f$" % meantsr)
        plt.xlabel(r"$\theta$ (degrees)")
        plt.ylabel(r"$C_P$")
        #plt.ylim((0, 1.0))
        plt.tight_layout()
        plt.show()
    if reached_theta_0:
        return {"C_P": meancp, "C_D": meancd, "TSR": meantsr}
    else:
        return {"C_P": "nan", "C_D": "nan", "TSR": "nan"}
Example #2
0
def calc_perf(theta_0=360, plot=False, verbose=True, inertial=False):
    t, torque, drag = foampy.load_all_torque_drag()
    _t, theta, omega = foampy.load_theta_omega(t_interp=t)
    reached_theta_0 = True
    if theta.max() < theta_0:
        theta_0 = 1
        reached_theta_0 = False
    # Compute tip speed ratio
    tsr = omega*R/U_infty
    # Compute mean TSR
    meantsr = np.mean(tsr[theta >= theta_0])
    if inertial:
        inertia = 3 # guess from SolidWorks model
        inertial_torque = inertia*fdiff.second_order_diff(omega, t)
        torque -= inertial_torque
    # Compute power coefficient
    power = torque*omega
    cp = power/(0.5*rho*area*U_infty**3)
    meancp = np.mean(cp[theta >= theta_0])
    # Compute drag coefficient
    cd = drag/(0.5*rho*area*U_infty**2)
    meancd = np.mean(cd[theta >= theta_0])
    if verbose:
        print("Performance from {:.1f}--{:.1f} degrees:".format(theta_0, 
                                                                theta.max()))
        print("Mean TSR = {:.3f}".format(meantsr))
        print("Mean C_P = {:.3f}".format(meancp))
        print("Mean C_D = {:.3f}".format(meancd))
    if plot:
        plt.close('all')
        plt.plot(theta[5:], cp[5:])
        plt.title(r"$\lambda = %1.1f$" %meantsr)
        plt.xlabel(r"$\theta$ (degrees)")
        plt.ylabel(r"$C_P$")
        #plt.ylim((0, 1.0))
        plt.tight_layout()
        plt.show()
    if reached_theta_0:
        return {"C_P" : meancp, 
                "C_D" : meancd, 
                "TSR" : meantsr}
    else:
        return {"C_P" : "nan", 
                "C_D" : "nan", 
                "TSR" : "nan"}
Example #3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Aug  8 09:22:09 2013

@author: pete
"""
from __future__ import division, print_function
import matplotlib.pyplot as plt
import numpy as np 
import foampy
from gendynmeshdict import meantsr

t, torque, drag = foampy.load_all_torque_drag(torque_axis="x")

# Compute tip speed ratio
R = 0.13
U = 1.0
omega = -meantsr*U/R 		# direction is reversed
theta = -omega*t*180.0/np.pi

print("Mean tsr:", meantsr)

# Pick an index to start from for mean calculations and plotting
# (allow turbine to reach steady state)
try:
    i = np.where(np.round(theta) == 100)[0][0]
except IndexError:
    i = 5
i2 = -1
Example #4
0
def test_load_all_torque_drag():
    t, torque, drag = foampy.load_all_torque_drag(casedir="test")
    assert t.max() == 4.0