Exemplo n.º 1
0
class PlantFromWWF(Component):
    """Create a Plant information from a .wwf WAsP file"""
    # Inputs
    filename = Str(iotype='in', desc='The .wwf file name')
    wt_desc = VarTree(GenericWindTurbinePowerCurveVT(),
                      iotype='in',
                      desc='The wind turbine power curve')

    # Outputs
    wt_layout = VarTree(GenericWindFarmTurbineLayout(),
                        iotype='out',
                        desc='wind turbine properties and layout')
    wind_rose_array = Array(
        iotype='out',
        units='m/s',
        desc='Windrose array [wind_directions, frequency, weibull_A, weibull_k]'
    )

    def execute(self):
        # Reading the .wwf file
        wwf = WWF(self.filename)
        self.wt_layout.wt_list.append(self.wt_desc)
        # self.wt_layout.wt_wind_roses.frequency_array =
        self.wt_layout.configure_single()

        for wt, wr in self.wwf.windroses.iteritems():
            self.wt_layout.wt_positions[i, :] = self.wwf.data[wt][:2]
            self.wt_layout.wt_wind_roses.append(wr)
            i += 1

        self.wt_layout.configure_single()
        # For practical reason we also output the first wind rose array outside
        # the wt_layout
        self.wind_rose_array = self.wt_layout.wt_wind_roses[0]
Exemplo n.º 2
0
class WTDescFromWTG(Component):
    """Create a wt_desc from a .wtg WAsP file"""
    # Inputs
    filename = Str(iotype='in', desc='The .wtg file name')

    # Outputs
    wt_desc = VarTree(GenericWindTurbinePowerCurveVT(),
                      iotype='out',
                      desc='The wind turbine power curve')

    def __init__(self, filename=None):
        super(WTDescFromWTG, self).__init__()

        if filename is not None:
            self.filename = filename
            self.execute()

    def execute(self):
        # Reading the .wtg file
        wtg = WTG(self.filename)

        # Filling up the VT
        self.wt_desc.power_curve = wtg.data[:, :2]
        self.wt_desc.c_t_curve = vstack([wtg.data[:, 0], wtg.data[:, 2]]).T
        self.wt_desc.cut_in_wind_speed = wtg.data[0, 0]
        self.wt_desc.cut_out_wind_speed = wtg.data[-1, 0]
        self.wt_desc.air_density = wtg.density
        self.wt_desc.rotor_diameter = wtg.rotor_diameter
        self.wt_desc.power_rating = self.wt_desc.power_curve[:, 1].max()
        self.wt_desc.hub_height = wtg.hub_height
        self.wt_desc.test_consistency()
Exemplo n.º 3
0
    def __init__(self, openwind_executable, workbook_path, 
                 turbine_name=None, script_file=None, machine_rating=None,
                 academic=False, debug=False):
        """ Creates a new LCOE Assembly object """

        foundErrors = False
        if not os.path.isfile(openwind_executable):
            sys.stderr.write('\n*** ERROR: executable {:} not found\n\n'.format(openwind_executable))
            foundErrors = True
        if not os.path.isfile(workbook_path):
            sys.stderr.write('\n*** ERROR: workbook {:} not found\n\n'.format(workbook_path))
            foundErrors = True
        if foundErrors:
            return None
        
        # Set the location where new scripts and turbine files will be written
        
        self.workDir = os.getcwd()
        #self.workDir = os.path.dirname(os.path.realpath(__file__)) # location of this source file
                
        self.openwind_executable = openwind_executable
        self.workbook_path = workbook_path
        self.turbine_name = turbine_name
        self.script_file = script_file
        self.academic = academic
        self.debug = debug
        
        if machine_rating is not None:
            self.machine_rating = machine_rating
            
        super(openwind_assembly, self).__init__()

        # TODO: hack for now assigning turbine
        self.turb = GenericWindTurbinePowerCurveVT()
        self.turb.power_rating = self.machine_rating
        self.turb.hub_height = self.hub_height
        self.turb.power_curve = np.copy(self.power_curve)
        for i in xrange(0,self.turbine_number):
            self.wt_layout.wt_list.append(self.turb)
Exemplo n.º 4
0
def generate_GenericWindTurbinePowerCurveVT(WT):
    """Generate a GenericWindTurbinePowerCurveVT instance from a WindTurbine
    instance

    Parameters
    ----------
    WT: WindTurbine
        A WindTurbine instance

    Returns
    -------
    wt_desc: GenericWindTurbinePowerCurveVT
        A GenericWindTurbinePowerCurveVT instance containing the same information
        as in WT

    """
    wt_desc = GenericWindTurbinePowerCurveVT()
    wt_desc.hub_height = WT.H
    wt_desc.rotor_diameter = WT.R * 2.0
    wt_desc.c_t_curve = np.vstack([WT.ref_u, WT.ref_CT]).T
    wt_desc.power_curve = np.vstack([WT.ref_u, WT.ref_P]).T
    wt_desc.cut_in_wind_speed = WT.u_cutin
    wt_desc.cut_out_wind_speed = WT.u_cutout
    return wt_desc
Exemplo n.º 5
0
def generate_GenericWindTurbinePowerCurveVT(WT):
    """Generate a GenericWindTurbinePowerCurveVT instance from a WindTurbine
    instance

    Parameters
    ----------
    WT: WindTurbine
        A WindTurbine instance

    Returns
    -------
    wt_desc: GenericWindTurbinePowerCurveVT
        A GenericWindTurbinePowerCurveVT instance containing the same information
        as in WT

    """
    wt_desc = GenericWindTurbinePowerCurveVT()
    wt_desc.hub_height = WT.H
    wt_desc.rotor_diameter = WT.R*2.0
    wt_desc.c_t_curve = np.vstack([WT.ref_u, WT.ref_CT]).T
    wt_desc.power_curve = np.vstack([WT.ref_u, WT.ref_P]).T
    wt_desc.cut_in_wind_speed = WT.u_cutin
    wt_desc.cut_out_wind_speed = WT.u_cutout
    return wt_desc
Exemplo n.º 6
0
def generate_random_GenericWindTurbinePowerCurveVT(D=None):
    """
    Generate a random turbine and power curve using the GenericWindTurbinePowerCurveVT class

    Parameters
    ----------
    D       float, default=random, (optional)
            The wind turbine rotor diameter

    Returns
    -------
    wt_desc GenericWindTurbinePowerCurveVT
            A random wind turbine power curve and c_t curve variable tree
    """
    if not D:
        D = 200 * random()

    wt_desc = GenericWindTurbinePowerCurveVT()
    wt_desc.rotor_diameter = D
    wt_desc.hub_height = D * (0.5 + random())
    wt_desc.cut_in_wind_speed = 2. + 4. * random()
    wt_desc.cut_out_wind_speed = 20. + 10. * random()
    rho = 1.225
    rated_wind_speed = 8. + 4. * random()
    max_a = 0.333 * random()
    max_cp = 4 * max_a * (1 - max_a)**2.
    max_ct = 4 * max_a * (1 - max_a)
    A = 0.25 * pi * D**2.  # Rotor area
    ideal_power = lambda ws: 0.5 * rho * A * max_cp * ws**3.
    real_power = lambda ws: ideal_power(
        ws) if ws < rated_wind_speed else ideal_power(rated_wind_speed)
    #a_ct = -sqrt(-c_t + 1)/2 + 1/2
    ct_from_cp = lambda cp: min(0.89, cp * 2.)
    cp_from_power = lambda power, ws: power / (0.5 * rho * A * ws**3.)
    ct_from_power = lambda pws: ct_from_cp(cp_from_power(pws[0], pws[1]))
    N = 3 + int(random() * 100)
    ws = linspace(wt_desc.cut_in_wind_speed, wt_desc.cut_out_wind_speed, N)
    wt_desc.power_curve = vstack([ws, map(real_power, ws)]).T
    wt_desc.c_t_curve = vstack(
        [ws, map(ct_from_power, zip(wt_desc.power_curve[:, 1], ws))]).T
    wt_desc.power_rating = ideal_power(rated_wind_speed)
    wt_desc.rated_wind_speed = rated_wind_speed
    wt_desc.air_density = rho
    wt_desc.test_consistency()
    return wt_desc
 def test_init(self):
     gwtpc = GenericWindTurbinePowerCurveVT()
Exemplo n.º 8
0
def generate_random_GenericWindTurbinePowerCurveVT(D=None):
    """
    Generate a random turbine and power curve using the GenericWindTurbinePowerCurveVT class

    Parameters
    ----------
    D       float, default=random, (optional)
            The wind turbine rotor diameter

    Returns
    -------
    wt_desc GenericWindTurbinePowerCurveVT
            A random wind turbine power curve and c_t curve variable tree
    """
    if not D:
        D = 200*random()

    wt_desc = GenericWindTurbinePowerCurveVT()
    wt_desc.rotor_diameter = D
    wt_desc.hub_height = D * (0.5 + random())
    wt_desc.cut_in_wind_speed = 2. + 4. * random()
    wt_desc.cut_out_wind_speed = 20. + 10. * random()
    rho = 1.225
    rated_wind_speed = 8. + 4. * random()
    max_a = 0.333 * random()
    max_cp = 4 * max_a * (1 - max_a)**2.
    max_ct = 4 * max_a * (1 - max_a)
    A = 0.25 * pi * D**2. # Rotor area
    ideal_power = lambda ws: 0.5 * rho * A * max_cp * ws **3.
    real_power = lambda ws: ideal_power(ws) if ws < rated_wind_speed else ideal_power(rated_wind_speed)
    #a_ct = -sqrt(-c_t + 1)/2 + 1/2
    ct_from_cp = lambda cp: min(0.89, cp  * 2.)
    cp_from_power = lambda power, ws: power/(0.5 * rho * A * ws**3.)
    ct_from_power = lambda pws: ct_from_cp(cp_from_power(pws[0], pws[1]))
    N = 3+int(random() * 100)
    ws = linspace(wt_desc.cut_in_wind_speed, wt_desc.cut_out_wind_speed, N)
    wt_desc.power_curve = vstack([ws, map(real_power, ws)]).T
    wt_desc.c_t_curve = vstack([ws, map(ct_from_power, zip(wt_desc.power_curve[:,1],ws))]).T
    wt_desc.power_rating = ideal_power(rated_wind_speed)
    wt_desc.rated_wind_speed = rated_wind_speed
    wt_desc.air_density = rho
    wt_desc.test_consistency()
    return wt_desc