[femap][api][Function...][how to define function ie. vs Frequency]
[femap][api][Function...][how to define function ie. vs Frequency]
(OP)
Hi!
Do anyone have some expirence how to define some function in femap? I mean do same with femap api like doing [main menu] Model -> Function (Define Time or Temperature Dependencies).
I have some data of accleration spectral density ASD that i want to put it to function vs Frequency in femap using femap api. How could i define that function using Femap Api?
ps:
When i have accleration function vs Time with usnits: (m/s^2)/s what digits will i get when transforming it to ASD? Will it be: f(t)[m^2/s] in time domain --> 2*FFT
And how will this transformation schema look? Will it be (with python code):
Do anyone have some expirence how to define some function in femap? I mean do same with femap api like doing [main menu] Model -> Function (Define Time or Temperature Dependencies).
I have some data of accleration spectral density ASD that i want to put it to function vs Frequency in femap using femap api. How could i define that function using Femap Api?
ps:
When i have accleration function vs Time with usnits: (m/s^2)/s what digits will i get when transforming it to ASD? Will it be: f(t)[m^2/s] in time domain --> 2*FFT
And how will this transformation schema look? Will it be (with python code):
CODE --> python
def fFFT_of_time_to_freq_domain(Ui,dt):
import numpy as np, numexpr as ne
#Ui[m/s^2]; dt[s]
freqs = np.fft.fftfreq(len(Ui), dt); ipos = np.where(freqs>0) #frequences in [Hz]
freqs_plus = freqs[ipos] #positive part of freqs [Hz+]
pi=np.pi
pulses_plus=ne.evaluate('2*pi*freqs_plus') #pulse [rad/s]
dpulses_plus=np.mean(np.diff(pulses_plus)) #derivative of pulses, delta pulse [rad/s]
Nfft=len(freqs) #number of freqs
amp = 2*abs(np.fft.fft(Ui,Nfft)[ipos])/Nfft #amplitudes[m/s^2]
PSD = (amp**2)/(2*dpulses_plus) #power spectral density, [m/s^2]^2[rad/s]^(-1)
return [freqs_plus,PSD] 




RE: [femap][api][Function...][how to define function ie. vs Frequency]
that:
"f(t)[m^2/s] in time domain --> 2*FFT"
should be:
f(t)[m^2/s] in time domain --> (2*FFT(f(t)))^2 / (dPulse) = F(pulse)[m/s^2]^2[rad/s]^(-1); where Pulse=[rad/s]"
RE: [femap][api][Function...][how to define function ie. vs Frequency]
Perhaps this will help. This create a FEMAP function (which you can then see and use in Model > Function)
AP
Const pi = 4*Atn(1)
Sub Main
Dim App As femap.model
Set App = feFemap()
'set size (ex: 10 below)
Dim freq(10) As Double, PSD(10) As Double
Dim f As femap.Function
Set f = App.feFunction
For i = 0 To UBound(freq)
freq(i) =
PSD(i) =
Next
f.type = 3 'vs. Freq
f.PutFunctionList(UBound(freq)+1,freq,PSD)
End Sub