Plugin WindLab PDFCheckTool

From LabRPS Documentation
Revision as of 01:08, 23 January 2025 by LabRPS (talk | contribs) (Created page with "{{Plugin |Name=PDF Check Tool Plugin |Description=This plugin assesses the probability distribution density of the simulated wind velocity. |Author=Koffi Daniel |Version=1.0 |Date=03/12/2022 |Features= PDF Check Tool |RPSVersion=All }} == Introduction == This plugin computes the histogram of the simulated wind velocity and compares it to the Weibull distribution. 1024px == Correlation Ergodic...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Generic plugin icon. Create your personal icon with the same name of the plugin PDF Check Tool Plugin

Description
This plugin assesses the probability distribution density of the simulated wind velocity.

Plugin version: 1.0
Last modified: 03/12/2022
LabRPS version: All
Author: Koffi Daniel
Author
Koffi Daniel
Download
None
Features
PDF Check Tool
Plugin Version
1.0
Date last modified
03/12/2022
LabRPS Version(s)
All
Default shortcut
None
See also
None

Introduction

This plugin computes the histogram of the simulated wind velocity and compares it to the Weibull distribution.

Plugin WindLab PDFCheckTool Screenshot 1.png

Correlation Ergodicity Check Tool

This is the only RPS feature that the plugin implements. It belongs to the table tool group. This feature uses the simulated wind velocity to compute the histogram. Therefore, you need to make sure you simulate random wind velocity first. You can also import the wind velocity from file. Note that if you use the mouse (GUI mode) to run this feature, you have to make sure the active window is the window containing the wind velocity data for which you want to compute the temporal correlation.

Properties

  • DataMeanSpeedIncrement: The increment of the mean speed.
  • DataNumberOfBins: TThe number of bins.
  • DataShapeParameter: The shape parameter.
  • DataScaleParameter: The scale parameter.
  • DataUserDefinedWeibullParameters: This defines whether Weibul parameters will be inputed directly or calculated.
  • DatapdfLength: This is the length of pdf function data.
  • DataWeibulParametersEstimationMethod: The Weibul parameters estimation method.


Scripting

import LabRPS
import WindLabObjects
import WindLabGui
import WindLab
import GeneralToolsGui

# Before you run this macro, simulation must be run and there  must be a table containing the simulated wind velocities.
def checkResult():
    # Install the PDF checking tool
    installResuslt = WindLab.installPlugin("PDFCheckToolPlugin")
    if not installResuslt:
        LabRPS.Console.PrintError("The installation of the PDF tool Plugin has failed.\n")
        return None

    # Get the active simulation which as this time has been run already.   
    sim = WindLabGui.getActiveSimulation()

    # get the simulation data as list assuming that a wind simulation is run and 
    # the result is shown in an AlphaPlot table called "table". Please, edit this table name
    # according to the name of the table where your simulated data are stored.
    velocities = GeneralToolsGui.GeneralToolsPyTool.getTableByName("table")
    
    # create new table tool
    pdfCheck = WindLabObjects.makeFeature("pdfCheck", sim.Name,  "PDF Check Tool", "Table Tool")
    
    # check if the created randomness provider feature
    if not pdfCheck:
        LabRPS.Console.PrintError("The creation of the table tool was not successuful.\n")
        return None
    
    pdfCheck.MeanSpeedIncrement = '0.50 m/s'
    pdfCheck.WeibulParametersEstimationMethod = "Density Power Method"
    pdfCheck.NumberOfBins = 30
    sim.setActiveFeature(pdfCheck)        
    pdfCheckRest = sim.tableToolCompute(velocities)

    # if we are in Gui mode, show plots
    if LabRPS.GuiUp:
        import numpy
        import matplotlib.pyplot as plt

        # convert the list to numpy array
        array = numpy.asarray(pdfCheckRest)

        location = sim.LocationIndexJ + 1
        str = "Velocity at Location {:d}".format(location)
        fig, ax = plt.subplots()
        ax.set_title(str)
        pl = pdfCheck.pdfLength - 1      
        ax.plot(array[0:pl,2], array[0:pl,3], color='red')
        ax.hist(array[:,1], bins = pdfCheck.NumberOfBins, density = 1, color='skyblue', edgecolor='black')
        ax.set_xlabel('Velocity (m/s)')
        ax.set_ylabel('Probability Density')
        # ax.grid(True)
        fig.tight_layout()
        ax.legend(["Weibull fit", "Velocity"], loc="upper left", frameon=False)
        plt.show()

checkResult()