Macro Deodatis 1996 Wind Simulation Points: Difference between revisions

From LabRPS Documentation
Jump to navigation Jump to search
No edit summary
No edit summary
Line 22: Line 22:
'''Macro_Deodatis_1996_Wind_Simulation_Points.RPSMacro'''
'''Macro_Deodatis_1996_Wind_Simulation_Points.RPSMacro'''


{{MacroCode|code=
{{Code|code=
   
   
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# (c) Koffi Daniel 2024
# (c) Koffi Daniel 2024
import LabRPS
from LabRPS import Vector as vec


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


class Deodatis1996LocationDistribution():
def compute():
     def __init__(self):
     installResuslt = WindLab.installPlugin("WindLabPlugin")
        #install the WindLab plugin with all its plugged features
        installResuslt = WindLab.installPlugin("WindLabPlugin")


        # create new document
    doc = LabRPS.ActiveDocument
        doc = LabRPS.newDocument()
    if not doc:
      doc = LabRPS.newDocument()


        # create new simulation with default name "Simulation" in the above document
    # create WindLab simulation called "Simulation"
        sim = WindLabObjects.makeSimulation(doc)
    sim = WindLabObjects.makeSimulation(doc, "Simulation")
   
    # check if the simulation does really exist
    if not sim:
      LabRPS.Console.PrintError("The simulation does not exist.\n")
      # abord the computation
 
    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 simulation is successfully created
    # check if the created feature is good
        if not sim:
    if not genSimPoints:
            LabRPS.Console.PrintError("The simulation does not exist.\n")
      LabRPS.Console.PrintError("Error on creating the uniform points feature.\n")
            return None
      # abord the computation


        # create new location distribution in the simulation called "Simulation"
    # create the simulation points by their coordinates
        loc = WindLabObjects.makeFeature("SimulationPoints", "Simulation", "Location Distribution", "General Distribution")
    v1 = vec(0, 0, 35)
      
    v2 = vec(0, 0, 40)
        # check if the created location distribution feature is null
     v3 = vec(0, 0, 140)
        if not loc:
            LabRPS.Console.PrintError("Error on creating the location distribution.\n")
            return None


        # set the coordinates of the simulation points
    # add the points to the locations
        v1 = vec(0, 0, 35000)
    genSimPoints.Locations = [v1, v2, v3]
        v2 = vec(0, 0, 40000)
        v3 = vec(0, 0, 140000)
        loc.Locations = [v1, v2, v3]


        # run the method "computeLocationCoordinateMatrixP3" of the feature and store the result.
    # compute the simulation points coordinates. WindLab will internally use the "genSimPoints" feature
        locRes = sim.computeLocationCoordinateMatrixP3()
    simPoints = sim.computeLocationCoordinateMatrixP3()


        if LabRPS.GuiUp:
    # now you can convert the coordinate matrix to numpy array and use it for any other purposes
            import WindLabGui
    arr = numpy.asarray(simPoints)
            #show the location coordinate in Alphaplot
            WindLabGui.WindLabPyTool.showArray(sim.getSimulationData().numberOfSpatialPosition, 4, locRes)
            loc.ViewObject.Document.activeView().viewAxonometric()
            loc.ViewObject.Document.activeView().fitAll()


            import numpy
    # you can also show the result in a table, pass False as last argument to the function to ask
            import matplotlib.pyplot as plt
    # LabRPS to only show the data without plotting them
            arr = numpy.asarray(locRes)
    GeneralToolsGui.GeneralToolsPyTool.showArray(sim.getSimulationData().numberOfSpatialPosition, 4, simPoints, False)
            fig, ax = plt.subplots()
            fig.suptitle('Location Distribution')
            ax.plot(arr[:,0], arr[:,3], 'o-')
            ax.set_xlabel('Simulation Point Number')
            ax.set_ylabel('Height (m)')
            ax.grid(True)
            plt.show()
   
        doc.recompute()


Deodatis1996LocationDistribution()
compute()


}}
}}


{{clear}}
{{clear}}

Revision as of 08:15, 17 January 2025

Macro Deodatis 1996 Wind Simulation Points.png Macro Deodatis 1996 Wind Simulation Points

Description
This macro create simulation point according to G. Deodatis 1996.

Macro version: 1.0
Last modified: 2024-04-15
LabRPS version: All
Author: LabRPS
Author
LabRPS
Download
None
Links
Macro Version
1.0
Date last modified
2024-04-15
LabRPS Version(s)
All
Default shortcut
None
See also
Macro Deodatis 1996 Mean Wind Profile

This macro create simulation point according to G. Deodatis 1996. There are three simulation points created with WindLabFeatureLocationDistribution feature.

Deodatis1996WindSimulationPoints.png

Simulation Point Distribution

Points Heights‎

Script

You can find the source code on the following Github repository: Get the code here!

Macro_Deodatis_1996_Wind_Simulation_Points.RPSMacro

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

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

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")
       # abord the computation 
  
    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")
       # abord the computation

    # 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)

    # 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)

compute()