I have begun to make my own train simulator. Actually, I've just been doing a bit of research. I started out writing it in C, but I think I am going to scrap that and program it in Java or C++. I need object oriented programming for this. Because, I realized that locomotives have multiple driven axles. So, it is easier to use object oriented programming. I will have an axle object. Each axle will have it's polar moment of inertia, and coefficent of rolling resistance, and how much weight is on it. Resistive force would be calculated. Then, there would be a locomotive object.
The locomotive object would have axles defined, a motor, the locomotive's mass, and aerodynamic properties. The motor object would have a maximum amount of torque, which would be the output at 0 rad/s, and maximum rad/s, at which the torque would be zero. This torque would be changed by the throttle which I think is a linear relationship, but that calculation could be mucked around with. So, at 50% throttle the torque output would be half of what it would be at full throttle at that given RPM.
All of this would be used to calculate the total pulling force that the locomotive can produce, with all of the aerodynamics and resistance calculated.
The top-level object would basically be a train object. The train object would define the whole train. It would sum all the cars net forces together. Regular train cars might actually use the same object as the locomotive. Only difference would be no motor driving it. Infact, there might be a general train car object, which is a parent of the locomotive object. Each "tick" of the clock would call a tick method, which would notify the train that there was a timestep. So then, the physics for that tick would be calculated.
This post is pretty random, I just needed somewhere to write down my ideas and have people critique them. If there's anything that I left out that is easy to implement, I'm willing to accept suggestions. The sim will have no graphics to start with, and will have no turns either. It will be a little more difficult to calculate the angle of each car, and the fact that there is less forward pulling force.
The locomotive object would have axles defined, a motor, the locomotive's mass, and aerodynamic properties. The motor object would have a maximum amount of torque, which would be the output at 0 rad/s, and maximum rad/s, at which the torque would be zero. This torque would be changed by the throttle which I think is a linear relationship, but that calculation could be mucked around with. So, at 50% throttle the torque output would be half of what it would be at full throttle at that given RPM.
All of this would be used to calculate the total pulling force that the locomotive can produce, with all of the aerodynamics and resistance calculated.
The top-level object would basically be a train object. The train object would define the whole train. It would sum all the cars net forces together. Regular train cars might actually use the same object as the locomotive. Only difference would be no motor driving it. Infact, there might be a general train car object, which is a parent of the locomotive object. Each "tick" of the clock would call a tick method, which would notify the train that there was a timestep. So then, the physics for that tick would be calculated.
This post is pretty random, I just needed somewhere to write down my ideas and have people critique them. If there's anything that I left out that is easy to implement, I'm willing to accept suggestions. The sim will have no graphics to start with, and will have no turns either. It will be a little more difficult to calculate the angle of each car, and the fact that there is less forward pulling force.