Message Boards Message Boards

GROUPS:

Update value and precision of InputField inside Manipulate?

Posted 4 years ago
2380 Views
|
0 Replies
|
0 Total Likes
|

I have a code to determine translation factor of fiber strength in a composite pressure vessel based on the vessel's burst test data. Manipulate functionality has been designed around several Input Fields and a slider. One of the Input Fields is being rogue. Sometimes (depending on the dynamic value selected from a drop down list), it is showing a weird precision of digits. Furthermore I cannot update the field and register the value even though it has been defined as a dynamic Input Field.

I would appreciate if someone could look at my code and provide some helpful hints on how to get rid of these issues.

The InputField for 'Hoop bandwidth (in' cannot be updated and shows strange precision.


Clear["Global`*"];

Framed[

 Column[{

   Manipulate[
    Tfac =.;

    ID = OD - 2.*tm;

    R = ID/2 + (tm + tc)/2;

    Em = 9.8 10^6; Y = 40. 10^3; 
    T = 44. 10^3; \[Epsilon]Y = .004; \[Epsilon]T = .1;
    Et = (T - Y)/(\[Epsilon]T - \[Epsilon]Y);
    Vf = .6;
    Ef = Switch[fibtype, "Toray T700", 33.4 10^6, "Toray T800", 
      37.5 10^6, "Hyosung H2550", 33.4 10^6, "OC X H-glass", 13. 10^6];
    E1 = Vf*Ef; E2 = 1.3 10^6;
    \[Rho]f = 
     Switch[fibtype, "Toray T700", 1.8, "Toray T800", 1.8, 
      "Hyosung H2550", 1.8, "OC X H-glass", 2.6];
    TEX = 
     Switch[fibtype, "Toray T700", 800, "Toray T800", 1030, 
      "Hyosung H2550", 800, "OC X H-glass", 2400];
    bwt = 
     Switch[fibtype, "Toray T700", .14, "Toray T800", .136, 
      "Hyosung H2550", .1386, "OC X H-glass", .177];

    CSA = TEX/(10^5*\[Rho]f)*1/2.54^2;

    thoop = 2*Ntows*CSA/(bw*Vf);
    theli = 1/.9*thoop;
    tc = nhoop*thoop + nheli*theli;
    \[Theta] = helangle*\[Pi]/180;

    Ec = (
     nhoop*thoop*E1 + 
      nheli*theli*(E1 (Sin[\[Theta]])^2 + E2  (Cos[\[Theta]])^2))/(
     nhoop*thoop + nheli*theli);

    (*--- \[Epsilon]cu = failure strain in composite ----*)

    \[Epsilon]cu = 
     Switch[fibtype, "Toray T700", 1.9, "Toray T800", 2, 
      "Hyosung H2550", 2, "OC X H-glass", 2.5];

    \[Sigma]cu = Tfac*Ec*\[Epsilon]cu/100*(Cos[bw/(\[Pi] ID)])^2;

    (*--- normalized stiffnesses ----*)

    Etn = Et/Em; Ecn = Ec/Em;
    Be = Em tm + Ec tc; Ben = tm + Ecn tc; Bpn = Etn tm + Ecn tc;

    (*--- \[Sigma]me = 
    stress in the metal liner before yielding ----*)

    \[Sigma]me = Em (p R)/Be;(*--- \[Sigma]ce = 
    stress in the composite shell before yielding ----*)

    \[Sigma]ce = Ec (p R)/Be;

    (*--- py = pressure where the vessel yields ----*)

    py = (Y Be)/(Em R);

    (*--- \[Sigma]mp = 
    stress in the metal liner after yielding ----*)

    \[Sigma]mp = (p R Etn + Y (1 - Etn) Ecn tc)/(Etn tm + Ecn tc);

    (*--- \[Sigma]cp = 
    stress in the composite shell after yielding ----*)

    \[Sigma]cp = (Ecn (p R - Y (1 - Etn) tm))/(Etn tm + Ecn tc);

    (*--- \[Sigma]ma = 
    stress in metal liner at autofrettage pressure ----*)

    \[Sigma]ma = (pa R Etn + Y (1 - Etn) Ecn tc)/(Etn tm + Ecn tc);

    (*--- \[Sigma]m0 = 
    residual stress in metal liner at zero pressure after unloading \
from autofrettage ----*)

    \[Sigma]m0 = -(((1 - Etn) Ecn tc)/(Ben Bpn)) (pa - py) R;
    k\[Sigma]0 = \[Sigma]cu tc + \[Sigma]m0 tm;

    (*--- \[Sigma]c0 = 
    residual stress in the composite shell at zero pressure after \
unloading from autofrettage ----*)

    \[Sigma]c0 = -\[Sigma]m0 tm/tc;

    (*--- pya = pressure beyond which the liner yields again = 
    autofrettage pressure ----*)

    pya = ((\[Sigma]ma - \[Sigma]m0) Be)/(Em R);

    (*--- \[Sigma]mae = 
    stress in the metal liner after autofrettage and unloading ----*)
\


    \[Sigma]mae = \[Sigma]m0 + Em (p R)/Be;

    (*--- \[Sigma]cae = 
    stress in the composite after autofrettage and unloading ----*)

    \[Sigma]cae = \[Sigma]c0 + Ec (p R)/Be;

    (*--- pb = burst pressure ----*)

    Pb = 1/( 
      Ecn R) (\[Sigma]cu (Etn tm + Ecn tc) + Ecn Y (1 - Etn) tm);
    sol = NSolve[{Pb == Pburst}, {Tfac}];
    z = 100*Tfac /. sol[[1]];

    Trans = Which[z < 0, 0, z > 100, 100, 0 <= z <= 100, z];

    Column[{

      Framed[
       AngularGauge[Trans, {0, 100}, GaugeFaceStyle -> LightBlue, 
        GaugeFrameElementFunction -> "BezelSector", 
        GaugeLabels -> {Automatic, "%"}, 
        GaugeMarkers -> "BezelBevelNeedle", 
        LabelStyle -> {14, GrayLevel[.1]}]
       ,
       BaseStyle -> {FontWeight -> "Thin", FontSize -> 14, 
         FontFamily -> "Arial"}, RoundingRadius -> 5, 
       FrameMargins -> 10, Background -> GrayLevel[.7], 
       FrameStyle -> None],
      "",

      Framed[

       Row[
        {"Translation factor: ", NumberForm[Trans, {3, 2}], " %"

         }
        ],
       BaseStyle -> {FontWeight -> "Thin", FontSize -> 14, 
         FontFamily -> "Arial"}, RoundingRadius -> 5, 
       FrameMargins -> 10, Background -> LightBlue]

      }],
    Grid[
     {
      {"Liner OD (in.) :"
        DynamicModule[{},
         InputField[Dynamic[OD], Number, FieldSize -> 6, 
          Background -> LightYellow], Initialization :> (OD = 6)]},
      {"Liner wall thickness (in.) :"
        DynamicModule[{},
         InputField[Dynamic[tm], Number, FieldSize -> 6, 
          Background -> LightRed], Initialization :> (tm = .125)]},

      {Row[{"Fiber Type : ",

         PopupMenu[
          Dynamic[fibtype], {"Toray T700", "Toray T800", 
           "Hyosung H2550", "OC X H-glass"}]}

        ]},

      {"Number of tows :"
        DynamicModule[{},
         InputField[Dynamic[Ntows], Number, FieldSize -> 6, 
          Background -> LightCyan], Initialization :> (Ntows = 5)]},
      {"Hoop bandwidth (in.) :"
        DynamicModule[{},
         InputField[Dynamic[bw, SetAccuracy[bw, 3]], Number, 
          FieldSize -> {6, 1}, Background -> LightGray], 
         Initialization :> (bw = .68)]},
      {"Helical angle :"
        DynamicModule[{},
         InputField[Dynamic[helangle], Number, FieldSize -> 6, 
          Background -> LightMagenta], 
         Initialization :> (helangle = 17.5)]},
      {"Number of helical layers :"
        DynamicModule[{},
         InputField[Dynamic[nheli], Number, FieldSize -> 6, 
          Background -> LightGreen], Initialization :> (nheli = 2)]},
      {"Number of hoop layers :"
        DynamicModule[{},
         InputField[Dynamic[nhoop], Number, FieldSize -> 6, 
          Background -> LightOrange], Initialization :> (nhoop = 2)]},

      {""},
      {Button["OK", Background -> Green, BaseStyle -> "16", 
        ImageSize -> Medium ]}
      }, BaseStyle -> {FontSize -> 14, Background -> GrayLevel[.7]},


     Alignment -> Right],
    {{Pburst, 1, "Burst Pressure (psi)" }, 500, 10000, 1, 
     Appearance -> {"Labeled", "DownArrow", "Open"}, 
     ImageMargins -> 5, ImageSize -> Tiny, 
     BaseStyle -> FontSize -> 14, 
     AppearanceElements -> {"ProgressSlider", "InputField", 
       "StepLeftButton", "StepRightButton"}},
    Initialization :> {Ntows = 5, Pburst = 5500, bw = Ntows*bwt},
    Alignment -> {Top}, 
    BaseStyle -> {FontSize -> 14, FontFamily -> "Arial"},
    LabelStyle -> Directive[Black, FontSize -> 14], Paneled -> False, 
    ControlPlacement -> Left, ContentSize -> {250, 300}
    ]

   }],
 Alignment -> Left, FrameMargins -> 20, Background -> GrayLevel[.7], 
 RoundingRadius -> 10, 
 BaseStyle -> {FontWeight -> "Regular", FontSize -> 16, 
   FontFamily -> "Arial"}


 ]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract