using System; using XP=Science.Physics.GeneralPhysics; namespace ScienceTest.PhysicsTest.GeneralPhysicsTest { /// /// Atwood Mashine, NewtonEquationText /// public class NewtonEquationTest { private string result; public string Result { get{return result;} } public NewtonEquationTest() { } public void Compute() // atwood machine { XP.TotalForce[] f = new XP.TotalForce[2]; XP.Mass[] m = new XP.Mass[2]; XP.Acceleration[] a = new XP.Acceleration[2]; m[0]= new XP.Mass(); m[0].kg = 10.0; m[1]= new XP.Mass(); m[1].kg = 20.0; XP.Force[] ff = new XP.Force[2]; ff[0] = new XP.Force(); ff[0].YVariableQ = true; ff[1] = new XP.Force(); ff[1].Y = -m[0].kg*XP.Constant.AccelerationOfGravity; f[0] = new XP.TotalForce(ff); XP.Force[] sf = new XP.Force[2]; sf[0] = new XP.Force(); sf[1] = new XP.Force(); sf[0].YVariableQ = true; sf[1].Y = -m[1].kg*XP.Constant.AccelerationOfGravity; f[1] = new XP.TotalForce(sf); a[0] = new XP.Acceleration(); a[0].YVariableQ = true; a[1] = new XP.Acceleration(); a[1].YVariableQ = true; XP.NewtonEquation.ConstraintFunctionToBeZero[] cf = new XP.NewtonEquation.ConstraintFunctionToBeZero[2]; cf[0] = new XP.NewtonEquation.ConstraintFunctionToBeZero(Min1); cf[1] = new XP.NewtonEquation.ConstraintFunctionToBeZero(Min2); XP.NewtonEquation eq = new XP.NewtonEquation(f,m,a); eq.Constraint(cf); eq.Solve(); result += f[0].ToString()+"\r\n"; result += a[0].ToString()+"\r\n"; result += f[1].DecomposedForce[1].ToString()+"\r\n"; } private double Min1(XP.TotalForce[] f, XP.Mass[] m, XP.Acceleration[] a) { return f[0].DecomposedForce[0].Y - f[1].DecomposedForce[0].Y; } private double Min2(XP.TotalForce[] f, XP.Mass[] m, XP.Acceleration[] a) { return a[0].Y + a[1].Y; } } } /* 0 +/- 0 i +32.6666666665975 +/- 0 j +0 +/- 0 k (N) 0 +/- 0 i +3.26666666666005 +/- 0 j +0 +/- 0 k (m/s^2) 0 +/- 0 i -196 +/- 0 j +0 +/- 0 k (N) */