0

I need to perform a Fourier Transform on the results of a ParametricNDSolve function as well as on the derivative of one of the coefficients. Now I do this by evaluating the interpolation function. This is awfully slow and I don't know if there is any faster approach. Maybe you can help me out.

This is essentially my current approach with c1 being a coefficient in my NDSolve solution fermiD and c1' its derivative :

x2 = Table[Evaluate[{c1'[2*Pi*0.001][t]} /. fermiD[[1]]], {t, 3000, 1/10}]

In my code I loop it, because I need to evaluate at different frequencies. But I first tried looping one time. The equation are a system of linear differential equations.

fermiD = ParametricNDSolve[{equ, equ1}, {c1, c2, c3, c4}, {t, 0, tn},{wp}]

For[i = 1, i < 1 + 1, i++, {m = 2Pii0.001, Print[m], x1 = Table[Evaluate[{c1[m][t]} /. fermiD[[1]]], {t, 0, 3000, 1/10}], x2 = 2Table[Evaluate[{c1'[m][t]} /. fermiD[[1]]], {t, 3000, 1/10}], Print["data2"], data1 - data2, Print["data"], Export[StringJoin[{ToString[m], ".txt"}], data] } ]

MarcoB
  • 67,153
  • 18
  • 91
  • 189
  • 3
    Show us the NDSolve expression and equations you used. I don’t understand the structure of your results from what you showed, – MarcoB Jan 10 '21 at 17:36
  • Does that help or did you mean the whole system of linear equations – Interestedbutnotknowing Jan 10 '21 at 18:17
  • 1
    Without complete code, sometimes what you imagine will work won't in fact. It looks to me like you should have c1[2*Pi*0.001]'[t] instead of c1'[2*Pi*0.001][t]. – Michael E2 Jan 10 '21 at 19:49
  • I would describe c1 as a solution of your equation rather than a coefficient. To expand on @Michael's comment, c1'[w][t] is the first derivative of c1 with respect to the parameter w, whereas c1[w]'[t] is the first derivative with respect to your independent variable t. From what we gather, you seem to want the latter. Is that right? Also, 1) avoid For loops altogether; try Table or Map instead; 2) you should separate commands with ;, instead of enclosing them in braces and separating them with commas. – MarcoB Jan 10 '21 at 21:46

0 Answers0