Plugin UserLab

From LabRPS Documentation
Revision as of 08:50, 1 February 2025 by LabRPS (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

Feature Dependency

The features required by this feature are summarized as follows:

Properties

  • DataPeakShape1: The peak shape of the first peak.
  • DataPeakShape2: The peak shape of the second peak.
  • DataPeakFrequency1: The peak frequency of the first peak.
  • DataPeakFrequency2: The peak frequency of the second peak.
  • DataSignificantWaveHeight1: The significant wave height of the first peak.
  • DataSignificantWaveHeight2: The significant wave height of the second peak.
  • DataAutoPara: Whether to automatically compute the six previous parameter.
  • DataSignificantWaveHeight: The significant wave height used the calculate those six parameters in case of automatic parameters calculation .

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

# 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():
    
    # get an existing UserLab simulation called "Simulation"
    sim = UserLab.getSimulation("Simulation")
    
    # check if the simulation does really exist
    if not sim:
       LabRPS.Console.PrintError("The simulation does not exist.\n")
       return None 
  
    featureType = "Ochi-Hubble spectrum"
    featureGroup = "Frequency Spectrum"
  
    # 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)
    spectrum = UserLabObjects.makeFeature("MyNewFeature", sim.Name, featureType, featureGroup)
    
    # check if the created feature is good
    if not spectrum:
       LabRPS.Console.PrintError("Error on creating the spectrum function feature.\n")
       return None 
    
    sim.MaxFrequency = '0.04 1/s'
    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
    v1 = vec(simPoints[0][1], simPoints[0][2], simPoints[0][3])
    # 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
    GeneralToolsGui.GeneralToolsPyTool.showArray(len(spectrums), len(spectrums[0]), spectrums)
    LabRPS.ActiveDocument.recompute()

compute()