Skip to content

Commit 117c9e1

Browse files
committed
Added more models
1 parent b149f25 commit 117c9e1

File tree

2 files changed

+5
-50
lines changed

2 files changed

+5
-50
lines changed

for_local_use.py

+1-49
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,6 @@
33

44
if __name__ == '__main__':
55

6-
A = BaseSpecies()
7-
p1, p2 = ModelParameters([1], [1 / u.hour, 2 / u.hour, 3 / u.hour])
8-
A >> Zero[p1 * p2]
9-
A(100)
10-
S = Simulation(A)
11-
S.run(duration=5 * u.hour, plot_data=False, level=-1)
12-
print(S.results)
13-
14-
exit()
15-
16-
"""
17-
This is the Tree model from the paper
18-
We have a population of Trees
19-
The Trees can die, age, have different colors and be in two different forests
20-
The colors can change randomly from time to time
21-
All old Trees can reproduce, but the Three is born green and young
22-
"""
23-
Ager, Mortal, Colored, Location = BaseSpecies()
24-
Colored.green, Colored.yellow, Colored.brown
25-
Location.dense, Location.sparse
26-
Ager.young >> Ager.old[1 / 10 / u.year]
27-
Mortal >> Zero [lambda r1: 0.1 / u.year if r1.old else 0]
28-
Tree = Ager * Colored * Mortal * Location
29-
30-
# replication
31-
Tree.old >> Tree + Tree.green.young[0.1/u.year]
32-
33-
# competition
34-
Tree.dense.old + Tree.dense.young >> Tree.dense.old[1e-10 * u.decimeter ** 2 / u.year]
35-
36-
# reproduction
37-
bf = 1e-10 * u.decimeter ** 2 / u.year
38-
rep_r = lambda t1, t2: 5 * bf if (Location(t1) == Location(t2) and Colored(t1) == Colored(t2)) else bf
39-
2 * Tree >> 2 * Tree + Tree.yound[rep_r]
40-
41-
# color cycling
42-
colors = ['green', 'yellow', 'brown']
43-
for color, next_color in zip(colors, colors[1:] + colors[:1]):
44-
Tree.c(color) >> Tree.c(next_color)[10/u.year]
45-
46-
# initial conditions
47-
Tree.dense(50), Tree.dense.old(50), Tree.sparse(50), Tree.sparse.old(50)
48-
# initial conditions
49-
Tree.dense(50), Tree.dense.old(50), Tree.sparse(50), Tree.sparse.old(50)
50-
MySim = Simulation(Tree)
51-
MySim.run(volume = 1 * u.meter ** 2, unit_x='year',
52-
duration=100 * u.years, repetitions=3, output_concentration=False,
53-
simulation_method='stochastic', save_data=False, plot_data=False)
54-
MySim.plot_stochastic(Tree.dense, Tree.sparse, Tree.brown)
6+
pass
557

568

mobspy/modules/meta_class.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,6 @@ def __rshift__(self, other):
471471
return reaction
472472

473473
# Reacting_Species call
474-
475474
def __call__(self, quantity):
476475
"""
477476
The call operator here is used to add counts to species non-default state. This stores the characteristics
@@ -1022,14 +1021,17 @@ def __call__(self, quantity):
10221021
# If called within a Any context, add the characteristics of the Any context to the specie called.
10231022
# The specie becomes a reacting specie.
10241023
if len(Species.meta_specie_named_any_context) != 0:
1024+
10251025
for i in Species.meta_specie_named_any_context:
10261026
self.c(i)
10271027
quantity_dict = self.add_quantities(Species.meta_specie_named_any_context.copy(), quantity)
10281028

10291029
# Check if the quantity is a valid type and add the new count to the specie
10301030
elif (type(quantity) == int or type(quantity) == float or isinstance(quantity, Quantity)
10311031
or isinstance(quantity, mp_Mobspy_Parameter)) and not asgi_Assign.check_context():
1032+
10321033
quantity_dict = self.add_quantities('std$', quantity)
1034+
10331035
elif asgi_Assign.check_context():
10341036
self.assign(quantity)
10351037
elif isinstance(quantity, me_Specific_Species_Operator):
@@ -1061,6 +1063,7 @@ def __call__(self, quantity):
10611063
else:
10621064
return self
10631065

1066+
# Species add_quantities
10641067
def add_quantities(self, characteristics, quantity):
10651068
"""
10661069
This function was implemented because Python can't accept sets as dictionary keys

0 commit comments

Comments
 (0)