I recently moved an Manipulate block from a notebook to a package (.m file). The original manipulate called functions from the package in the form of Package`f(x) and was used in the Manipulate. The call for package is shown below:
Needs["Hydrates`", "C:\\Users\\colin\\eclipseworkspace\\AdvancedFlowAnalysis\\CDF Release\\Packages_Encoded\\Hydratese.m"];
Now, the entire Manipulate block is kept inside the original packages and accessed via function, for instance see the large block of code below. However, the result was a Kernel that ran indefinitely at 30-40%. I included some screen captures after the code showing the Kernel behavior before and after the manipulate move to the package. Everything works well except that the extra Kernel seems to continuously run.
HydratePlotT3[Pmax_]:=Manipulate[
pData=Range[14.7,Pmax];
meterData=pData*6.895/9.81; (*Convert to kPa and then to meters*)
TData=TowlerCorrelation[pData, SGHydrate];
MData=MotieeCorrelation[pData,SGHydrate];
HData=HammerS[pData];
TempData[DepthLoc_, Tsurface_, TGrad_]:=Tsurface+TGrad*DepthLoc;
Grid[{
{
If[!bPressure,
LogLinearPlot[{
If[ShowTowler ,TowlerCorrelation[p, SGHydrate]],
If[ShowMotiee , MotieeCorrelation[p,SGHydrate]],
If[ShowHammer , HammerS[p]],
If[ DoSensitivityM,Table[MotieeCorrelation[p,SGsens],{SGsens,0.5,.8,.1}]],
If[ DoSensitivityT,Table[TowlerCorrelation[p,SGsens],{SGsens,0.5,.8,.1}]]
},
{p,14.7, Pmax},
FrameLabel->{ PresLabel<>" "<>punits, TempLabel <>" "<>tempunits},
LabelStyle->Directive[FontSize->FL,FLF],
AxesOrigin->{0,0},
PlotRange->{{10,Pmax},{0,GR}},
GridLines->Automatic,
Frame->FrameForm,
ImageSize->PlotSize,
PlotStyle->ColorForm,
PlotPoints-> ControlActive[MinPoint,MaxPoint],
Filling-> Top,
Background->White,
PlotLegends->Placed[{"Towler","Motiee", "HammerS...","GeoThermal Gradient"},Below],
Epilog->{Text[HydLabel ,Scaled[{.3,.8}]]}
],
ListPlot[{
If[ShowTowler, Table[{TData[[i]], meterData[[i]]}, {i,1,Length[pData]} ]],
If[ShowMotiee, Table[{MData[[i]], meterData[[i]]}, {i,1,Length[pData]} ]],
If[ShowHammer, Table[{HData[[i]], meterData[[i]]}, {i,1,Length[pData]} ]],
Table[{ TempData[meterData[[i]], TSurface, Tgradient], meterData[[i]] },{i, 1, Length[meterData]} ]
},
ScalingFunctions->"Reverse",
FrameLabel->{ TempLabel <>" "<>tempunits, MeterLabel<>" "<>Meterunits },
GridLines->Automatic,
PlotRange->{{Automatic,Automatic},{0,1600}},
Frame->FrameForm,
ImageSize->PlotSize,
LabelStyle->Directive[FontSize->FL,FLF],
ImageSize->PlotSize,
Background->White,
PlotStyle->ColorForm4,
PlotLegends->Placed[{"Towler","Motiee", "HammerS..."},Below],
Joined->True
]
]
}}],(*End of Grid*)
Grid[{
{ Evaluate[BlankLine]},
{ Style[PVTparams,FL,FLF]},(*Head/title of inputs*)
{ Evaluate[BlankLine]},
{ Control[ {{SGHydrate, 0.6, Style[SGtext,FL2]},0.5,0.75 , App1, App2, ImageSize->Small}] },
{ Control[ {{TSurface, 20, Style["Surface "<>TempLabel,FL2]},-40, 40 , App1, App2,ImageSize->Small}] },
{ Control[ {{Tgradient, 0.030, Style[TempLabel<>" Gradient",FL2]},0.01, 0.03, App1, App2, ImageSize->Small}] },
{ Evaluate[BlankLine]},
{ Style[ModelSelect,FL,FLF]},(*Head/title of sensitivities s*)
{ Evaluate[BlankLine]},
{ Control[ {{ShowTowler,True,"Towler Correlation"},{True,False}}] },
{ Control[ {{ShowMotiee,True,"Motiee Correlation"},{True,False}}] },
{ Control[ {{ShowHammer,True,"Hammer Correlation"},{True,False}}] },
{ Evaluate[BlankLine]},
{ Control[ {{bPressure,True,"Permaforst/Marine Hydrate/Zone"},{True,False}}] },
{ Evaluate[BlankLine]},
{ Style[SNSparams,FL,FLF]},(*Head/title of sensitivities s*)
{ Evaluate[BlankLine]},
{ Control[ {{DoSensitivityM,False,"Motiee SG Senstivity"},{True,False}}] },
{ Control[ {{DoSensitivityT,False,"Towler SG Senstivity"},{True,False}}] }
},
Alignment->Right
],(*End of Grid*)
ContinuousAction->False,(*Do not update until slide finished moving*)
SynchronousUpdating->False,
Paneled->False,
ControlPlacement->CP
(*SaveDefinitions->True*)
]
Screen captures of Kernel problems