def simulate(self, max_its=np.inf, max_time=np.inf*u.s):
"""Simulates the plasma as set up, either for the given number of
iterations or until the simulation reaches the given time.
Parameters
----------
max_its : int
Tells the simulation to run for a set number of iterations.
max_time : astropy.units.Quantity
Maximum total (in-simulation) time to allow the simulation to run.
Must have units of time.
Examples
--------
>>> # Run a simulation for exactly one thousand iterations.
>>> myplasma.simulate(max_time=1000)
>>> # Run a simulation for up to half an hour of simulation time.
>>> myplasma.simulate(max_time=30*u.minute)
"""
if np.isinf(max_its) and np.isinf(max_time.value):
raise ValueError("Either max_time or max_its must be set.")
physics = self.simulation_physics
dt = physics.dt
if np.isinf(max_time):
pb = ProgressBar(max_its)
else:
pb = ProgressBar(int(max_time / dt))
with pb as bar:
while (physics.current_iteration < max_its
and physics.current_time < max_time):
physics.time_stepper()
bar.update()
评论列表
文章目录