Skip to content

Commit 5f53db1

Browse files
authored
Merge branch 'master' into incr_nbval_timeout
2 parents 83effc1 + 39e81d1 commit 5f53db1

6 files changed

Lines changed: 105 additions & 83 deletions

File tree

mumot/controllers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,7 @@ def __init__(self, controllers, params=None, initWidgets=None, **kwargs):
10311031
controller._view._chooseXrange = kwargs.get('choose_xrange')
10321032
if key == 'initialState':
10331033
ep1 = views_[0]._mumotModel._getAllReactants()
1034+
ep2 = [True, [react for react in views_[0]._mumotModel._getAllReactants()[0] if react not in views_[0]._mumotModel._reactants][0] if views_[0]._mumotModel._systemSize is not None else None]
10341035
# @todo assuming same model for all views.
10351036
# This operation is NOT correct when multicotroller views have different models.
10361037
if key == 'visualisationType':

mumot/exceptions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""MuMoT warning, exception and error classes."""
22

3-
43
class MuMoTWarning(Warning):
54
"""Class to report MuMoT-specific warnings.
65
"""

mumot/models.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
Function
2626
)
2727
from sympy.parsing.latex import parse_latex
28+
from warnings import warn
2829

2930
from . import (
3031
controllers,
@@ -804,11 +805,15 @@ def integrate(self, showStateVars=None, initWidgets=None, **kwargs):
804805

805806
IntParams = {}
806807
# read input parameters
808+
IntParams['substitutedReactant'] = [[react for react in self._getAllReactants()[0] if react not in self._reactants][0] if self._systemSize is not None else None, True]
809+
# the first item of extraParam2 for intial state is fixSumTo1, the second is the idle reactant
810+
extraParam2initS = [True, IntParams['substitutedReactant'][0]]
807811
IntParams['initialState'] = utils._format_advanced_option(
808812
optionName='initialState',
809813
inputValue=kwargs.get('initialState'),
810814
initValues=initWidgets.get('initialState'),
811-
extraParam=self._getAllReactants())
815+
extraParam=self._getAllReactants(),
816+
extraParam2 = extraParam2initS )
812817
IntParams['maxTime'] = utils._format_advanced_option(
813818
optionName='maxTime',
814819
inputValue=kwargs.get('maxTime'),
@@ -818,7 +823,6 @@ def integrate(self, showStateVars=None, initWidgets=None, **kwargs):
818823
inputValue=kwargs.get('plotProportions'),
819824
initValues=initWidgets.get('plotProportions'))
820825
IntParams['conserved'] = [kwargs.get('conserved', False), True]
821-
IntParams['substitutedReactant'] = [[react for react in self._getAllReactants()[0] if react not in self._reactants][0] if self._systemSize is not None else None, True]
822826

823827
# construct controller
824828
viewController = controllers.MuMoTtimeEvolutionController(
@@ -919,17 +923,20 @@ def noiseCorrelations(self, initWidgets=None, **kwargs):
919923

920924
NCParams = {}
921925
# read input parameters
926+
NCParams['substitutedReactant'] = [[react for react in self._getAllReactants()[0] if react not in self._reactants][0] if self._systemSize is not None else None, True]
927+
# the first item of extraParam2 for intial state is fixSumTo1, the second is the idle reactant
928+
extraParam2initS = [True, NCParams['substitutedReactant'][0]]
922929
NCParams['initialState'] = utils._format_advanced_option(
923930
optionName='initialState',
924931
inputValue=kwargs.get('initialState'),
925932
initValues=initWidgets.get('initialState'),
926-
extraParam=self._getAllReactants())
933+
extraParam=self._getAllReactants(),
934+
extraParam2=extraParam2initS)
927935
NCParams['maxTime'] = utils._format_advanced_option(
928936
optionName='maxTime',
929937
inputValue=kwargs.get('maxTime'),
930938
initValues=initWidgets.get('maxTime'))
931939
NCParams['conserved'] = [kwargs.get('conserved', False), True]
932-
NCParams['substitutedReactant'] = [[react for react in self._getAllReactants()[0] if react not in self._reactants][0] if self._systemSize is not None else None, True]
933940

934941
EQsys1stOrdMom, EOM_1stOrderMom, NoiseSubs1stOrder, EQsys2ndOrdMom, EOM_2ndOrderMom, NoiseSubs2ndOrder = \
935942
_getNoiseEOM(_getFokkerPlanckEquation, _get_orderedLists_vKE, self._stoichiometry)
@@ -1370,14 +1377,17 @@ def bifurcation(self, bifurcationParameter, stateVariable1,
13701377
optionName='initBifParam',
13711378
inputValue=kwargs.get('initBifParam'),
13721379
initValues=initWidgets.get('initBifParam'))
1380+
BfcParams['substitutedReactant'] = [[react for react in self._getAllReactants()[0] if react not in self._reactants][0] if self._systemSize is not None else None, True]
1381+
# the first item of extraParam2 for intial state is fixSumTo1, the second is the idle reactant
1382+
extraParam2initS = [True, BfcParams['substitutedReactant'][0]]
13731383
BfcParams['initialState'] = utils._format_advanced_option(
13741384
optionName='initialState',
13751385
inputValue=kwargs.get('initialState'),
13761386
initValues=initWidgets.get('initialState'),
1377-
extraParam=self._getAllReactants())
1387+
extraParam=self._getAllReactants(),
1388+
extraParam2=extraParam2initS)
13781389
BfcParams['bifurcationParameter'] = [bifPar, True]
13791390
BfcParams['conserved'] = [conserved, True]
1380-
BfcParams['substitutedReactant'] = [[react for react in self._getAllReactants()[0] if react not in self._reactants][0] if self._systemSize is not None else None, True]
13811391

13821392
# construct controller
13831393
viewController = controllers.MuMoTbifurcationController(
@@ -1464,12 +1474,18 @@ def multiagent(self, initWidgets=None, **kwargs):
14641474

14651475
MAParams = {}
14661476
# Read input parameters
1477+
MAParams['substitutedReactant'] = [[react for react in self._getAllReactants()[0] if react not in self._reactants][0] if self._systemSize is not None else None, True]
1478+
# the first item of extraParam2 for intial state is fixSumTo1, the second is the idle reactant
1479+
# in the multiagent() view, the sum of the initial states is fixed to 1. If this wants to be changed, remember to change also the callback function of the widgets _updateInitialStateWidgets in controllers.py
1480+
if MAParams['substitutedReactant'][0] is None and len(self._getAllReactants()[0]) > 1:
1481+
MAParams['substitutedReactant'][0] = sorted(self._getAllReactants()[0], key=str)[0]
1482+
extraParam2initS = [True, MAParams['substitutedReactant'][0]]
14671483
MAParams['initialState'] = utils._format_advanced_option(
14681484
optionName='initialState',
14691485
inputValue=kwargs.get('initialState'),
14701486
initValues=initWidgets.get('initialState'),
1471-
extraParam=self._getAllReactants())
1472-
MAParams['substitutedReactant'] = [[react for react in self._getAllReactants()[0] if react not in self._reactants][0] if self._systemSize is not None else None, True]
1487+
extraParam=self._getAllReactants(),
1488+
extraParam2=extraParam2initS)
14731489
MAParams['maxTime'] = utils._format_advanced_option(
14741490
optionName='maxTime',
14751491
inputValue=kwargs.get('maxTime'),
@@ -1622,12 +1638,18 @@ def SSA(self, initWidgets=None, **kwargs):
16221638

16231639
ssaParams = {}
16241640
# Read input parameters
1641+
ssaParams['substitutedReactant'] = [[react for react in self._getAllReactants()[0] if react not in self._reactants][0] if self._systemSize is not None else None, True]
1642+
# the first item of extraParam2 for intial state is fixSumTo1, the second is the idle reactant
1643+
# in the SSA() view, the sum of the initial states is fixed to 1. If this wants to be changed, remember to change also the callback function of the widgets _updateInitialStateWidgets in controllers.py
1644+
if ssaParams['substitutedReactant'][0] is None and len(self._getAllReactants()[0]) > 1:
1645+
ssaParams['substitutedReactant'][0] = sorted(self._getAllReactants()[0], key=str)[0]
1646+
extraParam2initS = [True, ssaParams['substitutedReactant'][0]]
16251647
ssaParams['initialState'] = utils._format_advanced_option(
16261648
optionName='initialState',
16271649
inputValue=kwargs.get('initialState'),
16281650
initValues=initWidgets.get('initialState'),
1629-
extraParam=self._getAllReactants())
1630-
ssaParams['substitutedReactant'] = [[react for react in self._getAllReactants()[0] if react not in self._reactants][0] if self._systemSize is not None else None, True]
1651+
extraParam=self._getAllReactants(),
1652+
extraParam2=extraParam2initS)
16311653
ssaParams['maxTime'] = utils._format_advanced_option(
16321654
optionName='maxTime',
16331655
inputValue=kwargs.get('maxTime'),
@@ -1782,7 +1804,7 @@ def _getSingleAgentRules(self):
17821804
if reactant in allConstantReactants:
17831805
warningMsg = 'WARNING! Constant reactants appearing on the right-handside are ignored. Every constant reactant on the left-handside (implicitly) corresponds to the same constant reactant on the right-handside.\n'\
17841806
f'E.g., in rule ' + str(rule.lhsReactants) + ' -> ' + str(rule.rhsReactants) + ' constant reactants should not appear on the right-handside.'
1785-
print(warningMsg)
1807+
warn(warningMsg, exceptions.MuMoTWarning)
17861808
break # print maximum one warning
17871809

17881810
# Add to the target of the first non-empty item the new born coming from empty-set or constant reactants

0 commit comments

Comments
 (0)