Implementation of Physics formulas and a convenient user interface for NumWorks calculator.
This project was motivated by the need to quickly perform redundant calculations of Heat and Mass transfer problems when solving them with paper, a pen and a calculator. In particular, the background theory is based on EPFL course ME-341. For theoretical details, refer to Fundamentals of heat and mass transfer. 6th ed, Frank P. Incropera.
For instance, the Churchill-Bernstein equation for convective heat transfer is used to approximate the dimensionless Nusselt number and thus estimate the average convection coefficient between two fluids in cross-flow around a cylinder. The formula is quiet cumbersome to type in a calculator:
where is the Nusselt number, the Reynolds number and the Prandtl number.
Designing a script running in the Numworks environment and that prompts the user for input variables would make the calculation of such formulas easy.
The calculator has no file explorer, i.e. cannot use directories. It also have very few memory (see below) So we must reduce the amount of code as much as possible by designing an efficent wrapping of mathematical formulas.
To avoid loading too much instructions at once in the calculator, we separate the formulas in sections:
- Utility functions: used by every other script
- Linear interpolation (generic)
- Linear interpolation of thermophysical properties of water (hard-coded data)
- Linear interpolation of thermophysical properties of air (hard-coded data)
- Equations for fins
- Equations for convection (implicitly only free and forced convection)
- Equations for the boiling part of convection
- Equations for the condensation part of convection
The idea is to load only two scripts at once: the utility module and the script of interest.
- The user chooses a script in the list of scripts on the calcultor
- The user runs the script
- The user is asked to choose which formula (of the loaded module) to use
- The user is prompted to enter values of the formula input variable
- Results are displayed
All functions implementing formulas calculations have no input and no output (in the Pythonic sense).
The input/output is handled by the utility module, via the function pr
(print) out
and get_params
.
In particular:
pr(msg, maxlen=29)
: print some text that properly fits on screenout(desc, val)
: print value of physical variable, handle scientific notationget_params(lst)
: prompt the user for the values of the formula variables whose names are given inlst
In particular, functions that implement formulas should perform in order:
- Print the name of the equation and the context in which it is used with
pr
- Prompt the user for the values of the input variables with
get_param
- Perform calculations
- Output the result
Every script should follow this architecture:
- Load the
utility
module - Set relevant functions that implement formulas (no input, no return)
- Use
utility.get_params
to ask the user for the parameter values and load them in a python dictionnary - Try to use as few memory as possible
- Output (numerical) results with
utility.out
- Use
- Create an option map that will allow the user to choose a formula, the map is a python dictionnary (key = display message, value = reference to the corresponding function)
- The script ends with
utility.choose_opt(optmap)
https://www.numworks.com/specs/
- Flash ROM: 8MB
- Static RAM: 256KB
https://www.numworks.com/resources/engineering/software/
Our device has 256 KB of RAM. That’s very little memory by today’s standards. That being said, by writing code carefuly, a huge lot can be achieved in that space. After all, that’s 64 times more memory than the computer of the Apollo mission!
- Stack memory: 32KB, all local variables + context of code execution
- Heap memory: ??