Plugin WindLab: Difference between revisions

From LabRPS Documentation
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
|Version=1.0
|Version=1.0
|Date=2024-04-15
|Date=2024-04-15
|Features= [[#Cholesky_Decomposition|Cholesky Decomposition]] [[#Horizontal_Uniform_Distribution|Horizontal Uniform Distribution]]
|Features= [[#Cholesky_Decomposition|Cholesky Decomposition]] [[#Horizontal_Uniform_Distribution|Horizontal Uniform Distribution]] [[#Vertical_Uniform_Distribution|Vertical Uniform Distribution]]
|RPSVersion=All
|RPSVersion=All
}}
}}
Line 125: Line 125:
  # let's set the first point of the distribution (x =0, y = 0, z = 80m)
  # let's set the first point of the distribution (x =0, y = 0, z = 80m)
  simPoints.FirstPoint = vec(0,0,80000)
  simPoints.FirstPoint = vec(0,0,80000)
# let's set the spacing (s = 10m)
simPoints.Spacing = '10m'
# compute the simulation points coordinates
simPoints = sim.computeLocationCoordinateMatrixP3()
# now you can convert the coordinate matrix to numpy array and use it for any other purposes
arr = numpy.asarray(simPoints)
}}
== Vertical Uniform Distribution ==
This feature provides an efficient method to distribute random wind simulation points uniformly in space. It allows users to generate a set of points within a 3D spatial domain, ensuring that the points are evenly distributed along a vertical line. This uniform distribution is critical in certain simulation methods. For <math>n</math> simulation points <math>(P_1,P_2,P_3,...,P_n)</math>, the distance <math>d_{jk}</math> between points <math>P_j</math> and <math>P_k</math> must be given by the following formula:
<math>d_{jk} = s\times|j-k|</math>
where <math>s</math> is the even space between any two adjacent points.
=== Properties ===
* {{PropertyData|LowestPoint}}: This is a point in 3D space representing the lowest point the distribution will start from. In many applications, this point should not be lower than 10 meters.
* {{PropertyData|Spacing}}: This is the even space between any two adjacent points in the distribution.
=== Scripting ===
{{Code|code=
import WindLab
import WindLabObjects
from LabRPS import Vector as vec
import numpy
# get an existing WindLab simulation called "Simulation"
sim = WindLab.getSimulation("Simulation")
   
# check if the simulation does really exist
if not sim:
    LabRPS.Console.PrintError("The simulation does not exist.\n")
    return None
 
featureType = "VerticalDistribution"
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)
unifSimPoints= WindLabObjects.makeFeature("MyNewFeature", sim.Name, featureType, featureGroup)
   
# check if the created feature is good
if not unifSimPoints:
    LabRPS.Console.PrintError("Error on creating the uniform points feature.\n")
    return None
# let's set the first point of the distribution (x =0, y = 0, z = 30m)
simPoints.LowestPoint = vec(0,0,30000)


  # let's set the spacing (s = 10m)
  # let's set the spacing (s = 10m)

Revision as of 19:25, 19 November 2024

Generic plugin icon. Create your personal icon with the same name of the plugin Plugin WindLab

Description
This plugin implement various WindLab features.

Plugin version: 1.0
Last modified: 2024-04-15
LabRPS version: All
Author: Koffi Daniel
Author
Koffi Daniel
Download
None
Features
Cholesky Decomposition Horizontal Uniform Distribution Vertical Uniform Distribution
Plugin Version
1.0
Date last modified
2024-04-15
LabRPS Version(s)
All
Default shortcut
None
See also
None

You can find the source code of this plugin on the following Github repository: Get the code here!. This plugin is one of the official plugins provided by LabRPS. It provides very useful features (tools) for the simulation of random wind velocity. Plugins are very easy to create in LabRPS, therefore, anyone can develop plugin for any random phenomenon in LabRPS. Go to this page to see how to create new plugin for LabRPS. You can get quick assistance from LabRPS community by sending your concern to the community forum.

Cholesky Decomposition

This feature performs the Cholesky decomposition of a positive Hermitian power spectrum matrix and returns the lower triangular matrix (L) of the decomposition. The Cholesky decomposition is a numerical method used to decompose a positive-definite matrix into the product of a lower triangular matrix and its conjugate transpose. Specifically, for a matrix A, the decomposition is given by:

[math]\displaystyle{ \mathbf{A} = \mathbf{L L}^{*}, }[/math]


[math]\displaystyle{ L_{j,j} = \sqrt{ A_{j,j} - \sum_{k=1}^{j-1} L_{j,k}^*L_{j,k} }, }[/math]


[math]\displaystyle{ L_{i,j} = \frac{1}{L_{j,j}} \left( A_{i,j} - \sum_{k=1}^{j-1} L_{j,k}^* L_{i,k} \right) \quad \text{for } i\gt j. }[/math]


where [math]\displaystyle{ L }[/math] is a lower triangular matrix with real and positive diagonal entries, and [math]\displaystyle{ L^* }[/math] denotes the conjugate transpose of [math]\displaystyle{ L }[/math].

The feature is optimized for performance and can handle large matrices efficiently using [math]\displaystyle{ O(n^3) }[/math] computational complexity in the worst case. It checks if the input matrix is indeed positive-definite and Hermitian before performing the decomposition and raises an error if the matrix does not meet these conditions. The feature belong to the PSD Decomposition Method feature group.

Scripting

The feature can be used from the python console as follows:

import WindLab
import WindLabObjects
from LabRPS import Vector as vec
import numpy

 # get an existing WindLab simulation called "Simulation"
 sim = WindLab.getSimulation("Simulation")
    
 # check if the simulation does really exist
 if not sim:
     LabRPS.Console.PrintError("The simulation does not exist.\n")
     return None
  
 featureType = "Cholesky Decomposition"
 featureGroup = "Spectrum Decomposition Method"
  
 # 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)
 decomposedPSD = WindLabObjects.makeFeature("MyNewFeature", sim.Name, featureType, featureGroup)
    
 # check if the created feature is good
 if not decomposedPSD :
     LabRPS.Console.PrintError("Error on creating the spectrum decomposition method.\n")
     return None
    
 # get the active simulation points feature and compute the simulation points coordinates
 simPoints = sim.computeLocationCoordinateMatrixP3()

 # use a vector to represent a simulation point based on its coordinates
 v1 = vec(simPoints[0][1], simPoints[0][2], simPoints[0][3])
 v2 = vec(simPoints[1][1], simPoints[1][2], simPoints[1][3])
 v3 = vec(simPoints[2][1], simPoints[2][2], simPoints[2][3])

 # This is feature is used to decompose power spectrum matrices which may vary in time. Let's assume that
 # the active power spectrun density function in this example is stationary. Meanning it is not varying in time.
 #Then, we use time instant of 0 second.
 time = 0.0

 # compute the decomposed cross spectrum between points 1 and 3, at time instant of 0 second and for all frequency
 # increments note that when the following code is ran, WindLab will try to identify the active frequency distribution, 
 # the active power spectrum feature, the active coherence function feature and others. It WindLab fails to find any 
 # of these dependency features, the computation will fails and specific error messages will be sent to the report view.
 # This only one its function. There are some other two.
 psd13 = sim.computeDecomposedCrossSpectrumVectorF(v1, v3, time)

 # psd13 can be converted to numpy vector and be used for some other purposes.
 arr = numpy.asarray(psd13)

Horizontal Uniform Distribution

This feature provides an efficient method to distribute random wind simulation points uniformly in space. It allows users to generate a set of points within a 3D spatial domain, ensuring that the points are evenly distributed along a horizontal line. This uniform distribution is critical in certain simulation methods. For [math]\displaystyle{ n }[/math] simulation points [math]\displaystyle{ (P_1,P_2,P_3,...,P_n) }[/math], the distance [math]\displaystyle{ d_{jk} }[/math] between points [math]\displaystyle{ P_j }[/math] and [math]\displaystyle{ P_k }[/math] must be given by the following formula:

[math]\displaystyle{ d_{jk} = s\times|j-k| }[/math]

where [math]\displaystyle{ s }[/math] is the even space between any two adjacent points.

Properties

  • DataFirstPoint: This is a point in 3D space representing the first point the distribution will start from.
  • DataSpacing: This is the even space between any two adjacent points in the distribution.

Scripting

import WindLab
import WindLabObjects
from LabRPS import Vector as vec
import numpy

 # get an existing WindLab simulation called "Simulation"
 sim = WindLab.getSimulation("Simulation")
    
 # check if the simulation does really exist
 if not sim:
     LabRPS.Console.PrintError("The simulation does not exist.\n")
     return None
  
 featureType = "Horizontal 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)
 unifSimPoints= WindLabObjects.makeFeature("MyNewFeature", sim.Name, featureType, featureGroup)
    
 # check if the created feature is good
 if not unifSimPoints:
     LabRPS.Console.PrintError("Error on creating the uniform points feature.\n")
     return None
 # let's set the first point of the distribution (x =0, y = 0, z = 80m)
 simPoints.FirstPoint = vec(0,0,80000)

 # let's set the spacing (s = 10m)
 simPoints.Spacing = '10m'

 # compute the simulation points coordinates
 simPoints = sim.computeLocationCoordinateMatrixP3()

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

Vertical Uniform Distribution

This feature provides an efficient method to distribute random wind simulation points uniformly in space. It allows users to generate a set of points within a 3D spatial domain, ensuring that the points are evenly distributed along a vertical line. This uniform distribution is critical in certain simulation methods. For [math]\displaystyle{ n }[/math] simulation points [math]\displaystyle{ (P_1,P_2,P_3,...,P_n) }[/math], the distance [math]\displaystyle{ d_{jk} }[/math] between points [math]\displaystyle{ P_j }[/math] and [math]\displaystyle{ P_k }[/math] must be given by the following formula:

[math]\displaystyle{ d_{jk} = s\times|j-k| }[/math]

where [math]\displaystyle{ s }[/math] is the even space between any two adjacent points.

Properties

  • DataLowestPoint: This is a point in 3D space representing the lowest point the distribution will start from. In many applications, this point should not be lower than 10 meters.
  • DataSpacing: This is the even space between any two adjacent points in the distribution.

Scripting

import WindLab
import WindLabObjects
from LabRPS import Vector as vec
import numpy

 # get an existing WindLab simulation called "Simulation"
 sim = WindLab.getSimulation("Simulation")
    
 # check if the simulation does really exist
 if not sim:
     LabRPS.Console.PrintError("The simulation does not exist.\n")
     return None
  
 featureType = "VerticalDistribution"
 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)
 unifSimPoints= WindLabObjects.makeFeature("MyNewFeature", sim.Name, featureType, featureGroup)
    
 # check if the created feature is good
 if not unifSimPoints:
     LabRPS.Console.PrintError("Error on creating the uniform points feature.\n")
     return None
 # let's set the first point of the distribution (x =0, y = 0, z = 30m)
 simPoints.LowestPoint = vec(0,0,30000)

 # let's set the spacing (s = 10m)
 simPoints.Spacing = '10m'

 # compute the simulation points coordinates
 simPoints = sim.computeLocationCoordinateMatrixP3()

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