0
$\begingroup$

I have 2 simultaneous equation of $x$ and $y$. Here is how I solve it, and it works. But I want to vary the parameters n and imax, and plot the result of seeb*(xx - yy) vs imax for different values of n (say imax from 1 to 10 and n=17,30,100,1000). How can I do that? Thanks.

n = 17;  
imax = 0.5; 

seeb = 2*n*0.0002; 
dTmax = 300 - ((Sqrt[1 + 2*0.72] - 1)/(0.72/300));
vmax = seeb*300;
qmax = seebimax*300 - 0.5*imax*seeb*(300 - dTmax);
r = (300 - dTmax)*vmax/(300*imax); 
rth = (2*300*dTmax)/((300 - dTmax) vmax*imax); 
length = r/(0.001/100)*0.65*0.65/1000/2/n;


equation1[x_, y_] := -(308 - x)/0.01 + (x - y)/rth + 
  seeb^2*x*(x - y)/2/r - 0.5 seeb^2*(x - y)*(x - y)/4/r
equation2[x_, y_] := (y - 300)/100 - (x - y)/rth - 
  seeb^2*y*(x - y)/2/r - 0.5 seeb^2*(x - y)*(x - y)/4/r
{xx, yy} = {x, y} /. 
  FindRoot[{equation1[x, y], equation2[x, y]}, {{x, 308}, {y, 300}}]

Print["V="]; seeb*(xx - yy)
$\endgroup$
1
$\begingroup$

You can do it by wrapping your code by Table. Something like this:

Clear[imax];
n=17;

lst = Table[{imax, seeb = 2*n*0.0002;
   dTmax = 300 - ((Sqrt[1 + 2*0.72] - 1)/(0.72/300));
   vmax = seeb*300;

   r = (300 - dTmax)*vmax/(300*imax);
   rth = (2*300*dTmax)/((300 - dTmax) vmax*imax);
   length = r/(0.001/100)*0.65*0.65/1000/2/n;

   equation1[x_, y_] := -(308 - x)/0.01 + (x - y)/rth + 
     seeb^2*x*(x - y)/2/r - 0.5 seeb^2*(x - y)*(x - y)/4/r;
   equation2[x_, y_] := (y - 300)/100 - (x - y)/rth - 
     seeb^2*y*(x - y)/2/r - 0.5 seeb^2*(x - y)*(x - y)/4/r;
   fr = FindRoot[{equation1[x, y], 
      equation2[x, y]}, {{x, 308}, {y, 300}}];
   {xx, yy} = {x, y} /. fr}, {imax, 1, 10, 0.5}];

Then you get the list each element of which has the structure {imax, {solution1, solution2}}. It can be printed as follows:

ListPlot[{lst /. {x_, {y_, z_}} -> {x, y}, lst /. {x_, {y_, z_}} -> {x, z}}, PlotStyle -> {Blue, Red}]

yielding the plot:

enter image description here

Since you need to do all this with different n values you can wrap it by table once more:

Clear[n, imax]];

lst2=Table[thePreviousCodeWithoutnAssignment,{n,{17,30,100,1000}}]

However, your plot will be overcrowded in such a case.

Have fun!

$\endgroup$

Your Answer

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

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