public MainFunction(GeometryOptions model, MaterialsOptions material, AdditionallyOptions add, FileName file, CommonReport finalReport, GeneralReport genReport, Routes rout, ArgumentsCMD cmd, FilesForVolume filesForVolume) { this.model = model; this.material = material; this.add = add; this.file = file; this.finalReport = finalReport; this.genReport = genReport; this.rout = rout; this.cmd = cmd; this.filesForVolume = filesForVolume; }
public SimplexPlanning(GeometryOptions model, MaterialsOptions material, AdditionallyOptions add, FileName file, CommonReport finalReport, Routes rout, ArgumentsCMD cmd, FilesForVolume filesForVolume) { this.model = model; this.material = material; this.add = add; this.file = file; this.finalReport = finalReport; this.rout = rout; this.cmd = cmd; this.filesForVolume = filesForVolume; }
public void Processing(GeometryOptions model, FileName file, FilesForVolume filesForVolume, GeneralReport genReport) { try { Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); var extract = new RunExtract(rout); extract.ExtractName(cmd.extractName, file); extract.ChangeName(file); extract.ExtractFiles(cmd.extractFiles); extract.ExtractNodes(cmd.extractNodes, file); var extrRoutes = new RoutesForExtract(); extrRoutes.setReactionForceRoute = rout.workingDirectory + @"\RF3Stamp.csv"; var extrRF = new ExtractRF(); extrRF.Extract(extrRoutes, model); var reprRF = new ReactionForceReport(); reprRF.ReportReactionForce(model, genReport, file, extrRF); filesForVolume.stampNodeDisplacementRoute = rout.workingDirectory + @"\" + filesForVolume.stampNodeDisplacementName; filesForVolume.blankNodeDisplacementRoute = rout.workingDirectory + @"\" + filesForVolume.blankNodeDisplacementName; filesForVolume.blankCoordinatesRoute = rout.workingDirectory + @"\" + filesForVolume.blankCoordinatesName; filesForVolume.elementCoordinatesRoute = rout.workingDirectory + @"\" + filesForVolume.elementCoordinatesName; filesForVolume.stampNodesRoute = rout.workingDirectory + @"\" + filesForVolume.stampNodesName; filesForVolume.elementVolumeRoute = rout.workingDirectory + @"\" + filesForVolume.elementVolumeName; var extrVolume = new ExtractVolume(); //extrVolume.GetStampNodesDisplacement(filesForVolume); extrVolume.GetBlankNodesDisplacement(filesForVolume); //extrVolume.GetBlanksNodeCoordinates(filesForVolume); //extrVolume.GetElementCoordinates(filesForVolume, model); extrVolume.Volume(model); var reprVolume = new VolumeReport(); reprVolume.ReportVolume(model, genReport, file, extrVolume); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void SwitchTrack() { if (trackPrefabs == null || trackPrefabs.Length == 0) { return; } activeIndex = activeIndex + 1 < trackPrefabs.Length ? activeIndex + 1 : 0; Destroy(_activeTrack.gameObject); _activeTrack = Instantiate(trackPrefabs[activeIndex], geometry, false)?.GetComponent <GeometryOptions>(); _activeTrack.name = trackPrefabs[activeIndex].name; if (m_UITrackLabel) { m_UITrackLabel.text = _activeTrack.name; } }
public void ReportVolume(GeometryOptions model, GeneralReport genReport, FileName file, ExtractVolume extrVolume) { try { model.blankVolume = Convert.ToDouble(extrVolume.getVolume()); model.blankVolume = Math.Round(model.blankVolume, 1); model.pctOfDieFilling = (model.blankVolume / model.dieVolume) * 100; model.pctOfDieFilling = Math.Round(model.pctOfDieFilling, 1); String header = String.Join( Environment.NewLine, "Radius, mm" + ";" + "Angle, degrees" + ";" + "Friction coeff" + ";" + "Volume, mm^3" + ";" + "Die Filling, %" + ";" + "Date" + ";" + Environment.NewLine); String csv = String.Join( Environment.NewLine, (model.blankRadius + ";" + model.stampAngle + ";" + model.friction + ";" + model.blankVolume + ";" + model.pctOfDieFilling + ";" + DateTime.Now + ";")); if (!Directory.Exists(genReport.folderName)) { Directory.CreateDirectory(genReport.folderName); } string path = Path.Combine(genReport.folderName, file.volumeReport); if (!File.Exists(path)) { File.WriteAllText(path, header); } File.AppendAllText(path, csv + Environment.NewLine); } catch (Exception e) { MessageBox.Show("Volume Report :" + e); } }
//передать в массивы значения параметров топологии и eps public double[,] makeWorkingArray(double[,] planningMatrix, GeometryOptions model) { double[,] newArray = new double[planningMatrix.GetLength(0), planningMatrix.GetLength(1)]; //for 3 params //double[] input = { model.setStartAngle, model.blankRadius, model.setStartFriction }; //for 2 params double[] input = { model.startBlankRadius, model.startFriction }; //double angleEps = (model.setStartAngle * 10) / 100; double blankEps = (model.startBlankRadius * 3) / 100; //3 double frictionEps = (model.startFriction * 10) / 100; //for 3 params //double[] eps = { angleEps, blankEps, frictionEps }; //for 2 params double[] eps = { blankEps, frictionEps }; for (int i = 0; i < planningMatrix.GetLength(0); i++) { for (int j = 0; j < planningMatrix.GetLength(1); j++) { newArray[i, j] = input[j] + eps[j] * planningMatrix[i, j]; } } var str = new StringBuilder(); str.Append("#"); str.Append(";"); str.Append("Radius,mm"); str.Append(";"); str.Append("Friction"); str.Append(";"); str.Append("Filling, %"); str.Append(";"); str.Append("Force, MN"); str.Append(";"); fileCreate.CreateHeader("", "SimplexNodes", "csv", str.ToString()); return(newArray); }
public void Extract(RoutesForExtract extrRoutes, GeometryOptions model) { try { ReactionForce = File.ReadLines(extrRoutes.setReactionForceRoute).Select(line => line.Split(';')).ToDictionary(data => Convert.ToDouble(data[0]), data => Math.Abs(Convert.ToDouble(data[1]))); ReactionForce = ReactionForce .Where(f => f.Value != 0) .ToDictionary(x => x.Key, x => x.Value); _reactionForce = ReactionForce.Max(y => y.Value); ReactionForce.Clear(); } catch (Exception e) { MessageBox.Show("ExtractRF: " + e); } }
public void Volume(FilesForVolume filesForVolume, GeometryOptions model) { //Верменная переменная для подсчёта объёма Dictionary <double, double> array = new Dictionary <double, double>(); ElementVolume = File.ReadLines(filesForVolume.elementVolumeRoute).Select(line => line.Split(';')).ToDictionary(data => Convert.ToInt32(data[0]), data => Convert.ToDouble(data[1])); ElementVolume = ElementVolume .Where(f => f.Value != 0) .ToDictionary(x => x.Key, x => x.Value); ElementVolume = ElementVolume.Keys.Intersect(ElementNumber.Keys).ToDictionary(t => t, t => ElementVolume[t]); double sum = ElementVolume.Sum(y => y.Value); array.Add(model.blankRadius, sum); String csv = String.Join( Environment.NewLine, array.Select(d => d.Key + ";" + d.Value)); File.AppendAllText("TempVolume.csv", csv + Environment.NewLine); }
public void ReportReactionForce(GeometryOptions model, GeneralReport genReport, FileName file, ExtractRF extrRF) { double RF = Math.Round(extrRF.getRF(), 1); model.reactionForceToBlank = RF; String header = String.Join( Environment.NewLine, "Radius,mm" + ";" + "Angle,degrees" + ";" + "Friction coeff" + ";" + "Force, MN" + ";" + "Date" + ";" + Environment.NewLine); String csv = String.Join( Environment.NewLine, (model.blankRadius + ";" + model.stampAngle + ";" + model.friction + ";" + (model.reactionForceToBlank / 1000000) + ";" + DateTime.Now + ";")); if (!Directory.Exists(genReport.folderName)) { Directory.CreateDirectory(genReport.folderName); } string path = Path.Combine(genReport.folderName, file.RFReport); if (!File.Exists(path)) { File.WriteAllText(path, header); } File.AppendAllText(path, csv + Environment.NewLine); }
public void makeNewCoordinate(double[,] array, GeometryOptions model, SimplexPlanningParams param, FunctionParams funcParam) { double minRadius = 10; double minFriction = 0.2; double maxRadius = model.startBlankRadius * 1.25; double maxFriction = model.endFriction; param.newCoordinate = new double[array.GetLength(1)]; double[,] temp = array; double[] f = new double[array.GetLength(1)]; //новый шаг, который уменьшает размеры симплекса double newN = funcParam.getFactorsCount() + param.moreEps; if (param.countOfArrays > param.Nmax) { for (int i = 0; i < temp.GetLength(0); i++) { for (int j = 0; j < temp.GetLength(1); j++) { f[j] += array[i, j]; } } for (int j = 0; j < temp.GetLength(1); j++) { param.newCoordinate[j] = (2 * f[j] / newN) - param.badCoordinate[j]; } param.moreEps += 0.005; } else { for (int i = 0; i < temp.GetLength(0); i++) { for (int j = 0; j < temp.GetLength(1); j++) { f[j] += array[i, j]; } } for (int j = 0; j < temp.GetLength(1); j++) { param.newCoordinate[j] = (2 * f[j] / funcParam.getFactorsCount()) - param.badCoordinate[j]; } } #region проверка каждого элемента на мин и макс if (param.newCoordinate[0] < minRadius) { param.newCoordinate[0] = minRadius; } if (param.newCoordinate[1] < minFriction) { param.newCoordinate[1] = minFriction; } if (param.newCoordinate[0] > maxRadius) { param.newCoordinate[0] = maxRadius; } if (param.newCoordinate[1] > maxFriction) { param.newCoordinate[1] = maxFriction; } #endregion double tempStep = Math.Sqrt(Math.Pow(param.badCoordinate[0] - param.newCoordinate[0], 2) + Math.Pow(param.badCoordinate[1] - param.newCoordinate[1], 2)); double[] tempPct = new double[param.newCoordinate.Length]; for (int j = 0; j < tempPct.Length; j++) { tempPct[j] = (param.badCoordinate[j] * 1 / 100); //badCoordinate[j] * точность / 100 } double maxPct = tempPct.Max(); if (tempStep < maxPct) { param.Step = 0; } else { param.Step = 1; } }
public void Optimization(GeometryOptions model, MaterialsOptions material, AdditionallyOptions add, FileName file, CommonReport fReport) { double firstRadius = model.startBlankRadius; double lastRadius = 10.5; //double firstRadius = 10.87; //double lastRadius = firstRadius; double frictionStep = 0.1; for (model.stampAngle = model.startAngle; model.stampAngle <= model.endAngle; model.stampAngle += model.stepAngle) { for (model.incrBlankRadius = firstRadius; model.incrBlankRadius <= lastRadius; model.incrBlankRadius += 0.05) { // округляем из-за проблемы сложения чисел 0.1 + 0.2 for (model.friction = model.startFriction; model.friction <= model.endFriction; model.friction = Math.Round(model.friction + frictionStep, 1)) { // считаем радиус усечённого конуса model.dieRadius = (Math.Tan(model.stampAngle * Math.PI / 180) * 60) + 10; //объём цилиндра (верхний радиус 10, нижний может меняться) model.dieVolume = (Math.PI * 60 * (Math.Pow(model.dieRadius, 2) + model.dieRadius * 10 + Math.Pow(10, 2)) / 3); #region необходимо для вычесления облоя double upperRadius; double angle30X; double filletLength; //3 - радиус скругления, 90 - градус filletLength = Math.Tan((180 - (((90 + model.stampAngle) / 2) + 90)) * Math.PI / 180) * 3; upperRadius = model.dieRadius + filletLength + 10; angle30X = upperRadius - 5; #endregion double lowerVolume = Math.Pow((angle30X - 5), 2) * Math.PI * 1; model.dieVolume += lowerVolume; double shave = Math.Pow(angle30X, 2) * Math.PI * 1; shave -= lowerVolume; model.dieVolume = Math.Round(model.dieVolume, 1); model.blankRadius = model.incrBlankRadius; model.blankUpperRadius = model.blankRadius - (Math.Tan(model.stampAngle * Math.PI / 180) * 2); model.blankChamferVolume = (Math.PI * 2 * (Math.Pow(model.blankRadius, 2) + model.blankRadius * (model.blankUpperRadius) + Math.Pow((model.blankUpperRadius), 2))) / 3; model.blankChamferVolume = Math.Round(model.blankChamferVolume, 2); //объем цилиндра, не считая фаску (как будто её нет,а заготовка имеет форму просто цилиндра) double abstractRadiusVolume = Math.PI * Math.Pow(model.blankRadius, 2) * 2; double blankVolume = model.dieVolume + (abstractRadiusVolume - model.blankChamferVolume); blankVolume += shave; model.blankHeight = blankVolume / (Math.PI * Math.Pow(model.blankRadius, 2)); model.blankHeight = Math.Round(model.blankHeight, 2); double radiusAfterLowerFillet = angle30X - 5; double radiusHeightInStamp; //необходимо для вычесления объёма от пуансона до конца матрицы model.lowerFilletRadius = radiusAfterLowerFillet; radiusHeightInStamp = 60 * ((radiusAfterLowerFillet - model.blankRadius) / (radiusAfterLowerFillet - 10)); if (model.blankRadius > 12.5) { //model.blankPosition = model.blankHeight * ((model.dieRadius - model.blankRadius) / (model.dieRadius - 10)); model.blankPosition = model.blankHeight * ((radiusAfterLowerFillet - model.blankRadius) / (radiusAfterLowerFillet - 10)); model.blankPosition = Math.Round(model.blankPosition, 1); model.blankPosition = Math.Abs(model.blankPosition - model.blankHeight); //model.blankPosition += 2; } else if (model.blankRadius > 10) { //model.blankPosition = 60 * ((model.dieRadius - model.blankRadius) / (model.dieRadius - 10)); model.blankPosition = model.blankHeight - radiusHeightInStamp; model.blankPosition = Math.Round(model.blankPosition, 1); model.blankPosition += 5; } else { //предположим, что это высота заготовки, которая равняется разницей в высоте //между ей и высотой матрицы, должно помочь, когда заготовка высокая double tempHeight = model.blankHeight - 60; model.blankPosition = tempHeight * ((model.dieRadius - 10) / (model.dieRadius - 10)); model.blankPosition = Math.Round(model.blankPosition, 1); //допуск +2мм на всякий пожарный случай model.blankPosition += 2; } //задаем перемещение матрицы model.stampDisplacement = model.blankPosition; //оставляем зазор 3мм model.stampDisplacement -= 1; #region Создание общей папки с название радиуса заготовки genReport.folderName = Convert.ToString(model.blankRadius); if (!Directory.Exists(genReport.folderName)) { Directory.CreateDirectory(genReport.folderName); } #endregion string abaqusOutputFolder = Convert.ToString(model.blankRadius) + "r" + Convert.ToString(model.stampAngle) + "a" + Convert.ToString(model.friction) + "f"; file.outputFolder = Path.Combine(genReport.folderName, abaqusOutputFolder); if (!Directory.Exists(file.outputFolder)) { Directory.CreateDirectory(file.outputFolder); } file.caeFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, add.jobName + ".cae"); file.caeFolder = file.caeFolder.Replace(@"\", "/"); file.stampFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, "Stamp.IGS"); file.stampFolder = file.stampFolder.Replace(@"\", "/"); file.blankFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, "Blank.IGS"); file.blankFolder = file.blankFolder.Replace(@"\", "/"); file.platformFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, "Platform.IGS"); file.platformFolder = file.platformFolder.Replace(@"\", "/"); solid.UseSolid(file, model); rout.pathIn = "abaqusMacros.py"; // old rout.setWorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); rout.workingDirectory = file.outputFolder; rout.pathOut = rout.workingDirectory + @"\abaqusMacros.py"; change.Output(rout, model, material, add, file); //Form1._Form1.runAbaqus(file); //Form1._Form1.GetHistoryregionName(file); //Form1._Form1.Processing(model, file); //report.ReportReactionForce(model, genReport, file); //rpr.ReportVolume(model, genReport, file); RadiusChart(model); FrictionChart(model); } //genReport.DrawFrictionChart(model); } //genReport.DrawRadiusChart(model); } }
public void AddData(GeometryOptions model) { minVolume.Add(new VariablesForReport(model.blankRadius, model.stampAngle, model.friction, model.pctOfDieFilling, model.reactionForceToBlank)); }
public double GetVolumeByAngle(double x, GeometryOptions model, FileName file, MaterialsOptions material, AdditionallyOptions add, CommonReport finalReport) { //добавляем здесь, так как прошло изменение радиуса //после изменения радиуса, добавляем последние значения в постройку графика //округляем высоту заготовки, иначе после работы алгоритма добавит как новую высоту, //из-за точности знаков после запятой и моего костыля :) model.stampAngle = Math.Round(model.startAngle); AngleChart(model); model.friction = model.startFriction; model.friction = Math.Round(model.startFriction, 2); x = Math.Round(x); #region "+" будут обозначены строки, котоыре необходимы в методе вычесления угла матрицы, заключенніе в регион model.dieRadius = (Math.Tan(x * Math.PI / 180) * 57) + 10; model.dieRadius = Math.Round(model.dieRadius, 1); //объём усеченного конуса (верхний радиус 10, нижний может меняться) model.dieVolume = (Math.PI * 57 * (Math.Pow(model.dieRadius, 2) + model.dieRadius * 10 + Math.Pow(10, 2))) / 3; model.dieVolume = Math.Round(model.dieVolume, 2); #endregion #region "+" model.blankUpperRadius = model.blankRadius - (Math.Tan(model.stampAngle * Math.PI / 180) * 2); model.blankPosition = (Math.PI * 2 * (Math.Pow(model.blankRadius, 2) + model.blankRadius * (model.blankUpperRadius) + Math.Pow((model.blankUpperRadius), 2))) / 3; model.blankPosition = Math.Round(model.blankPosition, 2); //объем цилиндра, не считая фаску (как будто её нет,а заготовка имеет форму просто цилиндра) double abstractRadiusVolume = Math.PI * Math.Pow(model.blankRadius, 2) * 2; double blankVolume = model.dieVolume + (abstractRadiusVolume - model.blankPosition); double tempVolume = blankVolume * 10; tempVolume /= 100; blankVolume += tempVolume; model.blankHeight = blankVolume / (Math.PI * Math.Pow(model.blankRadius, 2)); model.blankHeight = Math.Round(model.blankHeight, 2); model.blankPosition = model.blankHeight * ((model.dieRadius - model.blankRadius) / (model.dieRadius - 10)); model.blankPosition = Math.Round(model.blankPosition, 1); model.blankPosition += 2; //задаем перемещение матрицы model.stampDisplacement = model.blankPosition; model.stampDisplacement -= 3; #endregion model.stampAngle = x; string abaqusOutputFolder = "b" + Convert.ToString(model.blankRadius) + "r" + Convert.ToString(model.stampAngle) + "a"; file.outputFolder = Path.Combine(genReport.folderName, abaqusOutputFolder); if (!Directory.Exists(file.outputFolder)) { Directory.CreateDirectory(file.outputFolder); } file.caeFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, add.jobName + ".cae"); file.caeFolder = file.caeFolder.Replace(@"\", "/"); file.stampFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, "Stamp.IGS"); file.stampFolder = file.stampFolder.Replace(@"\", "/"); file.blankFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, "Blank.IGS"); file.blankFolder = file.blankFolder.Replace(@"\", "/"); file.platformFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, "Platform.IGS"); file.platformFolder = file.platformFolder.Replace(@"\", "/"); solid.UseSolid(file, model); rout.workingDirectory = file.outputFolder; rout.pathOut = rout.workingDirectory + @"\abaqusMacros.py"; change.Output(rout, model, material, add, file); //Form1._Form1.runAbaqus(file); //Form1._Form1.GetHistoryregionName(file); //Form1._Form1.Processing(model, file); genReport.folderName = Convert.ToString(model.blankRadius); //report.ReportReactionForce(model, genReport, file); //rpr.ReportVolume(model, genReport, file); AngleChart(model); //просчёт с изменением силы трения //CalculateFriction(model, material, add, file, finalReport); finalReport.AddData(model); //FReport.setMaxVolume.Add( // new VariablesForReport(model.blankRadius, model.blankRadius, // model.friction, model.pctOfDieFilling, model.setRectionForceToBlank) // ); return(model.pctOfDieFilling); }
public double GetVolumeByRadius(double x, GeometryOptions model, FileName file, MaterialsOptions material, AdditionallyOptions add, CommonReport finalReport) { model.stampAngle = model.startAngle; model.stampAngle = Math.Round(model.stampAngle); model.friction = model.startFriction; model.friction = Math.Round(model.startFriction, 2); #region "+" будут обозначены строки, котоыре необходимы в методе вычесления угла матрицы, заключенніе в регион //10 - верхний радиус model.dieRadius = (Math.Tan(model.stampAngle * Math.PI / 180) * 57) + 10; model.dieRadius = Math.Round(model.dieRadius, 1); //объем цилиндрического выреза в матрице // double tempVolume = Math.PI * Math.Pow(model.dieRadius, 2) * 4; //объём усеченного конуса (верхний радиус 10, нижний может меняться) model.dieVolume = (Math.PI * 57 * (Math.Pow(model.dieRadius, 2) + model.dieRadius * 10 + Math.Pow(10, 2))) / 3; // model.dieVolume = model.dieVolume + tempVolume; model.dieVolume = Math.Round(model.dieVolume, 2); #endregion //ЗАМЕНИТЬ НА Х ОБРАТНО model.blankRadius = x; model.blankRadius = Math.Round(model.blankRadius, 2); #region "+" model.blankUpperRadius = model.blankRadius - (Math.Tan(model.stampAngle * Math.PI / 180) * 2); model.blankPosition = (Math.PI * 2 * (Math.Pow(model.blankRadius, 2) + model.blankRadius * (model.blankUpperRadius) + Math.Pow((model.blankUpperRadius), 2))) / 3; model.blankPosition = Math.Round(model.blankPosition, 2); //объем цилиндра, не считая фаску (как будто её нет,а заготовка имеет форму просто цилиндра) double abstractRadiusVolume = Math.PI * Math.Pow(model.blankRadius, 2) * 2; double blankVolume = model.dieVolume + (abstractRadiusVolume - model.blankPosition); //объём зазора между матрицей и площадкой //double tempVolume = Math.Pow((model.dieRadius + 10), 2) * 3; double tempVolume = blankVolume * 10; tempVolume /= 100; blankVolume += tempVolume; model.blankHeight = blankVolume / (Math.PI * Math.Pow(model.blankRadius, 2)); model.blankHeight = Math.Round(model.blankHeight, 2); model.blankPosition = model.blankHeight * ((model.dieRadius - model.blankRadius) / (model.dieRadius - 10)); model.blankPosition = Math.Round(model.blankPosition, 1); model.blankPosition += 2; //задаем перемещение матрицы model.stampDisplacement = model.blankPosition; model.stampDisplacement -= 3; #endregion #region Создание общей папки с название радиуса заготовки genReport.folderName = Convert.ToString(model.blankRadius); if (!Directory.Exists(genReport.folderName)) { Directory.CreateDirectory(genReport.folderName); } #endregion string abaqusOutputFolder = "b" + Convert.ToString(model.blankRadius) + "r" + Convert.ToString(model.stampAngle) + "a"; file.outputFolder = Path.Combine(genReport.folderName, abaqusOutputFolder); if (!Directory.Exists(file.outputFolder)) { Directory.CreateDirectory(file.outputFolder); } file.caeFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, add.jobName + ".cae"); file.caeFolder = file.caeFolder.Replace(@"\", "/"); file.stampFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, "Stamp.IGS"); file.stampFolder = file.stampFolder.Replace(@"\", "/"); file.blankFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, "Blank.IGS"); file.blankFolder = file.blankFolder.Replace(@"\", "/"); file.platformFolder = Path.Combine(Environment.CurrentDirectory, file.outputFolder, "Platform.IGS"); file.platformFolder = file.platformFolder.Replace(@"\", "/"); solid.UseSolid(file, model); rout.pathIn = "abaqusMacros.py"; // old rout.setWorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); rout.workingDirectory = file.outputFolder; rout.pathOut = rout.workingDirectory + @"\abaqusMacros.py"; change.Output(rout, model, material, add, file); //Form1._Form1.runAbaqus(file); //Form1._Form1.GetHistoryregionName(file); //Form1._Form1.Processing(model, file); //report.ReportReactionForce(model, genReport, file); //rpr.ReportVolume(model, genReport, file); finalReport.AddData(model); //FReport.setMaxVolume.Add( // new VariablesForReport(model.blankRadius, model.blankRadius, // model.friction, model.blankVolume, model.setRectionForceToBlank) // ); return(model.pctOfDieFilling); }
public void makeRewriteArray(SimplexPlanningParams param, FunctionParams funcParam, GeometryOptions model) { double[] x = new double[param.finalArray.Length]; double[,] tempFinalArray = new double[param.finalArray.GetLength(0) - 1, param.finalArray.GetLength(1)]; param.badCoordinate = new double[param.finalArray.GetLength(1)]; int currentRow = 0; for (int i = 0; i < param.finalArray.GetLength(0); i++) { if (i != funcParam.Index) { for (int j = 0; j < param.finalArray.GetLength(1); j++) { tempFinalArray[currentRow, j] = param.finalArray[i, j]; } currentRow++; } else { for (int j = 0; j < param.finalArray.GetLength(1); j++) { param.badCoordinate[j] = param.finalArray[i, j]; } } } #region Проверка на зацикливание //сравнивание двух массивов на наличие одинаковой точки //если таково, то добавляем +2 в ячейку(т.к. сравниванием 2 массива) for (int i = 0; i < param.finalArray.GetLength(0); i++) { int Count = 2; for (int j = 0; j < param.finalArray.GetLength(1); j++) { if (param.finalArray[i, j] == param.tempOldArray[i, j]) { param.sameNodeSimplexCount[i, j] += Count; } else { param.sameNodeSimplexCount[i, j] = 0; } } } //находим максимальную строку, по её сумме, //чтобы по ней посчитать сколько симплексов имеют одинаковую точку //симплексы могут иметь 2 одинаковые точки, но таких симплексов может быть 2 или 3 //поэтому нужно отбросить такой вариант List <double> maxList = new List <double>(); for (int i = 0; i < param.sameNodeSimplexCount.GetLength(0); i++) { double max = 0; for (int j = 0; j < param.sameNodeSimplexCount.GetLength(1); j++) { max += param.sameNodeSimplexCount[i, j]; } maxList.Add(max); } param.countOfArrays = maxList.Max(); param.countOfArrays /= (funcParam.getFactorsCount() * funcParam.getFactorsCount()); param.Nmax = (1.65 * funcParam.getFactorsCount()) + (0.05 * Math.Pow(funcParam.getFactorsCount(), 2)); //записываем новый массив в старый for (int i = 0; i < param.finalArray.GetLength(0); i++) { for (int j = 0; j < param.finalArray.GetLength(1); j++) { param.tempOldArray[i, j] = param.finalArray[i, j]; } } #endregion var newCoord = new NewCoordinate(); newCoord.makeNewCoordinate(tempFinalArray, model, param, funcParam); var addRow = new AddRow(); addRow.AddingRow(tempFinalArray, param); }
public void GetElementCoordinates(FilesForVolume filesForVolume, GeometryOptions model) { try { // Новый список координат узлов заготовки, координаты которых меньше координаты перемещения штампа из списка координат узлов выше ^ Dictionary <double, NodesInStamp> NodesInStampDic = new Dictionary <double, NodesInStamp>(); Dictionary <int, double> radius = new Dictionary <int, double>(); Dictionary <int, double> StampNodes = new Dictionary <int, double>(); //double radius; ElementCoordinates = File.ReadLines(filesForVolume.elementCoordinatesRoute) .Skip(1) .Select(line => line.Split(';')) .ToDictionary(split => int.Parse(split[0]), split => new ElementNodes(int.Parse(split[1]), int.Parse(split[2]), int.Parse(split[3]), int.Parse(split[4]), int.Parse(split[5]), int.Parse(split[6]), int.Parse(split[7]), int.Parse(split[8]))); //пишем знак меньше, так как координаты увеличиваются к основанию заготовки (от меньшего к большему) //следовательно, для подсчёта объема в матрице, нам нужно то, что не больше перемещения матрицы NodesInStampDic = BlankCoordinatesDic.Where(f => f.Value.Z <= NodeDisplacement).ToDictionary(k => k.Key, v => new NodesInStamp(v.Value.X, v.Value.Y, v.Value.Z)); //Новый отбор точек. //Отбираются точки заготовки, которые меньше радиуса, после скругления //Т.к. подсчёт объёма идёт от пуансона до конца матрицы и мы прсото заносим в этот словарь //ведь он используется дальше и чтобы не менять структуру проги NodesInStampDic = BlankCoordinatesDic.ToDictionary(k => k.Key, v => new NodesInStamp(v.Value.X, v.Value.Y, v.Value.Z)); #region Проверка, путём записис в файл, что в словаре имеются правильные узлы, находящиеся в матрице, с координатами String NodeInStampCSV = String.Join( Environment.NewLine, NodesInStampDic.Select(d => d.Key + ";" + d.Value.X + ";" + d.Value.Y + ";" + d.Value.Z + ";")); File.WriteAllText("NodesInStamp.csv", NodeInStampCSV); #endregion StampNodes = File.ReadLines(filesForVolume.stampNodesRoute) .Select(line => line.Split(';')) .ToDictionary(key => Convert.ToInt32(key[0]), value => Math.Abs(Convert.ToDouble(value[3]))); #region Проверка, путём записис в файл, что в словаре имеются правильные соотнешения узла и его координаты Z (считается радиусом матрицы) String StampNodesCSV = String.Join( Environment.NewLine, StampNodes.Select(d => d.Key + ";" + d.Value + ";")); File.WriteAllText("StampNodes.csv", StampNodesCSV); #endregion double stampRadius = model.dieRadius; radius = NodesInStampDic.ToDictionary(k => Convert.ToInt32(k.Key), v => Math.Sqrt(Math.Pow(v.Value.X, 2) + Math.Pow(v.Value.Y, 2))); //добавить сраненние радиусов //Dictionary<double, double> stampDeltaRadius = new Dictionary<double, double>(); //stampDeltaRadius = NodesInStampDic.ToDictionary(k =>k.Key, v=> model.dieRadius - ((v.Value.Z/60) * (model.dieRadius - 10))); //radius = radius.Where(v => stampDeltaRadius[v.Key] <= v.Value).ToDictionary(k => k.Key, v => v.Value); //старый вариант отбора радиусов //radius = radius.Where(v => v.Value <= stampRadius).ToDictionary(k => k.Key, v => v.Value); //test radius = radius.Where(v => v.Value <= model.lowerFilletRadius).ToDictionary(k => k.Key, v => v.Value); String csvradius = String.Join( Environment.NewLine, radius.Select(d => d.Key + ";" + d.Value + ";")); File.WriteAllText("Radius.csv", csvradius); double minNodeNumber = radius.Min(x => x.Key); File.WriteAllText("minNodeNumber.txt", Convert.ToString(minNodeNumber)); ElementNumber = ElementCoordinates .Where(v => radius.Keys.Contains(v.Value.Node1) && radius.Keys.Contains(v.Value.Node2) && radius.Keys.Contains(v.Value.Node3) && radius.Keys.Contains(v.Value.Node4) && radius.Keys.Contains(v.Value.Node5) && radius.Keys.Contains(v.Value.Node6) && radius.Keys.Contains(v.Value.Node7) && radius.Keys.Contains(v.Value.Node8)) .ToDictionary(keyValue => keyValue.Key, keyValue => keyValue.Value.Node1); String csv = String.Join( Environment.NewLine, ElementNumber.Select(d => d.Key + ";" + d.Value + ";")); File.WriteAllText("ElementNumbers.csv", csv); } catch (Exception e) { MessageBox.Show("Get Elemnt Coordinates: " + e); } //string test = ElementCoord.FirstOrDefault(x=>x.Key == 1).Value; }
public void UseSolid(FileName file, GeometryOptions model) { SldWorks swApp; IModelDoc2 swModel; CloseSolid(); object process = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("SldWorks.Application")); swApp = (SldWorks)process; swApp.Visible = false; swApp.NewPart(); swModel = swApp.IActiveDoc2; swModel.Extension.SelectByID2("Спереди", "PLANE", 0, 0, 0, false, 0, null, 0); swModel.SketchManager.InsertSketch(true); swModel.ClearSelection2(true); #region oldStamp //отрисовка куба //swModel.SketchManager.CreateLine(-(model.dieRadius / 1000) - 0.01, (model.dieRadius / 1000) + 0.01, 0, -(model.dieRadius / 1000) - 0.01, -(model.dieRadius / 1000) - 0.01, 0);//размер куба 14 на 14 //swModel.SketchManager.CreateLine(-(model.dieRadius / 1000) - 0.01, -(model.dieRadius / 1000) - 0.01, 0, (model.dieRadius / 1000) + 0.01, -(model.dieRadius / 1000) - 0.01, 0); //swModel.SketchManager.CreateLine((model.dieRadius / 1000) + 0.01, -(model.dieRadius / 1000) - 0.01, 0, (model.dieRadius / 1000) + 0.01, (model.dieRadius / 1000) + 0.01, 0); //swModel.SketchManager.CreateLine((model.dieRadius / 1000) + 0.01, (model.dieRadius / 1000) + 0.01, 0, -(model.dieRadius / 1000) - 0.01, (model.dieRadius / 1000) + 0.01, 0); //swModel.ClearSelection2(true); //swModel.Extension.SelectByID2("Line4", "SKETCHSEGMENT", 0, 0, 0, false, 0, null, 0); //swModel.FeatureManager.FeatureExtrusion2(true, false, false, 0, 0, 0.07, 0.02, // false, false, false, false, 1.74532925199433E-02, 1.74532925199433E-02, // false, false, false, false, true, true, true, 0, 0, false);//первое значение 0.07 это высота 70мм ////делаем вырез //swModel.Extension.SelectByID2("Спереди", "PLANE", 0, 0, 0, false, 0, null, 0); //swModel.SketchManager.InsertSketch(true); //swModel.ClearSelection2(true); //swModel.SketchManager.CreateLine(0, 0.057, 0, -0.01, 0.057, 0);//0.057-это высота внутри //swModel.SketchManager.CreateLine(-0.01, 0.057, 0, -model.dieRadius / 1000, 0, 0);//-0.01-верхний радиус //swModel.SketchManager.CreateLine(-model.dieRadius / 1000, 0, 0, 0, 0, 0);//-0.0046-нижний радиус //swModel.SketchManager.CreateLine(0, 0, 0, 0, 0.057, 0); //swModel.Extension.SelectByID2("Line4", "SKETCHSEGMENT", 0, 0, 0, true, 0, null, 0); //swModel.ClearSelection2(true); //swModel.Extension.SelectByID2("Line4", "SKETCHSEGMENT", 0, 0, 0, false, 16, null, 0); //swModel.FeatureManager.FeatureRevolve2(true, true, false, true, false, false, 0, 0, 6.2831853071796, 0, false, false, 0.01, 0.01, 0, 0, 0, true, true, true); //swModel.SaveAs3(file.stampFolder, 0, 0);//путь сохранения //swApp.NewPart(); //swModel = swApp.IActiveDoc2; //swApp.CloseDoc("Деталь1.SLDPRT"); #endregion double upperRadius; double angle30X; double angle30Y; double filletLength; //3 - радиус скругления, 90 - градус filletLength = Math.Tan((180 - (((90 + model.stampAngle) / 2) + 90)) * Math.PI / 180) * 0.003; upperRadius = model.dieRadius / 1000 + filletLength + 0.01; angle30X = upperRadius - 0.005; angle30Y = Math.Tan(30 * Math.PI / 180) * 0.005; //отрисовка куба swModel.SketchManager.CreateLine(0.01, 0.06, 0, 0, 0.06, 0); //0.6 высота внутри 0,1 радиус верхний swModel.SketchManager.CreateLine(0, 0.06, 0, 0, 0.065, 0); //0,65 высота общая swModel.SketchManager.CreateLine(0, 0.065, 0, upperRadius, 0.065, 0); //0.02799831333 внешний радиус сверху swModel.SketchManager.CreateLine(upperRadius, 0.065, 0, upperRadius, angle30Y, 0); //высота до угла 30 swModel.SetInferenceMode(false); swModel.SketchManager.CreateLine(upperRadius, angle30Y, 0, angle30X, 0, 0); //под углом 30 swModel.SketchManager.CreateLine(angle30X, 0, 0, model.dieRadius / 1000, 0, 0); //прямая до скругления swModel.SetInferenceMode(true); swModel.SketchManager.CreateLine(model.dieRadius / 1000, 0, 0, 0.01, 0.06, 0); //усеченный конус swModel.Extension.SelectByID2("Point6", "SKETCHPOINT", model.dieRadius / 1000, 0, 0, false, 0, null, 0); swModel.SketchManager.CreateFillet(0.003, 1); swModel.Extension.SelectByID2("Point1", "SKETCHPOINT", 0.01, 0.06, 0, false, 0, null, 0); swModel.SketchManager.CreateFillet(0.002, 1); swModel.Extension.SelectByID2("Line5", "SKETCHSEGMENT", 0, 0, 0, false, 0, null, 0); swModel.SketchAddConstraints("sgFIXED"); swModel.Extension.SelectByID2("Line6", "SKETCHSEGMENT", 0, 0, 0, false, 0, null, 0); swModel.SketchAddConstraints("sgFIXED"); swModel.Extension.SelectByID2("Line2", "SKETCHSEGMENT", 0, 0, 0, false, 16, null, 0); swModel.FeatureManager.FeatureRevolve2(true, true, false, false, false, false, 0, 0, 6.2831853071796, 0, false, false, 0.01, 0.01, 0, 0, 0, true, true, true); swModel.SaveAs3(file.stampFolder, 0, 0);//путь сохранения swApp.NewPart(); swModel = swApp.IActiveDoc2; swApp.CloseDoc("Деталь1.SLDPRT"); //строим цилиндр swModel.Extension.SelectByID2("Спереди", "PLANE", 0, 0, 0, false, 0, null, 0); swModel.SketchManager.InsertSketch(true); swModel.ClearSelection2(true); swModel.SketchManager.CreateLine(0, 0, 0, 0, model.blankHeight / 1000, 0); //0.018-это высота // радиус заготовки с учетом фаски swModel.SketchManager.CreateLine(0, model.blankHeight / 1000, 0, -model.blankUpperRadius / 1000, model.blankHeight / 1000, 0); //-0.0046- радиус swModel.SetInferenceMode(false); swModel.SketchManager.CreateLine(-model.blankUpperRadius / 1000, model.blankHeight / 1000, 0, -model.blankRadius / 1000, model.blankHeight / 1000 - 0.002, 0); //0.0001748-tan 5 градусов * высоту фаски swModel.SetInferenceMode(true); swModel.SketchManager.CreateLine(-model.blankRadius / 1000, model.blankHeight / 1000 - 0.002, 0, -model.blankRadius / 1000, 0, 0); //0.016 высота на 2 мм(высота фаски) ниже swModel.SketchManager.CreateLine(-model.blankRadius / 1000, 0, 0, 0, 0, 0); swModel.Extension.SelectByID2("Line3", "SKETCHSEGMENT", 0, 0, 0, false, 0, null, 0); swModel.SketchAddConstraints("sgFIXED"); swModel.Extension.SelectByID2("Line4", "SKETCHSEGMENT", -3.11882415580314E-03, 0, 0, true, 0, null, 0); /// swModel.Extension.SelectByID2("Line1", "SKETCHSEGMENT", -5.49748992413931E-04, 1.70942234292196E-02, -1.35495829391757E-03, true, 0, null, 0); swModel.ClearSelection2(true); swModel.Extension.SelectByID2("Line1", "SKETCHSEGMENT", -5.49748992413931E-04, 1.70942234292196E-02, -1.35495829391757E-03, false, 16, null, 0); swModel.FeatureManager.FeatureRevolve2(true, true, false, false, false, false, 0, 0, 6.2831853071796, 0, false, false, 0.01, 0.01, 0, 0, 0, true, true, true); swModel.SaveAs3(file.blankFolder, 0, 0);//путь сохранения swApp.NewPart(); swModel = swApp.IActiveDoc2; swApp.CloseDoc("Деталь2.SLDPRT"); swModel.Extension.SelectByID2("Сверху", "PLANE", 0, 0, 0, false, 0, null, 0); swModel.SketchManager.InsertSketch(true); swModel.ClearSelection2(true); swModel.SketchManager.CreateLine(-(model.dieRadius / 1000) - 0.01, (model.dieRadius / 1000) + 0.01, 0, -(model.dieRadius / 1000) - 0.01, -(model.dieRadius / 1000) - 0.01, 0);//размер площадки 20 на 20 swModel.SketchManager.CreateLine(-(model.dieRadius / 1000) - 0.01, -(model.dieRadius / 1000) - 0.01, 0, (model.dieRadius / 1000) + 0.01, -(model.dieRadius / 1000) - 0.01, 0); swModel.SketchManager.CreateLine((model.dieRadius / 1000) + 0.01, -(model.dieRadius / 1000) - 0.01, 0, (model.dieRadius / 1000) + 0.01, (model.dieRadius / 1000) + 0.01, 0); swModel.SketchManager.CreateLine((model.dieRadius / 1000) + 0.01, (model.dieRadius / 1000) + 0.01, 0, -(model.dieRadius / 1000) - 0.01, (model.dieRadius / 1000) + 0.01, 0); swModel.ClearSelection2(true); swModel.Extension.SelectByID2("Line4", "SKETCHSEGMENT", 0, 0, 0, false, 0, null, 0); swModel.FeatureManager.FeatureExtrusion2(true, false, false, 0, 0, 0.001, 0.02, false, false, false, false, 1.74532925199433E-02, 1.74532925199433E-02, false, false, false, false, true, true, true, 0, 0, false); //первое значение 0.01 это высота 1мм swModel.SaveAs3(file.platformFolder, 0, 0); //путь сохранения Thread.Sleep(1000); CloseSolid(); }
private void Reset() { geometry = GameObject.FindWithTag("Geometry")?.transform; _activeTrack = GameObject.FindWithTag("Track")?.GetComponent <GeometryOptions>(); }
private void Computing(GeometryOptions model) { prevOldArray = new double[param.finalArray.GetLength(0), param.finalArray.GetLength(1)]; //для проверки на зацикливание param.tempOldArray = new double[param.finalArray.GetLength(0), param.finalArray.GetLength(1)]; param.sameNodeSimplexCount = new double[param.finalArray.GetLength(0), param.finalArray.GetLength(1)]; param.oldArray = new double[param.finalArray.GetLength(0), param.finalArray.GetLength(1)]; int kForNodes = 1; while (param.Step > param.getEps()) { if (check.CheckArrayPoints(param.finalArray) == true) { param.oldArray = prevOldArray; break; } var newRow = new NewRow(); int counterStart = newRow.CheckNewRow(param.finalArray, param.oldArray, param); var listOfComputedPoints = new ListOfComputedPoints(); param.indexOfRestrictions = listOfComputedPoints .getListOfComputedPoints(param) .ToDictionary(k => k.Key, v => new Restrictions(v.Value.Filling, v.Value.Force)); for (int i = counterStart; i < param.finalArray.GetLength(0); i++) { var mainFunction = new MainFunction(model, material, add, file, finalReport, genReport, rout, cmd, filesForVolume); //выполнение главной функции mainFunction.Compute(param.finalArray, i, kForNodes); param.indexOfRestrictions.Add(i, new Restrictions(model.pctOfDieFilling, model.reactionForceToBlank)); kForNodes++; } var checker = new Checker(); if (checker.CheckRestrictions(param, funcParam) == false) { break; } //если в новая точка оказалась плохой, то возвращаемся к старому массиву //и данынм о заполняемости с индексам точек var checkNewCoord = new CheckNewCoordinate(); if (param.arrayStatus == true && funcParam.Index == funcParam.getFactorsCount()) { checkNewCoord.CheckingNewCoordinate(param, funcParam); } else { param.badPointsList.Clear(); param.badPointsList.Add(funcParam.Index, new Restrictions(funcParam.IndexFilling, funcParam.IndexForce)); } #region Копия старого симплекса с плохой точкой prevOldArray = param.oldArray; param.oldIndexOfRestrictions = param.indexOfRestrictions.ToDictionary(k => k.Key, v => new Restrictions(v.Value.Filling, v.Value.Force)); param.oldArray = param.finalArray; #endregion var rewrire = new RewriteArray(); rewrire.makeRewriteArray(param, funcParam, model); param.arrayStatus = true; param.Step = 0; } genReport.folderName = finalReport.finalReportFolder; finalReport.makeFinalReport(param.oldArray); var charts = new Charts(genReport); charts.DrawFrictionChart(); charts.DrawRadiusChart(); MessageBox.Show("Computing is complete!"); }