void EvalDiffusion() { VecR dr = new VecR(); int ni; for (int nb = 0; nb < nBuffDiffuse; nb++) { if (tBuf[nb].GetCount == 0) { foreach (Node node in nodes) { tBuf[nb].AddorigR(node.Getr); tBuf[nb].AddrTrue(node.Getr); } } if (tBuf[nb].GetCount >= 0) { ni = tBuf[nb].GetCount; tBuf[nb].InitrrDiffuse(0.0); for (int n = 0; n < nodes.Count; n++) { dr.VSub(tBuf[nb].GetrTrue[n].Get, nodes[n].Getr); dr.VDiv(dr.Get, region.Get); dr.Nint(); dr.VMul(dr.Get, region.Get); tBuf[nb].GetrTrue[n].Get.VAdd(nodes[n].Getr, dr.Get); dr.VSub(tBuf[nb].GetrTrue[n].Get, tBuf[nb].GetorgR[n].Get); tBuf[nb].AddrrDiffuse(ni, dr.VLenSq()); } } tBuf[nb].AddCount(); } AccumDiffusion(); }
public void VWrap(VecR region) { if (x >= 0.5 * region.x) { x -= region.x; } if (x < -0.5 * region.x) { x += region.x; } if (y >= 0.5 * region.y) { y -= region.y; } if (y < -0.5 * region.y) { y += region.y; } if (z >= 0.5 * region.z) { z -= region.z; } if (z < -0.5 * region.z) { z += region.z; } }
private void Update(int per, List <Node> nodes, VecR region, int step) { progressBar1.Value = per; this.Text = per.ToString(); Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(bmp); int radius = 10; foreach (Node node in nodes) { float x = (float)((node.Getr.x + 0.5 * region.x) * pictureBox1.Width / region.x); float y = (float)((node.Getr.y + 0.5 * region.y) * pictureBox1.Height / region.y); try { g.DrawEllipse(new Pen(Color.Black), x, y, radius, radius); } catch (OverflowException) { if (listen.ThreadState == ThreadState.Running) { listen.Abort(); do { Thread.Sleep(100); } while (listen.ThreadState == ThreadState.Running); } buttonStart.Enabled = true; MessageBox.Show("Overflow error."); } // Console.WriteLine(x); pictureBox1.Image = bmp; Step.Text = step.ToString(); } }
//Initialize Coordinates public void InitCoords(VecI initUcell, double density) { int nx, ny, nz; VecR c, gap; int n = 0; Console.WriteLine("density = " + density); gap = new VecR(region.x / initUcell.x, region.y / initUcell.y, region.z / initUcell.z); for (nz = 0; nz < initUcell.z; nz++) { for (ny = 0; ny < initUcell.y; ny++) { for (nx = 0; nx < initUcell.x; nx++) { c.x = nx + 0.5; c.y = ny + 0.5; c.z = nz + 1.5; c.x *= gap.x; c.y *= gap.y; c.z *= gap.z; c.x += -0.5 * region.x; c.y += -0.5 * region.y; c.z += -0.5 * region.z; Node b = new Node(c, c, c); nodes.Add(b); //Introduce connection if (nx > 0.5) { nodes[n - 1].AddCon(n); nodes[n].AddCon(n - 1); } n++; } } } }
public void VWrap(VecR region) { if (r.x >= 0.5 * region.x) { r.x -= region.x; } if (r.x < -0.5 * region.x) { r.x += region.x; } if (r.y >= 0.5 * region.y) { r.y -= region.y; } if (r.y < -0.5 * region.y) { r.y += region.y; } if (r.z >= 0.5 * region.z) { r.z -= region.z; } if (r.z < -0.5 * region.z) { r.z += region.z; } }
public void SetParams() { //Cut-off radius rCut = Math.Pow(2.0, 1.0 / 6.0); density = 0.8; initUcell = new VecI(3, 3, 3); //Firstly manually assign the cell nMol = initUcell.x * initUcell.y * initUcell.z; velMag = Math.Sqrt(NDIM * (1.0 - 1.0 / nMol) * temperature); double fac = 1.0 / Math.Pow(density, 1.0 / 3.0); region = new VecR(fac * initUcell.x, fac * initUcell.y, fac * initUcell.z); }
private void Update(int per, List <Node> nodes, VecR region, int step) { progressBar1.Value = per; this.Text = per.ToString(); Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(bmp); int radius = 10; foreach (Node node in nodes) { float x = (float)((node.Getr.x + 0.5 * region.x) * pictureBox1.Width / region.x); float y = (float)((node.Getr.y + 0.5 * region.y) * pictureBox1.Height / region.y); g.DrawEllipse(new Pen(Color.Black), x, y, radius, radius); // Console.WriteLine(x); pictureBox1.Image = bmp; Step.Text = step.ToString(); } }
public void SetParams() { //Cut-off radius rCut = Math.Pow(2.0, 1.0 / 6.0); // density = 0.85; initUcell = new VecI(3, 3, 3); //Firstly manually assign the cell nMol = initUcell.x * initUcell.y * initUcell.z; velMag = Math.Sqrt(NDIM * (1.0 - 1.0 / nMol) * temperature); double fac = 1.0 / Math.Pow(density, 1.0 / 3.0); region = new VecR(fac * initUcell.x, fac * initUcell.y, fac * initUcell.z); //Set Diffusion Params nValDiffuse = 10; nBuffDiffuse = 1; limitDiffusivaAv = 100; stepDiffuse = 10; }
public void VVSAddR(double fac, VecR dr) { ra.x += fac * dr.x; ra.y += fac * dr.y; ra.z += fac * dr.z; }
public void VAdd(VecR a, VecR b) { x = a.x + b.x; y = a.y + b.y; z = a.z + b.z; }
public void VMul(VecR a, VecR b) { x = a.x * b.x; y = a.y * b.y; z = a.z * b.z; }
public void VDiv(VecR a, VecR b) { x = a.x / b.x; y = a.y / b.y; z = a.z / b.z; }
public void AddrTrue(VecR r) { rTrue.Add(r); }
public void AddorigR(VecR r) { orgR.Add(r); }
public void VVSAddV(double fac, VecR dr) { rv.x += fac * dr.x; rv.y += fac * dr.y; rv.z += fac * dr.z; }
public void Setr(VecR r) { this.r = r; }
public Node(VecR r, VecR rv, VecR ra) { this.r = r; this.rv = rv; this.ra = ra; }
public void VVAdd(VecR r) { x += r.x; y += r.y; z += r.z; }