|
1 | 1 | Running |
2 | 2 | ======= |
3 | 3 |
|
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 |
5 | 10 | arguments: the solver name, the problem setup to run with that solver |
6 | 11 | (this is defined in the solver's ``problems/`` sub-directory), and the |
7 | 12 | inputs file (again, usually from the solver's ``problems/`` |
@@ -38,12 +43,49 @@ above run, we could do: |
38 | 43 | plot the results after the fact using the ``plot.py`` script, as discussed |
39 | 44 | in :ref:`analysis`. |
40 | 45 |
|
| 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 | + |
41 | 83 | Runtime options |
42 | 84 | --------------- |
43 | 85 |
|
44 | 86 | The behavior of the main driver, the solver, and the problem setup can |
45 | 87 | 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, |
47 | 89 | with the heading of that section enclosed in ``[ .. ]``. The list of |
48 | 90 | parameters are stored in three places: |
49 | 91 |
|
|
0 commit comments