Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Help! System Initialization

Help! System Initialization

Hi,

I'm trying to model a train, but it seems that the current model is not solvable. I'm baffled how to initialise the system to obtain a solution. 

In the model there are 5 main components: train, motor, driver, track and signalling system. Train movement is governed by Newton's second law
m*a=f-r,
where:
f - tractive force from the motor, depends on train velocity;
r - running resistance, depends on train position;
Signalling system provides the driver with information regarding speed limits, which is a function of the train position as well.
So, both inputs f and r depend on the train position, which seems to be the main cause of the problem.

A simplified model is listed below. I would greatly appreciate it if you could give me any advise regarding this issue.

model testmodel
  vehicle train;
  controller driver;
  propulsion motor;
  signalling signallingSystem;
  track mainline;
equation
  connect(train.v, driver.speedometer);
  connect(driver.poweringSignal, motor.poweringSignal);
  connect(motor.f, train.f);
  connect(train.s, signallingSystem.s);
  connect(signallingSystem.PSR, driver.PSR);
  connect(train.s,mainline.s);
  connect(mainline.r,train.r);
end testmodel;

class vehicle
  parameter Real m=170000; //mass of the vehicle
  Real a; //acceleraion
  input Real f; //tractive force derived from the propulsion system
  input Real r; //running resistance due track gradient
  output Real v; //speed
  output Real s; //displacement
equation
  // equation of motion, Newton's second law
  v=der(s);
  a=der(v);
  m*a=f-r;
end vehicle;


class controller
  input Real speedometer; //speed information from the vehicle
  input Real PSR; //permament speed restriction from signalling system
  output Boolean poweringSignal; //control signal to the propulsion system
equation
  poweringSignal = if speedometer>PSR then false else true;
end controller;


class propulsion
  input Boolean poweringSignal; //powering signal from the controller
  output Real f; //tractive force to the vehicle
equation
  //f = 120000;
  f = if poweringSignal==true then 120000 else 0; //tractive force
end propulsion;


class signalling
  output Real PSR (start=100); //permament speed restriction
  input Real s; //current position
equation
  PSR = if s<1 then 0.3 else 10;
end signalling;


class track
  input Real s;//position of the vehicle
  output Real r (start=0, fixed=false);//running resistance depends on position
equation
  r=if s<5 then 10000 else 50000;
end track;


System run on:
Open Modelica 1.5.0 RC2
Win XP Pro 64-bit

Edited by: Ivan - Apr-24-10 00:34:46

Re: Help! System Initialization

I think the problem is that you give the train 0 power when it is higher than the limit. When you do that, its speed instantly drops. This means it will then give full throttle in the next timestep, because its speed is now lower than the limit. This means that it will again be higher than the limit and trigger an event.
The result is a stiff system, that will basically take forever to solve.

Re: Help! System Initialization

Thanks a lot! Very much appreciate your help.
Do you think introducing a delay for powering signal, say 1 sec, would help to solve the problem? or is it better to use a solver for stiff systems, such as Sundials CVODE? if so, can it be pluged-in to OpenModelica somehow?
Many thanks

Re: Help! System Initialization

Well, it's not a solver problem. It's more of a problem with Modelica events (if an event is triggered, you can't take a larger timestep).

One way to solve it would be to use a different kind of controller. I'm not a modeller myself, so I wouldn't know what kind to use though (discrete PI or PID comes to mind; we have some testcases that use those in the testsuite).

I will give you an implementation hint:
when sample(0.0,0.1) then ... will only trigger events every 0.1 seconds. So if you only check the velocity during these samples, you will ensure 0.1 seconds of engine-off state.
It also models real-life systems a lot better, since we tend to sample at given intervals and not infinitely small intervals current/smile

There are 0 guests and 0 other users also viewing this topic