コード例 #1
0
ファイル: test_all.py プロジェクト: byuflowlab/windfarm-ouu
def add_distribution(method_dict):
    # Specify the distribution according to the uncertain variable
    if method_dict['uncertain_var'] == 'speed':
        dist = distributions.getWeibull()
        method_dict['distribution'] = dist
    elif method_dict['uncertain_var'] == 'direction':
        dist = distributions.getWindRose()
        method_dict['distribution'] = dist
    else:
        raise ValueError('unknown uncertain_var option "%s", valid options "speed" or "direction".' %method_dict['uncertain_var'])
    return method_dict
コード例 #2
0
    #                   'layout1', 'layout2', 'layout3'
    #     'distribution' = a distribution object
    #     'dakota_filename' = 'dakotaInput.in', applicable for dakota method

    # Get arguments
    args = get_args()
    method_dict = vars(args)  # Start a dictionary with the arguments specified in the command line
    method_dict['method']           = 'dakota'
    method_dict['uncertain_var']    = 'direction'
    method_dict['layout']           = 'layout3'

    if method_dict['uncertain_var'] == 'speed':
        dist = distributions.getWeibull()
        method_dict['distribution'] = dist
    elif method_dict['uncertain_var'] == 'direction':
        dist = distributions.getWindRose()
        method_dict['distribution'] = dist
    else:
        raise ValueError('unknown uncertain_var option "%s", valid options "speed" or "direction".' %method_dict['uncertain_var'])

    method_dict['dakota_filename'] = 'dakotageneral.in'

    # n = int(sys.argv[1])  # number of points, i.e., number of winddirections and windspeeds pairs
    n = 10
    points, weights = windfarm_setup.getPoints(method_dict, n)

    if method_dict['uncertain_var'] == 'speed':
        # For wind speed
        windspeeds = points
        winddirections = np.ones(n)*225
    elif method_dict['uncertain_var'] == 'direction':
コード例 #3
0
    method_dict['method']           = 'dakota'
    # select model: floris, jensen, gauss, larsen (larsen not working yet) TODO get larsen model working
    method_dict['wake_model']       = 'floris'
    method_dict['uncertain_var']    = 'direction'
    # method_dict['layout']         = 'optimized'  # Now this is specified in the command line
    method_dict['dakota_filename']  = 'dakotageneral.in'
    # method_dict['dakota_filename']  = 'dakotageneralPy.in'  # Interface with python support
    # To Do specify the number of points (directions or speeds) as an option as well.
    method_dict['coeff_method']     = 'quadrature'

    # Specify the distribution according to the uncertain variable
    if method_dict['uncertain_var'] == 'speed':
        dist = distributions.getWeibull()
        method_dict['distribution'] = dist
    elif method_dict['uncertain_var'] == 'direction':
        dist = distributions.getWindRose()
        method_dict['distribution'] = dist
    elif method_dict['uncertain_var'] == 'direction_and_speed':
        dist1 = distributions.getWindRose()
        dist2 = distributions.getWeibull()
        dist = cp.J(dist1, dist2)
        method_dict['distribution'] = dist
    else:
        raise ValueError('unknown uncertain_var option "%s", valid options "speed", "direction" or "direction_and_speed".' %method_dict['uncertain_var'])

    # Run the problem multiple times for statistics convergence
    mean = []
    std = []
    samples = []
    if verbose:
        winddir = []
コード例 #4
0
        p = p[order]

        windspeed_approx = x_s
        winddirection_approx = x_d
        power_approx = p

    else:
        raise ValueError('unknown uncertain_var option "%s", valid options "speed" or "direction".' %uncertain_var)

    return winddirection_approx, windspeed_approx, power_approx


if __name__ == "__main__":

    # method_dict = {'uncertain_var': 'speed', 'distribution': distributions.getWeibull()}
    method_dict = {'uncertain_var': 'direction', 'distribution': distributions.getWindRose(),
               'Noffset': 10, 'offset': 0, 'windspeed_ref': 8,
                   'winddirection_ref': 225}


    # Get the approximation points
    d, s, p = get_approximation(method_dict)

    # Get the reference for comparison
    f = open('figure1.json', 'r')
    r = json.load(f)
    f.close()

    if method_dict['uncertain_var'] == 'speed':
        pref = np.array(r['speed_optimized']['power'])
        xref = np.array(r['speed_optimized']['speed'])