Plugin UserLab: Difference between revisions

From LabRPS Documentation
Jump to navigation Jump to search
(Created page with "{{Plugin |Name=UserLab Plugin |Description=This plugin implements various UserLab features. |Author=Koffi Daniel |Version=1.0 |Date=2024-04-15 |Features= Goenaga et al 2017 |RPSVersion=All }} You can find the source code of this plugin on the following Github repository: [https://github.com/LabRPS/LabRPS-plugins/tree/master/UserLab/UserLabPlugin Get the code here!]. This plugin is one of the official plugins provided by LabRPS. It provides very u...")
 
No edit summary
 
Line 32: Line 32:


<math>m</math> is a pavement waviness indicator. It has been found that this parameter takes values between 1.75 and 2.25.
<math>m</math> is a pavement waviness indicator. It has been found that this parameter takes values between 1.75 and 2.25.
=== Feature Dependency ===
The features required by this feature are summarized as follows:
* A [[RPS_Feature_Group#Location_Distribution| simulation points feature]]
* A [[RPS_Feature_Group#Frequency_Distribution| frequency discretization feature]]


=== Properties ===  
=== Properties ===  


* {{PropertyData|PeakShape1}}: The peak shape of the first peak.
* {{PropertyData|ReferenceWaveNumber}}: The reference wave number.
* {{PropertyData|PeakShape2}}: The peak shape of the second peak.
* {{PropertyData|ReferenceSpectrum}}: The spectrum at the reference wave number.
* {{PropertyData|PeakFrequency1}}: The peak frequency of the first peak.
* {{PropertyData|PavementWavinessIndicator}}: The pavement waviness indicator.
* {{PropertyData|PeakFrequency2}}: The peak frequency of the second peak.
* {{PropertyData|SignificantWaveHeight1}}: The significant wave height of the first peak.
* {{PropertyData|SignificantWaveHeight2}}: The significant wave height of the second peak.
* {{PropertyData|AutoPara}}: Whether to automatically compute the six previous parameter.
* {{PropertyData|SignificantWaveHeight}}: The significant wave height used the calculate those six parameters in case of automatic parameters calculation .


=== Scripting ===  
=== Scripting ===  
Line 61: Line 50:
from LabRPS import Vector as vec
from LabRPS import Vector as vec


# Before you run this code, you should first have created a document with a UserLab simulation with
# active simulation points and frequency distribution
def compute():
def compute():
      
      
     # get an existing UserLab simulation called "Simulation"
     installResuslt = UserLab.installPlugin("UserLabPlugin")
     sim = UserLab.getSimulation("Simulation")
     if not installResuslt:
      LabRPS.Console.PrintError("The installation the UserLabPlugin has failed.\n")
      return None
      
      
     # check if the simulation does really exist
     # Document
    doc = LabRPS.newDocument()
 
    # Simulation
    sim = UserLabObjects.makeSimulation(doc, "Simulation")
     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  
       return None
    
    
     featureType = "Ochi-Hubble spectrum"
     featureType = "Goenaga et al 2017"
     featureGroup = "Frequency Spectrum"
     featureGroup = "Simulation Method"
    
    
     # create the feature and add it to the existing simulation (you may refer to the UserLab Workbench page in  
     # create the feature and add it to the existing simulation (you may refer to the UserLab Workbench page in  
     # case you don't understand the next line)
     # case you don't understand the next line)
     spectrum = UserLabObjects.makeFeature("MyNewFeature", sim.Name, featureType, featureGroup)
     method = UserLabObjects.makeFeature("Goenaga et al 2017", sim.Name, featureType, featureGroup)
      
      
     # check if the created feature is good
     # check if the created feature is good
     if not spectrum:
     if not method:
       LabRPS.Console.PrintError("Error on creating the spectrum function feature.\n")
       LabRPS.Console.PrintError("Error on creating the method function feature.\n")
       return None  
       return None  
      
      
    sim.MaxFrequency = '0.04 1/s'
     sim.setActiveFeature(method)         
    sim.NumberOfFrequency = 1024
    sim.FrequencyIncrement = sim.MaxFrequency/sim.NumberOfFrequency
     sim.setActiveFeature(spectrum)         
 
    # For this example we shall compute the cross spectrum matrix at time instant of 0 second and for the frequency value of 0.25 rad/s.
    time = 0.0
 
    # compute the simulation points coordinates
    simPoints = sim.computeLocationCoordinateMatrixP3()
 
    if not simPoints :
      LabRPS.Console.PrintError("Make sure you have an active location disttribution in the simulation with at least 3 simulation points.\n")
      return None


     # let pick the first simulation point
     # run the simulation and return the first sample
    v1 = vec(simPoints[0][1], simPoints[0][2], simPoints[0][3])
     pavement = sim.simulate(0)
    # compute the spectrum vector at time instant of 0 second
    # Note that when the following code is run, UserLab will try to identify the active locations distribution, the active frequency discretization,
    # If UserLab fails to find these dependency features, the computation will fails and specific error messages will be sent to the report view.
     spectrums = sim.computeAutoFrequencySpectrumVectorF(v1, time)


     # show the results
     # show the results
     GeneralToolsGui.GeneralToolsPyTool.showArray(len(spectrums), len(spectrums[0]), spectrums)
     GeneralToolsGui.GeneralToolsPyTool.showArray(len(pavement), len(pavement[0]), pavement)
     LabRPS.ActiveDocument.recompute()
     LabRPS.ActiveDocument.recompute()


compute()
compute()
}}
}}

Latest revision as of 08:52, 1 February 2025

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

Description
This plugin implements various UserLab features.

Plugin version: 1.0
Last modified: 2024-04-15
LabRPS version: All
Author: Koffi Daniel
Author
Koffi Daniel
Download
None
Features
Goenaga et al 2017
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 user defined random phenomena. 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.

Goenaga et al 2017

This feature simulates pavement profiles according to the sinusoidal approach proposed in Goenaga et al 2017 where the longitudinal pavement profiles corresponding to a wheel track can be mathematically constructed from a set of sinusoidal waves with different wavelengths, amplitudes and phases. Assuming a vehicle travels at a constant speed over a road segment with length L, a random pavement profile is approximated overlaying an infinite number of sine waves [math]\displaystyle{ (N \to \infty) }[/math] as follows:


[math]\displaystyle{ Z_R(s) = \sum_{i=1}^NA_i\mbox{sin}\left ( \Omega_is - \phi_i \right ) }[/math]


where:


[math]\displaystyle{ A_i = \sqrt{\Phi(\Omega_i)\left ( \frac{\Delta\Omega}{\pi} \right )} }[/math]


[math]\displaystyle{ \Phi(\Omega) }[/math] is the power spectral density function of the random pavement profiles can be approximated by a PSD in the following form:


[math]\displaystyle{ \Phi(\Omega) = \Phi(\Omega_0)\left ( \frac{\Omega}{\Omega_0} \right )^{-m} }[/math]


[math]\displaystyle{ m }[/math] is a pavement waviness indicator. It has been found that this parameter takes values between 1.75 and 2.25.

Properties

  • DataReferenceWaveNumber: The reference wave number.
  • DataReferenceSpectrum: The spectrum at the reference wave number.
  • DataPavementWavinessIndicator: The pavement waviness indicator.

Scripting

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

import UserLab
import UserLabObjects
import GeneralToolsGui
import LabRPS
from LabRPS import Vector as vec

def compute():
    
    installResuslt = UserLab.installPlugin("UserLabPlugin")
    if not installResuslt:
       LabRPS.Console.PrintError("The installation the UserLabPlugin has failed.\n")
       return None
    
    # Document
    doc = LabRPS.newDocument()

    # Simulation
    sim = UserLabObjects.makeSimulation(doc, "Simulation")
    if not sim:
       LabRPS.Console.PrintError("The simulation does not exist.\n")
       return None
  
    featureType = "Goenaga et al 2017"
    featureGroup = "Simulation Method"
  
    # create the feature and add it to the existing simulation (you may refer to the UserLab Workbench page in 
    # case you don't understand the next line)
    method = UserLabObjects.makeFeature("Goenaga et al 2017", sim.Name, featureType, featureGroup)
    
    # check if the created feature is good
    if not method:
       LabRPS.Console.PrintError("Error on creating the method function feature.\n")
       return None 
    
    sim.setActiveFeature(method)        

    # run the simulation and return the first sample
    pavement = sim.simulate(0)

    # show the results
    GeneralToolsGui.GeneralToolsPyTool.showArray(len(pavement), len(pavement[0]), pavement)
    LabRPS.ActiveDocument.recompute()

compute()