Macro Deodatis 1996 Wind Simulation Points: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 34: | Line 34: | ||
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") | |||
return None | |||
# 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") | |||
return None | |||
v1 = vec(0, 0, 35) | # set the coordinates of the simulation points | ||
v2 = vec(0, 0, 40) | v1 = vec(0, 0, 35) | ||
v3 = vec(0, 0, 140) | v2 = vec(0, 0, 40) | ||
loc.Locations = [v1, v2, v3] | v3 = vec(0, 0, 140) | ||
loc.Locations = [v1, v2, v3] | |||
# run the method "computeLocationCoordinateMatrixP3" of the feature and store the result. | # run the method "computeLocationCoordinateMatrixP3" of the feature and store the result. | ||
locRes = sim.computeLocationCoordinateMatrixP3() | |||
locRes = sim.computeLocationCoordinateMatrixP3() | |||
if LabRPS.GuiUp: | 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() | doc.recompute() | ||
Deodatis1996LocationDistribution() | |||
}} | }} | ||
{{clear}} | {{clear}} |
Revision as of 12:56, 16 April 2024
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 |
Macros recipes How to install macros How to customize toolbars |
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.
Simulation Point Distribution
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()