0
$\begingroup$

I am trying to solve a 2 set of coupled differential equations one using parametricndsolve and other using *ndsolve . So far I am successful in solving these equations. The solution I found by using ndsolve (Pr1[z]) is evaluated at "zmin". While solving the equations using parametricndsolve my parameters are [Delta], [Phi]. Now my problem is as follows: Problem 1: I want the solution of parametricndsolve (Ar1[z]) to be evaluated at [Delta] =0 and [Phi].

Problem 2: I want to plot Absolute value of "Ar1[Delta=0, phi]/Pr1[z=zmin]" as a function of Delta. In the same plot I would like to add phi and see how phi affects the plot. I guess that I have to use Manipulate somehow to do this. I tried different things and none worked. My code is as follows.


     a = 1.11577*10^10;
     b = -2.11923*10^7;
     n = 11167.3;
     L = 0.4814*10^-3;
     zmin = 0.253*10^-3;
     zmax = 1.645*10^-3;

        q[z_] := a*z^2 + b*z + n;
        y = 1;
        g = \[Pi]/L;
        c = 0.25;
        \[Kappa][z_] := c*(g - q[z]);
            A1 = 3.56*10^-4;
            A2 = 3.77*10^-4;
            A3 = 3.62*10^-4;
            m = 1;
        A4 = Sqrt[A3]/m;
     tmin = 4 (A1 + A2);
        EF1[\[Delta]_] := (((A2 - A1)/2 - I \[Delta])/((A2 + A1)/2 - 
             I \[Delta]))*1;
        EF2[\[Delta]_] := (-Sqrt[A1]*A4)/((A1 + A2)/2 - I \[Delta])*1 ;
        t1 = (A2 - A1)/2/((A1 + A2)/2)*y;
        t2 = (-Sqrt[A1]*A4)/((A1 + A2)/2)*y;

        sol = ParametricNDSolve[{Ar1'[z] == 
             I*c*(g - q[z])*Ar2[z]*Exp[-I*q[z]*z], 
            Ar2'[z] == I*c*(g - q[z])*Ar1[z]*Exp[+I*q[z]*z], 
            Ar1[zmax] == EF1[\[Delta]]*Exp[i*\[Phi]], 
            Ar2[zmax] == EF2[\[Delta]]}, {Ar1, Ar2}, {z, zmax, 
            zmin}, {\[Delta], \[Phi]}]; 
        sol

        eqs = {Pr1'[z] == I*c*(g - q[z])*Pr2[z]*Exp[-I*q[z]*z], 
          Pr2'[z] == I*c*(g - q[z])*Pr1[z]*Exp[+I*q[z]*z]}
        conditions = {Pr1[zmax] == t1, Pr2[zmax] == t2};
        sol1 = NDSolve[{eqs, conditions}, {Pr1, Pr2}, {z, zmax, zmin}]
        orv1 = Pr1[zmin] /. sol1 (*Pr1[z] evaluated at zmin*)



        (***Problem 1 -I am not sure of the code written below, I assume it is evaluating Ar1[\[Delta=0],\[Phi]] evaluated at zmin***********)
        Ar1[\[Delta=0], \[Phi]][
          zmin] /. sol (*Ar1[\[Delta],\[Phi]] evaluated at zmin*)
    (*******Problem -2 - About the plot as a function of Delta; I need a slider to change phi and see how it affects the plot*********************)


        (*Manipulate[Plot[{Abs[(Ar1[\[Delta=0],\[Phi]][zmin]/.sol)/orv1]^2},{\[Delta],-\
        tmin,tmin},PlotRange\[Rule]All],{\[Phi], 0,5}*)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.