Skip to content

Re: How to plot a response PSD when applying a force PSD as input? #3865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AnsysDeveloper opened this issue Apr 23, 2025 · 0 comments
Open

Comments

@AnsysDeveloper
Copy link

AnsysDeveloper commented Apr 23, 2025

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()

https://discuss.ansys.com/discussion/4752/how-to-plot-a-response-psd-when-applying-a-force-psd-as-input#latest


Community Forum: https://discuss.ansys.com/discussion/comment/6012#Comment_6012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant