In order to illustrate a complex UDF, assume two material parameters
A
and B
depend upon the same
multi-ramp function U(X)
:
A = FA(U(X)), B = FB(U(X));
with
FA = A0 + U(X)*(A1 + U(X)*(A2 + U(X)*(A3 + U(X)*A4))) FB = B1 * (U(X) – B0)
The multi-ramp function U(X)
has 2000 values
() given with a constant step of length
deltaX
:
The number of points:
nX
= 2000The increment of X:
deltaX
= 0.0005428414207103552The minimum value of X:
xMin
= 0The maximum value of X:
xMax
=xMin+(nX-1)*deltaX
The estimated maximum values of ()
UValueMax
= 1000The estimated minimum values of ()
UValueMin
= 900
Since both UDFs FA
and FB
use
the same multi-ramp function, sub-functions will be used to obtain
U(X)
.
In order to illustrate the error code, assume the functions
FA
and FB
return a relevant
value if X
is within the range between
xMin
and xMax
. Therefore, one
needs to check the X
value with respect to
xMin
and xMax
. This could
occur with the divergence of the iterative procedure for a step. In this case, the
UDF will return a non-numeric value (T)
that will be
interpreted as an error code leading to the ending of the current evolution step.
This latter will be restarted with a lower evolution step.
Because there are many values for the multi-ramp function, by reading the file, it
is not easy to determine if they are correct or if there is a syntax error. It is
recommended to check if the number of values is correct, if the type is correct, if
the range of values is correct [UValueMin, UValueMax]
, etc.
This check can be time consuming, so it should be performed only once.
For X
belonging to the interval (i)
, the function U(X)
is given as
(32–11) |
with
(32–12) |
In term of CLIPS:
There are two UDFs:
FA(X)
andFB(X)
.Constant data are stored using global CLIPS variables:
Parameters
Ai
andBi
ofFA
andFB
functions.U
values and associated data.Interval values:
Working variables.
There are sub-functions called by both UDFs.
There are sub-functions to manage the error:
InitError()
to initializes the error code.DeclareError()
to declare an error.
There are sub-functions to check the validity of argument and data:
the function
IsXValid(X)
checks the validity of X with respect toxMin
andxMax
,the function
IsDataValid()
checks the validity ofU
values (number, type, etc.).
There are sub-functions related to the multi-ramp function:
a function
GetIntervalValues(X)
to get the interval values,a function
GetUValue(X)
returning the valueU(X)
.
The global variables related to the interval values: are computed by the function
GetIntervalValues()
that are called by the both UDFsFA
andFB
. If those values are initially computed inFA
, even if they are global and thus accessible fromFA
andFB
; for parallelization reason you cannot reuse the interval values fromFA
inFB
. Instead, you again have to callGetIntervalValues()
fromFB
.