Difference between revisions of "Contrib equationReader/Using equationReader"

From OpenFOAMWiki
(Migrated to github)
 
Line 1: Line 1:
== Dictionary syntax ==
+
This project has migrated over to '''github'''.
Any of these formats are acceptable to '''equationReader''':
+
  
=== Standard equation ===
+
'''''[http://github.com/Marupio/equationReader/wiki Click here for the new website.]'''''
keyword    "''equation''";
+
keyword    ''scalar'';
+
e.g.:
+
endTime    "2*pi_/360*60";
+
gamma      1.58e-6;
+
  
The '''standard equation''' format performs dimension checking for every operation.  Use this if you want OpenFOAM to be strict about the dimensions you use.  This has may unexpected consequences.  For example:
+
http://github.com/Marupio/equationReader/wiki
 
+
* <tt>sin(time)</tt> is wrong because you can't have dimensions in any transcendental functions; and
+
* <tt>max(deltaT, SMALL_)</tt> is wrong because <tt>SMALL</tt> is dimensionless.
+
 
+
If this is too troublesome, you can also use:
+
 
+
=== Dimensioned equation ===
+
keyword    [''dimensionSet''] "''equation''";
+
keyword    [''dimensionSet''] ''scalar'';
+
keyword    ''ignoredWord'' [''dimensionSet''] "''equation''";
+
keyword    ''ignoredWord'' [''dimensionSet''] ''scalar'';
+
e.g.:
+
nu      [0 2 -1 0 0 0 0] "1 / (1e-5 + 2.3/4000 + SMALL_)";
+
rho    [1 -3 0 0 0 0 0] 1.235;
+
delta  delta [0 1 0 0 0 0 0] "sin(pi_ * t)";
+
alhpa  alpha [0 1 0 0 0 0 0] 3.2;
+
 
+
The '''dimensioned equation''' format disables dimension checking, and forces the final result to a given ''dimensionSet''.  Also note the optional ''ignoredWord'' - this allows '''equationReader''' to be compatible with ''dimensionedScalar'' formats.
+
 
+
== Equation syntax ==
+
'''equationReader''' uses the conventional order of operations '''BEDMAS''', then left to right:
+
 
+
* '''B'''rackets (and functions);
+
* '''E'''xponents;
+
* '''DM''' - division and multiplication; and
+
* '''AS''' - addition and subtraction.
+
 
+
It's just like Excel, except exponents 'a^b' don't work - use 'pow(a,b)' instead.
+
 
+
* you can use any amount of whitespace you want (use a backslash for a line break);
+
* multiplication is <tt>*</tt>, for example <tt>2*3</tt> is <tt>6</tt>;
+
* there is no implied multiplication - you must explicitly use <tt>*</tt>.  For example:
+
::<tt>2 sin(theta)</tt> <span style="color:#ff0000">'''INCORRECT'''</span>
+
::<tt>2 * sin(theta)</tt> '''CORRECT'''
+
:and
+
::<tt>2(3 + 4)</tt> <span style="color:#ff0000">'''INCORRECT'''</span>
+
::<tt>2 * (3 + 4)</tt> '''CORRECT'''
+
 
+
=== Mathematical constants ===
+
'''equationReader''' recognizes all the mathematical constants I could find in the OpenFOAM library.  To specify a mathematical constant, append the regular OpenFOAM format with an underscore '_'.  The available constants are:
+
 
+
* <tt>e_</tt> (Euler's number);
+
* <tt>pi_</tt>;
+
* <tt>twoPi_</tt>;
+
* <tt>piByTwo_</tt>;
+
* <tt>GREAT_</tt>;
+
* <tt>VGREAT_</tt>;
+
* <tt>ROOTVGREAT_</tt>;
+
* <tt>SMALL_</tt>;
+
* <tt>VSMALL_</tt>; and
+
* <tt>ROOTSMALL_</tt>.
+
 
+
=== Functions ===
+
[[Contrib_equationReader/functions|Click here for a complete list of functions.]]
+
 
+
All the <tt>scalar</tt> and <tt>dimensionedScalar</tt> functions I could find in the [[OpenFOAM]] library have been implemented. 
+
 
+
== Troubleshooting your equations ==
+
Your equations may cause you trouble, such as:
+
 
+
* Giving you a <tt>SIGFPE</tt>; or
+
* Failing dimension checks.
+
 
+
If this happens and you don't know why, '''equationReader''' has a detailed set of debug switches to help.  To change the debug switch, edit the <tt>OpenFOAM/etc/controlDict</tt> file and add:
+
equationReader    ''integerValue'';
+
to the <tt>DebugSwitches</tt> list.
+
 
+
The debug switches available are:
+
 
+
0. Silent mode;<br>
+
1. scalar logging (light);<br>
+
2. scalar logging (verbose);<br>
+
3. dimension logging (light);<br>
+
4. dimension logging (verbose);<br>
+
5. scalar & dimension logging (light); or<br>
+
6. scalar & dimension logging (verbose).
+
 
+
The scalar logging will report scalar-related operations to the console.  The dimension logging, relates to dimensionSet operations.  ''verbose'' reports operation-by-operation, so it can be overwhelming.
+

Latest revision as of 21:43, 6 September 2013

This project has migrated over to github.

Click here for the new website.

http://github.com/Marupio/equationReader/wiki