0
$\begingroup$
DynamicModule[{Q1 = 175000, Q2 = 175000, P1 = 3500, P2 = 3500, 
  PW1 = 220, PW2 = 220},
 Deploy[
  Style[
   Panel[
    Grid[
     Transpose[{

                                    {"Input ",

                                     Style["Point 1"],

                                     Style["Point 2"]

                                  },


   {"  Flowrate m^3/h ",
    InputField[Dynamic[Q1], Number],
    InputField[Dynamic[Q2], Number]

    },
     {"Pressure ",
    InputField[Dynamic[P1], Number],
    InputField[Dynamic[P2], Number]
    },
   {"  Power kW ",
    InputField[Dynamic[PW1], Number],
    InputField[Dynamic[PW2], Number]
    },
   {
    "  Corrected Flow (m^3/h)",
    InputField[
     Dynamic[CQ1 = 
       25*Q1*(1 + ((25*(273.15 + 25)/(273.15 + 25)) - 
             1)*(.2857142857*PW1*P1*
              Log[(10125 + P1)*
                Log[10]/(10125*
                Log[1 + .2857142857*PW1*
                P1*((10125 + P1)/10125 - 1)/Q1])]/(Q1*Log[10]) - 
             1))], Enabled -> False, Background -> Green],
    InputField[
     Dynamic[CQ2 = 
       25*Q2*(1 + ((25*(273.15 + 25)/(273.15 + 25)) - 

             1)*(.2857142857*PW2*P2*
              Log[(10125 + P2)*
                Log[10]/(10125*
                Log[1 + .2857142857*PW2*
                P2*((10125 + P2)/10125 - 1)/Q2])]/(Q2*Log[10]) - 
             1))], Enabled -> False, Background -> Green]},
   {
    "  Corrected Head(Pa)",
    InputField[
     Dynamic[CH1 = 
       1000^2*P1*(1 + ((1000)) - 
          1)*(.2857142857*PW1*P1*
           Log[(10125 + P1)*
              Log[10]/(10125*
                Log[1 + .2857142857*PW1*
                P1*((10125 + P1)/10125 - 1)/Q1])]/(Q1*Log[10]) - 
          1)], Enabled -> False, Background -> Green],
    InputField[
     Dynamic[CH2 = 
       1000^2*P2*(1 + ((1000)) - 
          1)*(.2857142857*PW2*P2*
           Log[(10125 + P2)*
              Log[10]/(10125*
                Log[1 + .2857142857*PW2*
                P2*((10125 + P2)/10125 - 1)/Q2])]/(Q2*Log[10]) - 
          1)], Enabled -> False, Background -> Green]},
   {
    "  Corrected Power(kW)",
    InputField[
     Dynamic[CPW1 = 
       10125^3*
        PW1*(1 + ((10125*(273.15 + 25)/(273.15 + 20)) - 
             1)*(.2857142857*PW1*P1*
              Log[(10125 + P1)*
                Log[10]/(10125*
                Log[1 + .2857142857*PW1*
                P1*((10125 + P1)/10125 - 1)/Q1])]/(Q1*Log[10]) - 
             1))], Enabled -> False, Background -> Green],
    InputField[
     Dynamic[CPW2 = 
       10125^3*
        PW2*(1 + ((10125*(273.15 + 25)/(273.15 + 20)) - 
             1)*(.2857142857*PW2*P2*
              Log[(10125 + P2)*
                Log[10]/(10125*
                Log[1 + .2857142857*PW2*
                P2*((10125 + P2)/10125 - 1)/Q2])]/(Q2*Log[10]) - 
             1))], Enabled -> False, Background -> Green]},

   {"Result",
    InputField[
     Dynamic[fancurve1 = 
       Fit[{{CQ1, CH1}, {CQ2, CH2}}, {1, x, x^2}, x]], 
     Enabled -> False, Background -> Green], 
    InputField[
     Dynamic[powercurve1 = 
       Fit[{{CQ1, CPW1}, {CQ2, CPW2}}, {1, x, x^2}, x]], 
     Enabled -> False, Background -> Green]}

   }]
 ]],

   DefaultOptions -> {InputField -> {ContinuousAction -> True, 
       FieldSize -> {{5, 30}, {1, Infinity}}}}]]]

Here is the simplified version of codes. In fact, i have several questions.

1)Can we use a list in the dynamic module for the input field, such as here in my case, InputField[P[1]], InputField[P[2]], cuz i want to use the loop in the calculation, else i have to repeat the codes by a hundred times to do the same thing(makes me feel silly).

2) Can we hide some of the results, as you can see here in my case, the corrected pressure ,the corrected flow and the corrected power are just for getting the curve, but NOT neccessarily be part of the output. So i want to hide them, but since i still need to use them. I hope, there is a method to do it.

So, that is my question. Thanks a lot.

$\endgroup$
  • 1
    $\begingroup$ Does adding the semi-colon ; not suppress the output? $\endgroup$ – bill s Jun 11 '15 at 10:08
  • $\begingroup$ Thanks for your response, but i do not understand where should i put ; , because that will totally change the syntax of the sentence. Thx. $\endgroup$ – Yihuan Jun 12 '15 at 7:04
  • $\begingroup$ Can you strip down your question so that it is a small amount of code? Just one or two variables with a dummy calculation that shows the problem you want addressed. Your code does not run as it is above, and so it is impossible to tell what you are after. Normally, semicolon suppresses the output of a line being printed, but you haven't told which part of the output you want suppressed! $\endgroup$ – bill s Jun 12 '15 at 9:12
  • $\begingroup$ I have just uploaded the simplified version of codes. Thx very much for your response. $\endgroup$ – Yihuan Jun 12 '15 at 15:59
  • $\begingroup$ If you do not want to enter data for variables like CQ1 and CQ2, then do not put them in an InputField, simply define them in the code (followed by a semicolon) and then they will be calculated but not displayed. $\endgroup$ – bill s Jun 12 '15 at 16:00
1
$\begingroup$

I've done the change for the first set of variables...

DynamicModule[{Q1 = 175000, Q2 = 175000, P1 = 3500, P2 = 3500, 
  PW1 = 220, PW2 = 220},
 CQ1 := 25*
   Q1*(1 + ((25*(273.15 + 25)/(273.15 + 25)) - 
        1)*(.2857142857*PW1*P1*
         Log[(10125 + P1)*
            Log[10]/(10125*
               Log[1 + .2857142857*PW1*
                  P1*((10125 + P1)/10125 - 1)/Q1])]/(Q1*Log[10]) - 1));
 CQ2 := 25*
   Q2*(1 + ((25*(273.15 + 25)/(273.15 + 25)) - 
        1)*(.2857142857*PW2*P2*
         Log[(10125 + P2)*
            Log[10]/(10125*
               Log[1 + .2857142857*PW2*
                  P2*((10125 + P2)/10125 - 1)/Q2])]/(Q2*Log[10]) - 
        1)); Deploy[
  Style[Panel[
    Grid[Transpose[{{"Input ", Style["Point 1"], 
        Style["Point 2"]}, {"  Flowrate m^3/h ", 
        InputField[Dynamic[Q1], Number], 
        InputField[Dynamic[Q2], Number]}, {"Pressure ", 
        InputField[Dynamic[P1], Number], 
        InputField[Dynamic[P2], Number]}, {"  Power kW ", 
        InputField[Dynamic[PW1], Number], 
        InputField[Dynamic[PW2], Number]}, {"  Corrected Head(Pa)", 
        InputField[
         Dynamic[CH1 = 
           1000^2*P1*(1 + ((1000)) - 
              1)*(.2857142857*PW1*P1*
               Log[(10125 + P1)*

                  Log[10]/(10125*
                    Log[1 + .2857142857*PW1*
                    P1*((10125 + P1)/10125 - 1)/Q1])]/(Q1*Log[10]) - 
              1)], Enabled -> False, Background -> Green], 
        InputField[
         Dynamic[CH2 = 
           1000^2*P2*(1 + ((1000)) - 
              1)*(.2857142857*PW2*P2*
               Log[(10125 + P2)*
                  Log[10]/(10125*
                    Log[1 + .2857142857*PW2*
                    P2*((10125 + P2)/10125 - 1)/Q2])]/(Q2*Log[10]) - 
              1)], Enabled -> False, 
         Background -> Green]}, {"  Corrected Power(kW)", 
        InputField[
         Dynamic[CPW1 = 
           10125^3*
            PW1*(1 + ((10125*(273.15 + 25)/(273.15 + 20)) - 
                 1)*(.2857142857*PW1*P1*
                  Log[(10125 + P1)*
                    Log[10]/(10125*
                    Log[1 + .2857142857*PW1*
                    P1*((10125 + P1)/10125 - 1)/Q1])]/(Q1*Log[10]) - 
                 1))], Enabled -> False, Background -> Green], 
        InputField[
         Dynamic[CPW2 = 
           10125^3*
            PW2*(1 + ((10125*(273.15 + 25)/(273.15 + 20)) - 
                 1)*(.2857142857*PW2*P2*
                  Log[(10125 + P2)*
                    Log[10]/(10125*
                    Log[1 + .2857142857*PW2*
                    P2*((10125 + P2)/10125 - 1)/Q2])]/(Q2*Log[10]) - 
                 1))], Enabled -> False, 
         Background -> Green]}, {"Result", 
        InputField[
         Dynamic[fancurve1 = 
           Fit[{{CQ1, CH1}, {CQ2, CH2}}, {1, x, x^2}, x]], 
         Enabled -> False, Background -> Green], 
        InputField[
         Dynamic[powercurve1 = 
           Fit[{{CQ1, CPW1}, {CQ2, CPW2}}, {1, x, x^2}, x]], 
         Enabled -> False, Background -> Green]}}]]], 
   DefaultOptions -> {InputField -> {ContinuousAction -> True, 
       FieldSize -> {{5, 30}, {1, Infinity}}}}]]]
| improve this answer | |
$\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.