0
$\begingroup$
DynamicModule[{FlowratePARK = 100,TemperaturePARK = 350,heatPARKsensible,heatbalance}, 
  heatPARKsensible = 
 ThermodynamicData["Air", 
"Enthalpy", {"Temperature" -> 
  Quantity[TemperaturePARK, "DegreesCelsiuss"], 
 "Pressure" -> Quantity[101325, "Pascals"]}]*Quantity[FlowratePARK,"kg"]/Quantity[1,"hour"];
heatbalance = {{Button["Primary Air", 
  CreateDialog[
   Column[{Row[{Style["Flow rate(kg/hr)", Bold, 14], 
       InputField[Dynamic[FlowratePARK]]}], 
     Row[{Style["Flow temperature(\[Degree]C)", Bold, 14], 
       InputField[Dynamic[TemperaturePARK]]}]}]]] -> 
   "Rotary Kiln", 
   Mouseover[Style["Heat Flow", Bold, 12, Orange], 
 Dynamic[heatPARKsensible]]}};
Panel[Dynamic@
LayeredGraphPlot[heatbalance, VertexLabeling -> True, 
ImageSize -> Small]]]

Here is the simplified version of code to illustrate a process of heat flow. Here, I made a window by clicking the button to ask for value, then I would like to apply these values to the calculation. I did add Dynamic to the value of heat flow, but the value did not change upon the change of InputField. So, could anyone tell why it is not working?

$\endgroup$
3
  • $\begingroup$ heatPARKsensible = ThermodynamicData... is evaluated once, when you are creating Panel for initial values. Add a button to recalculate this, or something which will do what you want to be done. $\endgroup$
    – Kuba
    Jul 15, 2015 at 12:13
  • $\begingroup$ @Kuba, in fact i chose to use the dynamic module to take advantage of the interactivity, if i add another button to recalculate, i loss the interactivity or the advantage of dynamicmodule, no? Thx very much for ur response. =) $\endgroup$
    – Aha
    Jul 15, 2015 at 12:16
  • $\begingroup$ I have not idea what do you mean but let me answer the question anyway. $\endgroup$
    – Kuba
    Jul 15, 2015 at 12:23

1 Answer 1

2
$\begingroup$

You need to say that you want to recalculate heatPARKsensible or define it with SetDelayed so Dynamic can take care of it:

DynamicModule[{FlowratePARK = 100, TemperaturePARK = 350, 
  heatPARKsensible, heatbalance}
 ,
 heatbalance = {{
   Button["Primary Air", 
      CreateDialog[
       Column[{Row[{Style["Flow rate(kg/hr)", Bold, 14], 
           InputField[Dynamic[FlowratePARK]]}], 
         Row[{Style["Flow temperature(\[Degree]C)", Bold, 14], 
           InputField[Dynamic[TemperaturePARK]]}]}]], 
       Method -> "Queued"
   ] -> "Rotary Kiln"
   , 
   Mouseover[
     Style["Heat Flow", Bold, 12, Orange], 
     Dynamic[ heatPARKsensible[] ]
 ]}};

 Panel[
  LayeredGraphPlot[heatbalance, VertexLabeling -> True, 
   ImageSize -> Small]]
 ,
 Initialization :> (
   heatPARKsensible[] := 
    ThermodynamicData["Air", 
      "Enthalpy", {"Temperature" -> 
        Quantity[TemperaturePARK, "DegreesCelsiuss"], 
       "Pressure" -> Quantity[101325, "Pascals"]}]*
     Quantity[FlowratePARK, "kg"]/Quantity[1, "hour"]
   )]

You may also want to add ContinuousAction->True to your InputFields.

$\endgroup$
3
  • $\begingroup$ Thx very much for your response, could you explain the meaning of the Print[1] in button. Thx =) $\endgroup$
    – Aha
    Jul 15, 2015 at 12:49
  • $\begingroup$ @Aha sorry, just a left over. is everything else ok? $\endgroup$
    – Kuba
    Jul 15, 2015 at 12:52
  • $\begingroup$ Thanks for you solution, it works well, I just want to know why the problem appears, so that I can avoid it for the next time. Thanks very much for your patience. $\endgroup$
    – Aha
    Jul 15, 2015 at 13:47

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.