<!DOCTYPE OMNotebook>
<Notebook>
 <GroupCell closed="false" >
  <GroupCell closed="false" >
   <TextCell style="Title" >
    <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Arial; font-size:38pt; font-weight:600; color:#000000;">Package and Library Structuring&lt;/p>&lt;/body>&lt;/html></Text>
   </TextCell>
   <GroupCell closed="false" >
    <TextCell style="Section" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:18pt; font-weight:600; color:#000000;">General Description&lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
    <TextCell style="Text" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">A well-designed package structure is one of the most important aspects that influences the complexity, comprehension, and maintainability of large software systems. There are many factors to consider when designing a package, for example the name of the package or the structuring the package into subpackages. Other factors that are important to consider are reusability and encapsulation of the package as well as considering dependencies on other packages. &lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
   </GroupCell>
   <GroupCell closed="false" >
    <TextCell style="Section" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:18pt; font-weight:600; color:#000000;">Subpackages and Hierarchical Libraries&lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
    <TextCell style="Text" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">The main use of Modelica packages and subpackages is to structure hierarchical model libraries, of which the standard Modelica library is a good example. Below is a small example of a hierarchical package structure which has been extracted and adapted from the Modelica standard library. &lt;br />&lt;br />The example is a bit misleading since these packages are quite large, normally stored on separate files and directories, and not seen as a piece of code below. See the comments for the fully qualified names of each package or model component. &lt;br />&lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
    <InputCell style="Input" closed="true" >
     <Input>encapsulated package Modelica      // Modelica

  encapsulated package Mechanics    // Modelica.Mechanics

    encapsulated package Rotational    // Modelica.Mechanics.Rotational
      
      model Inertia            // Modelica.Mechanics.Rotational.Inertia
      end Inertia;

      model Torque            // Modelica.Mechanics.Rotational.Torque
      end Torque;

    end Rotational;

  end Mechanics;

end Modelica;
</Input>
     <Output></Output>
    </InputCell>
    <TextCell style="Text" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">&lt;br />Public components in hierchical libraries can be accessed through their fully qualified name. See model &lt;span style=" font-family:Courier New;">InertiaUser&lt;/span> below.&lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
    <InputCell style="Input" closed="true" >
     <Input>model InertiaUser
  Modelica.Mechanics.Rotational.Inertia w;
  // internal code
end InertiaUser;</Input>
     <Output></Output>
    </InputCell>
    <GroupCell closed="false" >
     <TextCell style="Subsection" >
      <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:14pt; font-weight:600; color:#000000;">Encapsulated Packages and Classes&lt;/p>&lt;/body>&lt;/html></Text>
     </TextCell>
     <TextCell style="Text" >
      <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">As emphasized before, the useage of the word "encapsulated" before a package name is good for eliminating the possibility of implicit dependences. However, sometimes it is useful to have &lt;span style=" font-family:Courier New;">encapsulated&lt;/span> &lt;span style=" font-style:italic;">models&lt;/span> where there is no danger of implicit dependences, e.g. application examples that are intended to be self consistent and might be sent around to other users and developers. &lt;br />&lt;/p>&lt;/body>&lt;/html></Text>
     </TextCell>
     <InputCell style="Input" closed="true" >
      <Input>encapsulated model TorqueUserExample1
  import Modelica.Mechanics.Rotational;          // Import package Rotational
  Rotational.Torque t2;                  // Use Torque OK!
  
  Modelica.Mechanics.Rotational.Inertia w2;        
  // Error! No direct reference to outside an encapsulated class
  // ...
end TorqueUserExample1;
</Input>
      <Output></Output>
     </InputCell>
    </GroupCell>
   </GroupCell>
  </GroupCell>
 </GroupCell>
</Notebook>
