Skip to content

Instantly share code, notes, and snippets.

@robertdfrench
Forked from mcknightcasey/Stupid Error
Created July 14, 2010 04:27
Show Gist options
  • Save robertdfrench/475027 to your computer and use it in GitHub Desktop.
Save robertdfrench/475027 to your computer and use it in GitHub Desktop.
FEMNotebookOpen[Filename_] :=
NotebookOpen[
"/Users/cmcknight14/Documents/FEM Pittsburgh/Bamboo/" <> Filename <>
".nb"];
FEMEvaluateNotebook[NotebookHandle_] := (
SelectionMove[NotebookHandle, All, Notebook];
SelectionEvaluate[NotebookHandle];
);
InitializationSection =
FEMNotebookOpen["Run 1-Initialization Section"];
FEMEvaluateNotebook[InitializationSection];
InputSection = FEMNotebookOpen["Run 2-Input Section"];
FEMEvaluateNotebook[InputSection];
MaxError = {0}; (* Initialize the error array. *)
i = 1;
While[Diff > 0.1,
HamburgerPatty = FEMNotebookOpen["Run 3-Meat Part"];
FEMEvaluateNotebook[HamburgerPatty];
Solution = FEMNotebookOpen["Run 4-Solution"];
FEMEvaluateNotebook[Solution];
Recordings = FEMNotebookOpen["Run 5-Date Time Recordings"];
FEMEvaluateNotebook[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