Parampool has a feature that allows a user to create an account, log in,
and save the results from simulations.
The results of a run consists of the
HTML code and plots, which are stored in a database.
Later, old results can be retrieved in the GUI. Enabling login
is just a matter of writing enable_login=True
in the call
to the generate function:
from parampool.generator.flask import generate
from compute import compute_motion_and_forces
generate(compute_motion_and_forces, MathJax=True,
enable_login=True)
The generated controller.py
file is now much more complicated in the
Flask case, but the details are not important for the plain user of
Parampool. The usage should be explanatory: first click on Register
to
register a new user, later one can just click on Login
.
After having run a simlation, a Comments field arises where one can
add comments about this run, and then click on Add if the results
are sufficiently interesting to be stored in the database. The upper
right corner has a link Previous simulations which gives access to
previous results in the database. At the bottom of the page with
previous runs, there is a Delete all button that clears the database.
In case of error messages regarding sending email through Google's
server, it may help to add the following line to controller.py
, e.g.,
right before the send_email
function:
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
One can use Python expressions like sin(0.5)*exp(-1)
in the input
fields. Parampool will recognize arithmetic expressions or use of
mathematical functions, and in such cases run eval
on the input
to interpret it. If special functions are needed, e.g., the input
is like myfunc(0.1)
, one can supply a namespace to the data
item in question through the namespace
parameter. Here we create
a custom namespace for a parameter, where the namespace includes
myfunc
from mymodule
and all functions (or more precisely, all names)
in yourmodule
that
do not start with an underscore:
import mymodule, yourmodule
namespace = {'myfunc': mymodule.myfunc}
namespace.update({key: value for key, value in
yourmodule.__dict__.iteritems()
if not key.startswith('_')}