Home

An approach to virtual-lab implementation using Modelica

image

Contents

1. and the third one called right connector placed on the opposite side Interface of interactive controls and drawable elements It has two connectors called left connectors one filled and one empty see figures 1b amp Ic The virtual lab programmer must observe the following three rules when connecting the graphic elements i Only connectors with the same shape circular or squared can be connected ii Each filled connector must be connected to one and only one empty connector iii Each empty connector can be left unconnected or can be connected to one and only one filled connector The meaning of the connections among the graphic components is as follows If two components are connected using their left connectors then both components are hosted within the same container The component position in the chain of connected elements determines its insertion order within the container If two components are connected using the right connector of the first component and a left connec tor of the second component then the second component is hosted within the first component The following example tries to illustrate how the graphic elements can be used to compose the view of a virtual lab In particular the view of the tank process described in section 3 The Modelica description of the virtual lab view and the obtained virtual lab are shown in figure 4 In this case the model of the
2. model tank parameter Real Ainitial Initial value of the tank section Real A start Ainitial Tank section Interactive magnitude equation der A 0 end tank Let s consider that all the interactive magnitudes can be simultaneously selected as state variables this condition will be removed in section 3 3 Provided that this restriction is satisfied the virtual lab developer does not need to perform further modifications in the model In particular the required code to implement the user s changes in the value of the interactive magnitudes is pre defined in the interactive control elements shown in figure 1b Changes in the model state are performed as state re initialization events by using the Modelica s reinit x expr operator It re initializes an state variable x with the value obtained by evaluating an expression expr at the event instant These changes are triggered using when clauses Defining the interactive parameters and input variables as state variables increases the number of state variables This has an unwanted effect it slows down the simulation We could think of redefining the interactive parameters and input variables as discrete time variables or alternatively as input variables whose values are provided by the virtual lab view In this way the number of state variables would not be increased However this is not a valid approach Dymola automatically performs model manipulations in order to form
3. 4 Set Point i ulow 1 0 02 270 0 387 8 505 6 6233 7411 A3 waterSP m 3 2 0 vaporMol 1273 100 7 8 56 33 11 4000000 y v uhigh1 0 02 uhigh 5000000 0 0 0 7 1 3 2 0 2 7 0 444 9889 1333 1778 vaporMol 4 1 yas Temp K 463 0 00 22 44 67 89 10000000 0 4 9 13 18 1270 0 387 8 505 6 623 3 741 1 Figure 8 View of the boiler virtual lab 13 May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder 14 C Martin Villalba A Urquia and S Dormido see figure 9 panelSouth hosts interactive controls of Label and Slider classes These sliders allow the user to perform interactive changes in the value of the boiler volume the output pressure the valve opening the water volume and the vapour flow set points the mass and temperature of the water and the vapour moles contained inside the boiler The dialog container hosts interactive controls of Slider class These sliders allow the user to change the parameter values of the two PID controllers The dialog1 container generates the graphic interface shown in figure 10 This container hosts components of PlottingPanel class which contain drawables of Trail class These drawables generate traces that show the time evolution of some relevant system variables see figure 10 5 3 Virtual lab set up and launch The virtual lab description is obtained as discussed in section 3 It is
4. Arrow class panelNorth hosts interactive controls of RadioButton InfoButton PauseButton and Slider classes The two radio buttons allow the user to select the control strategy manual or decentralized PID The two sliders allow the user to change the pump input flow and the heater heat flow when the manual control strategy is selected The button of the InfoButton and PauseButton classes allows the user respectively to pause and resume the simulation and to display a window with the information about the virtual lab May 4 2007 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder An approach to virtual lab implementation using Modelica a a E3 a o Jr i 3 Pr a Fr 3 3 Figure 7 Diagram of the Modelica description of the view MainFrame _ controlparam automatic O manual _ Show plots heatFlow J 1 liquid m 3 s 0 0 N pause info 0 10000000 0 02 0 02 Kp1 1 0 Kp2 5000000 0 00 0 44 0 89 1 33 1 78 10000000 Ti1 9 0 Ti2 2 1 50 7 0 9 0 10 30 50 7 0 Td1 0 1 Td2 0 02 0 0 100 0 0 00 0 22 0 44 0 67 0 89 N2 10 pressure atm 11 0 Boiler volume m 3 5 7 0 00 6 67 13 33 20 00 26 67 1 00 256 4 11 567 7 22 opening 1 00 i waterMikg 2200 00 02 04 Of 09 2000 3778 5556 7333 9111 Ea e waterT K 420 0 zj z i 0 9 13 18 0 0 0
5. C Martin Villalba A Urquia and S Dormido i a Text T1 K 288 T2 K 288 T3 K 288 273 295 3147 340 362 273 295 3147 340 362 273 295 3147 340 362 Specific thermal conductivity of dry wall Vi mK 1 7 Thickness of conduction layer m 0 14 1 0 12 1 4 1 7 1 9 0 05 0 08 0 12 0 15 0 18 Specific heat capacity of dry wall J Kg K 840 Wall density Kg m 3 1762 700 767 833 900 967 1500 1611 1722 1833 1944 Wall thickness m 0 41 Absorption 0 50 b 0 10 0 21 0 32 0 43 0 54 0 00 0 22 0 44 0 67 0 89 Figure 11 ExWallView class a diagram and b generated view ated is shown in figure 11b The ExWallView class contains instances of graphic elements contained in VirtualLabBuilder library i e Dialog DrawinPanel Panel Polygon Text and Slider The connection among these elements determines the layout of the graphic interface The graphic interface consists of a window that contains a set of sliders at the bottom and at the top see figure 11b These sliders allow the user to modify the temperature and thermodynamic properties of the wall including the specific thermal conductivity of the dry wall the thickness of the conduction layer the specific heat capacity the density the thickness of the outer wall and absorption coefficient The centre of the window contains a graphical representation of the wall model which is composed of three conducting layers
6. InWallView class contains sliders that allow the user to change the temperature and thermodynamic properties of the wall i e specific thermal conductivity of the dry wall thickness of the conduction layer specific heat capacity density and thickness RoofView class contains sliders that allow the user to change the thermodynamic properties i e specific thermal conductivity thickness specific heat capacity and density of the three conducting layers that compose the roof SlabView class contains sliders that allow the user to change the slab thermodynamic properties i e May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder An approach to virtual lab implementation using Modelica 17 iat fa Miall Walz EA cat E Root BIE slab a 2 BedRoom 1 Yalli b C Slab C Root Figure 12 BedRoom1View class a diagram and b generated view specific thermal conductivity thickness of the slab specific heat capacity density and thickness of the conduction layer Modelica classes have been composed using VirtualLabBuilder to describe the view associated to the house HouseView the living room LivingRoomView and bedrooms 1 and 2 BedRoom1View and Bed Room2View These are briefly described next The diagram of the BedRoom1View class is shown in figure 12a and the generated graphic interface is shown in figure 12b This model conta
7. Systems 9 1 pp 65 118 22 Cellier F E and Nebot A The Modelica Bond Graph Library In Proceedings of the 4th International Modelica Conference Hamburg Germany 2006 pp 57 65 23 Weiner M 1992 Bond Graph Model of a Passive Solar Heating System MS Thesis University of Arizona Tucson Arizona 24 Weiner M and Cellier F E Modeling and Simulation of a Solar Energy System by Use of Bond Graphs In Proceedings of the 1st SCS Intl Conf on Bond Graph Modeling San Diego California 1993 pp 301 306
8. completed 14 i A systematic methodology to transform any Modelica model into a formulation suitable for interactive simulation has been proposed Modelica models adapted according to this methodology can be used to set up interactive virtual labs ii VirtualLabBuilder Modelica library has been designed and programmed It includes Modelica models implementing graphic interactive elements such as containers animated geometric shapes and inter active controls These models allow the virtual lab developer 1 to compose the view and 2 to link the visual properties of the virtual lab view with the model variables The interactive graphic interface is automatically generated during the model initialization process The components of the library con tain the code required to perform the bidirectional communication between the view and the model In addition VirtualLabBuilder library supports including in the virtual lab an introductory part which is composed of html pages An overview of the proposed approach to virtual lab implementation using Modelica is provided in section 2 The methodology to transform any Modelica model into a formulation suitable for interactive simulation is discussed in section 3 The architecture and use of VirtualLabBuilder library is described in section 4 Finally the application of the proposed approach is illustrated by means of two case studies 1 the implementation of a virtual lab intended to illustrate
9. proposed and it has been successfully applied The proposed approach has several advantages Firstly the virtual lab is completely described using Modelica language an object oriented modelling language aimed to be a de facto standard for representing models and to support model exchange Secondly existing Modelica libraries for modelling of physical systems can be reused in order to build the virtual lab models Finally the virtual lab view is modelled using the object oriented paradigm which facilitates its development maintenance and reuse In order to support the application of this approach the following two tasks have been completed 1 the proposal of a modelling methodology intended to transform any Modelica model into a description suitable for interactive simulation and 2 the design and implementation of a Modelica library named VirtualLabBuilder supporting the description of the virtual lab view and the bi directional communication between the model and the view This modelling methodology and the architecture and use of VirtualLabBuilder have been discussed The proposed approach has been illustrated by means of two case studies the industrial boiler virtual lab and the virtual lab describing the thermodynamic behaviour of a solar house The models describing the industrial boiler and the solar house have been adapted to suit the interactive simulation The virtual lab May 4 2007 20 9 44 Mathematical and Computer Modell
10. provide a visual representation of the simulated model behaviour and to facilitate the user s interactive actions on the model during the simulation run The graphical properties of the view elements are linked to the model variables producing a bi directional flow of information between the view and the model Any change of a model variable value is automatically displayed by the view Reciprocally any user interaction with the view automatically modifies the value of the corresponding model variable There are many software tools specifically intended to facilitate the implementation of virtual labs Two of them are Easy Java Simulations 38 4 and Sysquake 5 The strong point of these tools is that they allow easy creation of the virtual lab view Their weak point is the model definition that requires explicit state models ODE This restriction strongly conditions the modelling task which requires a considerable effort from the virtual lab developer Modelica 6 is a freely available object oriented modelling language that supports the physical modelling paradigm 7 Models are mathematically described by differential and algebraic equations DAE and discrete equations Modelica supports a declarative i e non causal description of the model Therefore Corresponding author Email carlaQdia uned es Mathematical and Computer Modelling of Dynamical Systems ISSN 1387 3954 print ISSN 1744 5051 online 2006 Taylor amp Francis h
11. 22 TO 2 14 Martin C Urquia A and Dormido S An Approach to Virtual lab Implementation using Modelica In Proceedings of the 20th Annual European Simulation and Modelling Conference Toulouse France 2006 pp 137 141 15 Otter M and Olsson H New features in Modelica 2 0 In Proceedings of the 2nd International Modelica Conference Oberpfaf fenhofen Germany 2002 pp 7 1 7 12 16 Mattsson S E Olsson H and Elmqvist H Dynamic Selection of States in Dymola In Proceedings of the Modelica Workshop Lund Sweden 2000 pp 61 67 17 Fritzson P 2004 Principles of Object Oriented Modeling and Simulation with Modelica 2 1 IEEE Press Wiley John amp Sons 18 Ramirez W F 1989 Computational Methods for Process Simulation Butterworths Publishers Boston pp 209 217 19 Martin C Urquia A and Dormido S JARA 2i A Modelica Library for Interactive Simulation of Physical Chemical Processes In Proceedings of the 18th European Simulation and Modelling Conference Paris France 2004 pp 128 132 20 Urquia A 2000 Modelado Orientado a Objetos y Simulacion de Sistemas Hibridos en el Ambito del Control de Procesos Quimicos PhD Thesis Dept Informatica y Automatica UNED Spain Downloaded from http www euclides dia uned es aurquia 21 Urquia A and Dormido S 2003 Object Oriented Design of Reusable Model Libraries of Hybrid Dynamic Systems Mathematical and Computer Modelling of Dynamical
12. May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder Mathematical and Computer Modelling of Dynamical Systems Vol 00 No 00 January 2006 1 21 An approach to virtual lab implementation using Modelica CARLA MARTIN VILLALBA ALFONSO URQUIA and SEBASTIAN DORMIDO Departamento de Informatica y Automatica UNED Juan del Rosal 16 28040 Madrid Spain A novel approach to the implementation of interactive virtual labs is proposed The virtual lab is completely described in Modelica language and translated using Dymola To achieve this goal a systematic methodology to transform any Modelica model into a formulation suitable for interactive simulation has been developed In addition VirtualLab Builder Modelica library has been programmed This library contains a set of Modelica models of visual interactive elements i e containers animated geometric shapes and interactive controls that allows easy creation of the virtual lab view i e the model to user interface This approach has two strong points Firstly it allows taking advantage of the Modelica capabilities for multi domain modelling and model reuse In particular existing Modelica libraries for modelling of physical systems can be reused in order to build the virtual lab models Secondly VirtualLabBuilder library allows describing the virtual lab view with Modelica which facilitates its development maintenance and reuse The proposed approach is
13. d a The boiler model has been composed using components from JAFA 2 a version of JARA Mlodelica library that has been adapted for interactive simulation JAFA is a Modelica brary of some fundamental plyysical cherucal principles J ARA s main application domain is the modelling of transport therrmo fluid phase change and cherucal processes in the Figure 9 Introduction of the boiler virtual lab Total molar flow mols s Liquid Volume m 3 l 10 20 30 40 50 time s Heat Flow J s Total mass flow Kq s 6 if 20 90 40 50 time s Figure 10 Time evolution of some selected variables of the boiler virtual lab 6 2 Composing the virtual lab The solar house model has been adapted to suit interactive simulation Interactive parameters and input variables have been re defined as constant state variables i e with zero time derivative The Modelica description of the virtual lab view has been developed modularly by extending and con necting the required graphic components of the VirtualLabBuilder library Modelica classes have been programmed to describe the view associated to an inner wall InWallView an outer wall ExWallView a slab SlabView and a roof RoofView These are described next The diagram of the ExWallView Modelica class is shown in figure 1la and the graphic interface gener May 4 2007 16 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder
14. discussed in this manuscript and it is illustrated by means of two case studies a virtual lab of an industrial boiler and a virtual lab describing the thermodynamic behaviour of a solar house Keywords Modelica Virtual laboratory Control education Interactive simulation Simulation animation AMS Subject Classification 97U04 93A04 93C04 1 Introduction A virtual lab is a distributed environment of simulation and animation tools intended to perform the interactive simulation of a mathematical model Virtual labs supporting interactive simulations are effective educational resources 1 During the interactive simulation run students can change the value of some selected inputs parameters and state variables of the model perceiving instantly how these changes affect the model dynamic An arbitrary number of actions can be made on the model during a given simulation run Virtual labs allow students to play an active role in their learning process and this promotes their motivation to study the subject Virtual labs are composed of introduction model and view The introduction is the documentation fre quently a set of html pages discussing the concepts and phenomena illustrated by the virtual lab how to experiment with the lab and also proposing some activities or exercises 2 The model is the mathematical model representing the relevant behaviour of the system under study The view is the user to model inter face It is intended to
15. e graphic elements and their properties can be found in 14 Containers package has those graphic elements that are intended to host other graphic elements The container properties are set in the view definition and they can not be modified during the simulation run VirtualLabBuilder contains the following five classes of containers MainFrame Dialog Panel DrawingPanel and PlottingPanel see figure 1d Drawables package contains several classes implementing interactive 2 D shapes whose properties i e size position rotation angle aspect ratio colour etc can be linked to the model variables They are intended to be used for building animated and interactive schematic representations of the system These classes are Polygon Oval Text Arrow and Trail see figure 1c Objects of Drawables classes must be placed inside containers that provide a coordinate system i e containers of DrawingPanel and PlottingPanel classes In addition to this general purpose interactive components other domain specific components can be implemented In order to demonstrate this capability Mechanics package has been included within Drawables package It contains two classes i e Damper and Spring implementing an interactive damper and an interactive spring InteractiveControls package contains classes that allow modifying interactively the value of model variables These are Slider NumberField RadioButton ButtonlAction Button2Action
16. e of the pipe section Real a start alnitial Pipe section Interactive magnitude equation der a 0 end pipe model pump parameter Real vinitial Initial value of the applied voltage Real v start vinitial Voltage applied to the pump Interactive parameter Real kInitial Initial value of the pump parameter Real k start kInitial Pump parameter Interactive magnitude equation der v 0 der k 0 end pump partial model physicalModel parameter Boolean 3 isState tank tanki hIsState isState 1 VIsState isState 2 pipe pipel FIsState isState 3 pump pumpi end physicalModel The boolean vector isState declared in physicalModel allows controlling the state selection The size of this vector is equal to the number of interactive time dependent magnitudes For instance if isState is set to the value false true false when instantiating the physical model then the liquid volume V is selected as a state variable Also the interactive parameters A a and the input variable v have been defined as constant state variables This first step in the implementation of the interactive model is represented in figure 3a ii The setParamVar class is defined see figure 3b It inherits from physicalModel and it contains the May 4 2007 Enabled iii 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder C Martin Villa
17. elica Association website http www modelica org Astrom K Elmqvist H and Mattsson S E Evolution of Continuous Time Modeling and Simulation In Proceedings of the 12th European Simulation Multiconference Manchester UK 1998 pp 9 18 Dynasim AB Dymola User s Manual Lund Sweden 2006 The OpenModelica Project website http www ida liu se pelab modelica OpenModelica html Engelson V 2000 Tools for Design Interactive Simulation and Visualization of Object Oriented Models in Scientific Computing PhD Thesis Linkping University Sweden Martin C Urquia A Sanchez J Dormido S Esquembre F Guzman J L and Berenguel M Interactive Simulation of Object Oriented Hybrid Models by Combined use of Ejs Matlab Simulink and Modelica Dymola In Proceedings of the 18th European May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder An approach to virtual lab implementation using Modelica 21 Simulation Multiconference Magdeburg Germany 2004 pp 210 215 12 Martin C Urquia A and Dormido S Object oriented modelling of interactive virtual laboratories with Modelica In Proceedings of the 4th Int Modelica Conference Hamburg Germany 2005 pp 159 168 13 Martin C Urquia A and Dormido S Object Oriented Modeling of Virtual Laboratories for Control Education In Proceedings of the 16th IFAC World Congress Prague Czech Republic 2005 paper code Th A
18. ial sections of the Modelica model describing the virtual lab are evaluated In particular the initial sections of the interactive graphic objects composing the virtual lab view class and of the PartialView class are executed These initial sections contain calls to Modelica functions which encapsulate calls to external C functions These May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder 4 C Martin Villalba A Urquia and S Dormido F kv Figure 2 Model used to illustrate the translation from the physical model to the interactive model C functions are Java code generators As a result during the model initialization the Java code of the virtual lab view is automatically generated compiled packed into a jar file and executed Also the communication procedure between the model and the view is automatically set up This communication is based on a client server architecture the C program generated by Dymola 8 i e dymosim exe see Step iv is the server and the Java program which has been automatically generated during the model initialization is the client Once the jar file is executed the initial layout of the virtual lab view is displayed and the client server communication is established Then the model simulation starts During the simulation run there is a bi directional flow of information between the model and the view 3 Model description for interactive simula
19. ing of Dynamical Systems VirtualLabBuilder C Martin Villalba A Urquia and S Dormido Heat Flow Air Conditioning OON OFF Low Temperature K 22 16 19 High Temperature K 27 29 32 Bedroom 2 Air Conditioning heat flow rate WV 3 heat flow rate 0AN 0 4 1 0 time h 1 5 x10 1 0 time h Room Temperatures soning Room Temperature eG Bedroom 1 Temperature 40 0 g zn gt 30 0 S S a a 20 0 10 0 0 0 0 10 ae 1 Oo 10 125 18 time h x1 g time ih x1 g hi Bedroom 2 Temperature i Ambient Temperature 40 0 40 0 oO D 30 0 ade a a E 20 0 r E 20 0 g 2 Es time h o8 10 1 2 time h 1 4 107 0 8 1 4 x10 Figure 15 Dynamic response of some selected magnitudes views have been implemented using VirtualLabBuilder References 1 2 3 TOC 000 10 11 Dormido S 2004 Control learning Present and Future Annual Reviews in Control 28 115 136 Euler M and Muller A Physics learning and the computer A review with a taste of meta analysis In Proceedings of the 2nd Int Conference of the European Science Education Research Association Kiel Germany 1999 Esquembre F 2004 Easy Java Simulations a Software Tool to Create Scientific Simulations in Java Computer Physics Commu nications 156 pp 199 204 Easy Java Simulations website http fem um es Ejs Sysquake website http www calerga com Mod
20. ins instances of SlabView RoofView ExWallView and InWallView classes The view consists of a window that has a set of checkboxes at the bottom and the floor plan of the room at the centre see figure 12b The checkboxes allow the user to show and hide the windows associated to each building component of the room outer and inner walls slab and roof The diagram of the HouseView class is shown in figure 13a and the generated graphic interface is shown in figure 13b The view consists of a window that has a set of checkboxes at the bottom and a diagram of the house floor plan in the centre see figure 13b The checkboxes allow the user to show and hide the windows associated to the bedrooms 1 and 2 and to the living room Each room of the floor plan has a colour that change from blue to red depending on the room temperature The arrows shown in the floor plan represent the heat flow through the outer walls see figure 13b The width and orientation May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder 18 C Martin Villalba A Urquia and S Dormido fea panel f a pE 1 H a MainFrame C Show living room _ Show bedroom 1 _ Show bedroom 2 b Show Temperatures C Show Heat Flow C Show Sunspace Figure 13 HouseView class a diagram and b generated view of the arrows depend on the magnitude and the direction of the heat flow respectively The Modelica descri
21. lba A Urquia and S Dormido model interactiveModel model physicalModel StateSelection1 Boolean isState when CK 1 Enabled 1 then reinit ivars 1 end when reinit state1 Istate n11 end when when CK N Enabled N then reinit ivars CKstate N end when when CKstate N Enabled N then Istate reinit stateN Istate nN1 9NM end when when CK Enabled then reinit ivars end when Enabled 1 N Figure 3 Schematic description of the proposed modelling methodology for interactive simulation when clauses required to change the value of the interactive parameters and input variables These interactive magnitudes are represented by the ivars array and their new values specified interactively by the virtual lab user are represented by the I array The size of these arrays is equal to the number of interactive parameters plus the number of interactive input variables The when clauses are triggered by the boolean variables CK and Enabled When the value of any of these two variables changes from false to true then the ivars array is re initialized to the value of the I array There are defined as many components StateSelection1 StateSelectionN as different state variable choices are required e1 statel ey stateN The number of state variable choices to be sup ported by the virtual lab is
22. lve output and the water pump are modeled using JARA source models 5 2 Virtual lab view The Modelica description of the virtual lab view is shown in figure 7 It automatically generates the Java code of the interactive graphic interface shown in figure 8 The relationship between the Modelica description and the corresponding graphic interface is briefly explained next The Modelica model describing the view must extend the PartialView class which contains one pre defined graphic element root The root component has three components hosted inside it mainFrame of MainFrame class and dialog and dialog1 of Dialog class The components mainFrame and dialog generate the two windows shown in figure 8 The mainFrame layout policy is set to BorderLayout in order to allow selecting the position of the hosted elements i e north south centre east or west positions In this case three containers are placed inside mainFrame drawingPanel of DrawingPanel class and panelNorth and panelSouth of Panel class drawingPanel is placed in the centre of the mainFrame This component contains the animated diagram of the plant This diagram is composed of drawable elements of Polygon Oval Text and Arrow classes The liquid heating system pump and valve are represented by components of Polygon class The two con trollers are represented by components of Oval class and the set point of the liquid volume is represented by a component of
23. nted by arrows The width and orientation of the arrow are functions of the magnitude and the direction of the heat flow respectively Also the virtual lab view contains plots of some selected magnitudes see figure 15 6 1 The Modelica model of the solar house This solar house model is included within the Bondlib library 22 The model describes the thermodynamic behaviour of an experimental house located near the airport in Tucson Arizona with a passive solar heating system The house has four rooms two bedrooms a living room and a solarium that collects heat during the winter and releases it during the summer The living room has an air conditioning unit The four rooms are composed using models that describe the outer and inner walls the roofs the windows and the slabs The bond graph technique is used to model the physical laws of heat transfer between the basic components of the house regarding conduction convection and radiation A detailed description of the model can be found in 23 24 May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder An approach to virtual lab implementation using Modelica 15 Info window wan m Boiler Virtuwal lab x The folowing figure shows a schematic chagram of the boiler model The input of hquid water is placed at the bower bottom and the vapour output valve is placed at the top The water contained in the bower is contumally heate
24. odel shown in figure 2 include er 7h e2 V e3 F where e represents one particular choice of the state variables The state variable selection should be made so that it includes all the interactive magnitudes For instance if the user wants to change interactively the level value A the appropriate choice is ej h Likewise if the user wants to change the liquid volume then the right choice is eg V and if he wants to change the output flow then e3 F In addition changes in the value of interactive parameters can have different effects depending on the state variable choice Consider a change in the cross section A of the model in figure 2 for instance the user interactively changes A from 1 cm to 3 cm7 If the volume V is a state variable then the change in A produces an abrupt change in the value of the liquid level h and flow F while the liquid volume remains constant On the contrary if the state variable is the height A or the flow F these magnitude values would not change as the result of an instantaneous change in A but the volume would In some cases all interactive magnitudes can be selected as state variables Then the description of the interactive model as it was proposed in section 3 2 is straightforward However this is not always the case Consider for instance a virtual lab illustrating the dynamic behaviour of the model shown in figure 2 This virtual lab is required to support two wa
25. onents The graphic components have to be connected forming a structure whose root is the root element The connections among the graphic components determines their layout in the virtual lab view VirtualLabBuilder s graphic components and their connection rules are discussed in section 4 Virtual lab set up The virtual lab developer has to define a Modelica class describing the complete virtual lab This class has to extend the VirtualLab class which is within the VirtualLabBuilder library see figure la VirtualLab class has two parameters the class describing the virtual lab model and the class describing the virtual lab view These two classes have been programmed in Steps i and ii respectively The virtual lab designer has to set the value of these parameters by writing the name of these two classes In addition he has to specify how the variables of the model and the view Modelica classes are linked This is accomplished by writing the required Modelica equations inside the Modelica class defining the complete virtual lab Virtual lab translation and execution The virtual lab developer needs to translate using Dymola 8 an instance of the Modelica class defined in Step iii into an executable file i e dymosim eze file The virtual lab is started by executing this file Automatic code generation and run At the beginning of the simulation run some calculations are performed in order to solve the model at the initial time The init
26. outlet hole a and the pump parameter k Time dependent variables the liquid level h Input variables the voltage applied to the pump v The interactive model combines the dynamic behaviour described in the physical model and the abrupt changes in the value of the interactive magnitudes produced by the user s actions i The evolution in time of the interactive time dependent magnitudes is described by the physical model equations In addition their value can change abruptly as a result of the user s interaction ii The value of the interactive model parameters can be abruptly changed by the user s action remaining constant between consecutive interactive changes iii The value of the interactive input variables is interactively set by the user Their values change abruptly as a result of the user s action remaining constant between consecutive changes May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder An approach to virtual lab implementation using Modelica 5 Parameters represent time independent magnitudes Input variables represent boundary conditions which are not calculated from the model equations Although they are conceptually different the dy namic behaviour of interactive parameters and interactive input variables is the same Their values change abruptly at the interaction instants remaining constant between consecutive changes As a consequence both t
27. proach to virtual lab implementation using Modelica 3 Packages Ss E Virtual abB wilder z7 7 ap k i i f LabModels Virtuall ab Partialiew _ viewElements Pause InfoBut ParentA oot z i F ChildRoot Fe E ETE Label CheckEos PauseButton InfoButton Slider MumberField RadioButton Button Action ButhonaActoans J Crawables Es J nteractiveContrals H Es Examples m BD D H m Folgon Oval Text Array Trail Mechanics MainFrame Dialog Po la DrawingPanel PlottingPanel Figure 1 VirtualLabBuilder library a General structure and Classes within the following packages b InteractiveControls c Drawables and d Containers be performed automatically by a software tool However at the present time they have to be carried out manually by the virtual lab developer Virtual lab view The virtual lab developer has to define a Modelica class describing the virtual lab view This class has to extend another class named PartialView that is included in VzrtualLabBuilder library see figure la PartialView class contains a pre defined component the root element for the view description The classes describing the graphic components are within the InteractiveControls Drawables and Containers packages of VirtualLabBuilder library see figures 1b 1c and 1d respectively The virtual lab designer has to compose the virtual lab view class by instantiating and connecting the required graphic comp
28. ption of the complete view i e class View is shown in figure 14 This model extends the PartialView class and contains instances of the VirtualLabBuilder library components describing plots These plots are used to display the time evolution of the heat flow and the temperature in the rooms of the house 6 3 Vurtual lab set up and launch The virtual lab description is obtained as discussed in section 3 It is translated using Dymola and executed Then the jar file containing the Java code of the virtual lab view is automatically generated and executed The dynamic response of the solar house when the air conditioning is turned off is shown in figure 15 May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder An approach to virtual lab implementation using Modelica 19 house ye vy Livingroom ero E tq E fal fA Figure 14 Modelica diagram of the complete virtual lab view This change has been interactively performed by the virtual lab user at the simulated time 100 h The following six plots are shown in figure 15 1 the heat flow rate in bedroom 2 2 the heat flow rate of the air conditioning 8 the living room temperature and the setpoint value for the minimum and maximum temperatures 4 the bedroom 1 temperature 5 the bedroom 2 temperature and 6 the ambient temperature 7 Conclusions A novel approach to virtual lab implementation using Modelica language has been
29. represented by N The class of these components inherits from setParamVar see figure 3c In addition it contains the when clauses required to re initialize its state variable array i e state array to the values interactively set by the user i e Istate array The CK 1 N and Enabled 1 N arrays trigger the re initialization of the interactive parameters and input variables The CKstate 1 N and Enabled 1 N arrays trigger the re initialization of the interactive time dependent magnitudes The 2 th component of these arrays controls the 7 th instantiation of the physical system i e StateSelection2 The array Enabled 1 N indicates which state variable selection is enabled It is used to select which output is connected to the output variables O These are the variables used to refresh the virtual lab view May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder An approach to virtual lab implementation using Modelica 9 A VirtualLabBuilder library VirtualLabBuilder library is composed of the packages shown in figure la Some of them are intended to be used by the virtual lab developers i e VirtualLabBuilder users These are 1 ViewElements and VLabModels packages which contain the classes required to implement the virtual lab view and to set up the complete virtual lab and 2 Examples package which contains some tutorial material illustrating the library
30. s Label and Checkbox In addition the PauseButton class creates a button that allows the user to pause and resume the simulation by clicking on it The InfoButton class creates a button that allows the user to show and hide a window displaying HTML pages This feature allows including documentation in the virtual lab That is to say it supports the implementation of the virtual lab introduction 4 2 Connection rules The interface of the interactive graphic components is composed of connectors which facilitate the con nection among the components Four connector types have been defined Each one has a distinctive icon Connector icons are squared or circular empty or filled The following two types of interfaces have been defined see figures 1b 1c amp 1d May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder 10 C Martin Villalba A Urquia and S Dormido panelN i dPanel MAIM MainF rame root Show plot mainFrame fo i sac f Hi anels e a 0 40 A 2 00 0 10 0 25 0 40 0 55 0 70 1 00 1 75 2 50 3 25 4 00 v 0 01 h 3 28 g o m ii 0 00 0 25 0 50 0 75 1 00 1 00 3 25 5 50 7 75 10 00 time s a Figure 4 Tank process a Modelica description of the virtual lab view and b virtual lab Interface of container components It has three connectors see figure 1d Two placed on one side called left connectors
31. same trajectory This procedure is briefly discussed next i The physical model has to be modified as it was described in section 3 2 In case of the model shown in figure 2 the physical model could be composed of the connection of three components 1 the May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder An approach to virtual lab implementation using Modelica 7 pump modelling the input flow of liquid Fin kv 2 the tank describing the conservation of the liquid volume dV dt Fj F and the relationship between the volume and the level of the liquid V Ah and 3 the pipe describing the output flow of liquid F a 2gh This physical model could be modified as it is shown next It is supposed that three selections of the state variables are required e1 h eg V and e3 F model tank parameter Boolean hIsState false parameter Boolean VIsState false Real h stateSelect if hIsState then StateSelect always else StateSelect never Liquid level Real V stateSelect if VIsState then StateSelect always else StateSelect never Liquid volume parameter Real Ainitial Initial value of the tank section Real A start Ainitial Tank section Interactive magnitude equation der A 0 end tank model pipe Real F stateSelect if FIsState then StateSelect always else StateSelect never Liquid flow parameter Real aInitial 1 Initial valu
32. tank process has only one state selection and one state variable the liquid level The mainFrame and dialog components are hosted inside root The dPanel panelS and panelN components are hosted inside mainFrame The C component is hosted inside panelN The pipe vase liqPipe and liquid components are hosted inside dPanel The a A v and h components are hosted inside panelS The plot component is hosted inside dialog Finally the component trail of Trail class is hosted inside plot The window showing the component parameters is displayed by double clicking on the component icon The parameter windows of the components trail a and mainFrame are shown in figures 5a 5b and 5c respectively May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder An approach to virtual lab implementation using Modelica 11 a in tank T Output tank TOUT pouty ew Add modifiers General trail in tank TOUT putT Ss tank TOOT poty ew Component Add modifiers Hame a Component Comment Hame trail Model Comment Fath YirtualabBuilderWiewE lements InteractveContrals Slider Model Comment Fath YirtuallabBuilder view lements Drawables Trail Comment Farameters position CE NT ER rg Position inside its container Parameters stingF ormat a 0 00 gt Format of the text displayed by the component masimumPoints 1000 Maximum number of points to be drawn tickFormat 1 00 Format of
33. the automatic control of an industrial boiler section 5 and 2 the implementation of a virtual lab describing the thermodynamic behaviour of a solar house section 6 2 Overview of the proposed approach The virtual lab definition includes the description of the introduction the model the view and the bidi rectional flow of information between the model and the view Next the virtual lab definition process is outlined i Virtual lab model Any Modelica model can be transformed into other Modelica model suitable for interactive simulation A systematic methodology to perform this transformation is proposed in section 3 Essentially it consists in modifying the model so that all the variables that need to be changed interactively during the simulation i e the interactive variables are formulated as state variables In particular parameters are redefined as time dependent variables whose time derivative is equal to zero Input variables are reformulated analogously in order to become interactive variables Modelica s when clause and reinit operator allow describing instantaneous changes in the value of the state variables This feature is exploited in order to perform the instantaneous changes in the value of the interactive variables produced by the user s interaction Some of these model manipulations could May 4 2007 iii iv 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder An ap
34. the text displayed with the ticks nSkip 10 Humber of points to skip before plotting one tickNumber 3 Number of ticks Ine Ean EF ae sJ ee coio minimum 01 a Minimum value of the variable linked to the component maximam 0 7 e Maxinum value of the variable linked to the component connected gt Whether to connect next point with the previous gt factor Scale factor enable tue rao True if the component iz enabled mamkrame in tank 1Outputi ss tank 1 Outputview Component Hame mrainF rame Comment Main ie Model Fath Virtuall abBuilder iewE lements Containers MainFrame Comment Parameters title hiai Frame f Test display as title sFostion i ip s coordinate of the window upper left comer in pixels yPosition 0 fe Y coordinate of the window upper left comer in pixels width 500 Window width in pixels Height 500 Window height in pixels LayoutPolicy BorderL ayot ify iv Layout policy nA owg fe Number of rows when GridLayout policy is selected AlColumne f Number of columns when GridLayout policy iz selected Figure 5 Parameter window of the components a trail b a and c mainFrame 5 Case study I virtual lab of an industrial boiler The approach discussed in the previous sections is applied to the implementation of a virtual lab for control education This virtual lab is intended to illustrate the dynamic behaviour of an industrial boiler operating
35. tion using Modelica language A methodology for transforming any Modelica model into a description suitable for interactive simulation is proposed in this section The following terminology will be used The original model of the system is called physical model and its reformulation for interactive simulation is called interactive model The model shown in figure 2 will be used to illustrate the discussion The voltage applied to the pump v is an input variable i e its value is not calculated from the model equations The cross sections of the tank A and the outlet hole a the pump parameter k and the gravitational acceleration g are parameters i e time independent magnitudes of the model The liquid volume V the input and output flows Fin F and the liquid level h are time dependent variables of the physical model 3 1 Interactive magnitudes The virtual lab design process includes selecting the interactive magnitudes These are the model magni tudes whose value will be interactively changed by the user during the simulation run The virtual lab goal is illustrating the dependence between the model dynamic behaviour and the value of these magnitudes Interactive magnitudes can be parameters input variables and time dependent variables of the physical model For instance some interactive magnitudes of the model shown in figure 2 could be the following Parameters the cross sections of the tank A and the
36. translated using Dymola and executed Then the jar file containing the Java code of the virtual lab view is automatically generated and executed Then the virtual lab view is displayed see figure 8 The dynamic response of the boiler to a step change in the output pressure is shown in figure 10 This change has been interactively performed by the virtual lab user at the simulated time 243 s The boiler is operating in automatic control mode The following four plots are shown in figure 10 1 the actual value of the vapour flow and its setpoint 2 the heat generated by the heater 3 the actual value of the water volume contained inside the boiler and its setpoint value and 4 the liquid flow rate generated by the pump 6 Case study II virtual lab of a solar house The implementation of a virtual lab intended to illustrate the thermodynamics of a solar house is discussed This virtual lab allows the user to 1 change the thermodynamic properties of the slab the outer and inner walls and the roof 2 turn on and off the air conditioning which is placed in the living room and 3 set the parameters of the air conditioning control system i e the setpoints for the minimum and maximum values of the temperature The virtual lab view contains the floor plan of the house see figure 13b The room colours change between blue and red as a function of the temperature inside the room The heat flow through the outer walls are represe
37. ttp www tandf co uk journals DOT 10 1080 1387395 Y Yxxxxxxxx May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder 2 C Martin Villalba A Urquia and S Dormido the use of Modelica reduces considerably the modelling effort and permits better reuse of the models In addition a number of free and commercial Modelica libraries in different domains are available 6 including electrical mechanical thermo fluid and physical chemical However neither Modelica language nor Modelica simulation environments i e Dymola 8 OpenMod elica 9 etc support interactive simulation As a consequence extending Modelica capabilities in order to facilitate interactive simulation i e virtual lab implementation is an open research field 10 13 Pre vious work on this topic addresses the combined use of Modelica Dymola and other software tools 11 13 the virtual lab model is described using Modelica and the virtual lab view is implemented using software tools suited for building interactive user interfaces In particular the combined use of Modelica Dymola Matlab and Easy Java Simulations is proposed in 11 13 and the combined use of Modelica Dymola and Sysquake is proposed in 12 1 1 Contributions of this paper The goal of the work discussed in this manuscript is to facilitate the description of virtual labs using Modelica language To achieve this goal the following two tasks have been
38. ulate the model according to the requested state selection The problem is that these model manipulations can require differentiating an interactive parameter or input variable which results in an error being generated An example is discussed next Consider the model shown in figure 2 It is formulated according to the state selection ey V The model can be manipulated as shown below in order for h to be a state variable instead of V The variable to evaluate from each equation is written within square brackets IF ay 2gh 1 May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder 6 C Martin Villalba A Urquia and S Dormido Fin kv 2 lderV Fy F 3 V Ah 4 5 derV h A ie 5 The time derivative of the tank cross section i e A appears in Eq 5 If the interactive magnitude A is defined as an input variable then an error is produced Dymola can not differentiate an input variable The same problem arises if A is defined as a discrete time variable A valid approach is the previously discussed defining the interactive parameters and input variables as constant state variables i e A 0 The interactive changes in the value of these magnitudes are implemented by re initializing their values 3 3 Supporting multiple selections of the state variables In general different choices of the state variables are possible For instance possible choices in the m
39. under two different control strategies manual and decentralized PID 5 1 Vurtual lab model The mathematical model of the boiler has been extracted from 18 The input of liquid water is placed at the boiler bottom and the vapour output valve is placed at the top The water contained in the boiler is continually heated The boiler model has been composed using components from JARA 2i 19 a version of JARA library 120 21 that has been adapted for interactive simulation by applying the methodology proposed in section 3 JARA is a Modelica library of some fundamental physical chemical principles JARA s main application domain is the modelling of transport thermo fluid phase change and chemical processes in the context of automatic control The model diagram of the boiler and its control system is shown in figure 6 Two control volumes have May 4 2007 9 44 Mathematical and Computer Modelling of Dynamical Systems VirtualLabBuilder 12 C Martin Villalba A Urquia and S Dormido MolFSP i La g b V Figure 6 Diagram of the boiler model been considered 1 a control volume containing the liquid water stored in the boiler and 2 a gaseous control volume containing the vapour The vapour volume is equal to the difference between the boiler recipient inner volume and the water volume The boiling is a transport phenomena represented by a model connecting both control volumes The heat flow into the boiler the pressure at the va
40. use The documentation of these packages is oriented to the VirtualLabBuilder users On the contrary the classes within the src package are not intended to be directly used by the virtual lab developers The documentation of this package describes the implementation details required to modify and extend the VirtualLabBuilder library In fact the classes within ViewElements and VLabModels packages inherit from classes defined within src package inheriting the structure and the behaviour and adding only the documentation oriented to the virtual lab developer VLabModels package contains two classes PartialView and VirtualLab The purpose of PartialView and Virtu alLab classes was briefly described in section 2 They have to be the super classes of the models defining the virtual lab view and the complete virtual lab respectively Further details can be found in the Virtu alLabBuilder library documentation ViewElements package is discussed next 4 1 Interactive graphic elements ViewElements package contains the graphic elements that can be used to define the view The initial sections of these elements contain calls to Modelica functions that perform calls to external C functions These C functions write the Java code of the elements to a file generating automatically the Java application i e a jar file that is the virtual lab view The three packages included within ViewElements are briefly described next A detailed description of thes
41. ypes of interactive magnitudes are described in the same manner in the interactive model 3 2 Description of the interactive magnitudes In order to support abrupt changes in their values during the simulation run interactive magnitudes need to be state variables of the interactive model The interactive model is obtained from the physical model by reformulating when required the declaration and evaluation of the interactive magnitudes so that they become state variables of the interactive model To this end the virtual lab developer has to perform the following tasks Time dependent variables need to be selected as state variables Modelica 2 0 and Dymola support the user s control on the state variables selection via the stateSelect attribute of Real variables 8 15 17 This attribute values include never the variable will never be selected as state variable and always the variable will always be used as a state This feature allows the user to select the model state variables without performing any manipulation on the model equations The required model manipulations are automatically performed by Dymola Parameters and input variables are redefined as time dependent variables with zero time derivative and they are selected as state variables For instance the parameter A of the tank model shown in figure 2 should be a Real variable of the interactive model calculated from the equation der A 0
42. ys of describing the interactive changes in the amount of liquid contained in the tank changes in the liquid volume V and changes in the liquid level h Each time the user needs to change the amount of liquid he can choose between describing it in terms of the volume or in terms of the level Different choices are possible during a given simulation run However V and h can not be simultaneously selected as state variables An approach to allow interactive models supporting simultaneously different choices of the state variables is the following Modelling the interactive model as composed of several instantiations of the physical model each one with a different choice of the state variables Modelica capability for state selection control i e stateSelect attribute allows the virtual lab developer to select the state variables without performing any model manipulation Therefore the interactive model is composed of as many instantiations of the physical model as different state selections are required The adequate physical model instantiation i e that with the required state selection is used for executing each interactive action from the user That is to say for performing the abrupt changes in the value of the interactive magnitudes and for solving the re start problem Next these calculated values are used to re initialize the other physical model instantiations This action guarantees that all physical model instantiations describe the

Download Pdf Manuals

image

Related Search

Related Contents

Desa 10BY150ECB Electric Heater User Manual  pate a joint eau potable  Jazz - Free  Sistema estéreo con reproductor de discos compactos  Image Management Service Manual    

Copyright © All rights reserved.
Failed to retrieve file