Extract the Real and Imag part of the displacement from Harmonic analysis without using get() command #3504
-
Hi everyone! I have a question regarding returning the real and imag part of the displacement from Harmonic analysis. Therefore, I would like to know if there is any way that I can extract displacement from the result stored by the Thank you in advance!
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @Victor-Kao To speed up your code you could use the Try the following: freq_values = np.unique(mapdl.post_processing.frequency_values)
Num_Freq = len(freq_values)
test = False
if test:
mapdl.parameters['U_real'] = np.zeros(Num_Freq)
mapdl.parameters['U_imag'] = np.zeros(Num_Freq)
mapdl.parameters['U_ampl'] = np.zeros(Num_Freq)
# get command is very slow!!
with mapdl.non_interactive:
for i_freq in range(Num_Freq+1):
mapdl.run(f"*GET,U_real({i_freq+1}),VARI,2,REAL,{freq_values[i_freq]}")
mapdl.run(f"*GET,U_imag({i_freq+1}),VARI,2,IMAG,{freq_values[i_freq]}")
mapdl.run(f"*GET,U_ampl({i_freq+1}),VARI,2,AMPL,{freq_values[i_freq]}")
U_real = mapdl.parameters['U_real']
U_imag = mapdl.parameters['U_imag']
U_ampl = mapdl.parameters['U_ampl']
else:
# default
#
U_real = np.zeros(Num_Freq)
U_imag = np.zeros(Num_Freq)
U_ampl = np.zeros(Num_Freq)
#
# get command is very slow!!
for i_freq in range(Num_Freq):
U_real[i_freq] = mapdl.get("U","VARI",2,"REAL",freq_values[i_freq])
U_imag[i_freq] = mapdl.get("U","VARI",2,"IMAG",freq_values[i_freq])
U_ampl[i_freq] = mapdl.get("U","VARI",2,"AMPL",freq_values[i_freq]) After running the first time, it goes down to 2s vs 4s (your version). |
Beta Was this translation helpful? Give feedback.
Hi @Victor-Kao & @germa89
A faster way would be to VGET the real and imaginary part of the NSOL variable to their own arrays. Then use them as you see fit. So something like:
Then when you want to work with them, just use mapdl.parameter["acc_z_1F_R"] for the real part and similar for the imaginary.
Mike