opengate.engines ================ .. py:module:: opengate.engines Classes ------- .. autoapisummary:: opengate.engines.EngineBase opengate.engines.SourceEngine opengate.engines.PhysicsEngine opengate.engines.ActionEngine opengate.engines.ActorEngine opengate.engines.ParallelWorldEngine opengate.engines.VolumeEngine opengate.engines.VisualisationEngine opengate.engines.SimulationOutput opengate.engines.SimulationEngine Functions --------- .. autoapisummary:: opengate.engines.start_gdml_visu opengate.engines.start_vrml_visu Module Contents --------------- .. py:class:: EngineBase(simulation_engine) Base class for all engines (SimulationEngine, VolumeEngine, etc.) .. py:attribute:: simulation_engine .. py:attribute:: verbose_getstate .. py:attribute:: verbose_close .. py:method:: close() .. py:class:: SourceEngine(simulation_engine) Bases: :py:obj:`EngineBase` Source Engine manages the G4 objects of sources at runtime .. py:attribute:: max_int :value: 2147483647 .. py:attribute:: simulation_engine .. py:attribute:: run_timing_intervals :value: None .. py:attribute:: current_run_interval :value: None .. py:attribute:: sources :value: [] .. py:attribute:: g4_master_source_manager :value: None .. py:attribute:: g4_thread_source_managers :value: [] .. py:attribute:: g4_particle_table :value: None .. py:attribute:: source_manager_options .. py:method:: close() .. py:method:: release_g4_references() .. py:method:: initialize(run_timing_intervals) .. py:method:: initialize_actors(actors) Parameters ---------- actors : dict The dictionary ActorEngine.actors which contains key-value pairs "actor_name" : "Actor object" .. py:method:: create_master_source_manager() .. py:method:: create_g4_source_manager(append=True) This is called by all threads This object is needed here, because it can only be created after physics initialization .. py:method:: start() .. py:class:: PhysicsEngine(*args) Bases: :py:obj:`EngineBase` Class that contains all the information and mechanism regarding physics to actually run a simulation. It is associated with a simulation engine. .. py:attribute:: physics_manager .. py:attribute:: g4_physics_list :value: None .. py:attribute:: g4_decay :value: None .. py:attribute:: g4_radioactive_decay :value: None .. py:attribute:: g4_cuts_by_regions :value: [] .. py:attribute:: g4_em_parameters :value: None .. py:attribute:: g4_parallel_world_physics :value: [] .. py:attribute:: g4_optical_material_tables .. py:attribute:: g4_physical_volumes :value: [] .. py:attribute:: g4_surface_properties :value: None .. py:attribute:: gate_physics_constructors :value: [] .. py:attribute:: optical_surfaces_properties_dict .. py:method:: close() .. py:method:: release_g4_references() .. py:method:: release_optical_surface_g4_references() .. py:method:: close_physics_constructors() This method removes PhysicsConstructors defined in python from the physics list. It should be called after a simulation run, i.e. when a simulation engine closes, because the RunManager will otherwise attempt to delete the PhysicsConstructor and cause a segfault. .. py:property:: user_info_physics_manager .. py:method:: initialize_before_runmanager() Initialize methods to be called *before* G4RunManager.Initialize() is called. .. py:method:: initialize_after_runmanager() .. py:method:: initialize_parallel_world_physics() .. py:method:: initialize_physics_list() Create a Physic List from the Factory .. py:method:: initialize_regions() .. py:method:: initialize_global_cuts() .. py:method:: initialize_g4_em_parameters() .. py:method:: initialize_optical_material_properties() .. py:method:: initialize_optical_surfaces() Calls initialize() method of each OpticalSurface instance. .. py:method:: initialize_user_limits_physics() .. py:class:: ActionEngine(simulation_engine) Bases: :py:obj:`opengate_core.G4VUserActionInitialization`, :py:obj:`EngineBase` Main object to manage all actions during a simulation. .. py:attribute:: g4_PrimaryGenerator :value: [] .. py:attribute:: g4_main_PrimaryGenerator :value: None .. py:attribute:: g4_RunAction :value: [] .. py:attribute:: g4_EventAction :value: [] .. py:attribute:: g4_TrackingAction :value: [] .. py:method:: close() .. py:method:: release_g4_references() .. py:method:: BuildForMaster() .. py:method:: Build() .. py:class:: ActorEngine(simulation_engine) Bases: :py:obj:`EngineBase` This object manages all actors G4 objects at runtime .. py:attribute:: simulation_engine_wr .. py:attribute:: actors .. py:method:: close() .. py:method:: get_actor(name) .. py:method:: create_actors() .. py:method:: initialize(volume_engine=None) .. py:method:: register_all_actions(actor) .. py:method:: register_sensitive_detectors(world_name) .. py:method:: register_sensitive_detector_to_children(actor, lv) .. py:method:: start_simulation() .. py:method:: stop_simulation() .. py:class:: ParallelWorldEngine(parallel_world_name, *args) Bases: :py:obj:`opengate_core.G4VUserParallelWorld`, :py:obj:`EngineBase` FIXME: Doc ParallelWorldEngine .. py:attribute:: parallel_world_name .. py:property:: parallel_world_volume .. py:method:: Construct() G4 overloaded. Override the Construct method from G4VUserParallelWorld .. py:method:: ConstructSD() .. py:class:: VolumeEngine(simulation_engine) Bases: :py:obj:`opengate_core.G4VUserDetectorConstruction`, :py:obj:`EngineBase` Engine that will create all G4 elements for the hierarchy of volumes. Correspond to the G4VUserDetectorConstruction (inherit) Also manage the list of parallel worlds. .. py:attribute:: _is_constructed :value: False .. py:attribute:: volume_manager .. py:attribute:: parallel_world_engines .. py:method:: create_parallel_world_engines() .. py:method:: register_to_volumes() .. py:method:: close() .. py:method:: initialize() .. py:method:: initialize_dynamic_parametrisations() .. py:method:: Construct() G4 overloaded. Override the Construct method from G4VUserDetectorConstruction .. py:method:: check_overlaps(verbose) .. py:method:: ConstructSDandField() G4 overloaded .. py:method:: get_volume(name) .. py:method:: get_database_material_names(db=None) .. py:method:: dump_build_materials(level=0) .. py:class:: VisualisationEngine(simulation_engine) Bases: :py:obj:`EngineBase` Main class to manage visualisation .. py:attribute:: g4_vis_executive :value: None .. py:attribute:: current_visu_filename :value: None .. py:attribute:: _is_closed :value: None .. py:attribute:: simulation .. py:method:: close() .. py:method:: release_g4_references() .. py:method:: __enter__() .. py:method:: __exit__(type, value, traceback) .. py:method:: initialize_visualisation() .. py:method:: initialize_visualisation_gdml() .. py:method:: initialize_visualisation_vrml() .. py:method:: start_visualisation() .. py:class:: SimulationOutput FIXME .. py:attribute:: simulation :value: None .. py:attribute:: actors .. py:attribute:: sources .. py:attribute:: sources_by_thread .. py:attribute:: pid .. py:attribute:: ppid .. py:attribute:: current_random_seed :value: None .. py:attribute:: hook_log :value: [] .. py:method:: store_actors(simulation_engine) .. py:method:: store_hook_log(simulation_engine) .. py:method:: store_sources(simulation_engine) .. py:method:: get_actor(name) .. py:method:: get_source(name) .. py:method:: get_source_mt(name, thread) .. py:class:: SimulationEngine(simulation, new_process=False) Main class to execute a Simulation (optionally in a separate subProcess) .. py:attribute:: simulation .. py:attribute:: verbose_getstate .. py:attribute:: verbose_close .. py:attribute:: volume_engine .. py:attribute:: physics_engine .. py:attribute:: source_engine .. py:attribute:: action_engine .. py:attribute:: actor_engine .. py:attribute:: visu_engine .. py:attribute:: run_timing_intervals :value: None .. py:attribute:: is_initialized :value: False .. py:attribute:: new_process .. py:attribute:: init_only :value: False .. py:attribute:: ui_session :value: None .. py:attribute:: g4_ui :value: None .. py:attribute:: g4_HepRandomEngine :value: None .. py:attribute:: current_random_seed :value: None .. py:attribute:: g4_RunManager :value: None .. py:attribute:: g4_StateManager .. py:attribute:: run_manager_finalizer :value: None .. py:attribute:: _is_closed :value: False .. py:attribute:: g4_exception_handler :value: None .. py:attribute:: user_hook_after_init .. py:attribute:: user_hook_after_run .. py:attribute:: hook_log :value: [] .. py:method:: close_engines() .. py:method:: release_engines() .. py:method:: release_g4_references() .. py:method:: notify_managers() .. py:method:: close() .. py:method:: __enter__() .. py:method:: __exit__(type, value, traceback) .. py:method:: __getstate__() .. py:method:: __setstate__(d) .. py:method:: run_engine() When the simulation is about to init, if the Simulation object is in a separate process (with 'spawn'), it has been pickled (copied) and the G4 phys list classes does not exist anymore, so we need to recreate them with 'create_physics_list_classes' Also, the StateManager must be recreated. NK: Yes, but not this way. Each class should take care of recreating attributes which where set to None during pickling by implementing a __setstate__ method. Implementing the resetting somewhere else (maybe in multiple places...) in the code will make it very difficult to maintain. -> removed the lines and implemented __setstate__ methods for the classes in question .. py:method:: start_and_stop() Start the simulation. The runs are managed in the SourceManager. .. py:method:: initialize_random_engine() .. py:method:: initialize_g4_verbose() .. py:method:: initialize() Build the main geant4 objects and initialize them. .. py:method:: create_run_manager() Get the correct RunManager according to the requested threads and make some basic settings. .. py:method:: apply_all_g4_commands_after_init() .. py:method:: apply_all_g4_commands_before_init() .. py:method:: add_g4_command_after_init(command) .. py:method:: check_volumes_overlap(verbose=True) .. py:property:: g4_state .. py:method:: enable_user_event_information(actors) .. py:function:: start_gdml_visu(filename) .. py:function:: start_vrml_visu(filename)