21.01.2015 Views

COMSOL Multiphysics™

COMSOL Multiphysics™

COMSOL Multiphysics™

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

elinline<br />

Purpose<br />

elinline<br />

Declare functions and corresponding symbolic derivatives.<br />

Syntax<br />

Description<br />

el.elem = 'elinline'<br />

el.name = fname<br />

el.args{iarg} = argname<br />

el.expr = evalexpr<br />

el.dexpr{iarg} = devalexpr<br />

el.complex = 'true' | 'false'<br />

el.linear = 'true' | 'false'<br />

The elinline element declares a new function with differentiation rules in terms<br />

of other built-in or <strong>COMSOL</strong> Script or MATLAB functions. <strong>COMSOL</strong><br />

Multiphysics calls the function using the MATLAB interpreter if you run <strong>COMSOL</strong><br />

Multiphysics with MATLAB and it calls the <strong>COMSOL</strong> Script interpreter otherwise.<br />

Declared in-line functions can be used with the syntax fname(arg1,arg2,...)<br />

anywhere except for in other in-line function definitions. The args field contains a<br />

list of formal parameter names which can be used in the expr field defining the<br />

function itself and the dexpr field defining derivative expressions with respect to<br />

each of the formal arguments.<br />

The evalexpr and devalexpr expressions can contain any valid expression in the<br />

formal arguments, including <strong>COMSOL</strong> Script function calls. Global constants and<br />

variables are not available with pi being the only noticeable exception. Note that<br />

differentiation with respect to some formal argument can be disabled by just<br />

specifying the corresponding devalexpr as '0'.<br />

Functions which can generate complex values from real data must have the complex<br />

field set to 'true'. The linear property decides if the function is treated as linear<br />

when deciding whether to reassemble the Jacobian at each time step/iteration or<br />

not.<br />

Cautionary<br />

Examples<br />

Note that in-line functions cannot depend on other in-line functions, only on<br />

built-ins and functions defined on your <strong>COMSOL</strong> Script or MATLAB path. In-line<br />

functions can be used to override built-ins but can never override another in-line<br />

function.<br />

An in-line function can be used to redefine the derivative of the sqrt function in<br />

such a way that the Jacobian of sqrt(u^2+v^2) will exist for u=v=0.<br />

el.elem = 'elinline';<br />

el.name = 'sqrt';<br />

el.args = {'a'};<br />

el.expr = 'sqrt(a)';<br />

82 | CHAPTER 1: COMMAND REFERENCE

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!