Skip to content

Instantly share code, notes, and snippets.

@mcknightcasey
Created July 14, 2010 04:11
Show Gist options
  • Save mcknightcasey/475019 to your computer and use it in GitHub Desktop.
Save mcknightcasey/475019 to your computer and use it in GitHub Desktop.
InitializationSection =
NotebookOpen[
"/Users/cmcknight14/Documents/FEM Pittsburgh/Bamboo/Run \
1-Initialization Section.nb"];
SelectionMove[InitializationSection, All, Notebook];
SelectionEvaluate[InitializationSection];
InputSection =
NotebookOpen[
"/Users/cmcknight14/Documents/FEM Pittsburgh/Bamboo/Run 2-Input \
Section.nb"];
SelectionMove[InputSection, All, Notebook];
SelectionEvaluate[InputSection];
MaxError = {0};
i = 1;
While[ Diff > 0.1,
HamburgerPatty =
NotebookOpen[
"/Users/cmcknight14/Documents/FEM Pittsburgh/Bamboo/Run 3-Meat \
Part.nb"];
SelectionMove[HamburgerPatty, All, Notebook];
SelectionEvaluate[HamburgerPatty];
Solution =
NotebookOpen[
"/Users/cmcknight14/Docapuments/FEM Pittsburgh/Bamboo/Run \
4-Solution.nb"];
SelectionMove[Solution, All, Notebook];
SelectionEvaluate[Solution];
Recordings =
NotebookOpen[
"/Users/cmcknight14/Documents/FEM Pittsburgh/Bamboo/Run 5-Date \
Time Recordings.nb"];
SelectionMove[Recordings, All, Notebook];
SelectionEvaluate[Recordings];
If[i == 1, MaxError[[1]] = N[(Max[\[Lambda]] - Min[\[Lambda]])/2],
MaxError = Append[MaxError, N[(Max[\[Lambda]] - Min[\[Lambda]])/2]];
Diff = MaxError[[i]] - MaxError[[i - 1]];
]
i++
]
Print["Appropriate step size is ", N[i - 1]];
(*or should we go with the appropriate step size being i, so it will \
be easier to save results without having to run one more time*)
WeCan = CreateDocument[];
Sure = SelectionMove[InputSection, All, Notebook];
FrontEndExecute[FrontEndToken[InputSection, "Copy"]]; FrontEndExecute[
FrontEndToken[WeCan, "Paste"]];
(*The following two stanzas writes the Solution Matrix and the Graph \
into an output file*)
(*Not sure if opening this same file OutputRec every time will work*)
OutputRec = $TemporaryPrefix <> "OutStuff";
Start = OpenWrite[OutputRec];
Write[Start, plotmatrix];
Close[Start];
Start = OpenAppend[OutputRec];
Write[Start, MagnificentPic];
Close[Start];
(*This prints the contents of that output file in a notebook with the \
Input Section*)
NotebookWrite[WeCan, "FilePrint[OutputRec]", All];
SelectionEvaluate[WeCan];
(*This pastes the evaluation results of Run 5-Date Time Recordings \
file into the WeCan Notebook*)
SelectionMove[Recordings, All, Notebook];
FrontEndExecute[FrontEndToken[Recordings, "Copy"]];
FrontEndExecute[FrontEndToken[WeCan, "Paste"]];
(*This saves the input and results notebook*)
NotebookSave[WeCan, ResultFile];
Appropriate step size is 1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment