Multi_R_Designer Tutorial |
How to add user model to Multi_R_Designer
This tutorial shows you the steps to follow to add a new model to Multi_R_Designer.
Requirements
1.The JavaTM 2 Platform, Standard Edition. You can download it from Sun Microsystem inc.
2. A text editor. On Windows platforms, you can use Notepad.
3. The models must be written in Java language. If your are not familiar with Java programming language, it is strongly recommended to read some of the Java Tutorial (at least Your First Cup of Java ).
Multi_R_Designer Model Architecture
When you start Multi_R_Designer, the software scans the directory TrickleBed/user/models to find the user's models.
A model is composed of three kinds of files :
1. A Model
Information file (.info) : It contains the model name, inputs, outputs
and much more informations (like validity range and comments).
2. A Java Source
File (.java) : The source code of the model.
3. A Java Bytecode
(.class) : The compiled version of the source code used by the software.
Your First Model
As an example, Ring and Missen have developed
a model predicting Dynamic liquid holdup. (Ref: Can. J. Chem. Eng., vol
69, pp 1016-1020, 1991).
The correlation is defined by :
Where UL is the Liquid superficial velocity in SI unit (m/s).
1. Create a new model
Click on Create to begin the model creation.
2. Choose a Filename
Enter the model name. If you don't want to generate a
Java Template
File, deselect the box. However, this option simplify the creation
of the model java source code.
3. Edit model information
Only the fields: Name,
Input
and Output are
required.
Field | What to do |
Name | Enter "Ring and Missen (1991)". |
Input | Click on the button "Add" and select Liquid superficial velocity in the list of properties. |
Output | Click on the button "Add" and select Dynamic liquid holdup in the list of properties. |
When all required fields are defined, press OK.
The model information is then saved in TrickleBed/user/models/Weekman.binfo.
If you have selected the template file option,
a Java source file is created in the same directory in which you
can write your code (your model).
4. Write your code for the model
Use the editor of your choice to edit the code.
An example of a template file generated by the Model Info Editor is shown below (Weekman.java).
import multirdesigner.model.*;
public class Ring extends
MRDModel
public Number
[] compute(Number inputs[]) throws Exception
// Enter your code here. // Outputs
return new
Number [] {new Double(output0)};
|
MRDModel is the abstract class used by the software as a valid model object. All models extend this class. |
The function public Number [] compute(Number inputs[]) throws Exception must be defined. This function is called by Multi_R_Designer for all simulations. All inputs and outputs units must be in the SI system. |
Modification to do
a) Rename the variable
input0
by ul
b) Rename the variable
output0
by hd
c) Enter the correlation
hd=15.51*Math.pow(G,0.679)
d) Save the file
with the modifications
Solution (Ring.java)
import multirdesigner.model.*;
public class Ring extends
MRDModel
public
Number [] compute(Number inputs[]) throws
Exception
// Outputs
return
new Double[] { new Double(hd) };
|
5. Compile the source file
a) Open a command shell (Command Prompt
on Windows).
b) Go to your user model directory (cd
C:/Program Files/Multi_R_Designer/TrickleBed/user/models)
c) Verify that modellib.jar
is in this directory
d) Type javac -classpath modellib.jar
Ring.java
The next time you start Multi_R_Designer, your model will be automatically
added.
See also Model
applicability test
When you perform a simulation, you can get information on the model's
applicability for the results. The graphical representation of valid results
are depicted by filled symbols. It can be done using two methods described
below.
REMARK:
This tutorial is the follow up of the How
to add user model to Multi_R_Designer Section.
If you do not want to read this tutorial, you can download the solution and extract the files to TrickleBed/user/models. |
Setting inputs/outputs applicability ranges in the model information dialog window
1. Edit model information (Applicability page)
Add the physical property Liquid superficial velocity in the Range panel and set the range from 1.4E-4 to 8.3E-4 m/s. When all required fields are defined, press OK.
The next time you start Multi_R_Designer, your model will be automatically
updated.
Setting the model applicability specifications inside the code
In some models, applicability variables are used even if they are not
part of the model inputs. In this case, you should use the following method
to set the applicability range. The function void
setValid(boolean bvalid) defined in the
abstract class MRDModel is used to modify the internal applicability variable.
Use the function void setValid(boolean bvalid) only in the function public Number [] compute(Number inputs[]) throws Exception to set the applicability for each simulation. |
import multirdesigner.model.*;
// This is not a true model public class ValidSampleModel
extends
MRDModel
public
Number [] compute(Number inputs[]) throws
Exception
// Reynolds number
setValid(ReL < 10); // Valid for Reynolds less than 10.
/ Outputs
return
new Double[] { new
Double(z) };
|
Multi_R_Designer Tutorial |