static void Main(string[] args) { NCGrid_Distribution funcp = new NCGrid_Distribution(new RBounds2D(0, 10, 0, 10), 400, 400); NCGrid_Distribution func = ExactFunctionGeneratorVB2D.GenerateFunctionToGrid("(-1*x) + (2*y)", funcp); DistributionSketchSettings settings = DistributionSketchSettings.Fancy(); int n = 10; settings.XLabelCount = n; settings.YLabelCount = n; settings.XGridlineCount = n; settings.YGridlineCount = n; DistributionSketch2D sktch = new DistributionSketch2D(func, settings); sktch.CreateSketch(true); sktch.SaveImage(@"C:\Users\Will\Desktop\output.png", true); }
static void testfunction() { Console.WriteLine("Press enter to begin, or enter \"c\" to clear repos."); if (Console.ReadLine() == "c") { RepoManagement.ClearRepo(Paths.DistributionRepo, Paths.ImageRepo); } DateTime then = DateTime.Now; Console.WriteLine("Solving..."); double L = 10; double H = 10; int n = 38; RBounds2D bounds = new RBounds2D(0, L, 0, H); NCGrid_Distribution dist = new NCGrid_Distribution(bounds, n, n); BoundaryConditions conditions = new BoundaryConditions(bounds, n, n, BoundaryConditions.BoundaryConditionType.Dirichlet); double dx = L / (n - 1); double max = 5; string fxn = string.Format("{0}*Sin({1}*x/{2})*(Exp({1}*y/{2}) - Exp(-1*{1}*y/{2}))/(Exp({1}*{3}/{2}) - Exp(-1*{1}*{3}/{2}))", max, Math.PI, L, H); conditions.SetConstant(0, BoundaryConditions.Direction.Negative_X); conditions.SetConstant(0, BoundaryConditions.Direction.Negative_Y); conditions.SetConstant(0, BoundaryConditions.Direction.Positive_Y); for (int i = 0; i < n; i++) { double x = i * dx; double z = max * Math.Sin(Math.PI * x / L); conditions[i, BoundaryConditions.Direction.Positive_Y] = z; } int solcount = 50; double[] errors = new double[solcount]; double[] iteration = new double[solcount]; DistributionSketchSettings S = DistributionSketchSettings.Fancy(); S.SetFigureTitle("Temperature Distribution"); for (int i = 0; i < solcount; i++) { Console.WriteLine(i.ToString() + " of " + solcount.ToString() + " iterations processed."); iteration[i] = i; BVPLinear2D problem = new BVPLinear2D(conditions, LinearOperatorOrder2.Laplace, dist); problem.EnableConsoleOutput(); NCGrid_Distribution soln = problem.Solve(Matrix.SystemSolvingScheme.Kaczmarz); NCGrid_Distribution analytic = ExactFunctionGeneratorVB2D.GenerateFunctionToGrid(fxn, soln); soln.ApplyMeshMorphGA(15); errors[i] = ErrorEstimation.NormDifference(soln, analytic); string title = "iterative-" + i.ToString(); soln.WriteToFile(title); DistributionSketch2D sketch = new DistributionSketch2D(soln, S); dist = soln.Clone(); sketch.CreateSketch(true); sketch.SaveImage(title + "-plot", false); } List <string> filestuff = new List <string>(); for (int i = 0; i < iteration.Length; i++) { filestuff.Add(iteration[i].ToString() + "," + errors[i].ToString()); } File.WriteAllLines(@"C:\Users\Will\Desktop\Folders\MATH435\repo\curves-1d\errors-temp.csv", filestuff.ToArray()); Console.WriteLine("Done."); Console.ReadLine(); }