|
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 automaticaly added.
See also
Model applicability test
1. Java is a trademark of Sun Microsystems, Inc.