Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create the relevant objects (links, quantities, element sets, data operations). Check the validity of selected data operations and populate the objects.
  2. Add the links between the components:
    • LinkRainToCatchm (links rainfall to the catchment): The target component (RRmodel) needs to know from which component to obtain the rainfall. The source component (RainModule) needs to know the target element set where it has to deliver the rainfall.
    • LinkRunoffToInflow: The target component (RiverModel) needs to know from which component to obtain the lateral inflow. The source component (RRmodel) needs to know the target element set where it has to deliver lateral inflows. Note that a flux towards the target destination (RiverModel) is positive.
    • TriggerLink: A trigger link to the river model - the downstream component in the data chain - is created and populated. The purpose of this link is to enable the first GetValues() call to the RiverModel. This call triggers the calculation chain.
  3. Validate the status of the components and their links using the Validate() method.

Phase III: Preparation

This phase is entered just before the computation/data retrieval process starts. Its main purpose is to define a clear take-off position before the bulky workload starts. This phase contains only one method: Prepare().
During this phase database or network connections (or both) might be established, monitoring stations might be called or model engines might prepare themselves by populating themselves with schematization input data (if this has not been done before), opening their output files, organizing their buffers, creating their data mapping matrices for (spatial) interpolation purposes, etc.
Note that this phase must include a final validation of the status of the linkable component.

Phase IV: Computation/execution

During this phase, the heavy workload will be executed and associated data transfer will get bulky. The data transfer mechanism of OpenMI is defined as a request-reply service mechanism, having direct interaction between two linkable components without any involvement of external facilities. Section 3.3 of the standard explains how data exchange takes place for unidirectional data exchange, bidirectional data exchange and iteration.
The computation starts by invoking the GetValues method via a link. This link can be connected to a trigger object (an 'empty' implementation of a LinkableComponent) or it might be connected to 'real' components such as a visualization tool or an output file.
While OpenMI linkable components sort out their own data communication and time synchronization, system developers should still pay attention to the question of process control.
System developers can easily develop an application that invokes the component chain with the end time as an argument in its GetValues call. The consequence is, however, that the model components do not return control to the main application until they are finished, thus making any smooth interruption of the process difficult. In addition, the 'overall' step size of the computation remains 'out-of-sight' as it is decided by an unknown component.
Given those disadvantages it is therefore recommended that you implement some execution facility that turns the entire simulation period into a loop of timesteps. (Within the org.OpenMI.Configuration package this execution facility is called the deployer.) While progressing through its simulation period, the GetValues call will be invoked for each step. Between each call, the application may react to external events, while the execution facility keeps control over the process. Figure 3 7 illustrates the function of such a loop.

Code Block

//--- Run ---
try
{
	MyRainModule.Prepare();
	MyRRModel.Prepare();
	MyRiverModel.Prepare();
	int nrsteps=100;
	DateTimestep = (end - start)/nrsteps;
	DateTime stop = end + 0.000001;
	DateTime _time = start;
	while (_time <= stop)
	{
		Application.DoEvents();
		IValueSet Values = _trigger.GetValues(new TimeStamp(_time),
		  _triggerLink.ID);
		_time = _time.AddSeconds(step);
	}
	GermanRhineModel.Finish();
	NethRhineModel.Finish();
} // end try

Figure 3 7 A time loop

Phase V: Completion

This phase comes directly after the computation/data retrieval process is completed. Code developers can use this phase to close their files and network connections, clean up memory etc. This phase contains only one step with one method-call: Finish.

Phase VI: Disposal

This phase is entered at the moment an application is closed. All remaining objects are cleaned and all memory (of unmanaged code) is de-allocated. Code developers are not forced to accommodate re-initialization of a linkable component after Dispose has been called.