public RunInfo() { Runs = 1; Iterations = 1; CurrentRun = 0; CurrentIteration = 0; RunType = ModelRunType.RunAsIs; }
public RunInfo(int runs, int iterations, ModelRunType runType) { Runs = runs; Iterations = iterations; RunType = runType; }
static void Main(string[] args) { try { ModelRunType modelRunType = ModelRunType.NewFeedrates; var gridOrigin = new Vector2(-.32, 0); double gridWidth = .64; double gridDepth = .5; double meshSize = .001; double alongLocation = 0.0; double jetCenterX = gridWidth / 2.0; double jetDiameter = .0558; double jetR = jetDiameter / 2.0; double nominalFeedrate = 40; double baseMrr = .00234211; double mrr = baseMrr; double maxMrr = .0025; double averagingWindow = .01; double critAngle = Math.PI * 0.0 / 180.0; double inspectionLoc = 0; double targetDepth = .049; double particleRadius = .014; int runCount = 11; bool findNewFeedrates = false; bool adjustMrr = true; bool adjustCritAngle = true; bool adjustCurvParams = false; //laptop string directory = " C:/Users/nickc/OneDrive/Documents/#729 155mm/Nick test files/"; //work desktop directory = "C:/Users/nickc_000/OneDrive/Documents/#729 155mm/Nick test files/"; Console.WriteLine("building grid"); var profile = new XSection(gridOrigin, gridWidth, meshSize); var tempProfile = new XSection(gridOrigin, gridWidth, meshSize); var jetRayList = new List <Ray2>(); //string targetProfileFilename = "190201_03 _TOP_33_60deg_out.csv"; string targetProfileFilename = "190201-04 - TOP-33-BOT-10-COR-04 - 60deg_out.csv"; string startProfileFilename = "top_channel_model_profile.csv"; // string targetDepthProfile = "190207-11 - 0.040Dm-60deg-Xpos-16pass_out-target.csv"; var targetProfile = new XSection(targetProfileFilename, 7, 1); var startProfile = new XSection(startProfileFilename, 0, 0); double startDepth = startProfile.GetValue(inspectionLoc); Console.WriteLine("startDepth: " + startDepth.ToString()); string jetscanFilename = "dn005-dm040-60deg.csv"; //jetscanFilename = "parabolaJet.csv"; var jet = new XSecJet(jetscanFilename, jetDiameter); //string path ="155_FLAT_TOP_33.csv"; //string pathCsvFilename = "singlepath-profile-toolpath.csv"; //pathCsvFilename = "BOT-profile-toolpath-depthmeasure-test-nick.csv"; string path = "bottom25.csv"; //pathCsvFilename = "top35.csv"; //build path from path entities //path is list of path entities //jet ray list is list of jet rays //pathExOrder,xLocation(across channel),yLocation(along channel),feed, direction,Depth,TargetDepth" var pathList = new XSecPathList(path, 1, 0); int pathCount = pathList.Count; int jetW = (int)(Math.Ceiling(jet.Diameter / meshSize)); //double[,] feedArr = new double[pathCount, jetW]; //build jet rays from path list Ray2[,] jetArr = BuildJetArray(pathList, jet, meshSize, nominalFeedrate); Console.WriteLine("running model"); var angleEffectList = new List <string>(); var normalsList = new List <string>(); var errorHistoryStr = new List <string>(); var errorHistoryList = new List <ErrorHistory>(); Error profileError = new Error(); double maxError = .0005; int innerIterator = 0; int innerIterations = 3; int outerIterations = 4; double critAngleMax = 85; double critAngleMin = 0; double critAngleChange = 5; double critAngDeg = 15; string timeCode = DateTime.Now.ToFileTimeUtc().ToString(); double startPosScaling = .008; double startNegScaling = .001; double posScalingFactor = startPosScaling; double negScalingFactor = startNegScaling; int outerIterator = 0; errorHistoryStr.Add("CRITANG,NEGSCALING,POSSCALING,ERROR"); double mrrAdjustFactor = 1; while (outerIterator < outerIterations)//pos scaling iteration { Console.WriteLine("Outer Iteration: " + outerIterator.ToString()); Console.WriteLine("Critangle: " + critAngDeg.ToString()); mrr = baseMrr; innerIterator = 0; while (innerIterator < innerIterations)//neg scaling iteration { Console.WriteLine("Inner Iteration: " + innerIterator.ToString()); Console.WriteLine("MRR: " + baseMrr.ToString()); critAngle = Math.PI * critAngDeg / 180.0; profile = new XSection(startProfile); int run = 0; double inspectionDepth = 0; while (run < runCount) { //index across jet locations in jet-path array for (int pathIndex = 0; pathIndex < jetArr.GetLength(0); pathIndex++) { tempProfile = new XSection(gridOrigin, gridWidth, meshSize); for (int jetLocIndex = 0; jetLocIndex < jetArr.GetLength(1); jetLocIndex++) { var jetRay = jetArr[pathIndex, jetLocIndex]; double x = jetRay.Origin.X; var profileNormal = profile.GetNormalAngle(x, averagingWindow); var angleEffect = AngleEffect(profileNormal, critAngle); var curvature = CurvatureEffect(profile.GetCurvature(x, particleRadius), posScalingFactor, negScalingFactor); double materialRemoved = mrr * jetRay.Length * angleEffect * curvature; tempProfile.SetValue(materialRemoved, x); } tempProfile.Smooth(jetR); profile.AddProfile(tempProfile); profile.Smooth(jetR); } Console.WriteLine("Run: " + run.ToString()); startDepth = startProfile.GetValue(inspectionLoc); inspectionDepth = profile.GetValue(inspectionLoc); double targetDepthAtRun = (targetDepth - startDepth) * (run + 1) / runCount; double depthAtRun = inspectionDepth - startDepth; double targetTotalDepth = startDepth + targetDepthAtRun; Console.WriteLine("StartDepth: " + startDepth.ToString()); Console.WriteLine("Total Depth: " + inspectionDepth.ToString()); Console.WriteLine("TargetDepthAtRun: " + targetDepthAtRun.ToString()); Console.WriteLine("TargetTotalDepthAtRun: " + targetTotalDepth.ToString()); Console.WriteLine("mrrAdjustFactor: " + mrrAdjustFactor.ToString()); Console.WriteLine(""); run++; } profileError = CalcError(profile, targetProfile, runCount, runCount); string paramString = critAngDeg.ToString() + "," + baseMrr.ToString() + "," + profileError.Ave.ToString() + "," + profileError.Max.ToString(); errorHistoryStr.Add(paramString); angleEffectList.Add("X,D,TD,AE,N,Curvature," + paramString); foreach (var pt in profile) { var n = profile.GetNormalAngle(pt.X, jetDiameter); var c = profile.GetCurvature(pt.X, averagingWindow); var td = targetProfile.GetValue(pt.X); // var f = feedProfile.GetValue(pt.X); angleEffectList.Add(pt.X.ToString() + "," + pt.Y.ToString() + "," + td.ToString() + "," + AngleEffect(n, critAngle).ToString() + "," + n.ToString() + "," + c.ToString()); } Console.WriteLine("CritAngle: " + critAngDeg + " baseMrr: " + mrr + " Error:ave: " + profileError.Ave.ToString() + " max: " + profileError.Max.ToString()); Console.WriteLine(""); Console.WriteLine("saving model"); timeCode = System.DateTime.Now.ToFileTimeUtc().ToString(); FileIOLib.FileIO.Save(angleEffectList, directory + "ProfileEffectList" + timeCode + ".csv"); string bitmapFilename = directory + "testgrid" + timeCode + ".bmp"; profile.SaveBitmap(bitmapFilename); //critAngDeg += critAngleChange; if (adjustMrr) { mrrAdjustFactor = Math.Abs(targetDepth / inspectionDepth); mrr *= mrrAdjustFactor; Console.WriteLine("new Mrr: " + mrr.ToString()); } if (findNewFeedrates) { double MeasureWidth = .002; DataLib.CartData depthData = new DataLib.CartData(path); foreach (var pt in profile) { depthData.Add(new Vector3(pt.X, pt.Y, 0)); } pathList.AdjustFeedrates(depthData, startProfile.AsCartData(), targetProfile.AsCartData(), MeasureWidth); jetArr = BuildJetArray(pathList, jet, meshSize, nominalFeedrate); FileIOLib.FileIO.Save(pathList.AsCSVFile(startProfileFilename, targetProfileFilename), directory + "pathlist" + timeCode + ".csv"); } innerIterator++; } if (adjustCritAngle) { critAngDeg += critAngleChange; } outerIterator++; } FileIOLib.FileIO.Save(errorHistoryStr, directory + "Errorhistory" + timeCode + ".csv"); Console.WriteLine("program complete"); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex.Message + ":" + ex.StackTrace); Console.ReadKey(); } }