I would like to solve (I think with NSolve, but I am not sure) and plot the function $w(z)$: the relation contains other known functions dependent on $z$, which are areasm
and p
, where p
is the function resulting from an NDSolve. In this relation there is no an explicit dependence of $w$ from $z$.
I try to write the wall code for clarity:
PARAMETERS:
d1 = 0.8*^-3;
d2 = 0.5*^-3;
l = 17*^-3;
ltot = 22*^-3;
l1 = 13.8*^-3;
l2 = 14.5*^-3;
aperture = 0.3;
slope = 10;
p1 = 2;
T = 300;
vi=1*^3;
step = 10^3;
Kb = 1.380649 10^(-23);
gamma = 1.660;
R = 8.314462618;
vsound = 965;
area1 = Pi (d1/2)^2;
pi = p1*10^6;
ri = pi/(Kb T);
k1 = ri vi area1;
k2 = pi ri^(-gamma);
FUNCTIONS:
radiussm = ((((d1/2) Exp[l1 slope*10^3])+((d2/2) Exp[slope*10^3 z]))/(Exp[l1 slope*10^3]+Exp[slope*10^3 z]))+UnitStep[z-l2] aperture (z-l2);
areasm = Pi radiussm^2;
dareasm = D[Pi radiussm^2, z];
DIFFERENTIAL EQUATION:
rsol = NDSolve[{((k1^2)/((areasm^2) r[z]) - (k2 r[z]^gamma) gamma) r'[z] == -((k1^2)/(areasm^3)) dareasm, r[0] == ri},r,{z, 0, ltot},InterpolationOrder -> All];
p = k2 (r[z]^gamma);
PROBLEM:
velocity = NSolve[k1 == ((areasm*(k2*((First[Evaluate[p[z] /. rsol]])^gamma)))/Sqrt[T])*(Sqrt[gamma/R])*(w/vsound)*(1 + ((gamma - 1)/2)*(w/vsound)^2)^(-(gamma + 1)/(2*gamma - 2)), w];
velocitytab = Table[w /. velocity, {z, 0, ltot, ltot/step}]
Plot[Evaluate[w /. velocitytab], {z, 0, ltot}, PlotRange -> All,AxesLabel -> {"z [m]", "v [m/s]"}, ImageSize -> 350]
...but I didn't get any plot! Where did I go wrong? Thank you in advance!
velocity = NSolve[...]
run? The calculation runs quite long on my machine. $\endgroup$ – Max1 May 1 '20 at 18:15NSolve
calculation takes a few seconds, but it still has other problems, at least in the plot. However I do not understand why the gamma in theNSolve
creates all this slowdown, because it appears as an exponent also in the previousNDSolve
which has no problems instead. $\endgroup$ – gecos May 1 '20 at 20:02NSolve
. It depends onz
, but its not a numeric value whenz
is passed as an argument. A second thought: You should be able to do theNSolve
calculation insideTable
for eachz
value right? Try to calculate that for like 10 value and then look if you actually get numeric values or garbage. $\endgroup$ – Max1 May 1 '20 at 20:58NSolve
argument: I would like to find the w(z) function. It depends on z as it depends on the areasm and p function that both are functions of z. z for me are simply steps of an interval betweenz=0
andz=ltot
, as it is in theNDSolve
argument. However, I was not able to enter this range of z values in theNSolve
. $\endgroup$ – gecos May 1 '20 at 21:35NSolve
either outside or inside theTable
I believe because of the fractional exponents. If I insert some integer coefficients, theTable
gives the same result both if I insert theNSolve
in the argument of the Table, and if I only recall the result of theNSolve
in the Table. I can't understand if they are numerical values or not from theTable
result, well I think they are, but then I don't understand why the plot is empty. $\endgroup$ – gecos May 1 '20 at 21:44