pogona.MoleculeManager

class pogona.MoleculeManager[source]

Bases: Component

Attributes

component_name

Unique name of this component, unless it is "Generic component".

update_molecule_collection_immediately

If True, adding or deleting a molecule will happen immediately when add_molecule or destroy_molecule is called.

__init__()[source]

Methods

__init__()

add_molecule(molecule)

apply_changes()

Apply any pending molecule insertions and deletions.

destroy_molecule(molecule)

finalize(simulation_kernel)

get_all_molecule_copies()

get_all_molecules()

initialize(simulation_kernel, init_stage)

Use InitStages to initialize this Component instance.

process_new_time_step(simulation_kernel, ...)

set_arguments(**kwargs)

Read arguments as key value pairs and set this component's member variables accordingly.

update_molecule(molecule)

Replace an existing molecule with an updated molecule with the same ID.

__init__()[source]
add_molecule(molecule)[source]
apply_changes()[source]

Apply any pending molecule insertions and deletions.

This should be called after every time step if update_molecule_collection_immediately is False.

destroy_molecule(molecule)[source]
finalize(simulation_kernel: SimulationKernel)
get_all_molecule_copies()[source]
get_all_molecules()[source]
initialize(simulation_kernel: SimulationKernel, init_stage: InitStages)[source]

Use InitStages to initialize this Component instance.

process_new_time_step(simulation_kernel: SimulationKernel, notification_stage: NotificationStages)
set_arguments(**kwargs)

Read arguments as key value pairs and set this component’s member variables accordingly. Validity of the argument values will be checked in initialize().

update_molecule(molecule)[source]

Replace an existing molecule with an updated molecule with the same ID.

Parameters

molecule

Returns

component_name = 'Generic component'

Unique name of this component, unless it is “Generic component”.

id

Unique integer component ID

update_molecule_collection_immediately = False

If True, adding or deleting a molecule will happen immediately when add_molecule or destroy_molecule is called.

However, since such calls usually happen while the collection of molecules is being iterated over, and because changing a collection while iterating over it may cause problems, we can alternatively collect all molecules to add and all molecules to delete in temporary lists. Since we can assume these temporary lists to be much smaller than the total number of molecules in each time step, which would have to be copied otherwise in each step, this should give us a performance benefit.

If False, make sure to call apply_changes at the end of each time step.