0
$\begingroup$

I have some differential equations as below. I have tried to solve them numerically with NDSolve:

cf = 200000000;
α = .7;
r = 0.4;
FSR = Pi (cf/500);
g0 = 1;
g1[t_] := g0 (Sin[t/τ]);
g2[t_] := -g0 (Cos[t/τ]);
γc1 = 000 Pi;
γc2 = 000 Pi;
γf = 44000 Pi;
τ = 1;
ξi = {{Re[α]}, {Im[α]}};
ai = 1/4 {{E^(-2 r), 0}, {0, E^(2 r)}};
γ1 = (2 γf (g1[t])^2)/FSR;
γ2 = (2 γf (g2[t])^2)/FSR;
γ12 = (2 γf (g1[t]) (g2[t]))/FSR;
sol1 = NDSolve[{Derivative[1][m1][
 t] == (-γc1 + γ1/2) (m1[t]) - 
 g1[t] (f0[t]) - (γ12/2) (m2[t]), 
 Derivative[1][f0][
 t] == -((γf/2) f0[t] + g1[t] (m1[t]) + g2[t] (m2[t])), 
 Derivative[1][m2][t] == (-γc2 + γ2/2) (m2[t]) - 
 g2[t] (f0[t]) - (γ12/2) (m1[t]), m1[0] == 1, f0[0] == 0, 
 m2[0] == 0}, {m1, m2, f0}, {t, 0, (Pi/2) τ}]

 MM[t_] = Evaluate[m2[t] /. sol1[[1]]]
 ans = MM[1.57]

As one can see, the final answer is a number. The question is, how can I solve these equations for a variety of values in FSR = Pi (cf/500)? The above is for just 500 but I want to have MM[t_] for FSR = Pi (cf/L) where L=100,110,120,...,500. Note that in each case, the final value of the t (after solving the set of equations) should be equal to \pi/2=1.57.

Thank U for helping.

$\endgroup$

3 Answers 3

1
$\begingroup$

I would use ParametricNDSolveValue instead, and change the target function from {m1, m2, f0} to just m2[Pi/2]:

FSR = Pi cf/L;
γ1 = (2 γf (g1[t])^2)/FSR;
γ2 = (2 γf (g2[t])^2)/FSR;
γ12 = (2 γf (g1[t]) (g2[t]))/FSR;

sol1 = ParametricNDSolveValue[
    {
    m1'[t]==(-γc1+γ1/2) m1[t]-g1[t] f0[t]-(γ12/2) m2[t],
    f0'[t]==-((γf/2) f0[t]+g1[t] m1[t]+g2[t] m2[t]),
    m2'[t]==(-γc2+γ2/2) m2[t]-g2[t] f0[t]-(γ12/2) m1[t],
    m1[0]==1,
    f0[0]==0,
    m2[0]==0
    },
    m2[Pi/2],
    {t,0,(Pi/2) τ},
    L
];

Then:

Table[sol1[t], {t, 100, 500, 10}]

{0.0110884, 0.0122086, 0.0133307, 0.0144548, 0.0155808, 0.0167088, 0.0178388, 0.0189707, 0.0201046, 0.0212405, 0.0223783, 0.0235181, 0.0246599, 0.0258037, 0.0269495, 0.0280973, 0.0292471, 0.0303988, 0.0315526, 0.0327085, 0.0338663, 0.0350262, 0.0361881, 0.037352, 0.038518, 0.039686, 0.0408561, 0.0420282, 0.0432023, 0.0443786, 0.0455569, 0.0467372, 0.0479197, 0.0491042, 0.0502907, 0.0514794, 0.0526702, 0.053863, 0.055058, 0.0562551, 0.0574542}

$\endgroup$
1
  • $\begingroup$ Thank U for Ur answer, but I cannot have these numbers! The output is some {ParametricFunctions}! $\endgroup$ Commented Sep 1, 2018 at 18:36
1
$\begingroup$

Perhaps this is what you are looking for

cf = 200000000;
α = .7;
r = 0.4;
g0 = 1;
g1[t_] := g0 Sin[t/τ];
g2[t_] := -g0 Cos[t/τ];
γc1 = 000 Pi;
γc2 = 000 Pi;
γf = 44000 Pi;
τ = 1;
ξi = {{Re[α]}, {Im[α]}};
ai = 1/4 {{E^(-2 r), 0}, {0, E^(2 r)}};
Table[
 FSR = Pi cf/L;
 γ1 = 2 γf g1[t]^2/FSR;
 γ2 = 2 γf g2[t]^2/FSR;
 γ12 = 2 γf g1[t] g2[t]/FSR; 
 sol1 = NDSolve[{
    m1'[t] == (-γc1 + γ1/2) m1[t] - g1[t] f0[t] - γ12/2 m2[t], 
    f0'[t] == -(γf/2 f0[t] + g1[t] m1[t] + g2[t] m2[t]), 
    m2'[t] == (-γc2 + γ2/2) m2[t] - g2[t] f0[t] - γ12/2 m1[t],
    m1[0] == 1, f0[0] == 0, m2[0] == 0}, {m1, m2, f0}, {t, 0, Pi/2 τ}]; 
 MM[t_] = Evaluate[m2[t] /. sol1[[1]]]; MM[Pi/2], {L, 100, 500, 100}]

which gives you {0.0110884, 0.0223783, 0.0338663, 0.0455569, 0.0574542} for the 5 values of L.

Your γc1 = 000 Pi; γc2 = 000 Pi; worry me. Are those perhaps typos?

$\endgroup$
1
$\begingroup$

You can use the function of two variables

cf = 200000000;
\[Alpha] = .7;
r = 0.4;
FSR = Pi (cf/L);
g0 = 1;
g1[t_] := g0 (Sin[t/\[Tau]]);
g2[t_] := -g0 (Cos[t/\[Tau]]);
\[Gamma]c1 = 000 Pi;
\[Gamma]c2 = 000 Pi;
\[Gamma]f = 44000 Pi;
\[Tau] = 1;
\[Xi]i = {{Re[\[Alpha]]}, {Im[\[Alpha]]}};
ai = 1/4 {{E^(-2 r), 0}, {0, E^(2 r)}};
\[Gamma]1 = (2 \[Gamma]f (g1[t])^2)/FSR;
\[Gamma]2 = (2 \[Gamma]f (g2[t])^2)/FSR;
\[Gamma]12 = (2 \[Gamma]f (g1[t]) (g2[t]))/FSR;
sol1 = ParametricNDSolveValue[{Derivative[1][m1][
      t] == (-\[Gamma]c1 + \[Gamma]1/2) (m1[t]) - 
      g1[t] (f0[t]) - (\[Gamma]12/2) (m2[t]), 
    Derivative[1][f0][
      t] == -((\[Gamma]f/2) f0[t] + g1[t] (m1[t]) + g2[t] (m2[t])), 
    Derivative[1][m2][t] == (-\[Gamma]c2 + \[Gamma]2/2) (m2[t]) - 
      g2[t] (f0[t]) - (\[Gamma]12/2) (m1[t]), m1[0] == 1, f0[0] == 0, 
    m2[0] == 0}, m2, {t, 0, (Pi/2) \[Tau]}, {L}];

MM[L_, t_] := sol1[L][t]
ans = MM[100, 1.57]
0.0110884
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.