1
$\begingroup$

I have the following code for drawing two isotherms for a Carnot engine:

R = 8.3*(10^3); n = 1; 
P[V_, T_] := n*R*T/V 
Plot[{P[V, T = 355], P[V, T = 295], P[V = 0.0006, T = 295]}, {V, 0.0008, 0.0036}, 
  AxesOrigin -> {0, 0}, 
  AxesLabel -> {"Volume (cubic meters)", "Pressure (N/m^2)"}]

It's fine (though a word on how to exaggerate the vertical proportions without the aspect ratio command would be great).

But, what I want to do is plot the sides of this Carnot cycle problem -- I can get the isotherms, but when I add a third expression (like one where a different variable is held constant, i.e. volume) it seems to choke on it. Anyhow, any help for someone who knows almost nothing about Mathematica :-) Overlay didn't seem to do it.

$\endgroup$
7
  • 1
    $\begingroup$ I was sorely tempted to insert this image after the phrase "I have the following cod", but I restrained myself and fixed the typo instead. $\endgroup$
    – user484
    Commented May 16, 2014 at 6:37
  • $\begingroup$ @RahulNarain such puns give me a haddock. $\endgroup$
    – rcollyer
    Commented May 16, 2014 at 12:41
  • $\begingroup$ ho ho. Anyhow, I think I figure out the issue, but I am still thinking about vertical scaling. Aspectratio doesn't seem to really do it, and there doesn't seem to be a way to control how Mathematica scales things to "zoom in" on an axis in a specific way. $\endgroup$
    – Jesse
    Commented May 16, 2014 at 13:46
  • 1
    $\begingroup$ @rcollyer, RahulNarain this is definitely of interest. Jesse how else would you be able to exaggerate the vertical proportions? And what is it that you dislike about aspect ratio? $\endgroup$
    – gpap
    Commented May 16, 2014 at 13:58
  • 1
    $\begingroup$ @gpap those are brill-ant. Ouch. $\endgroup$
    – rcollyer
    Commented May 16, 2014 at 14:36

2 Answers 2

2
$\begingroup$

I recommend you use the Epilog option to plot the lines of constant volume. Like so:

R = 8.3*(10^3); n = 1;
P[V_, T_] := n*R*T/V
Plot[{P[V, 355], P[V, 295]}, {V, 0.0008, 0.0036},
  PlotStyle -> Black,
  ImageSize -> {450, 450},
  AspectRatio -> 1.2,
  AxesOrigin -> {0, 0}, 
  AxesLabel -> {"Volume (cubic meters)", "Pressure (N/m^2)"}, 
  Epilog -> 
    {Line[{{0.0008, P[0.0008, 355]}, {0.0008, P[0.0008, 295]}}], 
     Line[{{0.0036, P[0.0036, 355]}, {0.0036, P[0.0036, 295]}}]}]

plot

$\endgroup$
2
  • 1
    $\begingroup$ should be 'lines of constant volume' $\endgroup$
    – ubpdqn
    Commented May 17, 2014 at 2:01
  • $\begingroup$ @ubpdqn. Thanks for pointing out the error. $\endgroup$
    – m_goldberg
    Commented May 17, 2014 at 2:33
1
$\begingroup$

I post this for variety. ContourPlot can also be used:

The following has arguments of two volumes and two temperatures.

ada[v1_, v2_, t1_, t2_] := Module[{r = 8.31 10^3, ep, lns},
  lns = {AbsoluteThickness[2], Line[#]} & /@ 
    Partition[
     ep = {#[[1]], #[[2]] r/#[[1]]} & /@ Tuples[{{v1, v2}, {t1, t2}}],
      2];
  ContourPlot[{p v/r == t1, p v/r == t2}, {v, v1, v2}, {p, 
    Min[ep[[All, 2]]], Max[ep[[All, 2]]]}, 
   ContourStyle -> {{AbsoluteThickness[2], 
      Red}, {AbsoluteThickness[2], Blue}}, 
   PlotLegends -> {StringForm["T=``  K", t1], 
     StringForm["T= `` K", t2]}, Epilog -> lns, 
   FrameLabel -> {"Volume (\!\(\*SuperscriptBox[\(m\), \(3\)]\))", 
     "Pressure (Pa)"}, BaseStyle -> {12, FontFamily -> "Kartika"}]
  ] 

Illustrating:

ada[0.0006, 0.0038, 295, 355]

enter image description here

Or using Manipulate:

Manipulate[
 Show[ada[0.0006, v, 295, t], 
  PlotRange -> {{0, 0.0040}, {0, 5 10^9}}], {v, 0.0010, 0.0038}, {t, 
  300, 355}]

enter image description here

$\endgroup$
0

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.