How to plot a response PSD when applying a force PSD as input?

Javier Vique
Javier Vique Member, Employee Posts: 90
Second Anniversary 5 Answers 25 Likes 10 Comments
✭✭✭✭

Natively, Mechanical only allows acceleration/velocity/displacement input PSD. By using APDL command snippets, a force spectra can be also applied as nodal excitation. However, when doing so, the Response PSD tool from Mechanical cannot be used. Is there any way to overcome this limitation by using PyAnsys?

Tagged:

Comments

  • Javier Vique
    Javier Vique Member, Employee Posts: 90
    Second Anniversary 5 Answers 25 Likes 10 Comments
    ✭✭✭✭

    PyMAPDL allows to get the response PSD in a python environment. Below is given a script which is getting the velocity PSD of node 1410. Last 3 values from results are discarded since they are zero.

    import os
    from ansys.mapdl.core import launch_mapdl
    import matplotlib.pyplot as plt
    import math
    
    Root_Folder = r'here_your_folder'
    PyMAPDL_Folder = os.path.join(Root_Folder,'pymapdl')
    
    db_file = os.path.join(PyMAPDL_Folder,'file')
    mapdl = launch_mapdl(license_server_check=False, run_location=PyMAPDL_Folder, port=50046)
    mapdl.prep7()
    mapdl.resume(fname = db_file, ext ='db')
    
    mapdl.post26()
    mapdl.file(fname = db_file, ext ='rst')
    
    mapdl.store(lab='PSD')
    mapdl.nsol(nvar=2,node=1418,item='U',comp='Z')
    mapdl.rpsd(ir=3,ia=2,itype=2,datum=2)
    
    array_freqs = mapdl.get_variable(1)
    array_RPSD = mapdl.get_variable(3)
    
    array_freqs = [item for sublist in array_freqs for item in sublist]
    array_freqs = array_freqs[:-3]
    array_RPSD = [item for sublist in array_RPSD for item in sublist]
    array_RPSD = array_RPSD[:-3]
    plt.plot(array_freqs, array_RPSD)
    plt.xscale('log')
    plt.yscale('log')
    plt.title('RPSD VZ')
    mapdl.exit()
    

    This is giving us the following plot: