variable list. If you want to keep it constant, you can do so by setting an initial value, and making it fixed in the fit.
User-defined function format
It is possible to create new functions which can be used as a black-box element in all circuits by simply typing its defining equation in file with extension *.fun. This files should be stored in directory \userfun and included into your netlist file with #include name.fun statement. If arbitrary circuit is created with CEDIT, include statement will be added automatically. Format of the function definition file is simple:
function <name>(w, var1, var2, .... varN)
x=....;
y=....;
z=....;
return 1/z;
Example:
function sph_diff(w, Rd, Cd)
z=Rd/(1+sqrt(1j*w*3*Cd*Rd));
return 1/z;
· Function should always return admittance, 1/Z
· Function name can be any word, but it is recommended to use short words, otherwise they will not look nice in the graphical schematic. Also, some names are reserved by the program and should not be used. These are mathematical functions names listed below), and names of predefined distributed elements listed in "summary of distributed elements".
· w should always be the first argument of the function. It means angular frequency.
· "1j" means imaginary multiplier i=sqrt(-1)
· function definition can has local variables with any names, which can be used for intermediate storage during calculations. All variables are considered as complex. Example
function fletcher1(w, Re,Ri, Cdl,Rp, Cp)
x = 1/(1j*w*Cdl+1/(Rp + (1/(1j*w*Cp))));
m=sqrt((Re+Ri)/(4*x));
z=(1+(tanh(m)/m))*Ri*Re/(Ri+Re)+sqrt((Ri+Re)*x)/tanh(2*m);
return 1/z;
· Each line should end with semicolon ";"
· You can use in your equations mathematical operators +,-,*,/ for both real or complex arguments. Additionally you can use large number of mathematical functions listed below. All of them accept complex arguments and give complex results when appropriate:
Function: 'abs'.
Function: 'arg'.
Function: 'real'.
Function: 'imag'.
Function: 'sqrt'.
Function: 'conj'.
Function: 'sin'.
Function: 'cos'.
Function: 'log'.
Function: 'exp'.
Function: 'sinh'.(hyperbolic sine)
Function: 'cosh'.(hyperbolic cosine)
Function: 'tanh' (hyperbolic tangent)
Function: 'pow' (pow(a,b) is equivalent to mathematical expression a^b)
Additionally, all distributed elements, can also be used as sub-functions in user-defined functions. If element's library name is given as <name> var1 var2 var3... varN it should be used as <name>(w, var1, war2, war3..varN).
Note that all distributed elements functions return admittance (1/Z) and not impedance (Z). Here is an example using porous electrode impedance function, fletch
function fletch_ser(w, Rser, Rp, Cdl, Re,Ri, Cp)
z=Rser+1/fletch(w, Rp, Cdl, Re,Ri, Cp);
return 1/z;
MEISP : (C) 2000-2002, Korea Kumho Petrochemical Co., Ltd. (KUMHO)