|
The SWAGE Function |
Top Previous Next |
|
The SWAGE function 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 SWAGE function generates a smooth transition from one value to another, with a specified transition width. It also has smooth derivatives. 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 = SWAGE(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 smeared over width.
See the RAMP function for a similar function which is smooth in value, but not in derivative.
Example: see "Samples | Misc | Swagetest.pde" for a picture of the SWAGE and RAMP transitions and their derivatives.
|