<< Click to Display Table of Contents >> The RAMP Function |
The RAMP function is a modification of the URAMP function, intended to make the usage more nearly like an IF..THEN statement.
It has been introduced to provide an alternative to discontinuous functions like USTEP and the discontinuous IF..THEN construct.
Discontinuous switching can cause serious difficulties, especially in time dependent problems, and is strongly discouraged. FlexPDE is an adaptive system. Its procedures are based on the assumption that by making timesteps and/or cell sizes smaller, a scale can be found at which the behavior of the solution is representable by polynomials. Discontinuities do not satisfy this assumption. A discontinuity is a discontinuity, no matter how close you look. Instantaneous turn-on or turn-off introduces high-frequency spatial or temporal components into the solution, including those which are far beyond the physical limits of real systems to respond. This makes the computation slow and possibly physically meaningless.
The RAMP function generates a smooth transition from one value to another, with the transition taking place as "expression" changes by and amount "width". It can be thought of as a "fuzzy IF", and has a usage very similar to an IF.. THEN, but without the harsh switching characteristics.
The form is:
value = RAMP(expression, left_value, right_value, width)
This expression is logically equivalent to
value = IF expression < 0 THEN left_value ELSE right_value
except that the transition will be linear over width. If the left and right values are functions, then you may not get a straight line as the ramp. The result will be a linear combination of the two functions.
See the SWAGE function for a similar function with both smooth value and derivative.
Example:
see "Samples | Usage | Swage_test.pde" for a picture of the SWAGE and RAMP transitions and their derivatives.