/// <summary> /// 初始化模型 /// 包括:计算小球的质量,并保存所有小球的初始位置和半径 /// </summary> /// <param name="balls"></param> private void InitStatus(SpherePlot balls) { mass = new Matrix <double>(objNum, 1); radii = new Matrix <double>(objNum, 1); //Matrix<double>类初始化时都是0 rtPos = new Matrix <double>(objNum, dim); rtVel = new Matrix <double>(objNum, dim); rtAcc = new Matrix <double>(objNum, dim); distances = new Matrix <double>(objNum, objNum); energy = new Matrix <double>(iteration, 1); for (int i = 0; i < objNum; i++) { radii[i, 0] = balls.Spheres[i].GetRadius(); mass[i, 0] = 4 / 3 * Math.PI * Math.Pow(radii[i, 0], 3); rtPos[i, 0] = balls.Spheres[i].GetCenter()[0]; rtPos[i, 1] = balls.Spheres[i].GetCenter()[1]; rtPos[i, 2] = balls.Spheres[i].GetCenter()[2]; //给每个小球一个初始化向下的速度 rtVel[i, 2] = -MaxVel; } localBallsIndex = new List <List <int> >(); for (int i = 0; i < objNum; i++) { localBallsIndex.Add(new List <int>()); } shouldVelBeDecayed = new Matrix <double>(objNum, dim); }
/// <summary> /// 模拟烧结过程 /// 将小球的半径按照rate的比例进行放大,使得小球之间有一定程度的相交 /// </summary> /// <param name="balls"></param> /// <param name="rate"></param> public static void SinteringProcess(SpherePlot balls, double rate = 1.2) { for (int i = 0; i < balls.Spheres.Count(); i++) { balls.SetRadius(balls.Spheres[i].GetRadius() * rate, i); } }
/// <summary> /// 更新小球的位置、半径和质量信息 /// 当重新从文件中导入小球信息以后需要更新 /// </summary> /// <param name="balls"></param> public void UpdateBallInfo(SpherePlot balls) { for (int i = 0; i < balls.Spheres.Count(); i++) { radii[i, 0] = balls.Spheres[i].GetRadius(); mass[i, 0] = 4 / 3 * Math.PI * Math.Pow(radii[i, 0], 3); rtPos[i, 0] = balls.Spheres[i].GetCenter()[0]; rtPos[i, 1] = balls.Spheres[i].GetCenter()[1]; rtPos[i, 2] = balls.Spheres[i].GetCenter()[2]; } }
public ModelDem3D(SpherePlot balls, SimpleModelForSave sModel = null) { this.objNum = balls.Spheres.Count(); this.porosity = new Matrix <double>(iteration, 1); InitStatus(balls); if (PackingSystemSetting.SystemBoundType == BoundType.CubeType) { //kns = 1e3; cubeBound = new CubeBound(PackingSystemSetting.CubeLength, PackingSystemSetting.CubeLength, PackingSystemSetting.CubeLength); } else if (PackingSystemSetting.SystemBoundType == BoundType.CylinderType) { //kns = 1e3; cylinderBound = new CylinderBound(PackingSystemSetting.Radius, PackingSystemSetting.Height); } }