CE 394K.2 Hydrology Introduction to OpenMI

65
CE 394K.2 Hydrology Introduction to OpenMI Tim Whiteaker

description

CE 394K.2 Hydrology Introduction to OpenMI. Tim Whiteaker. What is OpenMI. - PowerPoint PPT Presentation

Transcript of CE 394K.2 Hydrology Introduction to OpenMI

Page 1: CE 394K.2 Hydrology Introduction to OpenMI

CE 394K.2 Hydrology

Introduction to OpenMI

Tim Whiteaker

Page 2: CE 394K.2 Hydrology Introduction to OpenMI

What is OpenMI

• The OpenMI standard defines an interface that allows time-dependent models to exchange data at runtime. When the standard is implemented, existing models can be run in parallel and share information at each time step.

http://www.openmi.org/

Page 3: CE 394K.2 Hydrology Introduction to OpenMI

Outline

• Background

• Thinking through integrated modeling

• The OpenMI standard

Page 4: CE 394K.2 Hydrology Introduction to OpenMI

Outline

• Background– Who created OpenMI– Why did they create OpenMI

• Thinking through integrated modeling

• The OpenMI standard

Page 5: CE 394K.2 Hydrology Introduction to OpenMI

History and Organization

• Development team– 14 organizations– 7 countries

• Funding– European Commission’s

Fifth Framework programme

European Commission

Fifth Framework programme

HarmonIT

OpenMI

Water Framework Directive

Page 6: CE 394K.2 Hydrology Introduction to OpenMI

European Commission (EC)

• Executive body of EU

• Proposes and implements legislation

• One Commissioner from each member state

• http://ec.europa.eu/

European Commission

Fifth Framework programme

HarmonIT

OpenMI

Water Framework Directive

Page 7: CE 394K.2 Hydrology Introduction to OpenMI

Water Framework Directive (WFD)

• Most substantial piece of EC water legislation to date

• Enacted December 22, 2000• 2015 – “good status” for inland

and coastal waters• Defines standards and

procedures• Requires whole catchment

modeling• http://ec.europa.eu/environmen

t/water/water-framework/index_en.html

European Commission

Fifth Framework programme

HarmonIT

OpenMI

Water Framework Directive

Page 8: CE 394K.2 Hydrology Introduction to OpenMI

Whole Catchment Modeling

• Model interactions between hydrologic components– Rainfall/Runoff– Hydraulics– Groundwater– Ecology– Social

• Key to integrated water management

Page 9: CE 394K.2 Hydrology Introduction to OpenMI

Fifth Framework programme (FP5)

• Prioritizes EU research, technological development and demonstration activities (1998-2002)

• ~15b euro for implementation• Programs

– Quality of Life and management of living resources

– User-friendly information society– Competitive and sustainable

growth– Energy, environment and

sustainable development• http://cordis.europa.eu/fp5/

European Commission

Fifth Framework programme

HarmonIT

OpenMI

Water Framework Directive

Page 10: CE 394K.2 Hydrology Introduction to OpenMI

HarmonIT

• Supported by FP5’s Energy, environment and sustainable development program

• Objective: to develop, implement and prove a system to simplify the linking of models to support whole catchment modeling

• http://www.harmonit.org/

European Commission

Fifth Framework programme

HarmonIT

OpenMI

Water Framework Directive

Page 11: CE 394K.2 Hydrology Introduction to OpenMI

HarmonIT Team• Centre for Ecology and Hydrology

• DHI Water and Environment• WL Delft Hydraulics• HR Wallingford Group

• Institute for Inland Water Management and Waste Water Treatment RIZA

• University of Dortmund• Instituto di Ricerca Sulle Acque (IRSA)• National Technical University of Athens• WRc plc• DHI Hydroinform a.s.• Povodi Labe s.p.• Hydroprojekt a.s.• Alterra B.V.• Centre National du Machinisme Agricole, du Genie Rural,

des Eaux et des Forets

Team leader

Design and development

Management,Support,Testing

Page 12: CE 394K.2 Hydrology Introduction to OpenMI

OpenMI

• Open Modeling Interface and Environment

• Interface for model integration

• Supports understanding and prediction of process interactions

• http://www.openmi.org/

European Commission

Fifth Framework programme

HarmonIT

OpenMI

Water Framework Directive

Page 13: CE 394K.2 Hydrology Introduction to OpenMI

OpenMI Aims and Objectives• The aim of the OpenMI is to provide a mechanism by which physical

and socioeconomic process models can be linked to each other, to other data sources and to a variety of tools at runtime, hence enabling process interactions to be better modeled.

• Specific objectives are that the mechanism’s design should:– Be applicable to new and existing models– Impose as few restrictions as possible on the modeler’s freedom– Be applicable to most, if not all, time-based simulation techniques– Require the minimum of change to the program code of existing

applications– Keep the cost, skill and time required to migrate an existing model to a

minimum so that these factors are not a deterrent to the OpenMI’s use– Be easy to use– Not unreasonably degrade performance

http://www.openmi.org/openminew/documents/A_OpenMI_Scope.pdf

Page 14: CE 394K.2 Hydrology Introduction to OpenMI

Outline

• Background

• Thinking through integrated modeling– What is a model– How can models communicate

• The OpenMI standard

Page 15: CE 394K.2 Hydrology Introduction to OpenMI

What models do we have now

• HMS - hydrologic• RAS – hydraulic – 1D, steady/unsteady• SWAT – Soil Water Assessment Tool• HSPF• BASINS (HSPF, QUAL2E)• MODFLOW• SWMM• EPA NET

Page 16: CE 394K.2 Hydrology Introduction to OpenMI

What comprises a model

Page 17: CE 394K.2 Hydrology Introduction to OpenMI

What does a model need to run

• Separate Engine from User Interface

• Set model parameters

• Deal with Inputs and Outputs

Page 18: CE 394K.2 Hydrology Introduction to OpenMI

Integrated Modeling

Rainfall/Runoff

Output data

Input data

User interface

Application

Hydraulics

Output data

Input data

User interface

Application

Surface runoff

Evaporation

Precipitation

Estuary

Coast

Evaporation

River

How ?

Rainfall runoff model

Hydraulic model

?

Page 19: CE 394K.2 Hydrology Introduction to OpenMI

Benefits of Integrated Modeling

• Water Balance

• Standardized, Modular system

• Process interactions

• Plug-and-play

• Chance for individuals to publish models

Page 20: CE 394K.2 Hydrology Introduction to OpenMI

How can models exchange data

Page 21: CE 394K.2 Hydrology Introduction to OpenMI

What

Quantities are variables accepted or provided by a model

Page 22: CE 394K.2 Hydrology Introduction to OpenMI

Where

Elements are the locations where quantities are

measured

Page 23: CE 394K.2 Hydrology Introduction to OpenMI

When

At each time step?

After simulations?

Iterations?

Page 24: CE 394K.2 Hydrology Introduction to OpenMI

How

• Model definition: Define quantities a model can exchange, and at which elements can it exchange them.

• Configuration: Define which models are linked in terms of quantities and elements.

• Runtime operation: Enable the model to accept or provide data at run time.

Page 25: CE 394K.2 Hydrology Introduction to OpenMI

Outline

• Background

• Thinking through integrated modeling

• The OpenMI standard

Page 26: CE 394K.2 Hydrology Introduction to OpenMI

What is OpenMI: Revisted

• The OpenMI standard defines an interface that allows time-dependent models to exchange data at runtime. When the standard is implemented, existing models can be run in parallel and share information at each time step.

http://www.openmi.org/

Page 27: CE 394K.2 Hydrology Introduction to OpenMI

What is an Interface

Program

Mathlibrary

Add

Multiply

SquareRoot

Functions:

What’s the square root

of 16?

16

4

result = Calculator.SquareRoot(16)

Programs and functions, revisted

Page 28: CE 394K.2 Hydrology Introduction to OpenMI

What is an Interface

• An interface defines how a program interacts with an object

• An interface includes properties and methods (functions)

Math library

Calculator

Add (NumberArray) : Number

Multiply (NumberArray) : Number

SquareRoot (Number) : Number

Mathlibrary

Add

Multiply

SquareRoot

Functions:

Calculatorobject

Page 29: CE 394K.2 Hydrology Introduction to OpenMI

Interface for Hydro Data Exchange

Rainfall runoffGet values

HydraulicGet values

EcologyGet values

EconomicGet values

OpenMI defines an Interface with a GetValues method, among others

Interface

Page 30: CE 394K.2 Hydrology Introduction to OpenMI

OpenMI is ‘interface-based’

• Its ‘standardized’ part is defined as a software interface specification.

• This interface acts as a ‘contract’ between software components.

• The interface is not limited to specific technology platforms or implementations.

• By implementing this interface a component becomes an OpenMI compliant component.

Page 31: CE 394K.2 Hydrology Introduction to OpenMI

OpenMI is ‘open’• Its specification is publicly available via the Internet (

www.OpenMI.org).

• It enables linkages between different kinds of models, different disciplines and different domains.

• It offers a complete metadata structure to describe the numerical data that can be exchanged in terms of semantics, units, dimensions, spatial and temporal representation and data operations.

• It provides a means to define exactly what is linked, how and when.

• Its default implementation and software utilities are available under an open source software license.

Page 32: CE 394K.2 Hydrology Introduction to OpenMI

OpenMI is a ‘standard’

• It standardizes the way data transfer is specified and executed.

• It allows any model to talk to any other model (e.g. from a different developer) without the need for cooperation between model developers or close communication between integrators and model developers.

• Its generic nature does not limit itself to a specific domain in the water discipline or even in the environmental discipline.

Page 33: CE 394K.2 Hydrology Introduction to OpenMI

GetValues Method

• Occurs at a time step

• Models called sequentially

• For the geeks…ILinkableComponent.GetValues(time :ITime, linkID :string) : IValueSet

Page 34: CE 394K.2 Hydrology Introduction to OpenMI

GetValues Chaining Options

Page 35: CE 394K.2 Hydrology Introduction to OpenMI

Handling GetValues

Page 36: CE 394K.2 Hydrology Introduction to OpenMI

Conceptual Model for Data Exchange

GetValues(time, linkID)

when what,where

Page 37: CE 394K.2 Hydrology Introduction to OpenMI

Conceptual Model for Data Exchange

• What the values represent and in what unit they are expressed is indicated by the quantity and its unit.

• Where these values apply is indicated by the ElementSet class, which contains an ordered set of elements.

• When the values apply is indicated by the time, either expressed as an instantaneous moment in time (a timestep) or a period over time (a time span).

Page 38: CE 394K.2 Hydrology Introduction to OpenMI

Base units and base quantities in OpenMI (derived from SI)

Base quantity SI base unit Symbol used

Length metre m

Mass kilogram kg

Time second s

ElectricCurrent ampere A

Temperature Kelvin K

AmountOfSubstance mole mol

LuminousIntensity candela cd

Currency Euro E

Page 39: CE 394K.2 Hydrology Introduction to OpenMI

Example of ‘Quantities’

Page 40: CE 394K.2 Hydrology Introduction to OpenMI

Elements (where exchange happens)

• ID-based or geospatial representation

• If geospatial, defined by set of nodes

• May or may not be georeferenced

• Elements in an ElementSet must be of the same type

Page 41: CE 394K.2 Hydrology Introduction to OpenMI

Element Types

Page 42: CE 394K.2 Hydrology Introduction to OpenMI

Examples of Element Sets

Page 43: CE 394K.2 Hydrology Introduction to OpenMI

Element Set Properties

Page 44: CE 394K.2 Hydrology Introduction to OpenMI

Interpreting positive values of fluxes, levels and depths

Page 45: CE 394K.2 Hydrology Introduction to OpenMI

Data Operations

• Operations which define how information is exchanged between exchange items

• Spatial– Interpolation– TakeNearest

• Temporal– Aggregation– Extrapolation

• Other

Page 46: CE 394K.2 Hydrology Introduction to OpenMI

Advanced Example

Data operations allow data to be exchanged between these two models at various types of interfaces (e.g., nodes, lines, interpolations on areas)

Page 47: CE 394K.2 Hydrology Introduction to OpenMI

Exchange Items

• Grouping of Quantity and ElementSet

• Input and Output exchange items

• Output exchange items include DataOperation

Page 48: CE 394K.2 Hydrology Introduction to OpenMI

Example of Exchange Items

Page 49: CE 394K.2 Hydrology Introduction to OpenMI

Linkable Component

• Model engine with implementation of OpenMI standard interface– DLL– Model Definition

• Exchange Items

– Configuration– Run-time operation

• GetValues

Rainfall-Runoff Model --InputExchangeItems --Quantities --ElementSets --OutputExchangeItems --Quantities --ElementSets

Model

Linkable Component

Page 50: CE 394K.2 Hydrology Introduction to OpenMI

Links

Rainfall-Runoff Model --InputExchangeItems --Quantities --ElementSets --OutputExchangeItems --Quantities --ElementSets

River Model --InputExchangeItems --Quantities --ElementSets --OutputExchangeItems --Quantities --ElementSets

LINK

IDDescription

TargetComponentTargetQuantity

TargetElementSetSourceComponent

SourceQuantitySourceElementSet

DataOperationsCountGetDataOperation

A link is the data path connecting two linkable components

Model Model

Linkable Component Linkable Component

Page 51: CE 394K.2 Hydrology Introduction to OpenMI

Example Links

Page 52: CE 394K.2 Hydrology Introduction to OpenMI

Composition

Rainfall-Runoff Model --InputExchangeItems --Quantities --ElementSets --OutputExchangeItems --Quantities --ElementSets

River Model --InputExchangeItems --Quantities --ElementSets --OutputExchangeItems --Quantities --ElementSets

LINK

A composition is a set of linkable components, possibly populatedwith model data and interconnected with links.

Model Model

Composition

Page 53: CE 394K.2 Hydrology Introduction to OpenMI

OpenMI Systems

• An OpenMI system is any software application that includes a set of one or more OpenMI compliant components.

• The system must know:– where it can find linkable components.– what links exist between linkable components.– how to instantiate, deploy and run a

combination of linkable components.

Page 54: CE 394K.2 Hydrology Introduction to OpenMI

OMI Files

• An OMI file is an XML file that contains the information needed to instantiate an OpenMI component and populate it with input data.

• An OMI file points to:– Location of DLL for the OpenMI compliant

model– Location of input files

Page 55: CE 394K.2 Hydrology Introduction to OpenMI

Deployment of an OpenMI linkable component

• Instantiation and initialization. Read OMI file, construct linkable component, and populate with input data.

• Inspection and configuration. Set up links with exchange items and validate links.

• Preparation. Finish preparatory work before computation begins. For example, database and network connections are established, output files are opened and buffers are organized.

• Computation/execution. Loop through each time step, making necessary calculations and exchanging data with other linkable components.

• Completion. Close file and network connections, clean up memory, etc.

• Disposal. This phase is entered when the application is closed. Remaining objects are removed and memory is deallocated.

Page 56: CE 394K.2 Hydrology Introduction to OpenMI

OmiEdA visual tool for building and running OpenMI systems

Page 57: CE 394K.2 Hydrology Introduction to OpenMI

Steps to Building an OpenMI System

• Start the configuration editor.

• Add models to the composition.

• Establish connections between the models.

• Configure the connections.

• Add a trigger.

• Run the composition.

Page 58: CE 394K.2 Hydrology Introduction to OpenMI

Migrating Existing Models

• Rework engine to implement OpenMI interfaces– Allows exchange of quantities– Can be applied to databases or other data

sources

• Easiest way is to modify engine core and then wrap it

Page 59: CE 394K.2 Hydrology Introduction to OpenMI

Requirements for OpenMI Linkable Components (1)

• Initialization is separate from computation.

• Available modeled quantities are exposed to the outside world.

• Modeled quantities can be provided for any requested point in time and space.

• The model must be able to respond to a request, even when the component itself is time independent; if the response requires data from another component, the component must be able to pass on the time in its own request.

• The model must be able to submit to runtime control by an outside entity.

Page 60: CE 394K.2 Hydrology Introduction to OpenMI

Requirements for OpenMI Linkable Components (2)

• For components progressing in time, the requirement ‘always’ to return values when requested imposes the following conditions:

– The delivering component must know what time it has reached, how that compares to the requested time, and how to proceed if the times don’t match up (extrapolate, compute, etc.).

– Components must be able to interpolate if the requested time is not in their own time step or space frame.

– Components must know when they are waiting for data, in which case they will have to return an extrapolated value.

Page 61: CE 394K.2 Hydrology Introduction to OpenMI

Migrating a Model

• OpenMI provides utilities to assist in migrating a model.

• Model migration involves 7 steps.

1. Change the engine core. 2. Create the .NET assemblies. 3. Access the functions in the engine core. 4. Implement MyEngineDotNetAccess. 5. Implement the wrapper class. 6. Implement the linkable component. 7. Implement the remaining IEngine methods.

Page 62: CE 394K.2 Hydrology Introduction to OpenMI

Model Migration: 11. Change the engine core. The model engine should be converted from

an EXE file to a DLL, which can be accessed by other components.

Page 63: CE 394K.2 Hydrology Introduction to OpenMI

Model Migration: 22. Create the .NET assemblies. After installing the OpenMI Environment,

create assemblies for wrapper classes and test classes in the .NET development environment.

Page 64: CE 394K.2 Hydrology Introduction to OpenMI

Model Migration: 3-73. Access the functions in the engine core. The engine needs to be accessible

from .NET. The MyEngineDLLAccess class makes a one-to-one conversion of all exported functions in the engine core code to public .NET methods.

4. Implement MyEngineDotNetAccess. This class changes the calling conventions to C# conventions and converts error messages into .NET exceptions.

5. Implement the wrapper class. The MyEngineWrapper class implements the ILinkableEngine interface. (Initializing, Finalizing)

6. Implement the linkable component. The MyModelLinkableComponent class must be implemented. This class defines the linkable component that is accessed by other models.

7. Implement the remaining IEngine methods. The remaining methods in the MyEngineWrapper class must be implemented (e.g., GetValues). In some cases you may need to make changes to the engine core as well as adding code to the IEngine methods.

Page 65: CE 394K.2 Hydrology Introduction to OpenMI

Acknowledgements

• Content and images are taken from material at – http://www.openmi.org/openminew/– http://www.openmi-life.org/