**
前言
铁路设计院行车专业时长借助牵引电算软件进行列车运行模拟,出于兴趣,本文对多质点列车纵向动力学模型求解过程进行了分析。知网上搜了好多文章,看的不太懂,大多数都是采用Newmark或其它高级方法进行仿真。此文采用简单的动力学方程,以HXD单机,C70型货车54辆编组进行验证学习,纯C#代码实现,没有Matlab或其它仿真软件辅助。内容简单,期待有该方面大佬深入指点一二。模型及仿真按钮图片如下:
补充说明
以下代码在WinForm窗体运行,需要两个控件,Button与ListBox,代码较简单,先读懂再修改运行。
代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TractionCalculation
{
public partial class TrainDynamicsSolver : Form
{
public TrainDynamicsSolver()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
TrainDynamicsSolver solver = new TrainDynamicsSolver();
solver.TimeStep = 0.0000008;
solver.TotalTime = 0.08*2+0.03;
solver.TrainLength = 55;
solver.Mass = new double[(int)solver.TrainLength];
solver.Position = new double[(int)solver.TrainLength];
solver.Velocity = new double[(int)solver.TrainLength];
solver.Force= new double[(int)solver.TrainLength];
solver.couplingForce = new double[(int)solver.TrainLength];
for (int i = 0; i < solver.TrainLength; i++)
{
if (i < solver.TrainLength - 1)
{
solver.Mass[i] = 94;
solver.Position[i] = i * (14 + 14) / 2;
}
else
{
solver.Mass[i] = 150;
solver.Position[i] = 1.0*(14 + 23) / 2 + (solver.TrainLength - 2) * (14 + 14) / 2.0;
}
solver.Velocity[i] = 0;
if (i == solver.TrainLength - 1)
{
solver.Force[i] = solver.GetTractionForce(solver.Velocity[i]);
}
else
{
solver.Force[i] = 0;
}
}
solver.Solve();
// 输出结果
listBox1.Items.Add("迭代完成!!!");
//for (int i = solver.Mass.Length-1; i > -1; i--)
//{
// listBox1.Items.Add("车辆:" + ((solver.Mass.Length - 1) - i)+" "+"位置:"+ solver.Position[i] + " " +"速度:"+ solver.Velocity[i]);
//}
//for (int i = solver.Mass.Length - 1; i >0; i--)
//{
// listBox1.Items.Add("第"+ ((solver.Mass.Length - 1) - i) + "与"+ ((solver.Mass.Length - 1) - i+1) + "辆车"+" 位置差:" + (solver.Position[i]- solver.Position[i-1]) + " " + "速度差:" + (solver.Velocity[i]- solver.Velocity[i-1]));
//}
}
public double TimeStep {
get; set; } // 时间步长
public double TotalTime {
get; set; } // 总时间
public double TrainLength {
get; set; } // 列车长度
public double[] Mass {
get; set; } // 各质点质量,以数组形式存储