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
  • Index
  • » Users
  • » Ivan
  • » Profile

Posts

Posts

Oct-04-11 14:41:25
Problem with reading data from external files

Thanks a lot Christian,

It is a brilliant package, and works great in both OM and Dymola.

Best wishes,
Ivan

Oct-03-11 22:18:34
Problem with reading data from external files

Hi All,
Can anyone advise how to use tableOnFile option of combiTable2D? It seems that there is a problem with interpreting external file content during simulation.

model lookup_test "table lookup"
  Modelica.Blocks.Sources.Ramp u1_input(height = 2, duration = 1, offset = 0, startTime = 0);
  Modelica.Blocks.Tables.CombiTable2D lookupFunction(tableOnFile = true, tableName = "table2D_1", fileName = "D:/Modelica/RailSim/Tests/lookup_test.txt");
  Modelica.Blocks.Sources.Constant u2_input(k = 2);

equation
  connect(u2_input.y,lookupFunction.u2);
  connect(u1_input.y,lookupFunction.u1);
end lookup_test;


lookup_test.txt contains the following (as in example for combiTable2D):

#1
double table2D_1(3,4)   # comment line
0.0  1.0  2.0  3.0  # u[2] grid points
1.0  1.0  3.0  5.0
2.0  2.0  4.0  6.0

double table2D_2(4,4)   # comment line
0.0  1.0  2.0  3.0  # u[2] grid points
1.0  1.0  3.0  5.0
2.0  2.0  4.0  6.0
3.0  3.0  5.0  7.0


SIMULATION RESULT:

Simulation execution failed for model: lookup_test
No table named `table2D_1' in file `D:/Modelica/RailSim/Tests/lookup_test.txt'.
Simulation terminated while the initialization. Could not find suitable initial values.


I also tried to load .mat file generated by Matlab (v4) / Dymola 2012 (demo), but no luck with simulation run. u1 and u2 are strictly monotonous in the input table, but OM gives the following message:
ISimulation execution failed for model: Model1
Table2D: independent variable u1 not strictly monotonous: 21.15 >= 0.
Simulation terminated while the initialization. Could not find suitable initial values.



In contrast, when tableOnFile=false and data specified within the model, it works fine.

Similar problem reported http://openmodelica.org/index.php/forum/topic?id=351
Any ideas what is wrong with interpreting external file?

Many thanks!

Win 7, OpenModelica 1.7.0

Oct-02-11 20:17:53
Category: Programming

Similar problem found with combiTable2D
http://openmodelica.org/index.php/forum/topic?id=384

See also http://www.mail-archive.com/openmodelic … 00026.html
suggests that combiTables implementation is Dymola specific.

It should be supported by OpenModelica.

Oct-02-11 20:09:23
Category: Programming

Sorry for off-topic,
relocated to http://openmodelica.org/index.php/forum/topic?id=389

Hello,

Can anyone give an advice on connections between nested and top classes? I am a bit confused how it works. I have two models for comparison:
1. vehicle and its motor as two separate classes
2. motor as a nested class of the vehicle class

I use the standard mechanical connectors, Flange_a and Flange_b for communication between these classes.
In the first case it works perfectly fine. However, the second one, it returns either an error of structural singularity or an error of overdetermined model. I tried to encapsulate the motor class, but it did not work either.

Can anyone help me with this, please?
Here are simplified models:

1. vehicle and its motor as two separate classes
model test_model
  vehicle test_vehicle;
  motor test_motor;
equation
  connect(test_vehicle.vehicle_connector, test_motor.motor_connector);
end test_model;

class vehicle
  Real velocity,displacement (start=0);
  parameter Real mass = 170;
  Flange_a vehicle_connector;
equation
  velocity = der(displacement);
  mass*der(velocity) = -vehicle_connector.f; // vehicle is powered by a motor
  vehicle_connector.s = displacement;
end vehicle;

class motor
  Real speed;
  Flange_b motor_connector;
equation
  speed = der (motor_connector.s);
  motor_connector.f = 100+0.2*speed; 
end motor;

connector Flange_a
  Real s;
  flow Real f;
end Flange_a;

connector Flange_b
  Real s;
  flow Real f;
end Flange_b;


2. motor as a nested class of the vehicle class
class vehicle
  Real velocity,displacement (start=0);
  parameter Real mass = 170;
  Flange_a vehicle_connector;
  motor testmotor;
equation
  connect(vehicle_connector, testmotor.motor_connector);
  velocity = der(displacement);
  mass*der(velocity) = -vehicle_connector.f; // vehicle is powered by a motor
  vehicle_connector.s = displacement;
end vehicle;

class motor
  Real speed;
  Flange_b motor_connector;
equation
  speed = der (motor_connector.s);
  motor_connector.f = 100+0.2*speed; 
end motor;

connector Flange_a
  Real s;
  flow Real f;
end Flange_a;

connector Flange_b
  Real s;
  flow Real f;
end Flange_b;

Any advice is highly appreciated.
Many thanks,
Ivan

PS: My system: WinXP Pro, OpenModelica 1.5 RC2

Hi there,

I'm having difficulties with simulation of the example model from Peter Fritzson book (page 248)
This is the model:

model WhenValidResult
  Real x,y;
equation
  x + y = 5;
  when sample(0,2) then
  y = 7 - 2*x;
  end when;
end WhenValidResult;

and here is the outcome:

>>simulate(WhenValidResult, startTime=0, stopTime=20, numberOfIntervals=500, tolerance=1e-4)
record SimulationResult
resultFile = "Simulation failed.
Error: Internal error generate_compute_output failed
Error: Internal error Generation of simulation code failed
"
end simulationResult;


I have a very similar problem to model and I was wondering if I can do anything about it in OpenModelica.

My system is:
OpenModelica 1.5. RC3
Windows XP Pro 32-bit

Many thanks,
Ivan

Apr-22-10 15:59:43
Problems with 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

Apr-22-10 11:34:58
Problems with 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

Hi,
Thanks for your help. It was just me trying to use enumeration type for connectors, which is not the right way to use it. I have found an alternative solution with Boolean connectors.
Thanks, anyway
Ivan

It works fine in RC2

>> simulate(dcmotor, startTime=0, stopTime=1, numberOfIntervals=500, tolerance=1e-4)
record SimulationResult
    resultFile = "dcmotor_res.plt"
end SimulationResult;

Hi there,
I am having difficulties with enumeration type in OM. It seems that the type is not supported completely. Any recommendations are very much appreciated.
Many thanks

  • Index
  • » Users
  • » Ivan
  • » Profile
You are here: