private double CirclePotentialInteraction(SimulationBox box, CircleWithPotential circle) { double dx = Math.Abs(circle.X - X); if (dx > box.XLength / 2) { dx = box.XLength - dx; } double dy = Math.Abs(circle.Y - Y); if (dy > box.YLength / 2) { dy = box.YLength - dy; } double r = Math.Sqrt(dx * dx + dy * dy); if (!(r > circle.Radius + Radius)) { double slope = (10 - 100) / (circle.Radius + Radius); double intercept = 100; return(slope * r + intercept); } double ratio = (circle.Radius + Radius + MinimumPotentialDistance) / r; var energy = PotentialStrength * (Math.Pow(ratio, 12) - 2 * Math.Pow(ratio, 6)); return(energy); }
private double CircleInteraction(SimulationBox box, Circle circle) { double dx = Math.Abs(circle.X - X); if (dx > box.XLength / 2) { dx = box.XLength - dx; } double dy = Math.Abs(circle.Y - Y); if (dy > box.YLength / 2) { dy = box.YLength - dy; } double r = Math.Sqrt(dx * dx + dy * dy); if (r > circle.Radius + Radius) { return(0); } double slope = (10 - 100) / (circle.Radius + Radius); double intercept = 100; return(slope * r + intercept); }
public override void ApplyMove(SimulationBox box, SimulationObject mcObject) { var deltaX = JobEngine.Rand.NextDouble() * 2 * MaxDistance - MaxDistance; var deltaY = JobEngine.Rand.NextDouble() * 2 * MaxDistance - MaxDistance; mcObject.X += deltaX; mcObject.Y += deltaY; if (mcObject.X > box.XLength) { mcObject.X -= box.XLength; } if (mcObject.Y > box.YLength) { mcObject.Y -= box.YLength; } if (mcObject.X < 0) { mcObject.X += box.XLength; } if (mcObject.Y < 0) { mcObject.Y += box.YLength; } }
public override double GetInteractionEnergy(SimulationBox box, SimulationObject interactingObject) { double energy = 0; if (interactingObject is CircleWithPotential circleWithPotential) { energy = CirclePotentialInteraction(box, circleWithPotential); } else { energy = base.GetInteractionEnergy(box, interactingObject); } return(energy); }
public override double GetInteractionEnergy(SimulationBox box, SimulationObject interactingObject) { // Want to integrate the area of the object over the potential energy double energy = 0; if (interactingObject is Circle circle) { energy = CircleInteraction(box, circle); } else { throw new Exception("I don't know how to interact with this object!"); } return(energy); }
private void UpdateMonteCarloPlot(SimulationBox box) { mySimulationBoxControl1.DrawSimulationBox(box); }
private void NewMonteCarloJob_SimulationBoxChangedEvent(SimulationBox box) { var deleg = new SimulationBoxHandler(UpdateMonteCarloPlot); this.Invoke(deleg, box); }
public void DrawSimulationBox(SimulationBox box) { _box = box; Refresh(); }
public abstract void ApplyMove(SimulationBox box, SimulationObject mcObject);
public override void ApplyMove(SimulationBox box, SimulationObject mcObject) { base.ApplyMove(box, mcObject); }
public MonteCarloSimulationJob(SimulationBox box) { Box = box; }
public MonteCarloSimulationJobAnnealed(SimulationBox box) : base(box) { }