Group Abstract Group Abstract

Message Boards Message Boards

0
|
11.2K Views
|
14 Replies
|
1 Total Like
View groups...
Share
Share this post:

How to link Wolfram system modeler with Mathematica ?

Posted 6 years ago
POSTED BY: Yvan Abbe
14 Replies
Posted 5 years ago

Thanks a lot. I have to read again, make tests, and work again,

-> but your advices made me progress a lot.

POSTED BY: Yvan Abbe

inner is added when you declare the component, not when you define it. This means you just have to add inner in the Vacmod.GlobalInfo globalInfo1 declaration inside _002596_ed01. For more details, you can look at the specification: link.

As for the use of SystemModelSimulate, you can use either the SystemModel object that you get when you import the model, or the model name, as I did in the previous answer. More details can be found in the documentation page: link.

POSTED BY: Sergio Vargas
Posted 5 years ago

@Sergio, So it works when I have this code (I type manually "inner" in the text of the schematic.

model _002596_ed01
  inner Vacmod.GlobalInfo globalInfo1 annotation(Placement(visible = true, transformation(origin = {-40, 27.009}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Vacmod.Components.Volume_ volume_1(V = 0.01) annotation(Placement(visible = true, transformation(origin = {0, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Vacmod.Components.qvcst_ qvcst_1(qvstd = 0.05) annotation(Placement(visible = true, transformation(origin = {0, -25}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(volume_1.a, qvcst_1.a) annotation(Line(visible = true, origin = {0, -2.5}, points = {{0, 12.5}, {0, -12.5}}, color = {0, 0, 255}));
  annotation(Diagram(coordinateSystem(extent = {{-500, -90}, {500, 90}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10}), graphics = {Rectangle(visible = true, lineColor = {0, 114, 195}, fillColor = {255, 255, 255}, extent = {{-100, -100}, {100, 100}}, radius = 25), Text(visible = true, textColor = {64, 64, 64}, extent = {{-150, 110}, {150, 150}}, textString = "%name")}));
end _002596_ed01;

But I must add it manually in the text of the schematic. I tried to add it in my component GlobalInfo, but it failed.

model GlobalInfo
  Real T = 293.15 "Température (K)";
  Real Air = 100 "en %";
  Real H2 = 0 "en %";
  Real He = 0 "en %";
  Real Xe = 0 "en %";
  Real M = 0.01 * (Air * 0.029 + H2 * 0.002 + He * 0.004 + Xe * 0.1313) "Masse en kg";
  Real Visc = 0.01 * (1.71e-5 * Air + 8.4e-6 * H2 + 1.95e-5 * He + 2.12e-5 * Xe) "Viscosité (Pa.s)";
  Real G = 0.01 * (1.4 * (Air + H2) + 1.66 * (He + Xe)) "Coefficient adiabatique";
  Real R = 8.314;
  annotation(Documentation(info = "<html>
<p> MUST BE placed on each schematic. Contains gas data and temperature </em> </p>
</html>", revisions = "<html>
<ul>

<li><em> 2020   </em>
     by Yvan Abbe<br> initially implemented<br>
     </li>
</ul>
</html>"), Icon(graphics = {Ellipse(fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}, endAngle = 360), Text(origin = {18, -12}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-80, 60}, {42, -28}}, textString = "Gas")}, coordinateSystem(initialScale = 0.1)));
end GlobalInfo;

Thanks if you still have time to answer. I think after, I can manage by myslef.

Yvan

POSTED BY: Yvan Abbe
POSTED BY: EDITORIAL BOARD
Posted 5 years ago

Hi Sergio Thank you so much to come back to my rescue again. yes !, it seems to compile now. great ! I have anyway questions, and would be very grateful if you can help me again: - Is there a simple way to simulate ? Because for the moment, I import a file like this, Import["C:\Users\Yvan\Google \Drive\CHRONOS\002596ed01Total.sma"] -> It gives me a mini-drawing, and I copy-paste the drawing inside the [ ] of SystemModelSimulate[ ]. Thanks by advance Yvan

(I think I have corrupted my previous model. Here is the new one just in case ...) https://drive.google.com/file/d/1BBYUDM_nxtCda8VcF4qa1mQh4Eb6BGqo/view?usp=sharing

POSTED BY: Yvan Abbe
POSTED BY: Sergio Vargas
Posted 5 years ago

Help .... ?

.. I come back to my problem : I still have a model that is OK with WSM, but I don't know how to launch a simulation from Mathematica. It is a basic problem , I know, but if anyone could help.

Thanks

Here is the total Model

POSTED BY: Yvan Abbe
Posted 6 years ago

I am using both 12 version for Mathematica an WSM. But I think I will avoid to use inner outer. It seems to be quite complex to understand. Initially, I only wanted global variable for the whole schematic. But that is not a good idea. The concept of global variable doesn't really exists in Modelica. I must modify my libraries. But I am now pretty sure that you have fixed my problem : I must load both my schematic, and the package.mo of the library I have made. I hope I will be able to work on it again soon. That is not possible for me for the moment.

POSTED BY: Yvan Abbe

If you want assistance, we would need more details to help with the inner/outer problem. If you are using different versions of Mathematica and System Modeler, you can experience different outcomes when running simulations.

POSTED BY: Sergio Vargas
Posted 6 years ago
Attachments:
POSTED BY: Yvan Abbe

Hi Yvan,

In order to load your library in Mathematica you can run

Import["full/path/to/your/library.mo"]

The expectation is that, if you have the same version of Mathematica and System Modeler, then loading the library in System Modeler would be enough for you to access it in Mathematica. This is also a necessary condition for the two to talk to each other.

Sergio

POSTED BY: Sergio Vargas
Posted 6 years ago

Hi Sergio. Thank you very much for your help. Anyway, it seems that it loads only my "Model1.mo" drawing, that is the single .mo file of my schematic. But my question is : How can I do to load all the libraries that I have made. It is a lot of files and various directories ....

Attachments:
POSTED BY: Yvan Abbe

Hi Yvan,

By looking at the error messages seems like Vacuum is your full library? I presume you have a package.mo file associated with it, so if you import that one, you'll load the whole library.

Sergio

POSTED BY: Sergio Vargas
Posted 6 years ago

POSTED BY: Yvan Abbe
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard