Skip to content

Commit 959b10d

Browse files
authored
Merge pull request #49 from harpolea/pyro_class
Pyro class implementation. Closes #44
2 parents 7ffff20 + 91787ed commit 959b10d

6 files changed

Lines changed: 702 additions & 298 deletions

File tree

docs/source/running.rst

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
Running
22
=======
33

4-
All the solvers are run through the ``pyro.py`` script. This takes 3
4+
Pyro can be run in two ways: either from the commandline, using the ``pyro.py`` script and passing in the solver, problem and inputs as arguments, or by using the :func:`Pyro <pyro.Pyro>` class.
5+
6+
Commandline
7+
------------
8+
9+
The ``pyro.py`` script takes 3
510
arguments: the solver name, the problem setup to run with that solver
611
(this is defined in the solver's ``problems/`` sub-directory), and the
712
inputs file (again, usually from the solver's ``problems/``
@@ -38,12 +43,49 @@ above run, we could do:
3843
plot the results after the fact using the ``plot.py`` script, as discussed
3944
in :ref:`analysis`.
4045

46+
47+
Pyro class
48+
----------
49+
50+
Alternatively, pyro can be run using the :func:`Pyro <pyro.Pyro>` class. This is done by the following steps:
51+
52+
* create a ``Pyro`` object, initializing it with a specific solver
53+
* initialize the problem, passing in runtime parameters and inputs
54+
* run the simulation
55+
56+
For example, if we wished to use the ``compressible`` solver to run the Kelvin-Helmholtz problem ``kh``, we would do the following:
57+
58+
.. code-block:: python
59+
60+
pyro = Pyro("compressible")
61+
pyro.initialize_problem(problem_name="kh",
62+
inputs_file="inputs.kh")
63+
pyro.run_sim()
64+
65+
Instead of using an inputs file to define the problem parameters, we can define a dictionary of parameters and pass them into the :func:`initialize_problem <pyro.Pyro.initialize_problem>` function using the keyword argument ``inputs_dict``. If an inputs file is also passed into the function, the parameters in the dictionary will override any parameters in the file. For example, if we wished to turn off visualization for the previous example, we would do:
66+
67+
.. code-block:: python
68+
69+
parameters = {"vis.dovis":0}
70+
pyro.initialize_problem(problem_name="kh",
71+
inputs_file="inputs.kh",
72+
inputs_dict=parameters)
73+
74+
It's possible to evolve the simulation forward timestep by timestep manually using the :func:`single_step <pyro.Pyro.single_step>` function (rather than allowing :func:`run_sim <pyro.Pyro.run_sim>` to do this for us). To evolve our example simulation forward by a single step, we'd run
75+
76+
.. code-block:: python
77+
78+
pyro.single_step()
79+
80+
This will fill the boundary conditions, compute the timestep ``dt``, evolve a single timestep and do output/visualization (if required).
81+
82+
4183
Runtime options
4284
---------------
4385

4486
The behavior of the main driver, the solver, and the problem setup can
4587
be controlled by runtime parameters specified in the inputs file (or
46-
via the command line). Runtime parameters are grouped into sections,
88+
via the command line or passed into the ``initialize_problem`` function). Runtime parameters are grouped into sections,
4789
with the heading of that section enclosed in ``[ .. ]``. The list of
4890
parameters are stored in three places:
4991

0 commit comments

Comments
 (0)