Group Abstract Group Abstract

Message Boards Message Boards

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

How to link Wolfram system modeler with Mathematica ?

Posted 5 years ago

Hello. I have build my own library in WSM. And I want now to launch simulations from Mathematica. But it does not work for my libraries, despite it works with the examples given in the Wolfram documentation. Here are the steps I followed unsuccessfully: - I load my library in WSM, I load my model (named "Model1"). I run a simulation. All is OK - Then I launch Mathematica - And I use the following instruction :

sim1 = SystemModelSimulate["Model1"]

It says the Model1 was not found I also tried by putting the complete path instead of only "Model1"

I probably forget to put few things, but which ones ?

Thanks by advance for the help. Yvan

POSTED BY: Yvan Abbe
14 Replies
Posted 4 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 4 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

@Yvan Abbe Please read the rules: http://wolfr.am/READ-1ST
The rules state that attaching files to posts and comments is preferred than providing external links. That is because external links expire eventually. Also your post contains several missing notebooks and this breaks the flow of the post, please try to attach them again.
Thank you.

POSTED BY: EDITORIAL BOARD
Posted 4 years ago
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use