コード例 #1
0
        /// <summary>
        /// Dynamicses this instance.
        /// </summary>
        public override void Dynamics(int dt)
        {
            const double a = 5, b = 10;

            // Check if Pump is closed
            if (!Open && Math.Round(Speed, 5) > 0)
            {
                Speed -= (gt * dt) / 2000;
                if (Speed < 0)
                {
                    Speed = 0;
                }
            }

            // Check if Pump is open
            if (Open && Math.Round(Speed, 5) < 1)
            {
                Speed += (gt * dt) / 2000;
                if (Speed > 1)
                {
                    Speed = 1;
                }
            }

            // Calculate flow difference
            double PressureDifference;

            if (NodeIn.Pressure >= NodeOut.Pressure)
            {
                PressureDifference = (NodeIn.Pressure - NodeOut.Pressure);
                Flow = K * Speed * a * (b + (System.Math.Sqrt(PressureDifference)));
            }
            else
            {
                PressureDifference = (NodeOut.Pressure - NodeIn.Pressure);
                Flow = K * Speed * a * (b - (System.Math.Sqrt(PressureDifference)));
            }
            NodeIn.AddSumFlow(-Flow);
            NodeOut.AddSumFlow(Flow);

            limitflow(1.0);
        }
コード例 #2
0
 public void nodeFlowAdjust()
 {
     NodeIn.AddSumFlow(-Flow);
     NodeOut.AddSumFlow(Flow);
 }