Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all Modelica has only one type of object, the class, and the other objects (model, record, package) are only special types of class with restrictions. That means that every object must follow the same rules, therefore I'll refer to the object class, but what I'll write will apply to every Modelica object. The variables are instantiated per object means that if you have a Modelica class like the following one:</p> <pre><code>partial class MySimpleClass Real variable1; equation variable1 = time; end MySimpleClass; </code></pre> <p>When you declare a member variable such as <em>MySimpleClass</em> in <em>instanceOfTypeMySimpleClass</em>:</p> <pre><code>class mySecondClass MySimpleClass instanceOfTypeMySimpleClass; MySimpleClass instanceTwoOfTypeMySimpleClass; Real variable1; equation variable1 = instanceOfTypeMySimpleClass.variable1; instanceTwoOfTypeMySimpleClass.variable1 = 3; end mySecondClass; </code></pre> <p>you declare an instance variable. Every time you create an instance of a class, the Modelica compiler creates one copy of each the class's instance variables for the instance and this is done by objects. You can access an object's instance variables from an object using the syntax <code>&lt;instanceName&gt;.&lt;VariableName&gt;</code>.</p> <p>The Modelica compiler allocates class variables once per instance. The The Modelica compiler allocates memory for class variables every time it encounters an instance of that class. Therefore all instances <strong>DID NOT</strong> share the same copy of the class's class variables as, for example, for static classes in Java. In other words in this example <em>instanceOfTypeMySimpleClass.variable1</em> and <em>instanceTwoOfTypeMySimpleClass.variable1</em> are two different variables.</p> <p>"The variables of Modelica classes are instantiated per object." meant to describe this difference.</p> <p>I hope this helps, Marco</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload