In [1]:
from pyro import Pyro
First we need to set up our problem. To do this, we choose which solver we want to use (advection), which problem we want to solve (smooth) and the name of a parameter file we want to use (inputs.smooth).
In [2]:
solver = "advection"
problem_name = "smooth"
param_file = "inputs.smooth"
Next, we need to create the Pyro object and initialize the problem.
In [3]:
pyro_sim = Pyro(solver)
pyro_sim.initialize_problem(problem_name, param_file)
At this point, we can print out some of the problem properties.
In [4]:
print(pyro_sim)
We can also plot the initial data by calling dovis on the object's sim variable.
In [5]:
pyro_sim.sim.dovis()
Let's evolve the problem by a single timestep by calling single_step. This will evolve the simulation and produce an updated plot of the data (unless the problem's vis.dovis parameter has been set to false). Let's try that a couple of times.
In [6]:
pyro_sim.single_step()
In [7]:
pyro_sim.single_step()
Alternatively, we can run the entire simulation (i.e. run until the time reaches the driver.tmax parameter or the number of steps reaches driver.max_steps). Let's reinitialize the problem and try that. This time, we shall pass in the extra parameter vis.dovis = False in order to suppress plotting at each timestep. We'll also shrink down the number of gridpoints in each direction and turn off the particles.
In [8]:
# NBVAL_IGNORE_OUTPUT
extra_parameters = {'vis.dovis': False, 'mesh.nx': 8, 'mesh.ny':8, 'particles.do_particles': False}
pyro_sim.initialize_problem(problem_name, param_file, inputs_dict=extra_parameters)
pyro_sim.run_sim()
Out[8]:
We can now plot the final data by calling dovis again
In [9]:
pyro_sim.sim.dovis()
We can extract the simulation data using the get_var function. Let's do that for the density.
In [10]:
dens = pyro_sim.get_var("density")
In [11]:
# NBVAL_IGNORE_OUTPUT
print(dens)
This can be printed in a slightly more human-readable format by using pretty_print
In [12]:
dens.pretty_print(show_ghost=False)
In [ ]: