Characteristics

MobsPy can also add characteristics to species and construct reactions based on these characteristics by a querying mechanism. In this example, we describe the characteristic mechanism in detail

First we define 2 BaseSpecies:

[1]:
from mobspy import *

Age, Color = BaseSpecies(2)

Characteristics can be added using the dot operator to a meta-species in the first time it is called. They can be added implicitly inside a reaction and explicitly outside a reaction. When added explicitly, the characteristics will automatically partake in the reaction. An example follows:

[2]:
Color.blue, Color.red, Color.yellow
Age.young >> Age.old [1]
[2]:
<mobspy.modules.meta_class.Reactions at 0x7ff66a42be20>

We next multiply Age and Color to create a Dummy meta-species. The new meta-species inherit the characteristics of Color and Age. It inherits them as a two-dimensional vector space with orthogonal characteristic sets. The Dummy meta-species represents all the possible combinations of characteristics from the meta-species it inherits from, separated by a dot. As an example, Dummy can be in the following states:

Dummy.blue.young,
Dummy.blue.old,
Dummy.red.young,
Dummy.red.old,
Dummy.yellow.young,
Dummy.yellow.old
[3]:
Dummy = Age*Color

One can query the meta-species that Dummy represents using characteristics. If the query is present on a reactant, it filters through the states that do not possess the requested characteristic. As an example, the meta-reaction:

[4]:
Dummy.old >> Zero [1]
[4]:
<mobspy.modules.meta_class.Reactions at 0x7ff66a42bb80>

Defines the following reactions:

Dummy.red.old ->
Dummy.yellow.old ->
Dummy.blue.old ->

One can also perform a query in the products. When performed in the products, the query specifies in which space one wishes the transformation to occur. For instance, the meta-reaction:

[5]:
Dummy >> Dummy.blue [1]
[5]:
<mobspy.modules.meta_class.Reactions at 0x7ff66a42b9a0>

Defines the following reactions:

Dummy.red.young -> Dummy.blue.young
Dummy.red.old -> Dummy.blue.old
Dummy.blue.young -> Dummy.blue.young
Dummy.blue.old -> Dummy.blue.old
Dummy.yellow.young -> Dummy.blue.young
Dummy.yellow.old -> Dummy.blue.old

Thus, by querying the blue characteristic in the products, one has specified that he wishes that the color characteristic transforms into blue.

It is also possible to query over multiple characteristics at the same time, and the order is irrelevant.

We finish by compiling the model to visualize all the reactions in detail:

[6]:
S = Simulation(Dummy)
print(S.compile())

Species
Dummy.blue.old,0
Dummy.blue.young,0
Dummy.red.old,0
Dummy.red.young,0
Dummy.yellow.old,0
Dummy.yellow.young,0

Mappings
Dummy :
Dummy.blue.old
Dummy.blue.young
Dummy.red.old
Dummy.red.young
Dummy.yellow.old
Dummy.yellow.young

Parameters
volume,1

Reactions
reaction_0,{'re': [(1, 'Dummy.blue.old')], 'pr': [(1, 'Dummy.blue.old')], 'kin': 'Dummy.blue.old * 1'}
reaction_1,{'re': [(1, 'Dummy.blue.old')], 'pr': [], 'kin': 'Dummy.blue.old * 1'}
reaction_2,{'re': [(1, 'Dummy.blue.young')], 'pr': [(1, 'Dummy.blue.old')], 'kin': 'Dummy.blue.young * 1'}
reaction_3,{'re': [(1, 'Dummy.blue.young')], 'pr': [(1, 'Dummy.blue.young')], 'kin': 'Dummy.blue.young * 1'}
reaction_4,{'re': [(1, 'Dummy.red.old')], 'pr': [(1, 'Dummy.blue.old')], 'kin': 'Dummy.red.old * 1'}
reaction_5,{'re': [(1, 'Dummy.red.old')], 'pr': [], 'kin': 'Dummy.red.old * 1'}
reaction_6,{'re': [(1, 'Dummy.red.young')], 'pr': [(1, 'Dummy.blue.young')], 'kin': 'Dummy.red.young * 1'}
reaction_7,{'re': [(1, 'Dummy.red.young')], 'pr': [(1, 'Dummy.red.old')], 'kin': 'Dummy.red.young * 1'}
reaction_8,{'re': [(1, 'Dummy.yellow.old')], 'pr': [(1, 'Dummy.blue.old')], 'kin': 'Dummy.yellow.old * 1'}
reaction_9,{'re': [(1, 'Dummy.yellow.old')], 'pr': [], 'kin': 'Dummy.yellow.old * 1'}
reaction_10,{'re': [(1, 'Dummy.yellow.young')], 'pr': [(1, 'Dummy.blue.young')], 'kin': 'Dummy.yellow.young * 1'}
reaction_11,{'re': [(1, 'Dummy.yellow.young')], 'pr': [(1, 'Dummy.yellow.old')], 'kin': 'Dummy.yellow.young * 1'}

Compiling model
WARNING: Automatic data-saving setup failed. Please save manually
[ ]: