Main package of the software. It contains the Program class which is the core application controller.
Bases: object
Main class of ARS.
To run a custom simulation, create a subclass. It must contain an implementation of the ‘create_sim_objects’ method which will be called during the simulation creation.
To use it, only two statements are necessary:
>>> sim_program = ProgramSubclass()
>>> sim_program.start()
Constructor. Defines some attributes and calls some initialization methods to:
Create a screenshot (of the frames displayed in the graphics window) recorder.
Each image will be written to a numbered file according to base_filename. By default it will create an image each time record_frame() is called. If periodically is True then screenshots will be saved in sequence. The time period between each frame is determined according to FPS.
This method must be overriden (at least once in the inheritance tree) by the subclass that will instatiated to run the simulator.
It shall contain statements calling its ‘sim’ attribute’s methods for adding objects (e.g. add_sphere).
For example:
>>> self.sim.add_sphere(0.5, (1,10,1), density=1)
Creates an empty simulation and:
adds basic simulation objects (add_basic_simulation_objects()),
coordinates-system origin,
vector and some visualization parameters,
subclasses),
the graphics adapter.
Finalize the program, deleting or releasing all associated resources.
Currently, the following is done:
all attributes are set to None or False
A finalized program file cannot be used for further simulations.
Note
This method may be called more than once without error.
This method will be called before each visualization frame is created. It is meant to be, optionally, implemented by subclasses.
This method will be called before each integration step of the simulation. It is meant to be, optionally, implemented by subclasses.
Record a frame using a screenshot recorder.
If frames are meant to be written periodically, a new one will be recorded only if enough time has elapsed, otherwise it will return False. The filename index will be time / period.
If frames are not meant to be written periodically, then index equals simulator’s frame number.
Resets the simulation by resetting the graphics adapter and creating a new simulation.