WindLab Tutorial GeorgeDeodatis 1996 Example SimulationPoints: Difference between revisions

From LabRPS Documentation
Jump to navigation Jump to search
No edit summary
 
Line 68: Line 68:
you can manipulate the created object easily through scripting as follows:
you can manipulate the created object easily through scripting as follows:
{{Code|code=
{{Code|code=
# The document where the feature is, The active feature here.
# -*- coding: utf-8 -*-
doc = App.ActiveDocument
# (c) Koffi Daniel 2024


# Now get the feature by its name
import WindLab
obj = doc.getObject("SimulationPoints")
import GeneralToolsGui
import WindLabObjects
from LabRPS import Vector as vec
import LabRPS
import numpy
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D


# You can assign the three points to the Locations property as follows
def compute():
obj.Locations = [(0.00, 0.00, 35.00), (0.00, 0.00, 40.00), (0.00, 0.00, 140.00), ]
    installResuslt = WindLab.installPlugin("WindLabPlugin")


# You can print the points
    doc = LabRPS.ActiveDocument
print(obj.Locations)
    if not doc:
      doc = LabRPS.newDocument()


# You can check the z coordinate of the first point for example
    # create WindLab simulation called "Simulation"
print(obj.Locations[0].z)
    sim = WindLabObjects.makeSimulation(doc, "Simulation")
   
    # check if the simulation does really exist
    if not sim:
      LabRPS.Console.PrintError("The simulation does not exist.\n")
      return None
 
    featureType = "General Distribution"
    featureGroup = "Location Distribution"
 
    # create the feature and add it to the existing simulation (you may refer to the WindLab Workbench page in
    # case you don't understand the next line)
    genSimPoints= WindLabObjects.makeFeature("MyNewFeature", sim.Name, featureType, featureGroup)
   
    # check if the created feature is good
    if not genSimPoints:
      LabRPS.Console.PrintError("Error on creating the uniform points feature.\n")
      return None
 
    # create the simulation points by their coordinates
    v1 = vec(0, 0, 35)
    v2 = vec(0, 0, 40)
    v3 = vec(0, 0, 140)
 
    # add the points to the locations
    genSimPoints.Locations = [v1, v2, v3]
 
    # compute the simulation points coordinates. WindLab will internally use the "genSimPoints" feature
    simPoints = sim.computeLocationCoordinateMatrixP3()
 
    # now you can convert the coordinate matrix to numpy array and use it for any other purposes
    arr = numpy.asarray(simPoints)
 
    # Example 3D points
    x = arr[:,1]
    y = arr[:,2]
    z = arr[:,3]
 
    # you can also show the result in a table, pass False as last argument to the function to ask
    # LabRPS to only show the data without plotting them
    GeneralToolsGui.GeneralToolsPyTool.showArray(sim.getSimulationData().numberOfSpatialPosition, 4, simPoints, False)
 
    # Create a figure
    fig = plt.figure()
 
    # Add 3D axes
    ax = fig.add_subplot(111, projection='3d')
 
    # Plot points
    ax.scatter(x, y, z, color='blue')
 
    # Hide all axes and labels
    ax.set_axis_off()
 
    # Set the title
    ax.set_title('3D Plotting of Points')
 
    # Show the plot
    plt.show()
 
compute()


}}
}}


you can find the entire scripting for this tutorial [[Macro_Deodatis_1996_Wind_Simulation_Points|here]].
you can find the entire scripting for this tutorial [[Macro_Deodatis_1996_Wind_Simulation_Points|here]].
==  What next? ==  
==  What next? ==  



Latest revision as of 19:20, 17 January 2025

Labrps.svg Tutorial
Topic
Wind Simulation Points (George Deodatis, 1996)
Level
Beginner
Time to complete
10 minutes
Authors
Koffi Daniel
LabRPS version
0.1.0 or above
Example files
None
See also
None

Introduction

Deodatis (1996) provides a comprehensive method for simulating ergodic wind velocity time histories by modeling the wind as a stationary random process with well-defined statistical properties. His approach is particularly focused on multivariate wind simulations (i.e., for multiple correlated wind components at different locations in space. These locations where the wind velocity components are considered in space are called Simulation Point in WindLab. This example is meant to show how a wind simulation points in LabRPS's WindLab Workbench looks like in the LabRPS interface and how their coordinates can be visualized. Every computation in LabRPS needs a RPS Feature. Here we rather need a WindLab Feature (RPS Feature) which should be provided by a plugin.

Requirements

  • A compatible version of LabRPS designated in the tutorial overview.
    Use the Help → About LabRPS to see the version of LabRPS installed.
  • No external software is needed for the computation of the locations coordinates as well as for visualizing the results.
  • Install the plugin that will provide the feature for the computation of the locations coordinates.

Plugin Installation

The first step is to start LabRPS by double-cliking its icon. Then active the WindLab workbench as shown in the following picture. Note that plugins are loaded according to the active workbench. If you do not activate the WindLab workbench, no wind velocity related plugin will be loaded.

WindLab Tutorial001 Pic001 WindLab Activated.png

According to Deodatis (1996), the simulation points are three in total and their distribution in space does not follow any particular distribution in space. To compute such simulation distribution, the General Distribution feature from the WindLab Plugin can be used. Let's install the feature first. Go to Tools → Std DlgRPSFeatures.svg RPS Features..., select the WindLabPlugin in the list and click Install as shown in the following picture.

WindLab Tutorial001 Pic002 WindLab Features Loaded.png

The Feature installation wizard will be launched. Please install the feautre by following the steps as shown in the following pictures:

WindLab Tutorial001 Pic003 WindLab Wizard 1.png WindLab Tutorial001 Pic003 WindLab Wizard 2.png

WindLab Tutorial001 Pic003 WindLab Wizard 3.png WindLab Tutorial001 Pic003 WindLab Wizard 4.png

Create New Feature

Please follow the following steps to create new WindLab simulation and add new Location distribution feature to it.

  1. Press the Std New.svg New button to create new document or
    • Select the File → Std New.svg New option from the menu or
    • Use the keyboard shortcut: Ctrl+N.
  2. Press the WindLab CreateSimulation.svg New Simulation button to create new WindLab simulation or
    • Select the WindLab → WindLab CreateSimulation.svg New Simulation option from the menu.
    • This will display the WindLab simulation creation task dialog as follows:

WindLab Tutorial001 Pic004 WindLab Sim Creation 1.png WindLab Tutorial001 Pic004 WindLab Sim Creation 2.png WindLab Tutorial001 Pic004 WindLab Sim Creation 3.png

  1. Press the WindLab CreateFeature.svg Create Feature button to create new Location Distribution feature or
    • Select the WindLab → WindLab CreateFeature.svg Create Feature option from the menu.

WindLab Tutorial001 Pic004 WindLab Sim Creation 3.png WindLab Tutorial001 Pic004 WindLab Feat Creation 1.png WindLab Tutorial001 Pic004 WindLab Feat Creation 2.png

Input Points Coordinates

We have created a locations distribution (simulation points) feature of type General Distribution. Now, we have to use the created feature to compute the coordinates of the simulation points. In the tree view, click on the simulationPoints feature, all the properties of this feature will be shown in the property editor. In the property editor scroll down and find a property named Locations. Click the ... near that property value to show a the vectors dialog that will allow you to input the coordinates of the three points: Point1(0,0,35), Point2(0,0,40) and Point3(0,0,140). Before inputting the points coordinates, you should first click the Table button to expand the points list. Note that value input in the LabRPS has default unit depending on the unit system you are using. Here, we are using the default unit system which is the Standard(mm/kg/s/degree). However, the coordinates are kept in metre because the vector dialog does not convert the values. That is why we keep the coordinates in metre as points coordinates outputs are expected in metre in LabRPS.

WindLab Tutorial001 Pic005 WindLab Feat Locations 1.png WindLab Tutorial001 Pic005 WindLab Feat Locations 2.png

Showing Results

Now that everything is ready, you can display the simulation points in table form. Right click on the feature in the tree view and choose Compute Location Array in the context menu. The points will be shown as follows.

Deodatis1996WindSimulationPoints.png

Scripting

you can manipulate the created object easily through scripting as follows:

# -*- coding: utf-8 -*-
# (c) Koffi Daniel 2024

import WindLab
import GeneralToolsGui
import WindLabObjects
from LabRPS import Vector as vec
import LabRPS
import numpy
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

def compute():
    installResuslt = WindLab.installPlugin("WindLabPlugin")

    doc = LabRPS.ActiveDocument
    if not doc:
       doc = LabRPS.newDocument()

    # create WindLab simulation called "Simulation"
    sim = WindLabObjects.makeSimulation(doc, "Simulation")
    
    # check if the simulation does really exist
    if not sim:
       LabRPS.Console.PrintError("The simulation does not exist.\n")
       return None 
  
    featureType = "General Distribution"
    featureGroup = "Location Distribution"
  
    # create the feature and add it to the existing simulation (you may refer to the WindLab Workbench page in 
    # case you don't understand the next line)
    genSimPoints= WindLabObjects.makeFeature("MyNewFeature", sim.Name, featureType, featureGroup)
    
    # check if the created feature is good
    if not genSimPoints:
       LabRPS.Console.PrintError("Error on creating the uniform points feature.\n")
       return None

    # create the simulation points by their coordinates
    v1 = vec(0, 0, 35)
    v2 = vec(0, 0, 40)
    v3 = vec(0, 0, 140)

    # add the points to the locations
    genSimPoints.Locations = [v1, v2, v3]

    # compute the simulation points coordinates. WindLab will internally use the "genSimPoints" feature
    simPoints = sim.computeLocationCoordinateMatrixP3()

    # now you can convert the coordinate matrix to numpy array and use it for any other purposes
    arr = numpy.asarray(simPoints)

    # Example 3D points
    x = arr[:,1]
    y = arr[:,2]
    z = arr[:,3]

    # you can also show the result in a table, pass False as last argument to the function to ask 
    # LabRPS to only show the data without plotting them
    GeneralToolsGui.GeneralToolsPyTool.showArray(sim.getSimulationData().numberOfSpatialPosition, 4, simPoints, False)

    # Create a figure
    fig = plt.figure()

    # Add 3D axes
    ax = fig.add_subplot(111, projection='3d')

    # Plot points
    ax.scatter(x, y, z, color='blue')

    # Hide all axes and labels
    ax.set_axis_off()

    # Set the title
    ax.set_title('3D Plotting of Points')

    # Show the plot
    plt.show()

compute()

you can find the entire scripting for this tutorial here.

What next?

  • We are now finished with the basic workflow for the WindLab Workbench feature creation.
  • You are now prepared to do the second WindLab tutorial.
  • We will create mean wind profile that will use the simulation points coordinates created in this tutorial.