0

for thermodynamics, I would like to use a thermodynamic derivative $$ \frac 1 T=\frac{\partial S}{\partial E}\Bigg \vert_V $$i.e. the derivative of the entropy S with respect to the energy E with the volume kept constant. In this context I tried to differentiate as follows (subsituting E to Z since E is protected)

    V[Z_]:=Z^6;
    S[Z_]:=V[Z]^2-Z;

    TemperatureDef=1/T==D[S,Z]

How do I differentiate S with respect to Z without V[Z] being evaluated (i.e. plugged in)?

The result should read -1 instead of -1+12 Z^11

Uwe.Schneider
  • 251
  • 1
  • 6

3 Answers3

2

Update: Answer to changed question:

See below for some discussion.

Block[{V},
 SetAttributes[V, Constant];
 S'[V]
 ]
(*  -1  *)

Note that if you change S =.. to S[Z_] :=.., you should change D[S,Z] to D[S[Z],Z], which is equivalent to S'[Z] above.

Answer to original question:

Perhaps one of these methods will get you started. First, though, you have to Clear your previous definitions. Set (=) does not set up equations but makes symbols represent the values of the right-hand side at the time of definition. Hence S=V^2-Z makes S equal Z^12 - Z, and the value for S contains no instance of V.

ClearAll[S, V, Z];

1. Setting temporarily the attribute Constant:

Block[{V},
 SetAttributes[V, Constant];
 D[V^2 - Z, Z]]
(*  -1  *)

2. Using the option Constants of Dt:

Dt[S]/Dt[Z] /. 
 First@Solve[
   Dt[{S == V^2 - Z}, Constants -> {V}] /. 
    Verbatim[Dt][x_, ___] :> Dt[x], {Dt[S]}]
(*  -1  *)

Or this way seems a little cleaner:

Internal`InheritedBlock[{Dt},
 SetOptions[Dt, Constants -> {V}];
 Dt[S]/Dt[Z] /. First@Solve[Dt[{S == V^2 - Z}], {Dt[S]}]
 ]
(*  -1  *)
Michael E2
  • 235,386
  • 17
  • 334
  • 747
  • Ok, that works as long as V is indeed a constant defined by set (=). But how does it work if it is S[Z_],V[Z_] ? Do you know a way to set functions temporarily to a constant? – Uwe.Schneider Aug 24 '18 at 19:01
  • @Uwe.Schneider That's not how the original question was set up, was it? – Michael E2 Aug 24 '18 at 22:03
1

Why not make the dependence explicit:

S[V_, Z_] := V^2 - Z
V[Z_] := Z^6

Then:

Derivative[0, 1][S][V[Z], Z]

-1

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
0

A Little cludgy, but for temporary setting, try

V[Z_]=Z^6;
S[Z_]=V[Z]^2-Z;

Temperature_Def=1/T==D[(S[Z]),Z]/.D[V[Z]^2,Z]->0
(* 1/T==-1 )
Bill Watts
  • 8,217
  • 1
  • 11
  • 28