MoDeNa. Deliverable D4.2 Model and data containers. Delivery date: Authors: Sigve Karolius Cansu Birgen Heinz Preisig Henrik Rusche

Similar documents
Towards a formal description of models and workflows

Course Announcements. Bacon is due next Monday. Next lab is about drawing UIs. Today s lecture will help thinking about your DB interface.

Geometric Algorithms in GIS

Structure of Materials Prof. Anandh Subramaniam Department of Material Science and Engineering Indian Institute of Technology, Kanpur

Designing Information Devices and Systems I Spring 2018 Lecture Notes Note Introduction to Linear Algebra the EECS Way

Clojure Concurrency Constructs, Part Two. CSCI 5828: Foundations of Software Engineering Lecture 13 10/07/2014

Let s now begin to formalize our analysis of sequential machines Powerful methods for designing machines for System control Pattern recognition Etc.

Designing Information Devices and Systems I Fall 2018 Lecture Notes Note Introduction to Linear Algebra the EECS Way

A Comparison Between MongoDB and MySQL Document Store Considering Performance

Intelligent GIS: Automatic generation of qualitative spatial information

Geodatabase Best Practices. Dave Crawford Erik Hoel

P Q1 Q2 Q3 Q4 Q5 Tot (60) (20) (20) (20) (60) (20) (200) You are allotted a maximum of 4 hours to complete this exam.

ArcGIS Enterprise: What s New. Philip Heede Shannon Kalisky Melanie Summers Shreyas Shinde

An exploration of matrix equilibration

ST-Links. SpatialKit. Version 3.0.x. For ArcMap. ArcMap Extension for Directly Connecting to Spatial Databases. ST-Links Corporation.

Designing and Evaluating Generic Ontologies

Supplementary Material

NEC PerforCache. Influence on M-Series Disk Array Behavior and Performance. Version 1.0

GEOGRAPHY 350/550 Final Exam Fall 2005 NAME:

SideNail. Martín Schonaker, Santiago Martínez

Math 98 - Introduction to MATLAB Programming. Spring Lecture 3

Databases 2011 The Relational Algebra

Discrete-event simulations

INSTITUT FÜR INFORMATIK

Linear Regression and Its Applications

Linear Algebra (part 1) : Vector Spaces (by Evan Dummit, 2017, v. 1.07) 1.1 The Formal Denition of a Vector Space

The File Geodatabase API. Craig Gillgrass Lance Shipman

A fast algorithm to generate necklaces with xed content

Newton's second law of motion

Database Systems SQL. A.R. Hurson 323 CS Building

' $ Dependence Analysis & % 1

A Parallel Implementation of the. Yuan-Jye Jason Wu y. September 2, Abstract. The GTH algorithm is a very accurate direct method for nding

Chapter 30 Minimality and Stability of Interconnected Systems 30.1 Introduction: Relating I/O and State-Space Properties We have already seen in Chapt

Impression Store: Compressive Sensing-based Storage for. Big Data Analytics

Chuck Cartledge, PhD. 21 January 2018

A TOPOLOGY APPROACH TO MODELLING. Abstract

MapReduce in Spark. Krzysztof Dembczyński. Intelligent Decision Support Systems Laboratory (IDSS) Poznań University of Technology, Poland

Discrete Structures Proofwriting Checklist

Applied C Fri

a (b + c) = a b + a c

Computation Theory Finite Automata

Week 4. (1) 0 f ij u ij.

Scikit-learn. scikit. Machine learning for the small and the many Gaël Varoquaux. machine learning in Python

Analysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College

and combine the results of the searches. We consider parallel search with subdivision, although most notions can be generalized to using dierent searc

Functional Database Query Languages as. Typed Lambda Calculi of Fixed Order. Gerd G. Hillebrand and Paris C. Kanellakis

Administering your Enterprise Geodatabase using Python. Jill Penney

Flexible Support for Spatial Decision- Making

Essentials of Intermediate Algebra

Data Replication in LIGO

Are You Maximizing The Value Of All Your Data?

Robust Programs with Filtered Iterators

Flexible Support for Spatial Decision-Making

Data Science Unit. Global DTM Support Team, HQ Geneva

Potential energy. Sunil Kumar Singh

Contents. 2.1 Vectors in R n. Linear Algebra (part 2) : Vector Spaces (by Evan Dummit, 2017, v. 2.50) 2 Vector Spaces

hapter 8 Simulation/Realization 8 Introduction Given an nth-order state-space description of the form x_ (t) = f (x(t) u(t) t) (state evolution equati

The semantics of ALN knowledge bases is the standard model-based semantics of rst-order logic. An interpretation I contains a non-empty domain O I. It

Comparing whole genomes

Normalization by Evaluation

Machine Learning Analyses of Meteor Data

Equalisation of the PMT response to charge particles for the Lucid detector of the ATLAS experiment

VCell Tutorial. Building a Rule-Based Model

Aalto University 2) University of Oxford

Logic and Philosophical Logic. 1 Inferentialism. Inferentialism and Meaning Underdetermination

CS 243 Lecture 11 Binary Decision Diagrams (BDDs) in Pointer Analysis

Scripting Languages Fast development, extensible programs

Math 471 (Numerical methods) Chapter 3 (second half). System of equations

An Introduction to Bioinformatics Algorithms Hidden Markov Models

Research on Object-Oriented Geographical Data Model in GIS

Performance and Application of Observation Sensitivity to Global Forecasts on the KMA Cray XE6

OBEUS. (Object-Based Environment for Urban Simulation) Shareware Version. Itzhak Benenson 1,2, Slava Birfur 1, Vlad Kharbash 1

Gravitational potential energy *

4th year Project demo presentation

TDDD08 Tutorial 1. Who? From? When? 6 september Victor Lagerkvist (& Wªodek Drabent)

Design of discrete-event simulations

1 Introduction A priority queue is a data structure that maintains a set of elements and supports operations insert, decrease-key, and extract-min. Pr

CityGML XFM Application Template Documentation. Bentley Map V8i (SELECTseries 2)

Motivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis

Lie Groups for 2D and 3D Transformations

CHAPTER 2 AN ALGORITHM FOR OPTIMIZATION OF QUANTUM COST. 2.1 Introduction

Feature selection. c Victor Kitov August Summer school on Machine Learning in High Energy Physics in partnership with

RESEARCH ON THE DISTRIBUTED PARALLEL SPATIAL INDEXING SCHEMA BASED ON R-TREE

LAB 1: MATLAB - Introduction to Programming. Objective:

Standard Particle Swarm Optimisation

Chemists are from Mars, Biologists from Venus. Originally published 7th November 2006

EE263 Review Session 1

Geodatabase: Best Practices. Robert LeClair, Senior Instructor

MapReduce in Spark. Krzysztof Dembczyński. Intelligent Decision Support Systems Laboratory (IDSS) Poznań University of Technology, Poland

SPATIAL INFORMATION GRID AND ITS APPLICATION IN GEOLOGICAL SURVEY

Animating Maps: Visual Analytics meets Geoweb 2.0

ArcGIS Enterprise: What s New. Philip Heede Shannon Kalisky Melanie Summers Sam Williamson

with the ability to perform a restricted set of operations on quantum registers. These operations consist of state preparation, some unitary operation

Ph219/CS219 Problem Set 3

VII Selected Topics. 28 Matrix Operations

NINE CHOICE SERIAL REACTION TIME TASK

Machine Learning Methods and Real-Time Economics

Linear Algebra and Eigenproblems

Programs, Semantics and Eective Atomicity

Innovation. The Push and Pull at ESRI. September Kevin Daugherty Cadastral/Land Records Industry Solutions Manager

Transcription:

Delivery date: 31-08-2015 MoDeNa Authors: Sigve Karolius Cansu Birgen Heinz Preisig Henrik Rusche Deliverable D4.2 Model and data containers Principal investigators: Sigve Karolius Henrik Rusche Dominik Christ Hrvoje Jasak Heinz Preisig Collaborators: Cansu Birgen Project coordinator: Heinz A Preisig heinz.preisig@chemeng.ntnu.no Abstract: Describes the model and data containers as currently utilised in the MoDeNa project as well as the construction of a layered ontology for the abstract represenation of mathematical models.

c 2015 MoDeNa ii

Contents 1 Introduction 1 2 High level framework 1 2.1 Surrogate Functions..................................... 1 2.1.1 Surogate function Framework Implementation................... 2 2.2 Surrogate Models....................................... 3 2.2.1 Surrogate Model, Framework Implementation................... 5 3 Low level framework 9 3.1 Modena Function....................................... 9 3.2 Modena Model........................................ 9 4 Data containers 10 5 Abstract model representation 16 5.1 The basic structural elements of the ontology....................... 16 5.2 Mathematical section..................................... 17 5.3 Multiple networks....................................... 21 5.4 Conclusion........................................... 21 Nomenclature 22 iii

1 Introduction The report has three major sections, namely the description of the high level framework, the low level framework of the data containers and the abstract mathematical model representation. The rst part considers the ground-rules for the data containers in the MoDeNa framework, which where implicitly set when MongoDB was chosen as the tool for data storage at the top level. However, using a NoSQL database provides exibility, and allows the design of the framework around the top level data container to be precisely tailored to the application. In fact, because a NoSQL database queries data using key-value pairs, the content of the database can be almost anything. The top level database is the second theme of the report. It is the location where all the information is being stored, namely input-output data from simulations, as well as all necessary information in order to re-instantiate a surrogate model. In that sense the database can be described as a self-contained environment for all the individual surrogate models that are used in a simulation. However, in order to provide a full description of the data containers it is necessary to look beyond the database itself and consider both the information that is stored and how it is handled in the context of the framework. The data containers in the MoDeNa framework are described beyond the top level database to include the abstraction from a mathematical representation to computer code; which is the basis for facilitating the interlinking of scales and the storage representation in the top-level database. Ultimately, the goal of this report is to elaborate on how the database and the underlying framework communicates and interacts in order to facilitate the scale interactions. 2 High level framework The structure of the top-level database and the properties of NoSQL databases will be introduced later, in section 4. For the this section, it is sucient to note that a NoSQL database consists of collections of documents. Every collection holds a set of documents which contains key-value pairs. The MoDeNa framework uses two collections: surrogate function and surrogate model, both corresponding to the terminology from the introduction of the chapter. The underlying high-level computer framework was based on generalising the set of key-value pairs for the surrogate function and surrogate model documents, respectively. Consequently, the relationship between the database and the computer-framework becomes symbiotic in the sense that the information in database, which is unique to every surrogate function and surrogate model, has no functionality unless it put into context by the general computer-framework. This section will show examples of how a generic surrogate function and surrogate model is instantiated without discussing the technical aspects behind the implementation of the framework. One of the most notable subjects of the section is the idea of strategies, described in section 2.2, which enables the MoDeNa framework to perform event-handling specic to every model based on what happens during a simulation. Ultimately, however, the goal is to clarify that a data-container in the MoDeNa framework is more than an entry in a database. 2.1 Surrogate Functions From a programming perspective, a surrogate function is an executable le compiled from C-code that is stored in the database when the function is instantiated. The function has inputs, outputs and parameters and limits to the domain in which the function is applicable, in the form of physical or 1

mathematical constraints. Therefore, a document in the surrogate function collection, shown in Listings 2, species a block of C-code in line 2, as well as the global constraints and argument position of every input, output and parameter of the function. 1 f = C F u n c t i o n ( 2 C c o d e = ' ' ' O m i t t e d, w o r k i n g e x a m p l e c o n t a i n s a C - f u n c t i o n in t h i s s t r i n g ' ' ', 3 # G l o b a l b o u n d s for the f u n c t i o n 4 i n p u t s ={ 5 ' i n p u t _ 1 ' : { ' min ' : 0, ' max ' : 9 e99, ' a r g P o s ' : 0 }, 6 }, 7 o u t p u t s ={ 8 ' o u t p u t _ 1 ' : { ' min ' : -9 e99, ' max ' : 9 e99, ' a r g P o s ' : 0 }, 9 }, 10 p a r a m e t e r s ={ 11 ' p a r a m 0 ' : { ' min ' : 0.0, ' max ' : 10.0, ' a r g P o s ' : 0 }, 12 ' p a r a m 1 ' : { ' min ' : 0.0, ' max ' : 10.0, ' a r g P o s ' : 1 }, 13 }, 14 ) Listing 1: The code block shows an example of how to instantiate a surrogate function in the MoDeNa framework. The surrogate function document represents the code specic to the function as well as the global constraints, position and symbol of the inputs, outputs and parameters that are used in the code. The MoDeNa framework automatically handles compilation and linking of the C-code that is specied in line 1 and updates the database. An illustration of how a document in the surrogate function collection looks like can be seen in Figure 2. The reason for separating the surrogate functions from the surrogate models is that the function is dened to contain information that is specic to the function itself and will not change. In contrast, the surrogate model in section 2.2 species a lot more information that can also be updated at runtime. An illustration showing how surrogate functions, such as the example in Listing 2, is saved in MongoDB is shown in Figure 2. 2.1.1 Surogate function Framework Implementation MoDeNa's surrogate function implementation is a class which functions as a link between the database and the framework. The instantiation of the class creates an entry in the surrogate function collection of the database based on the keyword input arguments. This means that the class that inherits the Surrogate Function class in Listing 2, e.g. CFunction in Listing 2, has to perform the necessary pre-processing, such as compiling the function library. The class consists of ve methods that are called both from the high and low-level framework: init (line 12): Initialisation method called at the end of the instantiation of the CFunction in Listing 2, which takes care of compiling the C library for the function. This method creates an entry for the input in the database. indexset (line 38): Method returning the index set used in the function. checkvariablename (line 42): Method checking wether the indecies specied by the user are valid, i.e. a part of the index set. exceptionload (line 48): Method returning an error code when the low-level framework fails to load the dynamic library for the C-function. 2

load (line 54): Method loading a surrogate model based on the _id, returns an instance of the model. 1 c l a s s S u r r o g a t e F u n c t i o n ( D y n a m i c D o c u m e n t ): 2 3 # D a t a b a s e d e f i n i t i o n 4 n a m e = S t r i n g F i e l d ( p r i m a r y _ k e y = T r u e ) 5 p a r a m e t e r s = M a p F i e l d ( E m b e d d e d D o c u m e n t F i e l d ( M i n M a x A r g P o s )) 6 f u n c t i o n N a m e = S t r i n g F i e l d ( r e q u i r e d = T r u e ) 7 l i b r a r y N a m e = S t r i n g F i e l d ( r e q u i r e d = T r u e ) 8 i n d i c e s = M a p F i e l d ( R e f e r e n c e F i e l d ( I n d e x S e t )) 9 m e t a = { ' a l l o w _ i n h e r i t a n c e ' : T r u e } 10 11 @ a b c. a b s t r a c t m e t h o d 12 def i n i t ( self, * args, ** k w a r g s ): 13 14 for k, v in k w a r g s [ ' i n p u t s ' ]. i t e r i t e m s (): 15 if not i s i n s t a n c e ( v, M i n M a x A r g P o s ): 16 k w a r g s [ ' i n p u t s ' ][ k ] = M i n M a x A r g P o s (** v ) 17 18 for k, v in k w a r g s [ ' o u t p u t s ' ]. i t e r i t e m s (): 19 if not i s i n s t a n c e ( v, M i n M a x A r g P o s ): 20 k w a r g s [ ' o u t p u t s ' ][ k ] = M i n M a x A r g P o s (** v ) 21 22 for k, v in k w a r g s [ ' p a r a m e t e r s ' ]. i t e r i t e m s (): 23 if not i s i n s t a n c e ( v, M i n M a x A r g P o s ): 24 k w a r g s [ ' p a r a m e t e r s ' ][ k ] = M i n M a x A r g P o s (** v ) 25 26 D y n a m i c D o c u m e n t. i n i t ( self, ** k w a r g s ) 27 28 for k in s e l f. i n p u t s. k e y s (): 29 s e l f. c h e c k V a r i a b l e N a m e ( k ); 30 31 for k in s e l f. o u t p u t s. k e y s (): 32 s e l f. c h e c k V a r i a b l e N a m e ( k ); 33 34 for k in s e l f. p a r a m e t e r s. k e y s (): 35 s e l f. c h e c k V a r i a b l e N a m e ( k ); 36 37 38 def i n d e x S e t ( self, n a m e ): 39 r e t u r n s e l f. i n d i c e s [ n a m e ] 40 41 42 def c h e c k V a r i a b l e N a m e ( self, n a m e ): 43 m = re. s e a r c h ( ' \ [ (. * ) \ ] ', n a m e ) 44 if m and not m. g r o u p (1) in s e l f. i n d i c e s : 45 r a i s e E x c e p t i o n ( ' I n d e x % s not d e f i n e d ' % m. g r o u p ( 1 ) ) 46 47 48 @ c l a s s m e t h o d 49 def e x c e p t i o n L o a d ( self, s u r r o g a t e F u n c t i o n I d ): 50 r e t u r n 201 51 52 53 @ c l a s s m e t h o d 54 def l o a d ( self, s u r r o g a t e F u n c t i o n I d ): 55 r e t u r n s e l f. o b j e c t s. g e t ( _id = s u r r o g a t e F u n c t i o n I d ) 2.2 Surrogate Models A generic example of a document in the surrogate model collection, shown in Listing 3, and compared to the surrogate function in Listing 2 it looks much more complex. As shown in line 3 the surrogate 3

function is in fact a parameter in the surrogate model. In addition to the surrogate function, which is dened in line 3, line 169 species the exact simulation, whose input-output data should be used in order to dene the parameters of the surrogate function. This means that the underlying framework of the backward mapping model can be coded using a general syntax to call a for instance a surrogate function, and the information from the database ensures that the general call corresponds to a specic surrogate function. 1 m = B a c k w a r d M a p p i n g M o d e l ( 2 _id = ' test - s u r r o g a t e - m o d e l ', 3 s u r r o g a t e F u n c t i o n = f, 4 e x a c t T a s k = F l o w R a t e E x a c t S i m (), 5 s u b s t i t u t e M o d e l s = [ ], 6 i n i t i a l i s a t i o n S t r a t e g y = S t r a t e g y. I n i t i a l P o i n t s ( 7 i n i t i a l P o i n t s = 8 { 9 ' i n p u t _ 1 ' : list, 10 }, 11 ), 12 o u t O f B o u n d s S t r a t e g y = S t r a t e g y. E x t e n d S p a c e S t o c h a s t i c S a m p l i n g ( 13 n N e w P o i n t s = 4 14 ), 15 p a r a m e t e r F i t t i n g S t r a t e g y = S t r a t e g y. N o n L i n F i t W i t h E r r o r C o n t o l ( 16 t e s t D a t a P e r c e n t a g e = 0.2, 17 m a x E r r o r = 0.05, 18 i m p r o v e E r r o r S t r a t e g y = S t r a t e g y. S t o c h a s t i c S a m p l i n g ( 19 n N e w P o i n t s = 2 20 ), 21 ), 22 ) Listing 3: The code block shows an example of the syntax for instantiating a backward mapping surrogate model in Python. The key-value pairs in the example are all required in order to instantiate the model, and it will automatically be uploaded as a document in the surrogate model collection of the MongoDB database. Once the model has been instantiated however, it contains more information, such as input-output from the exact model, and consequently several key-value pairs are automatically created by the framework to accomodate the information. Figure 3 shows an illustration of how a document corresponding to a surrogate model will look like in the database. An important feature of the surrogate model is that it introduces the concept of strategies. The idea behind strategies in the MoDeNa framework was to enable each individual surrogate model to handle events that the framework can solve, but whose trigger can not be planned; thus a surrogate model is essentially allowed to fail at any point during a simulation, triggering standardised procedures as necessary in order to address the problem. In other words, when a surrogate model fails the framework will stop the simulation and take action according to the dened strategies ensuring that the surrogate model will not fail at the same point during the next run of the simulation. The use of strategies also contributes to reducing the total computational cost of a simulation because a surrogate model can be instantiated in a domain that is smaller than the global boundaries dened in the surrogate function in Listing 2. This ensures that fewer number of exact simulations, specied in line 169, have to be performed in order to t the the surrogate model to a domain that is larger than necessary. Instead, the surrogate model is instantiated to a more practical domain and the strategies for handling events for the model being out of bounds and parameter tting in line 12 and 15 will automatically be used to expand the domain when necessary. Additionally, the database will automatically be updated with the input-output data from all the exact simulations, which ensures that the improved surrogate model can be re-used at a later point in time. 4

2.2.1 Surrogate Model, Framework Implementation The framework implementation of the surrogate model class, shown in in Listing 4, is designed to serve as the spine for the backward and forward mapping models; thus it is intended to inhereted by those classes and provide common functionality, such as the method callmodel in line 143 of Listing 4, which calls the surrogate function. There are a total of nine methods in the Surrogate Model class in Listing 4: init (line 12): Method instantiating the surrogate method, appending a reference to the surrogate model instance to a list which keeps track of all instances of surrogate model. parseindices (line 15): A method that searches the surrogate functions name in order to determine wether it contains an index set, and returnd the indeces. outputstomodels (line 29): Method used in order to replace output with that from substitute models. inputs_argpos (line 36): Checks wether an input variable that is specied by the user exist in the surrogate function denition. Returns the position of the input argument in the surrogate function. outputs_argpos (line 48): Checks wether an output variable that is specied by the user exist in the surrogate function denition. Returns the position of the input argument in the surrogate function. parameters_argpos (line 60): Checks wether a parameter that is specied by the user exist in the surrogate function denition. Returns the position of the input argument in the surrogate function. inputs_max_argpos (line 72): Returns the number of input variables to a surrogate function. calculate_maps (line 76): Method mapping inputs and outputs from the surrogate function to the substitute models. minmax (line 97): Returns two lists respectively containing the minimum and maximum values for every input variable. In other words, the method returns the design space in which the surrogate function can be used. The position of the variables in the list correspond to inputs_argpos. getattribute (line 108): Method dening rules for how to accsess the objects attribute values. setattribute (line 115): Method dening rules for how to set an objects attribute values. exceptionload (line 123): Method called when a model has not been instantiated, returns 201 for the return handler. exceptionoutofbounds (line 133): Saves the point that triggered the out of bounds exception in the database, and returns the exception 200 for the return handler. callmodel (line 143): Method for evaluating a surrogate model, i.e. executing modena_model_t, in the low-level framework. load (line 164): A class method which locates a surrogate model in the database using the _id reference and returns the model. 5

loadfailing (line 169): The method the surrogate model that is out of bounds and returns the model. loadfrommodule (line 175): Finds the surrogate model which has not yet been instantiated, i.e. the C-code has not been compiled, and returns an instance of the model equivalent to that shown in Listings 3. get_instances (line 184): Returns an itterator containing references to all instances of the Surrogate Model class. 1 c l a s s S u r r o g a t e M o d e l ( D y n a m i c D o c u m e n t ): 2 3 # L i s t of all i n s t a n c e s ( for i n i t i a l i s a t i o n ) 4 _ r e f s _ = [] 5 6 # D a t a b a s e d e f i n i t i o n 7 _id = S t r i n g F i e l d ( p r i m a r y _ k e y = T r u e ) 8 s u r r o g a t e F u n c t i o n = R e f e r e n c e F i e l d ( S u r r o g a t e F u n c t i o n, r e q u i r e d = T r u e ) 9 p a r a m e t e r s = L i s t F i e l d ( F l o a t F i e l d ()) 10 m e t a = { ' a l l o w _ i n h e r i t a n c e ' : T r u e } 11 12 def i n i t ( self, * args, ** k w a r g s ): 13 s e l f. _ r e f s _. a p p e n d ( w e a k r e f. ref ( s e l f )) 14 15 def p a r s e I n d i c e s ( s e l f ): 16 i n d i c e s = {} 17 m = re. s e a r c h ( '. * \ [ (. * ) \ ] ', s e l f. _id ) 18 if m : 19 for exp in m. g r o u p (1). s p l i t ( ', ' ): 20 m = re. s e a r c h ( ' (. * ) = (. * ) ', exp ) 21 if m : 22 i n d i c e s [ m. g r o u p ( 1 ) ] = m. g r o u p (2) 23 e l s e : 24 r a i s e E x c e p t i o n ( ' U n a b l e to p a r s e % s ' % exp ) 25 26 r e t u r n i n d i c e s 27 28 29 def o u t p u t s T o M o d e l s ( s e l f ): 30 o = { k : s e l f for k in s e l f. o u t p u t s } 31 for m in s e l f. s u b s t i t u t e M o d e l s : 32 o. u p d a t e ( m. o u t p u t s T o M o d e l s ()) 33 r e t u r n o 34 35 36 def i n p u t s _ a r g P o s ( self, n a m e ): 37 try : 38 r e t u r n e x i s t s A n d H a s A r g P o s ( s e l f. inputs, n a m e ) 39 e x c e p t : 40 try : 41 r e t u r n e x i s t s A n d H a s A r g P o s ( 42 s e l f. s u r r o g a t e F u n c t i o n. inputs, 43 n a m e ) 44 e x c e p t : 45 r a i s e E x c e p t i o n ( n a m e + ' not f o u n d in i n p u t s ' ) 46 47 48 def o u t p u t s _ a r g P o s ( self, n a m e ): 49 try : 50 r e t u r n e x i s t s A n d H a s A r g P o s ( s e l f. o u t p u t s, n a m e ) 51 e x c e p t : 52 try : 6

53 r e t u r n e x i s t s A n d H a s A r g P o s ( 54 s e l f. s u r r o g a t e F u n c t i o n. o u t p u t s, 55 n a m e ) 56 e x c e p t : 57 r a i s e E x c e p t i o n ( n a m e + ' not f o u n d in o u t p u t s ' ) 58 59 60 def p a r a m e t e r s _ a r g P o s ( self, n a m e ): 61 try : 62 r e t u r n e x i s t s A n d H a s A r g P o s ( s e l f. p a r a m e t e r s, n a m e ) 63 e x c e p t : 64 try : 65 r e t u r n e x i s t s A n d H a s A r g P o s ( 66 s e l f. s u r r o g a t e F u n c t i o n. p a r a m e t e r s, 67 n a m e ) 68 e x c e p t : 69 r a i s e E x c e p t i o n ( n a m e + ' not f o u n d in p a r a m e t e r s ' ) 70 71 72 def i n p u t s _ m a x _ a r g P o s ( s e l f ): 73 r e t u r n max ( s e l f. i n p u t s _ a r g P o s ( k ) for k in s e l f. i n p u t s ) 74 75 76 def c a l c u l a t e _ m a p s ( self, sm ): 77 m a p _ o u t p u t s = [] 78 m a p _ i n p u t s = [] 79 80 for k in s e l f. i n p u t s : 81 try : 82 m a p _ i n p u t s. e x t e n d ( 83 [ s e l f. i n p u t s _ a r g P o s ( k ), sm. i n p u t s _ a r g P o s ( k )] 84 ) 85 e x c e p t : 86 p a s s 87 88 for k, v in s e l f. s u r r o g a t e F u n c t i o n. i n p u t s. i t e r i t e m s (): 89 try : 90 m a p _ o u t p u t s. e x t e n d ([ sm. o u t p u t s _ a r g P o s ( k ), v. a r g P o s ]) 91 e x c e p t : 92 p a s s 93 94 r e t u r n m a p _ o u t p u t s, m a p _ i n p u t s 95 96 97 def m i n M a x ( s e l f ): 98 len = 1 + s e l f. i n p u t s _ m a x _ a r g P o s () 99 m i n V a l u e s = [ -9 e99 ] * len 100 m a x V a l u e s = [9 e99 ] * len 101 for k, v in s e l f. i n p u t s. i t e r i t e m s (): 102 m i n V a l u e s [ s e l f. i n p u t s _ a r g P o s ( k )] = v. min 103 m a x V a l u e s [ s e l f. i n p u t s _ a r g P o s ( k )] = v. max 104 105 r e t u r n m i n V a l u e s, m a x V a l u e s 106 107 108 def g e t a t t r i b u t e ( self, n a m e ): 109 if n a m e. s t a r t s w i t h ( ' ' ): 110 r e t u r n o b j e c t. g e t a t t r i b u t e ( self, n a m e ) 111 e l s e : 112 r e t u r n s u p e r ( D y n a m i c D o c u m e n t, s e l f ). g e t a t t r i b u t e ( n a m e ) 113 114 115 def s e t a t t r i b u t e ( self, name, v a l u e ): 116 if n a m e. s t a r t s w i t h ( ' ' ): 117 o b j e c t. s e t a t t r i b u t e ( self, name, v a l u e ) 7

118 e l s e : 119 s u p e r ( D y n a m i c D o c u m e n t, s e l f ). s e t a t t r i b u t e ( name, v a l u e ) 120 121 122 @ c l a s s m e t h o d 123 def e x c e p t i o n L o a d ( self, s u r r o g a t e M o d e l I d ): 124 c o l l e c t i o n = s e l f. _ g e t _ c o l l e c t i o n () 125 c o l l e c t i o n. u p d a t e ( 126 { ' _id ' : s u r r o g a t e M o d e l I d }, 127 { ' _id ' : s u r r o g a t e M o d e l I d }, 128 u p s e r t = T r u e 129 ) 130 r e t u r n 201 131 132 133 def e x c e p t i o n O u t O f B o u n d s ( self, o P o i n t ): 134 o P o i n t D i c t = { 135 k : o P o i n t [ v. a r g P o s ] 136 for k, v in s e l f. i n p u t s. i t e r i t e m s () 137 } 138 s e l f. o u t s i d e P o i n t = E m b D o c (** o P o i n t D i c t ) 139 s e l f. s a v e () 140 r e t u r n 200 141 142 143 def c a l l M o d e l ( self, i n p u t s ): 144 # I n s t a n t i a t e the s u r r o g a t e m o d e l 145 c M o d e l = m o d e n a. l i b m o d e n a. m o d e n a _ m o d e l _ t ( m o d e l = s e l f ) 146 147 i n _ i = l i s t () 148 i = [0] * (1 + s e l f. i n p u t s _ m a x _ a r g P o s ()) 149 150 for k, v in s e l f. i n p u t s. i t e r i t e m s (): # Set i n p u t s 151 i [ s e l f. i n p u t s _ a r g P o s ( k )] = i n p u t s [ k ] 152 153 out = c M o d e l. c a l l ( in_i, i ) # C a l l the s u r r o g a t e m o d e l 154 155 o u t p u t s = { 156 k : out [ v. a r g P o s ] 157 for k, v in s e l f. s u r r o g a t e F u n c t i o n. o u t p u t s. i t e r i t e m s () 158 }; 159 160 r e t u r n o u t p u t s 161 162 163 @ c l a s s m e t h o d 164 def l o a d ( self, s u r r o g a t e M o d e l I d ): 165 r e t u r n s e l f. o b j e c t s. g e t ( _id = s u r r o g a t e M o d e l I d ) 166 167 168 @ c l a s s m e t h o d 169 def l o a d F a i l i n g ( s e l f ): 170 r e t u r n s e l f. o b j e c t s ( r a w ={ ' o u t s i d e P o i n t ' : { ' $ e x i s t s ' : T r u e }} 171 ). f i r s t () 172 173 174 @ c l a s s m e t h o d 175 def l o a d F r o m M o d u l e ( s e l f ): 176 c o l l e c t i o n = s e l f. _ g e t _ c o l l e c t i o n () 177 doc = c o l l e c t i o n. f i n d _ o n e ({ ' _ c l s ' : { ' $ e x i s t s ' : F a l s e }}) 178 m o d e l I d = doc [ ' _id ' ] 179 mod = i m p o r t ( m o d e l I d ) 180 r e t u r n mod. m 181 182 8

183 @ c l a s s m e t h o d 184 def g e t _ i n s t a n c e s ( s e l f ): 185 for i n s t _ r e f in s e l f. _ r e f s _ : 186 i n s t = i n s t _ r e f () 187 if i n s t is not N o n e : 188 y i e l d i n s t 3 Low level framework The low level framework allows the surrogate models to be used in C and Fortran, but are initiated in Python; hence it can be described as providing extension types specic to the MoDeNa framework. It is compiled and linked as a shared library, which means that it can in principle can be linked against existing projects implemented in C and Fortran, as well as being imported into high-level level scripting languages, such as Matlab. 3.1 Modena Function The denition of the surrogate function type, a type-declaration for the low-level C-functions, is shown in Listings 5. The declaration denes a struct, a complex data type that bundles a list of variables under a common name in memory, containing pointers to various members. PyObject_HEAD is a macro which is expanded to two pointers respectively containing the reference count and a pointer to a Type object. The rest of the structure denes three members: a pointer, pfunction, to a python object, a dynamic library handle, and function pointer. 1 t y p e d e f s t r u c t m o d e n a _ f u n c t i o n _ t 2 { 3 P y O b j e c t _ H E A D 4 P y O b j e c t * p F u n c t i o n ; 5 l t _ d l h a n d l e h a n d l e ; 6 v o i d (* f u n c t i o n ) 7 ( 8 c o n s t d o u b l e * p, 9 c o n s t d o u b l e * in_i, 10 c o n s t d o u b l e * i, 11 d o u b l e * o 12 ); 13 14 } m o d e n a _ f u n c t i o n _ t ; Listing 5: The code block shows the low-level type-denition for the surrogate function. The low-level implementation in itself deserves more space than what can be include into this report. So we constrain ourselves to the document the main issues: The important detail to note is that the implementation uses the python header le, which provides access to the internal python API; thus allowing the framework to be embedded into the Python interpreter. Moreover, the modena function type is mostly used as by the modena model in 6 in order to load a surrogate function from the database and parse the index set. 3.2 Modena Model The code block in Listing 6 shows the type denition for a surrogate model. Similar to the modena function in section 3.1 the modena model is also a python extension. However, unlike the modena 9

function it is the modena model that actually calls the surrogate function, setting the input and fetching the output. 1 t y p e d e f s t r u c t m o d e n a _ m o d e l _ t 2 { 3 P y O b j e c t _ H E A D 4 P y O b j e c t * p M o d e l ; 5 s i z e _ t o u t p u t s _ s i z e ; 6 s i z e _ t i n p u t s _ s i z e ; 7 s i z e _ t i n p u t s _ m i n M a x _ s i z e ; 8 d o u b l e * i n p u t s _ m i n ; 9 d o u b l e * i n p u t s _ m a x ; 10 b o o l * a r g P o s _ u s e d ; 11 s i z e _ t i n h e r i t e d _ i n p u t s _ s i z e ; 12 s i z e _ t p a r a m e t e r s _ s i z e ; 13 d o u b l e * p a r a m e t e r s ; 14 s t r u c t m o d e n a _ f u n c t i o n _ t * mf ; 15 16 v o i d (* f u n c t i o n ) 17 ( 18 c o n s t d o u b l e * p, 19 c o n s t d o u b l e * in_i, 20 c o n s t d o u b l e * i, 21 d o u b l e * o 22 ); 23 24 s i z e _ t s u b s t i t u t e M o d e l s _ s i z e ; 25 m o d e n a _ s u b s t i t u t e _ m o d e l _ t * s u b s t i t u t e M o d e l s ; 26 27 } m o d e n a _ m o d e l _ t ; Listing 6: The code block shows the low-level type-denition for the surrogate function. 4 Data containers A database can be dened as an organized collection of data which enables us to handle large quantities of information by inputting, storing, retrieving and managing them. A relational database is dened as a database in which the data is organized based on the relational model of data. The purpose of this model is to provide a declarative method for data and query specication. Relational databases mostly use structured query language (SQL) which can also be used as a term to describe a relational database. Non-relational databases, dubbed as NoSQL (Not Only SQL), provide a mechanism for storage and retrieval of data which is modeled in a way dierent than in a relational database. NoSQL databases are of interest in MoDeNa project since they allow database schemas which adapt to the users needs in a seemless manner. MongoDB is a auch a NoSQL document store database written in CPP and developed in an open-source project by the company 10gen Inc. The motivation behind its development is to close the gap between the fast and highly scalable key-value-stores and feature-rich traditional relational database management systems. Some fundamental features of MongoDB are listed below to provide a more concrete insight and detailed information about the terminology and concepts: Document database A record in MongoDB is a document, which is a data structure composed of pairs (eld and value), or (key and value). The values of elds can also include arrays of other documents. MongoDB documents are in BSON ('Binary JSON') data format. Essentially, it is 10

Table 1: Terminology and concepts in SQL and MongoDB. SQL Database Table Row Column Index Table joins Primary key (specify any unique column or column combinations as primary key) Aggregation (e.g. by group) MongoDB Database Collection Document or BSON Document Field Index Embedded documents and linking Primary key (the primary key is automatically set to the _id eld in MongoDB) Aggregation pipeline a binary form for representing objects or documents. Using documents is advantageous since in many programming languages they correspond to native data types, embedded documents (subdocuments) and arrays reduce need for expensive joins, and dynamic schema supports uent polymorphism. In the documents, the value of a eld can be any of the BSON data types, including other documents, arrays, and arrays of documents. MongoDB stores all documents in collections. A collection is a group of related documents that have a set of shared common indexes. Collections are analogous to a table in relational databases. High performance MongoDB provides high performance data persistence. In particular, support for embedded data models reduces I/O activity on database system, and indexes support faster queries and can include keys from embedded documents and arrays. High availability To provide high availability, MongoDB's replication facility, called replica sets, provide automatic failover and data redundancy. A replica set is a group of MongoDB servers that maintain the same data set, providing redundancy and increasing data availability. Automatic scaling MongoDB provides horizontal scalability as part of its core functionality. Automatic sharding distributes data across a cluster of machines. Replica sets can provide eventuallyconsistent reads for low-latency high throughput deployment. To provide insight in MongoDB in a comparative manner with more widely used relational database (SQL) approach, terminology and concepts of these two are summarized and shown in Table 1. MongoDB implements the basic functions of data storage, initially dened for SQL: (create, read, update, delete) CRUD. In MongoDB, these are represented as query which corresponds to read operations while data modication stands for create, update and delete operations. In MongoDB, read operation is a query which targets a specic collection of documents. Queries specify criteria, or conditions, that identify the documents that MongoDB returns to the clients. A query may include a projection that species the elds from the matching documents to return. MongoDB queries exhibit the following behaviour: All queries in MongoDB address a single collection. Queries can be modied to impose limits, skips, and sort orders. The order of documents returned by a query is not dened unless a sort() method is used. 11

Figure 1: Illustration of database organization in MongoDB on a local host. Operations that modify existing documents use the same query syntax as queries to select documents to update. In aggregation pipeline, the $ match pipeline stage provides access to MongoDB queries. The MoDeNa project uses MongoDB for data storage. As shown in Figure 1, the database has a crucial role as it resides in the core of the ow of information. In MongoDB, when there is data insertion, default database named as test is automatically populated unless specied otherwise. The test database in MoDeNa project contains information regarding work-ow, work-ow state, models, experiments, metadata, simulation context. Moreover, the software, Fireworks used in the project also employs MongoDB for work-ow (FireTasks) storage in a database called as fireworks. In addition to test and fireworks databases, there is another database (local) that is automatically created by MongoDB for the purpose of saving log information. Figure 1 shows an illustration of the MongoDB databases and corresponding collections. As can be seen in Figure 1, there are three MongoDB databases (test, local, fireworks) on local host and their corresponding collections are also shown. In MongoDB, the system generates the name by concatenating the index key eld and value with an underscore, e.g. cat_1., if 12

the user does not specify an index name, and they are stored in a collection named as system.indexes which can be observed in the gure both for the test and fireworks databases. Each collection has at least one document which are not shown in the gure. Since the local database is generated by MongoDB and fireworks database structure is dened by the software itself, the main focus will be the test database which is developed within the scope of the MoDeNa project. For twotank example in the project, data is stored in test database as well which has 3 collections: surrogate_function, surrogate_model and system.indexes. Each collection stores documents which consist of key and value pairs. The collection, surrogate_function contains one single document with the keys: id of the function _id; class of the function, _cls; the global bounds for the function, inputs which are p0, rho0, p1byp0 and D, outputs which is flowrate and parameters which are param1 and param2 with global minimum value min, global maximum value max and argument position argpos; name of the function libraryname; compiled model in the library libraryname; C-code of the function for model execution and parameter estimation Ccode. All the mentioned keys and their value, and the hierarchy between them in terms of subdocuments constitute the database schema. The database schema is specied with corresponding keys and values in the initialization script except libraryname whose value is compiled in surrogate model script. To illustrate the data structure, data schema for surrogate_function collection is drawn with keys and it is shown in Figure 2. As can be seen in Figure 2, surrogate_function collection has one document which has 8 keys (_id, _cls, inputs, libraryname, outputs, libraryname, parameters, Ccode). Three of the keys store documents as values e.g. subdocuments (p0, rho0, p1byp0, D, flowrate, param1, param2), and subdocuments also store documents (min, max and argpos). Thus, there are three levels of hierarchy in the data structure. The collection, surrogate_model contains also one single document with the keys: class of the model, _cls; id of the model _id; Firework spec exacttask which has a name of _fw_name; tting data fitdata which are p0, rho0, p1byp0 and D; inherited inputs inherited_inputs; initialization strategy initializationstrategy which has initialpoints of p0, rho0, p1byp0 and D, and a name of _fw_name; the global bounds for the function, inputs which are p0, rho0, p1byp0 and D with global minimum value min, global maximum value max; number of sample points nsamples; determination of points outside of the bounds outofboundsstrategy and corresponding number of points nnewpoints and a name of _fw_name; output of the calculation outputs which is flowrate with global minimum value min, global maximum value max; parameter tting strategy ParameterFittingStrategy with maximum error limit of maxerror, sub-strategy for improvement improveerrorstrategy and corresponding number of points nnewpoints and a name of _fw_name, maximum number of iterations maxiterations, name of _fw_name and testdatapercentage; parameters, corresponding function of the model surrogatefunction and calculated numbers outside of bounds outsidepoint. To illustrate the data structure, data schema for surrogate_model collection is drawn with keys and it is shown in Figure 3. As can be seen in Figure 3, surrogate_model collection has one document which has 14 keys (_id, fitdata, inherited_inputs, initializationstrategy, exacttask, _cls, inputs, nsamples, surrogatefunction, outputs, outofboundsstrategy, parameters, ParameterFittingStrategy, outsidepoint). As described in Figure 2, keys store documents e.g. subdocuments. Thus, there are three levels of hierarchy in the data structure. 13

Figure 2: Data schema of surrogate_function collection. 14

Figure 3: Data schema of surrogate_model collection. 15

5 Abstract model representation The representation of models for the purpose of being used in coded form is a key issue in computational engineering. A simple set of rules, a simple structure that provides the complete model in all details would make it possible to transfer and inherit models in a myriad of application. This approach brings the model into the centre of computational activities and provides consistency between the dierent applications and utilisations of the model. The original idea that was reected in the MoDeNa proposal and the follow up Description of Work, describes the plan of building the model systematically using a layered approach. The work done on the subject veried that indeed this approach yields the desired result, but it also showed that one had yet to take a step backwards from the position one started. The decision was taken to enter the design of a layered ontology for the representation of mathematical models that use a state space description for a network with nodes being characterised by their respective state and the arcs representing interactions between the nodes aecting the states of the two connected nodes. This has lead to a more fundamental description, which is now able to contain mathematical models of not only physical systems but any system that satises those basic properties. Below we will describe the current state and the eect the development had on the implementation of model containers in MoDeNa. 5.1 The basic structural elements of the ontology The ontologies are built on a basic core structure consisting of three parts and identied by three keywords namely structure, behaviour, typing. The rst section, identied with structure contains the structural components, namely the structure of the model, in our case a graph consisting of node and arc. The two latter terms are used in singular. The fact that they are going to be lists or sets of nodes and arcs is reected by adding a decorator. So we use a * to indicate vector/list/set properties, a. to indicate a scalar and! to indicated the ability to transform. Later we use for representing reactions and other similarly motivated transformations. 1 [ s t r u c t u r e ] # b u i l d i n g b l o c k s 2 g r a p h = [ ' * n o d e ', ' * arc ' ] 3 f r a m e = [ '. t i m e ' ] 4 5 [ b e h a v i o u r ] # l i n k to m a t h e m a t i c a l d e s c r i p t i o n 6 n o d e = [ ' s t a t e ', ' c o n s t a n t ' ] 7 8 [ t y p i n g ] # s p e c i a l i s a t i o n of b u i l d i n g b l o c k 9 g r a p h = [ ' p h y s i c a l ' ] 10 n o d e = [ ' e v e n t ', ' d y n a m i c ', ' c o n s t a n t ' ] 11 arc = [ ' uni - d i r e c t i o n a l ', ' bi - d i r e c t i o n a l ' ] Listing 7: The root ontology The structure denes the graph and in the frame time. Thus we dene here dynamic models. The behaviour denes that the nodes are described by state and constant. The section typing provides the renement for the networks, in our example only one, namely physical. The nodes are placed into three subdomains in a given time scale interpretation and the arc may or may not be limited to positive ow. The arcs are dened as reference coordinates when dening the ows. Listing 7 The root ontology denes the rst layer and is inherited by all the following ones. The forming of the next layer is initiated by the typing entry graph. The Listing 9 shows the next layer. 16

1 [ s t r u c t u r e ] # e x t e n d s s t r u c t u r e w i t h the r e l e v a n t p h y s i c a l c o m p o n e n t s 2 f r a m e = [ " * s p a t c o o r d " ] 3 t o k e n = [ ". m a s s ", ". e n e r g y ", " *! s p e c i e s ", ". e n t r o p y ", " * i n f o r m a t i o n " ] 4 5 [ b e h a v i o u r ] # s p e c i a l i s e s to r e l e v a n t p h y s i c a l v a r i a b l e t y p e s 6 n o d e = [ ' s e c o n d a r y _ s t a t e ', ' t r a n s p o s i t i o n ' ] 7 arc = [ ' t r a n s p o r t ' ] 8 9 [ t y p i n g ] 10 g r a p h = [ ' l i q u i d ', ' s o l i d ', ' gas ' ] # h o o k s for f u r t h e r s p e c i a l i s a t i o n 11 n o d e = [ ' 0 D ', ' 1 D ', ' 2 D ', ' 3 D ' ] # q u a l i f i e s n o d e s Listing 8: The specialisation to physical networks The structure provides the base description of a physical containment living in the frame of time and space. The token denes what goes into the containment, kind of colours. No interaction of dierent tokens are dened on this level. The behaviour is rened to reect a small classes of variables here motivated by the block diagram we use for the representation of physical system (Figure 4). balances F {ˆx} m transport transport equations {t m (y, θ t )} m {ẋ} s state deriv. state t > 0 {x} dt s t = 0 {root (s s (x, y, θ s ))} s {y} secondary state transposition { x} m initial conditions {x(0)} s state variable transformations { ξ} N T k dynamic extent {k r (y, θ k )} r transpostions / kinetics {y b } boundary conditions Figure 4: Block diagram of a network of physical systems with lumped elementary capacities 5.2 Mathematical section We have established an ontology editor that builds on the above structure. Currently the root ontology and the rened ontologies are generated manually. Current focus is on generating the complex equation editor. It starts of requesting additional information for the root structural elements, specically the state and the frame. Here we dene the physical units manually. The index sets are generated automatically from the structure components and the tokens. For our case this results the index sets as shown in Listing 4. 17

The & represents the product operator for the set. In algebra we will write more compactly. So we have: network components nodes :: N and arcs :: A frame components spatial coordinates :: C tokens species :: S product set node & spatial coordinates :: N C product set node & species :: N S product set arc & species :: AS token conversion r_species :: R 1 [ i n d e x s e t s ] 2 0 = arc 3 1 = arc & i n f o r m a t i o n 4 2 = arc & s p e c i e s 5 3 = i n f o r m a t i o n 6 4 = n o d e 7 5 = n o d e & i n f o r m a t i o n 8 6 = n o d e & s p a t c o o r d 9 7 = n o d e & s p e c i e s 10 8 = r _ s p e c i e s 11 9 = s p a t c o o r d 12 10 = s p e c i e s Listing 9: All automatically generated index sets The index sets are also automatically allocated to the states and the frame variables that themselves are generated from the dened frame and behaviour denitions. For the denition of the equations we have dened a small language, which implements a couple of operators that are handling the block structure of the network representation. The denition thus starts in the block diagram (4) at the integrator dening the states followed by the state variable transformation, the closure equations. The required constants are dened before they are used and equipped with appropriate units and index sets, where applicable. All operators check units and index sets according to given rules and generate them for the newly dened variable as they are dened. The language denes, besides the common operations, some special ones, as mentioned: 18

operator operation result expand analogue to scaler times matrix a mapping reduce matrix operations using Einstein indexing a N b N,A expands space to c N,A a N N bn,a reduces space to c A block reduce block-wise scalar product a S S bn S reduce block in product set index c N Khatri Rao block operations a N,A N,A bn S,AS keeps larger blocked space c N S,AS a N N bn S keeps larger blocked space c N S a N N,A bn S,AS keeps larger blocked space c N S,AS a A N,A bn S,AS keeps larger blocked space c N S,AS The next page shows a sample model representing a mass transfer system. 19

equations res vars given integrals n N S := t 0 ṅn S dt + n o N S n N S ṅ N S n o N S dierential balances ṅ N S = F n N S,AS AS ˆnAS ṅ N S ˆn AS, F n N S,AS constants F n N S,AS = F m N,A N,A SN S,AS F n N S,AS F m N,A, S N S,AS ows ˆn AS := ˆV A A cas ˆn AS ˆV A, c AS ˆV A := K V A F m N N,A pn ˆV A p N K V A, F m N,A 20 state variable transformations A c AS := d A F n N S N S,AS cn S c AS d A, F n N S,AS, c N S ( ) d A := sign F m N N,A pn c AS p N S F m N,A c N S := V 1 N N n N S c N S V N, n N S p N := ρ N g h N p N h N ρ N, g h N := A 1 N V N h N V N A N V N := ρ 1 N m N V N m N ρ N m N := λ S S nn S m N n N S λ S

5.3 Multiple networks The chosen structure of the ontology allows for the denition of sets of networks and connect them together. The extension to connected multiple networks is now open and allows for a multitude of combined modelling domains. The approach is to dene automatically connection networks that inherit common tokens from both sides and are limited to event dynamic, with token transformation allowing for the transposition of tokens of one type into tokens of another type in the connected networks. For example a measurement will be of the represented by the token : information on the resulting information processing network side and may be temperature on the other, physical network side. Similarly we can approach dierent time scales in that one part of the connection network is dedicated to the lifting operation (from the macroscopic to the particle level) and homogenisation in the other direction, namely from the particle to the macroscopic/eld level. 5.4 Conclusion The decision of making a step backwards and to extent the ontology representation into multiple network representations has resulted in a clear canonical structure. At the same time the user is given quite some freedom to dene her/his own details and thus the application domain has been greatly opened up. For materials modelling this implies that we have now the tools to capture not only multi-physics, but also dierent time scales in the same structures and combine them together. The direct result was the introduction of indexing into the MoDeNa software, which now enables the handling of dierent species. 21

Nomenclature ˆV volume ow. 21 F m mass-network matrix - the incidence matrix of the directed graph for the connected mass network. 21 F n moalr mass-network matrix - the incidence matrix of the directed graph for the connected molar mass network. 21 S selection matrix. 21 ˆn vector of molar mass ows. 21 λ vector of molecular masses. 21 ṅ vector of accumulated molar mass. 21 c concentration vector. 21 n vector of molar mass in mol/s. 21 K V diagonal matrix of conductivity for volume ow. 21 m mass in kg. 21 N C product index set nodes and spatial coordinates. 19 N S product index set nodes & species. 1921 N index set for nodes. 1921 p pressure. 21 R index set for reactions. 19 S index set for species. 1921 V volume. 21 product expanding to the minimal dimension (no duplication of dimension). 20, 21 Khatri Rao block product. 20, 21 ρ density. 21 reduce block product product. 20, 21 product reducing over the given dimension. 20, 21 A area. 21 AS product index set arcs & species. 1921 A index set for arcs. 1921 C index set for spatial coordinates. 19 d vector of directions for arcs. 21 g gravitation constant. 21 h height. 21 22