User subroutines

<< Click to Display Table of Contents >>

Navigation:  Users manual > Subroutines >

User subroutines

User subroutines are designed to computing user-defined fields that are not initially available in the list of fields of the QForm UK program, as well as for expanding the possibilities of specifying flow stress in a workpiece and friction on the contact. The following types of user-subroutines are possible:

1.Post-processing (executed after simulation)

2.Processing (executed during simulation)

a.dependent only on standard fields

b.dependent on standard and user-defined fields

Just like standard fields, user-defined fields are calculated in each node and displayed using standard viewing tools.

User subroutines in QForm UK are written in a specialized language Lua (refer to www.lua.org), designed for creating built-in applications. This manual is not a guide the Lua programming language. More information about the syntax of the language can be found at the link above.

Advantages of the Lua language over alternative solutions such as Fortran and Visual Basic:

No compiler is needed. The compilation tool is built into the host program (QForm UK12) and works with no user interaction;

Simple syntax;

Its use is free of charge.

Application code in Lua can be written in a standard text editor (Notepad). It is recommended to use the advanced text editor Notepad++ (www.notepad-plus-plus.org). The file extension must be *.lua, the name and location do not matter.

According to the Lua terminology — QForm UK is a host program that includes a so-called JIT-compiler (English just-in-time - "on the fly").  User subroutines have access to all standard fields and variables in QForm UK, as well as to the fields of other standard subroutines (refer to the table below). The fields are defined in each node of the finite-element mesh of a workpiece and a tool. Note that the variable names in the Lua language are not always the same as fileds names in the QForm UK interface, and are measured in SI (metric) units.

All fields in the Lua language are accessible in two variations - value at the current step (for example, the temperature value in the current node at the current step - T) and at the previous step - with the prefix prev_ (for example, the temperature value in the current node at the previous step is prev_T). The variable dt does not have a previous value.

The following are lists of standard variables available in user-defined subroutines.

hmtoggle_arrow1For workpiece
hmtoggle_arrow1For tool
hmtoggle_arrow1For friction conditions