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
  • » Malen
  • » Profile

Posts

Posts

Jul-08-14 13:54:50
The code is throwing me an error that I do not know how to solve

Hi Everyone,

I have a problem that I am trying to solve.  When I try to simulate the following code:


model Test
  parameter  Real m(unit = "kg/s", min = 0) = 9.96720e-005;
  parameter Real Pdown(unit = "bar", min = 0) = 2.048153 - 0.6209;
  parameter Real Cd = 0.7;
  parameter Real D(unit = "m") = 0.0005588;
  parameter Real Tup(unit = "°C") = 20.5;
  parameter Real g(unit = "Dimensionless") = 1.401;
  parameter Real Rspecific(unit = "J/(kgK)") = 287.1;
  constant Real PI = 3.14159265;
 
  Real Pup ;
  Real Aorifice(unit = "m2");
  Real Pcr;
  Real P;
equation
  Aorifice = PI * (D / 2) ^ 2;
  Pcr = (2 / (g + 1)) ^ (g / (g - 1));
  P = Pdown / Pup;
  if P > Pcr then
  m = Cd * Aorifice * 100000 * Pup / sqrt(Tup + 273.15) * sqrt(g / Rspecific * 2 / (g - 1) * ((Pdown / Pup) ^ (2 / g) - (Pdown / Pup) ^ ((g + 1) / g)));
  else
m = 1000 * Cd * Aorifice * 100000 * Pup / sqrt(Tup + 273.15) * sqrt(g / Rspecific * (2 / (g + 1)) ^ ((g + 1) / (g - 1)));
  end if;
end Test;

I get the following error message that says:

record SimulationResult
    resultFile = "Test_res.mat",
    messages = "stdout            | warning | While solving non-linear system an assertion failed.
|                 | |       | | The non-linear solver tries to solve the problem that could take some time.
|                 | |       | | It could help to provide better start-values for the iteration variables.
|                 | |       | | For more information simulate with -lv LOG_NLS
stdout            | warning | Non-Linear Solver try to handle a problem with a called assert.
"
end SimulationResult;
OMC-ERROR:
"Warning: Iteration variables with default zero start attribute in nonlinear equation system:
         Pup:VARIABLE() .Test, .Real type: Real
         P:VARIABLE() .Test, .Real type: Real
"

I was wondering if someone knew how to overcome the issue and how to set the start value for Pup

Thank you

Malen

Jul-03-14 13:11:19
fail to open simulation result

Hi Guys,

Saw your conversation and thought to jump in as I have the same issues.  Basically I am trying to solve the following equation :

model Test
  parameter  Real m(unit = "kg/s", min = 0) = 9.96720e-005;
  parameter Real Pdown(unit = "bar", min = 0) = 2.048153 - 0.6209;
  parameter Real Cd = 0.7;
  parameter Real D(unit = "m") = 0.0005588;
  parameter Real Tup(unit = "°C") = 20.5;
  parameter Real g(unit = "Dimensionless") = 1.401;
  parameter Real Rspecific(unit = "J/(kgK)") = 287.1;
  constant Real PI = 3.14159265;
 
  Real Pup ;
  Real Aorifice(unit = "m2");
   
equation
  Aorifice = PI * (D / 2) ^ 2;
  m = Cd * Aorifice * 100000 * Pup / sqrt(Tup + 273.15) * sqrt(g / Rspecific * 2 / (g - 1) * ((Pdown / Pup) ^ (2 / g) - (Pdown / Pup) ^ ((g + 1) / g)));
 
end Test;

However when I try to solve I get the following error message:

record SimulationResult
    resultFile = "",
    messages = "Simulation execution failed for model: Test
stdout            | warning | Non-Linear Solver try to handle a problem with a called assert.
stdout            | warning | While solving non-linear system an assertion failed.
|                 | |       | | The non-linear solver tries to solve the problem that could take some time.
|                 | |       | | It could help to provide better start-values for the iteration variables.
|                 | |       | | For more information simulate with -lv LOG_NLS
stdout            | warning | Non-Linear Solver try to handle a problem with a called assert.
stdout            | warning | While solving non-linear system an assertion failed.
|                 | |       | | The non-linear solver tries to solve the problem that could take some time.
|                 | |       | | It could help to provide better start-values for the iteration variables.
|                 | |       | | For more information simulate with -lv LOG_NLS
stdout            | warning | Error in initialization. Storing results and exiting.
|                 | |       | Use -lv=LOG_INIT -w for more information.
"
end SimulationResult;

Could you please help me how to overcome this issue?  I do not understand how to use the -lv=LOG_INIT -w command and what initial start values should I allocate to Pup

Thank you for the help

Jun-19-14 12:37:38
How to create a graphical user interface

Hello,

I have modelled a fluid component and now I want to be able to create a graphical user interface for other people to be able to use my model without the need to access the backbone code.  I was wondering how to do this, where can I start from?

Thank you for the help

May-28-14 13:55:21
Topic: Fluid
Inner Outer Declaration

Hi Guys,

I wanted to jump in the conversation as I have similar issues with the Fluid directory.  I have a pressure source, pressure sink, orifice and two pieces of pipes to connect the pressure source and sink to the orifice.  I also include the Fluid.System object where I set the parameters such as ambient pressure and temperature.  When I try and compile the code the instantiation fails and I get a notification saying there is a bug : " Inherited elements are not identical: bug: https://trac.modelica.org/Modelica/ticket/627".

I am trying  to simulate the flow through an orifice and how by altering the orifice diameter and pressure difference the mass flow rate changes.  I am not sure why the code is not compiling.

Thank you,

Malen

May-13-14 11:46:53
Failing to simulate the flow through an orifice using OMEdit

Hi guys,

I have a problem.  I am trying to simulate the flow through a simple orifice.  I am using the Boundary_pT as source and sink and also 2 pipes and the orifice connected to each other.  I am getting an error saying that a bug was found : https://trac.modelica.org/Modelica/ticket/627

I am not sure how to solve the problem and what should I be doing to make my model simulate properly.  Any help is appreciated.

Thank you in advance

Mar-20-14 14:30:02
Trying to run Exercise3, Chapter 9 Algorithms but getting error

Hi,

Thanks for the reply.  It is quite helpful.  I wanted to ask about the noEvent() operator, what does it implies?

Thank you for the help

Mar-18-14 18:42:28
Trying to run Exercise3, Chapter 9 Algorithms but getting error

Hi Guys,

I am trying to run Exercise 3 in Chapter 9 of Dr.Modelica, Algorithms.  The algorithm is meant to find the sum of  1*(1*1)-1/(2*2)+1/(3*3)+1/(4*4)-1/(5*5)+1/(6*6).....
The code is implemented as below:

class SumCalculation
  constant Real e = 0.000001;
  Real sum(start = 0);
  Real next(start = 1.0);
  Integer k(start = 1);
  Integer posneg(start = 1);
algorithm
  while noEvent(abs(next)) >= e loop
    sum := sum + next;   
    k := k + 1;           
    posneg := - posneg;
    next := posneg/(k*k);
end while;
end SumCalculation;

When I try to simulate the above I get:

record SimulationResult
    resultFile = "",
    messages = "Simulation execution failed for model: SumCalculation
assert            | debug   | ERROR: Too many event iterations. System is inconsistent. Simulation terminate.
"
end SimulationResult;


I do not know why this code is giving me this error.  I tried to decrease the number of iterations but I have the same problem.  Could you please advice me where the problem might be?

Thank in advance

Mar-07-14 11:23:28
Problems with modeling mechanical interfaces

Hi Daniel,

Thanks a lot for the reply.  Quite useful.  I modeled the Compliant having in mind the TwoPin model.  Cheers

Mar-05-14 14:54:51
Problems with modeling mechanical interfaces

Hi Guys,

I am trying to simulate the Oscillator Model described in page 156, section 5.4.4 from the book Principles of Object Oriented Modeling and Simulation with Modelica (same example is given in Chapter 5, section 5.3, example Oscillating Mass Connected to a spring in DrModelica).

The example given calls some classes  from predefined Modelica libraries.  The predefined classes used are: "Position", "Force", "Flange_a", "Flange_b".   In my case I am trying to build these classes from scratch using the information provided in the book.  The code that I have used for the modelling is as follows:

type Position = Real (quantity = "Position", unit = "m");

type Force = Real (quantity = "Force", unit = "N");

connector Flange_a
  Position s;
  flow Force f;
  end Flange_a;

connector Flange_b
  Position s;
  flow Force f;
end Flange_b;

partial model Compliant
  Flange_a flange_a;
  Flange_b flange_b;
  Position s_rel;
  flow Force f;
  equation
  f = flange_b.f;
  s_rel = flange_a.s - flange_b.s;
  0 = flange_a.f + flange_b.f;
  end Compliant;

At the end I manage to compile the whole code but the graph that I am getting is not oscillating.  I think the problem might lie on how I have done the modelling of the above classes however I am not sure where the issue might be.  Could you please recommend how to fix the issue?

Thanks in advance

Maleni

Feb-25-14 17:07:34
The graph does not display in OMShell

Hi sjoelund.se

I am a bit confused regarding the access control by prefixes.   In Example 3.4 in Dr.Modelica I have this code:

class AccessDemo
  parameter Real a = 2;
  public Real x, z;
  parameter Real y (fixed=true);
  protected
  parameter Real w (fixed=true), u(fixed=true);
  Real u2;
  public Real u3;
  equation
  x = 2;
  z = 5;
  u2 = 5;
  u3 = 8;
  end AccessDemo; 

Then I create an instance of this class and try to give values to protected variables in the class AccessDemo by writing:

class inherited
  AccessDemo ad(w=23, u=3);
  end inherited;

I try and simulate the code and plot the values of "w" and "u" and get the desired values.  However in the comments in the example it says this can not be performed (even though I did manage to get the values)  since AccessDemo it is not inherited.  Is the code above is valid and does this means that there is a typing mistake in Dr. Modelica?

Thanks in advance.

Feb-21-14 14:09:41
The graph does not display in OMShell

Hi sjoelund.se

I wanted to ask if OpenModelica allows you to perform calculations with variables which are not the same in SI units.  I wrote a simple code and tested it.  Usually in C++ if there is a  mismatch between variables units the compiler does not compile the code and outputs an error. 

"
type Voltage=Real(unit="V");
type Current=Real(unit="A");

class testing
  parameter Voltage v=13;
  Current i;
  equation
  i=6*v;
  end testing;

simulate(testing)

record SimulationResult
    resultFile = "testing_res.mat",
    messages = ""
end SimulationResult;
"

Feb-20-14 18:39:41
The graph does not display in OMShell

Thanks for the help current/smile

Feb-20-14 18:26:12
The graph does not display in OMShell

Regarding the two versions that you have attached, what is the difference between the nightly build and the beta.  How is the test coverage between these two?  Which one do you recommend I should donwload?

Thanks

Feb-20-14 14:03:40
The graph does not display in OMShell

Thanks a lot for the help

Feb-20-14 13:57:07
The graph does not display in OMShell

Thanks for the help.

I also wanted to inquire regardiong OM crashing whilst I am trying to save a model.  This means I need to kill the file and start everything from the beginning.  I am using OM on Windows and the version that I am using is OM-1.9.0-rwevision-17628.

I am not sure if there is a newer version that I can use?

Feb-18-14 19:18:20
The graph does not display in OMShell

Hi Adeel

Thank you for the reply.  I managed to solve the problem.  just wondering where do you get these commands from.  Is there a user guide?  I looked but I could not find them

Thanks

Feb-18-14 17:32:09
The graph does not display in OMShell

Hi everyone,

I have an issue with plotting in OMShell.  I try to run the example of the "dc.motor" that is explained in the user guide.  Everything goes smoothly until I reach the plot part.  When I type in the command "plot ({load.phi,load.w})", I get a message that shows:

{"_omc_PlotResult","C:/Users/mshushku/AppData/Local/Temp/OpenModelica/dcmotor_res.mat","","true","plot","false","false","time","","0.0","0.0","0.0","0.0","1.0","1","top","load.phi","load.w"}.

For some reason the graph does not show up as it is suppose to.  I can get the graph by going to OMEdit and open the result of the plot from there however I want to get the plot in OMShell.  Could you please suggest me how to achieve this?

Hi,

I pressume that your code look like this:

class VanDerPol
  Real x(start = 1);
  Real y(start = 1);
  parameter Real lambda = 0.3;
  equation
  der(x) = y;
  der(y) = -x + lambda*(1-x*x)*y;
  end VanDerPol;

When using the command : setCommandLineOptions("+d=initialization"), what you are telling the compiler is show me more detailed warnings, this command does not get rid of them.  Now the problem with your code is that you are "suggesting" the compiler to start x and y at 1, however you are not forcing it.  In order to do so, the right code is:

class VanDerPol
  Real x(start = 1, fixed=true);
  Real y(start = 1, fixed=true);
  parameter Real lambda = 0.3;
  equation
  der(x) = y;
  der(y) = -x + lambda*(1-x*x)*y;
  end VanDerPol;

Feb-14-14 15:23:29
How to get rid of the OMC-Error

Thanks for the reply.

Regarding the question that I had before about the number of equations not being equal to the number of variables in the "MoonLanding" example, I think that there is no need to mark some of the values in class "Rocket" as inputs. 

My understanding is that the whole system has 6 variables overall (all of them contained in the class "Rocket") and 6 equations overall ( 4 of them in class "Rocket" and 2 of them in class "MoonLanding") .  Is this the case?

Feb-14-14 12:04:58
How to get rid of the OMC-Error

Hi sjoelund.se

I have this simple piece of code:

class HelloWorld
  Real x(start=1);
  equation
  der(x)=-x;
  end HelloWorld;

try and simulate it and I get :

record SimulationResult
    resultFile = "HelloWorld_res.mat",
    messages = ""
end SimulationResult;
OMC-ERROR:
"Warning: Assuming fixed start value for the following 1 variables:
         x:VARIABLE(start = 1.0 ) .HelloWorld, .Real type: Real

I managed to get rid of the warning by using:

Real x(start=1, fixed=true);

However I do not understand why this happens.  Why when I use the "fixed=true" command I do not get a warning?  And also I used the command "setCommandLineOptions("+d=initialization") but I do not understand what it performs? 

Regards

Malen

Feb-13-14 12:54:10
How to get rid of the OMC-Error

Thanks for the help.

Feb-13-14 12:32:57
How to get rid of the OMC-Error

Thanks for the reply.  But is it possible to use "input" inside a "class" because from my understanding "inputs" and "outputs" are only used inside a "function".

Also I wanted to ask, I am having problems with new files that I open in OMN.  For some odd reason when I try to input "New Cells", the programe freezez.  I close the file, saving my work, but when I open it it shows only empty cells with no code written in them. 

Regards

Malen

Feb-12-14 19:41:01
How to get rid of the OMC-Error

Hi Sjoelund.se,

Further to my inquire about the +d=initialization, I wanted to ask regarding the rule that: "The number of variables inside a class should be equall to the number of functions".

I start with defining a class record:

record  CelestialBody
  constant Real g = 6.672e-11;
  parameter Real radius;
  parameter String name;
  parameter Real mass;
  end CelestialBody;

than I define another class:

class Rocket "rocket class"
  parameter String name;
  Real mass(start=1038.358);
  Real altitude(start=59404);
  Real velocity(start= -2003);
  Real acceleration;
  Real thrust; //Thrust force on rocket
  Real gravity; //Gravity forcefield
  parameter Real massLossRate=0.000277;
  equation (thrust-mass*gravity)/mass = acceleration;
  der (mass) = -massLossRate*abs(thrust);
  der (altitude) = velocity;
  der (velocity) = acceleration;
  end Rocket;

and at the end:

class MoonLanding
  parameter Real force1 = 36350;
  parameter Real force2 = 1308;
  protected
  parameter Real thrustEndTime = 210;
  parameter Real thrustDecreaseTime = 43.2;
  public
  Rocket apollo(name="apollo13");
  CelestialBody moon(name="moon",mass=7.372e22,radius=1.738e6);
  equation
apollo.thrust = if (time < thrustDecreaseTime) then force1
                else if (time < thrustEndTime) then force2
                else 0;
apollo.gravity=moon.g*moon.mass/(apollo.altitude+moon.radius)^2;
end MoonLanding;

I simulate the last class and everything is fine.  Nonetheless the number of eqautions in class MoonLanding is not eqaul to the number of variables.  Also in class Rocket the same is true however the code complies and gives me the desired result.  I am not sure how this follows the rule that I mentioned at the beginning?

Regards

Malen

Feb-12-14 14:24:53
How to get rid of the OMC-Error

Hi,

Thanks for the reply.

Managed to sort out the problem

Regards

Feb-12-14 13:33:31
How to get rid of the OMC-Error

Hi Guys,

I am a beginner that just started using OpenModelica.  When I try and run the examples given in the user guide (like Hello World) in OMN, I get the warning: "Warning: The initial conditions are not fully specified. Use +d=initialization for more information".

I have changed the setting in OME by going Tools->Options->Simulation->OMC Flags and typing in it +d=initialization.  However I still keep getting the warning and I am not sure why.

Could you please give me a hand with this?

Regards

Malen

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