Customization Manager
Custom Correlations Description and Quick Guide
Flow Simulator has three customization methods to add capabilities and correlations that are not available in the software as distributed by Altair. These correlations may be based on company proprietary methods or may be in the public domain. If the correlations are in the public domain, contact Altair about the possibility of adding the correlations to the distributed version of the software.
- User Defined Elements (UDEs)
UDE’s allow for an entire element to be added. In the user interface, the UDE Designer is used to create the UDE and define all required inputs. The UDE code (Python or Fortran) must include everything required to relate the inputs and boundary conditions to the thermo-fluid behavior of the element. This is a very flexible method but requires a higher level of expertise to implement. See User Defined Element (UDE) for more information.
- Controllers
The controller manipulates a specific part of an element solution. For instance, the Feed-Forward controller can be used to calculate a Heat Transfer Coefficient (HTC) based on a set in the “gauge” variables. The HTC is then applied to an element as a “manipulated” variable. Controllers are very flexible and do not require as much expertise as a UDE to implement. The controller can be tedious to implement on numerous items in a model, however. See Controllers for more information.
- Custom Correlations
The last customization option has a limited set of items that can be manipulated but is easy to implement on many elements. The items that can be manipulated by the custom correlation option include HTC’s, friction, and seal losses. If there is an item that you would like added to the custom correlations, Contact Altair if there is an item that you would like added to the custom correlations. The user interface customization manager defines the custom correlation.
Items That Use Custom Correlations
The following table shows the items that can have a custom correlation and the Flow Simulator modeling item (element, resistor, and so on) that can use the correlation.
Item (Subtype) | Description | Applies to These Elements |
---|---|---|
TURBULENT_FRICTION_FACTOR | Friction coefficient used to calculate pressure loss along length of element. Re in turbulent flow range. | CT, IT, AO, TP |
LAMINAR_FRICTION_FACTOR | Friction coefficient used to calculate pressure loss along the length of the element. Re in laminar flow range. | CT, IT, AO |
TURBULENT_DUCT_NU | Heat Transfer Coefficient. Re in Turbulent. | CT, IT, AO |
LAMINAR_DUCT_NU | Heat Transfer Coefficient. Re in Laminar. | CT, IT, AO |
NU_INLET_EFF | HTC multiplier to account for boundary layer developing at the start of the element. | CT, IT, AO |
FREE_CONV_NU | Heat Transfer Coefficient | Convectors (Thermal Resistor) |
FLAT_PLATE_NU | Heat Transfer Coefficient | Convectors (Thermal Resistor) |
CYL_XFLOW_NU | Heat Transfer Coefficient | Convectors (Thermal Resistor) |
INLET_K | K loss = Ptotal Drop/Dynamic Pressure | CT, IT, AO |
CAV_FRICTION_DISK_ROTOR | Friction coefficient used to calculate torque and windage between fluid and cavity surface. Surface is vertical and rotating. | Cavity Surface |
CAV_FRICTION_DISK_STATOR | Same as above, but surface is vertical and rotating. | Cavity Surface |
CAV_FRICTION_CYLINDER_ROTOR | Same as above, but surface is horizontal and stationary. | Cavity Surface |
CAV_FRICTION_CYLINDER_STATOR | Same as above, but surface is horizontal and stationary. | Cavity Surface |
VERMES_KEMULT | A vermes seal loss factor. See Verme Seal Element for more information. | Vermes Seal |
VERMES_KFAC | Vermes Seal | |
VERMES_SLMULT | Vermes Seal | |
VERMES_HCMULT | Vermes Seal | |
VERMES_GRVMULT | Vermes Seal |
- CT=Standard Compressible Tube
- IT=Incompressible Tube
- AO=Advanced Orifice
- TP=Turbulated Passage
- Re=Reynolds Number
Custom Correlations in the Graphical User Interface (GUI)
- Create the custom item in the Customization Manager.
- Select the custom item from the element properties editor.
From the PreProcessing menu, select the customization manager.
Create a Custom Item
- Click New to create a new custom item.
- Give the item a name; no spaces allowed in the name.
- Select the programming language: Python or Fortran.
- Select the subtype for the custom item.
- Select English or SI units to control the units of variables passed between the custom code and the Flow Simulator solver.
- Define the unique inputs for the custom items. These can be used to add
inputs for each element that uses this custom item. These variables are
added to the argument list for the Python and Fortran custom routines. No
spaces are allowed in the names.
- If Language=Python, write the Python code. Use the Restore button to update the Python code template that is supplied.
- If Language=Fortran, a unique ID can be given so that multiple items of the same subtype can be programmed in the same Fortran subroutine. The other option is to use a unique subroutine name for each item.
- If Language=Fortran, a unique DLL and subroutine names can be given. “Default” means the solver uses customize.dll and the subroutine names are found in the fs_custom_lib.f example file.
- Use Export to write a file containing all custom items in the current model.
- Use Import in another model to read all custom items into the model.
Custom Correlation in an Element
Once the custom correlation is created, it can be used in the element. Select the appropriate element type and property as shown in the table above. For instance, the “TURBULENT_FRICTION_FACTOR” subtype can be used in the Compressible Tube, Incompressible Tube, Advanced Orifice, and Turbulated Passage elements.
Another row is displayed to add input for the custom correlation. Currently there are no units associated with these inputs. The values entered are the values passed to the custom correlation.
Units in the Custom Correlation
Flow Simulator uses English units (inch, lbm, BTU) by default. However, the custom correlation has the option to use SI units (m, kg, W). If the SI unit set is selected, the values of the input arguments are scaled by Flow Simulator to SI units before being passed to the custom correlation, and the correlation can return the output arguments in SI units. The user input is the exception to this and are not scaled.
Custom Correlations in Fortran
The custom correlations can be written in Fortran or Python. Creating a Fortran correlation is more complicated than Python but may run faster than Python. Use the method you are more comfortable with. Flow Simulator reads a dynamic linked library (DLL) for the Fortran correlation. The default name is customize.dll, but you can specify the name in the customization manager. Flow Simulator can read multiple DLL’s if needed. For example, all custom correlations can be put in the same DLL or each correclation can have a different DLL file.
A sample custom correlation Fortran source code file is distributed with Flow Simulator. The file can be found in <FlowSimulator_install_folder>\Resources\Customize\fs_custom_lib.f. This file contains a sample subroutine for each of the custom correlation subtypes. Your Fortran file does not have to have all 18 subroutines in this file; it only needs the subroutines for the correlations used in your model.
The comments in the file describe the subroutine arguments. The arguments are the typical values needed by the correlation. The arguments also include an array containing the user-defined inputs. The order of the inputs in the array are the same as the user defined inputs in the customization manager.
- CUST_GET_SET_REFERENCE_CONDITION
- CUST_GET_FLUID_PROP
- <FlowSimulator_install_folder>\Resources\Customize\reference\custom_interface_mod.f90
- custom_param_mod.f90
CUST_GET_SET_REFERENCE_CONDITION is based on the Flow Simulator controllers and can be used to retrieve (gauge or GET) and manipulate (SET) many items in the model.
CALL CUST_GET_SET_REFERENCE_CONDITION (GET_MODE, ELEMENT_TYPE, ELEM, IDX, "NONE", 0, 0, "PS", PS, ISTATUS)
CALL CUST_GET_SET_REFERENCE_CONDITION (GET_MODE, ELEMENT_TYPE, ELEM, IDX, "NONE", 0, 0, "AREA", AREA, ISTATUS)
CUST_GET_FLUID_PROP retrieves fluid properties based on the pressure and temperature supplied.
CUST_PRP_INP(1) = CUST_PRP_P
CUST_PRP_INP(2) = CUST_PRP_T
CUST_PRP_VIN(1) = PS
CUST_PRP_VIN(2) = TS + 459.67
CUST_PRP_LOUT = .FALSE.
CUST_PRP_LOUT(CUST_PRP_CON) = .TRUE.
CALL CUST_GET_FLUID_PROP(CUST_PRP_INP, CUST_PRP_VIN, CUST_PRP_LOUT, CUST_PRP_VOUT, ELEM, CUST_FLOW_ELM, ISTATUS)
K = CUST_PRP_VOUT(CUST_PRP_CON)
The file custom_param_mod.f90 contains parameters such as ELEMENT_TYPE and CUST_PRP_P.
The INTEL Fortran compiler (v19.0.4.245) was used for development testing of this feature. Other compilers and versions may work but have not been tested. Compiling and linking should be done for 64-bit to be compatible with Flow Simulator. The fs_custom_lib.f uses the Fortran fixed format but with lines up to 132 columns, so use these compiler options. An example in Visual Studio:
Custom Correlations in Python
The Python code for a custom correlation is entered in the user interface Customization Manager. Each custom correlation subtype has a Python code template that shows the arguments passed to the correlation and the expected variables the code must fill and pass back to Flow Simulator. Any user-defined inputs are appended to the end of the argument list. The arguments in the “def” line do not need to be used in the custom correlation; only use what is required by your equations. The variables in the “return” line must be set to a value in your code.
The Python language uses the line indentation to recognize programming units so it's very important that the line indentation of the added code is consistent. The template uses a tab at the beginning of each line so each new line must begin with at least one tab.
- cust.get_set_reference_condition
- cust.get_fluid_prop
The arguments are like the Fortran code except that the returned values are not in the argument list.
propval = cust.get_set_reference_condition (mode, itemtype, itemnum, prop, locat1, locat1_str, locat2, locat3)
mode = GET (1) or SET (2)
itemtype = CHAMBER=3, ELEMENT=4, THERMAL=7, GENERAL=1, MISSION=2, COMPONENT=8
itemnum = Number from the .flo file of the item (chamber, element, etc..)
prop = A property name recognized by the controller (like "PT", "PS", "TT", "MDOT_TOTAL" etc..)
locat1 = First additional index. Ex: 5 for tube station 5, 0 if not needed
locat1_str = Only needed if itemtype=7 (Thermal). Then use "TNODE", "CDUCR", "CVECR", "RADTR", "HEAT_FLOW". "NONE" if not needed.
locat2 = Second additional index. Ex 2 for tube wall side 2, or 4 for TNODE 4, 0 if not needed
locat3 = Third additional index. Ex "2" for ?, 0 if not needed, etc..
propval = value returned from controller for "GET" and sent to controller for "SET"
pstatic = cust.get_set_reference_condition (cust.GET_MODE, cust.ELEMENT_TYPE, int(elem), "PS", int(idx), "NONE", 0, 0)
area = cust.get_set_reference_condition (cust.GET_MODE, cust.ELEMENT_TYPE, int(elem), "AREA", int(idx), "NONE", 0, 0)
propval = cust.get_fluid_prop (inp_type_1, inp_val_1, inp_type_2, inp_val_2, out_type, itemnum, ec_flag)
inp_type_1 = first independent variable type (typically pressure so use cust.PRP_P parameter)
inp_val_1 = value of the first independent variable
inp_type_2 = second independent variable type (typically temperature so use cust.PRP_T parameter)
inp_val_2 = value of the second independent variable
out_type = the fluid property to output
itemnum = Number from the .flo file of the element
ec_flag = identifies itemnum as an element or chamber (cust.FLOW_ELM)
cust.PRP_P | 1 | pressure used to get properties (psi) |
cust.PRP_T | 2 | temperature used to get properties (deg R) |
cust.PRP_QUAL | 3 | quality |
cust.PRP_RHO | 4 | density, (LBM/FT^3) |
cust.PRP_CP | 5 | specific heat at constant pressure, BTU/(LBM R) |
cust.PRP_CV | 6 | specific heat at constant volume, BTU/(LBM R) |
cust.PRP_GAM | 7 | gamma |
cust.PRP_CON | 8 | conductivity, BTU/(HR FT R) |
cust.PRP_VIS | 9 | dynamic viscosity, LBM/(HR FT) |
cust.PRP_PR | 10 | Prandtl number |
cust.PRP_MW | 11 | Molecular Weight, (lbm/lbmole) |
cust.PRP_R | 12 | Gas constant, (FT LBF)/(LBM R) |
cust.PRP_H | 13 | Specific Enthalpy (BTU/lbm) |
cust.PRP_S | 14 | Specific Entropy (BTU/lbm/R) |
cust.PRP_TSAT | 15 | Saturation Temperature (deg R) at the Pressure provided |
cust.PRP_HVAP | 16 | Heat of vaporization (BTU/lbm) (Specific Enthalpy Vapor - Specific Enthalpy Liquid) |
cust.PRP_PCRT | 17 | Critical pressure (psia) |
k = cust.get_fluid_prop (cust.PRP_P, pstatic, cust.PRP_T, tstatic, cust.PRP_CON, int(elem), cust.FLOW_ELM)