ecell / ecell4_base

An integrated software environment for multi-algorithm, multi-timescale, multi-spatial-representation simulation of various cellular phenomena
https://ecell4.e-cell.org/
GNU General Public License v3.0
63 stars 23 forks source link

The order of species attribute definitions affects the result #348

Closed kaizu closed 5 years ago

kaizu commented 5 years ago

The following code works correctly.

from ecell4 import *
from ecell4_base.core import *

# OK
with species_attributes():
    A | {'D': 1, 'location': 'M', 'dimension': 2}
    M | {'dimension': 2}

surface = Sphere(ones() * 0.5, 0.4).surface()
obs = FixedIntervalTrajectoryObserver(1e-4)

run_simulation(
    0.4, y0={'A': 10}, structures={'M': surface},
    solver='spatiocyte', observers=obs, return_type=None)

viz.plot_trajectory(obs, interactive=True)

However, the model below fails.

# FAIL
with species_attributes():
    A | {'D': 1, 'location': 'M'}
    M | {'dimension': 2}

To avoid this issue, M must be defined former than A:

# OK
with species_attributes():
    M | {'dimension': 2}
    A | {'D': 1, 'location': 'M'}
kaizu commented 5 years ago

Sorry. This seems okay now.