diff --git a/docs/user-guide/basic-simulation/index.rst b/docs/user-guide/basic-simulation/index.rst index f5e888c91..0d37f808d 100644 --- a/docs/user-guide/basic-simulation/index.rst +++ b/docs/user-guide/basic-simulation/index.rst @@ -12,13 +12,14 @@ Start with importing Swiftest. :: Initial Simulation Setup =========================== -Create a Swiftest Simulation object. +Create a Swiftest :class:`Simulation ` object. Outputs are stored in the ``./simdata`` directory by default. :: sim = swiftest.Simulation() Now that we have a simulation object set up (with default parameters), we can add bodies to the simulation. -The biggest body in the simulation is taken as the central body. +The biggest body in the simulation is taken as the central body. Swiftest sets a Simulation object up with a set of default parameters, +including a default unit system of AU, y, and solar masses. Solar System Bodies ========================= @@ -40,16 +41,39 @@ Add other small bodies too: :: Running the Simulation ======================== -We now set up the simulation parameters. Here we have a simulation starting from `0.0 y` and running for `1 My = 1e6 years` -with time steps of `0.01 years`. :: +We now can some simulation parameters using the :func:`set_parameter ` method. +Here we have a simulation that runs for 1 My a step size of 0.01 y. We will also save the system every 1000 y and wait until the end of the simulation to write the simulation data to file using the ``dump_cadence=0`` argument :: - sim.set_parameter(tstart=0.0, tstop=1.0e6, dt=0.01) + sim.set_parameter(tstop=1.0e6, tstep_out=1e3, dt=0.01, dump_cadence=0) -Once everything is set up, we can save the simulation object and then run it: :: +Once everything is set up, we call the :func:`run ` method to integrate the system forward in time:: - sim.save() sim.run() +Swiftest is relatively flexible with arguments. You can pass the parameters in when initializing the simulation object, or even later when running. +So the following are all equivalent:: + + sim = swiftest.Simulation(tstop=1.0e6, tstep_out=1e3, dt=0.01, dump_cadence=0) + sim.add_solar_system_body(["Sun","Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"]) + sim.run() + + sim = swiftest.Simulation() + sim.add_solar_system_body(["Sun","Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"]) + sim.set_parameter(tstop=1.0e6, tstep_out=1e3, dt=0.01, dump_cadence=0) + sim.run() + + sim = swiftest.Simulation() + sim.add_solar_system_body(["Sun","Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"]) + sim.run(tstop=1.0e6, tstep_out=1e3, dt=0.01, dump_cadence=0) + + +Analayzing Simulation Output +============================= + +Once a simulation has been run, its output data is stored in the ``./simdata`` directory. The main data is stored in a file with a +default name of ``data.nc``, which is a netCDF file. It is read in and stored as an `Xarray Dataset `__ object in the ``sim.data`` attribute. + + .. .. toctree:: .. :maxdepth: 2 .. :hidden: