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

Plotting in OMShell

Plotting 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?

Re: Plotting in OMShell

If you get a message from plot command it means your plot command is silent. You need to enable it,

Code:

setPlotSilent(false)

Adeel.

Re: Plotting 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

Re: Plotting in OMShell

https://build.openmodelica.org/Document … pting.html or read the help-text through help() (basically telling you to open OpenModelica.Scripting in OMEdit).

Note that the silent plotting is usually not enabled. You have to explicitly do it yourself. For example by sharing a session with OMNotebook...

Re: Plotting 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?

Re: Plotting in OMShell

Thanks a lot for the help

Re: Plotting 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

Re: Plotting in OMShell

We don't keep statistics on test coverage on Windows. It's a too minor platform current/smile The Linux tests for both of them are 100% (of the tested models).

I recommend the nightly builds unless you need to use a stable version for education or similar.

Re: Plotting in OMShell

Thanks for the help current/smile

Re: Plotting 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;
"

Re: Plotting in OMShell

In OpenModelica, we never do unit checking.
Some other tools also does not do unit checking by default (checkModel() command or similar in these tools will do unit checking).

Re: Plotting 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.

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