Macro Deodatis 1996 Wind Simulation Points: Difference between revisions

From LabRPS Documentation
Jump to navigation Jump to search
(Created page with "{{Macro |Name=Macro Deodatis 1996 Wind Simulation Points |Icon=Macro_Deodatis_1996_Wind_Simulation_Points.png |Description=This macro create simulation point according to G. Deodatis 1996. |Author=Koffi Daniel |Version=1.0 |Date=2024-04-15 |RPSVersion=All |Download=[https://wiki.freecad.org/images/f/f5/Macro_3D_Parametric_Curve.png ToolBar Icon] |SeeAlso=Macro Deodatis 1996 Mean Wind Profile }} ==Description== This macro create...")
 
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Macro
{{Macro
|Name=Macro Deodatis 1996 Wind Simulation Points
|Name=Macro Deodatis 1996 Wind Simulation Points
|Icon=Macro_Deodatis_1996_Wind_Simulation_Points.png
|Description=This macro create simulation point according to G. Deodatis 1996.
|Description=This macro create simulation point according to G. Deodatis 1996.
|Author=Koffi Daniel
|Author=Koffi Daniel
Line 7: Line 6:
|Date=2024-04-15
|Date=2024-04-15
|RPSVersion=All
|RPSVersion=All
|Download=[https://wiki.freecad.org/images/f/f5/Macro_3D_Parametric_Curve.png ToolBar Icon]
|SeeAlso=[[Macro_Deodatis_1996_Mean_Wind_Profile|Macro Deodatis 1996 Mean Wind Profile]]
|SeeAlso=[[Macro_Deodatis_1996_Mean_Wind_Profile|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.
[[File:Deodatis1996WindSimulationPoints.png|1024px|center]]


==Description==
{{Caption|Simulation Point Distribution}}


This macro create simulation point according to G. Deodatis 1996. There are three simulation points created with WindLabFeatureLocationDistribution feature.
[[File:Macro_Deodatis_1996_Wind_Simulation_Points_Heighs.png|600px|Points Heights‎|center]]
[[File:Deodatis1996WindSimulationPoints.png|600px]]
{{Caption|Example Simulation Point Distribution}}


==Original Script==  
==Script==  


You can find the updated code (16/04/2024) on the following Github repository:
You can find the source code on the following Github repository:
[https://github.com/LabRPS/LabRPS-macros/blob/master/WindLab/Deodatis1996/Deodatis1996_LocationDistribution.RPSMacro Get the code here!]
[https://github.com/LabRPS/LabRPS-macros/blob/master/WindLab/Deodatis1996/Deodatis1996_LocationDistribution.RPSMacro Get the code here!]


==Modified Script==
'''Macro Deodatis 1996 Wind Simulation Points.RPSMacro'''
 
[[File:Macro_Deodatis_1996_Wind_Simulation_Points_Heighs.png|600px|Points Heights‎]]
 
 
'''Macro Deodatis 1996 Wind Simulation Points.FCMacro'''


{{MacroCode|code=
{{MacroCode|code=
Line 40: Line 33:
import WindLabObjects
import WindLabObjects


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


doc = LabRPS.newDocument()
        # create new document
        doc = LabRPS.newDocument()


# create new simulation with default name "Simulation"
        # create new simulation with default name "Simulation" in the above document
sim = WindLabObjects.makeSimulation(doc)
        sim = WindLabObjects.makeSimulation(doc)
      
      
# check if the simulation is successfully created
        # check if the simulation is successfully created
if not sim:
        if not sim:
    LabRPS.Console.PrintError("The simulation does not exist.\n")
            LabRPS.Console.PrintError("The simulation does not exist.\n")
   
            return None
# set simulation parameters
sim.NumberOfFrequency = 2048
sim.MaxFrequency = "0.64 Hz" # 4 rad/s;
sim.FrequencyIncrement = "0.00031 Hz" # 0.00195 rad/s;
sim.TimeIncrement = "0.785 s"
sim.NumberOfTimeIncrements = 9651


# create new location distribution in the simulation called "Simulation"
        # create new location distribution in the simulation called "Simulation"
loc = WindLabObjects.makeFeature("SimulationPoints", "Simulation", "Location Distribution",  "General Distribution")
        loc = WindLabObjects.makeFeature("SimulationPoints", "Simulation", "Location Distribution",  "General Distribution")
      
      
# check if the created location distribution feature is null
        # check if the created location distribution feature is null
if not loc:
        if not loc:
    LabRPS.Console.PrintError("Error on creating the location distribution.\n")
            LabRPS.Console.PrintError("Error on creating the location distribution.\n")
            return None


# find all the feature which are location distribution feature
        # set the coordinates of the simulation points
myFeatures = sim.findAllWindLabFeaturesOfThisType('WindLabAPI::WindLabFeatureLocationDistribution')
        v1 = vec(0, 0, 35)
        v2 = vec(0, 0, 40)
        v3 = vec(0, 0, 140)
        loc.Locations = [v1, v2, v3]


#find all rps types
        # run the method "computeLocationCoordinateMatrixP3" of the feature and store the result.
rpsTypes = sim.getRPSTypesOfPluggableFeatures()
        locRes = sim.computeLocationCoordinateMatrixP3()
print(rpsTypes)


v1 = vec(0, 0, 35)
        if LabRPS.GuiUp:
v2 = vec(0, 0, 40)
            import WindLabGui
v3 = vec(0, 0, 140)
            #show the location coordinate in Alphaplot
loc.Locations = [v1, v2, v3]
            WindLabGui.WindLabPyTool.showArray(sim.getSimulationData().numberOfSpatialPosition, 4, locRes)
            loc.ViewObject.Document.activeView().viewAxonometric()
            loc.ViewObject.Document.activeView().fitAll()


# run the method "computeLocationCoordinateMatrixP3" of the feature and store the result.
            import numpy
# Note that here, this method will be called for the active location distribution feature
            import matplotlib.pyplot as plt
locRes = sim.computeLocationCoordinateMatrixP3()
            arr = numpy.asarray(locRes)
 
            fig, ax = plt.subplots()
if LabRPS.GuiUp:
            fig.suptitle('Location Distribution')
    import WindLabGui
            ax.plot(arr[:,0], arr[:,3], 'o-')
    #show the location coordinate in Alphaplot
            ax.set_xlabel('Simulation Point Number')
    WindLabGui.WindLabPythonPluginUtilities.showArray(sim.getSimulationData().numberOfSpatialPosition, 4, locRes)
            ax.set_ylabel('Height (m)')
    loc.ViewObject.Document.activeView().viewAxonometric()
            ax.grid(True)
    loc.ViewObject.Document.activeView().fitAll()
            plt.show()
   
        doc.recompute()


    import numpy
Deodatis1996LocationDistribution()
    import matplotlib.pyplot as plt
    arr = numpy.asarray(locRes)
    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()


}}
}}


{{clear}}
{{clear}}

Latest revision as of 13:44, 16 April 2024

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: Koffi Daniel
Author
Koffi Daniel
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 LabRPS
from LabRPS import Vector as vec

import WindLab
import WindLabObjects

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

        # create new document
        doc = LabRPS.newDocument()

        # create new simulation with default name "Simulation" in the above document
        sim = WindLabObjects.makeSimulation(doc)
    
        # check if the simulation is successfully created
        if not sim:
            LabRPS.Console.PrintError("The simulation does not exist.\n")
            return None

        # create new location distribution in the simulation called "Simulation"
        loc = WindLabObjects.makeFeature("SimulationPoints", "Simulation", "Location Distribution",  "General Distribution")
    
        # check if the created location distribution feature is null
        if not loc:
            LabRPS.Console.PrintError("Error on creating the location distribution.\n")
            return None

        # set the coordinates of the simulation points
        v1 = vec(0, 0, 35)
        v2 = vec(0, 0, 40)
        v3 = vec(0, 0, 140)
        loc.Locations = [v1, v2, v3]

        # run the method "computeLocationCoordinateMatrixP3" of the feature and store the result.
        locRes = sim.computeLocationCoordinateMatrixP3()

        if LabRPS.GuiUp:
            import WindLabGui
            #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
            import matplotlib.pyplot as plt
            arr = numpy.asarray(locRes)
            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()