Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

[femap][api][Function...][how to define function ie. vs Frequency]

Status
Not open for further replies.

rgr16

Marine/Ocean
Sep 21, 2013
9
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):

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]
 
Replies continue below

Recommended for you

damn, i made a mistake, and dont know how to edit post:
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]"
 
Hello,
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor