The previous sections show how inner definition declarations, e.g. in the Environment model, are implicitly connected to and propagated to outer reference declarations, e.g. in components of the environment. What happens if we have a more complex system structure, with possibly several levels of nested subsystems? Can we propagate across the subsystem boundaries? The answer is yes, but a bit clumsy. We would need to have different inner and outer declarations for the same entity in each subsystem, introduce a new name for each additional declaration, and couple these through additional equations. This is complicated and makes model re-use harder. To avoid these drawbacks when modeling with nested subsystems, the simultaneous inner-outer declaration has been introduced. This eliminates the need for extra names and equations, and increases reusability, e.g. as needed by libraries such as Modelica.Stategraph. The declaration has both keywords inner and outer as depicted below.
inner outer <Type> <variable>
To demonstrate the use of simultaneous inner outer declarations we have introduced a subsystem level, SubEnvironment, with instance subEnv, in the previous Environment model. The new model is called Environments WithSubsystem and is shown below.The model contains two environment instances env1 and env2, each containing an inner definition of a temperature T0 and a subsystem subEnv. The top-level environment temperatures env1.T0 and env2.T0 respectively are picked up by the reference (outer) part of the simultaneous inner outer T0 in subEnv, transferred to its definition (inner) T0 part which is implicitly accessed by the reference declarations of T0 in the components comp1 and comp2.
We simulate the EnvironmentsWithSubsystem model containing the two environments env1 and env2