Skip to content

Commit

Permalink
Merge pull request #344 from DiODeProject/def_sympy_funcs
Browse files Browse the repository at this point in the history
Unpin sympy version (WIP) - close #170
  • Loading branch information
jarmarshall committed Sep 18, 2019
2 parents fa920ef + 3b9cb72 commit 1679c57
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ python:
- "3.6"
- "3.7"
before_install:
- sudo apt-get install -y texlive graphviz dvipng
- sudo apt-get install -y texlive texlive-latex-extra graphviz dvipng
install:
- pip install tox-travis codecov
script:
Expand Down
23 changes: 17 additions & 6 deletions mumot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
solve,
Symbol,
symbols,
Function
)

from . import (
Expand Down Expand Up @@ -438,7 +439,8 @@ def getMasterEquation(self):
Dictionary of substitutions used, this defaults to `None` if no substitutions were made
"""
P, t = symbols('P t')
t = symbols('t')
P = Function('P')
stoich = self._stoichiometry
nvec = []
for key1 in stoich:
Expand Down Expand Up @@ -468,7 +470,8 @@ def showMasterEquation(self):
"""

P, t = symbols('P t')
t = symbols('t')
P = Function('P')
out_rhs = ""
stoich = self._stoichiometry
nvec = []
Expand Down Expand Up @@ -2208,7 +2211,8 @@ def _get_orderedLists_vKE(stoich):

def _getFokkerPlanckEquation(_get_orderedLists_vKE, stoich):
"""Return the Fokker-Planck equation."""
P, t = symbols('P t')
t = symbols('t')
P = Function('P')
V = Symbol(r'\overline{V}', real=True, constant=True)
Vlist_lhs, Vlist_rhs, substring = _get_orderedLists_vKE(stoich)
rhsFPE = 0
Expand Down Expand Up @@ -2261,7 +2265,10 @@ def _getNoiseEOM(_getFokkerPlanckEquation, _get_orderedLists_vKE, stoich):
Returns equations of motion for noise.
"""
P, M_1, M_2, t = symbols('P M_1 M_2 t')
t = symbols('t')
P = Function('P')
M_1 = Function('M_1')
M_2 = Function('M_2')

# A,B, alpha, beta, gamma = symbols('A B alpha beta gamma')
# custom_stoich= {'reaction1': {'rate': alpha, A: [0,1]}, 'reaction2': {'rate': gamma, A: [2,0], B: [0,1]},
Expand Down Expand Up @@ -2440,7 +2447,10 @@ def _getNoiseStationarySol(_getNoiseEOM, _getFokkerPlanckEquation, _get_orderedL
Returns analytical solution for stationary noise.
"""
P, M_1, M_2, t = symbols('P M_1 M_2 t')
t = symbols('t')
P = Function('P')
M_1 = Function('M_1')
M_2 = Function('M_2')

EQsys1stOrdMom, EOM_1stOrderMom, NoiseSubs1stOrder, EQsys2ndOrdMom, EOM_2ndOrderMom, NoiseSubs2ndOrder = _getNoiseEOM(_getFokkerPlanckEquation, _get_orderedLists_vKE, stoich)

Expand Down Expand Up @@ -2562,7 +2572,8 @@ def _getNoiseStationarySol(_getNoiseEOM, _getFokkerPlanckEquation, _get_orderedL

def _getODEs_vKE(_get_orderedLists_vKE, stoich):
"""Return the ODE system derived from Master equation."""
P, t = symbols('P t')
t = symbols('t')
P = Function('P')
V = Symbol(r'\overline{V}', real=True, constant=True)
Vlist_lhs, Vlist_rhs, substring = _get_orderedLists_vKE(stoich)
rhsODE = 0
Expand Down
22 changes: 16 additions & 6 deletions mumot/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
default_sort_key,
Derivative,
factorial,
Function,
lambdify,
latex,
simplify,
Expand Down Expand Up @@ -1188,7 +1189,8 @@ def _plot_NumSolODE(self, _=None):
for key in EOM_1stOrdMomDict:
noiseCorrEOMdict[sym * key] = sympy.expand(sym * EOM_1stOrdMomDict[key])

M_1, M_2 = sympy.symbols('M_1 M_2')
M_1 = Function('M_1')
M_2 = Function('M_2')
eta_SV1 = sympy.Symbol(f"eta_{self._stateVariable1}")
cVar1 = sympy.symbols('cVar1')
if self._stateVariable2:
Expand Down Expand Up @@ -1332,7 +1334,8 @@ def _numericSol2ndOrdMoment(self, EOM_2ndOrdMomDict, steadyStateDict, argDict):
# if len(self._stateVarList) == 3:
# eta_SV3 = sympy.Symbol('eta_' + str(self._stateVarList[2]))

M_1, M_2 = sympy.symbols('M_1 M_2')
M_1 = Function('M_1')
M_2 = Function('M_2')
eta_SV1 = sympy.Symbol('eta_' + str(self._stateVariable1))
if self._stateVariable2:
eta_SV2 = sympy.Symbol('eta_' + str(self._stateVariable2))
Expand Down Expand Up @@ -1680,7 +1683,7 @@ def _plot_field(self) -> None:
Phi_stateVar2 = sympy.Symbol('Phi_' + str(self._stateVariable2))
eta_stateVar1 = sympy.Symbol('eta_' + str(self._stateVariable1))
eta_stateVar2 = sympy.Symbol('eta_' + str(self._stateVariable2))
M_2 = sympy.Symbol('M_2')
M_2 = sympy.Function('M_2')

systemSize = sympy.Symbol('systemSize')
argDict = self._get_argDict()
Expand Down Expand Up @@ -5643,8 +5646,13 @@ def _deriveMasterEquation(stoichiometry):
Returns dictionary used in :method:`MuMoTmodel.showMasterEquation`.
"""
substring = None
P, E_op, x, y, v, w, t, m = symbols('P E_op x y v w t m')

x, y, v, w, t, m = symbols('x y v w t m')
E_op = Function('E_op')
z = Function('z')
P = Function('P')
V = Symbol(r'\overline{V}', real=True, constant=True)

stoich = stoichiometry
nvec = []
for key1 in stoich:
Expand All @@ -5665,7 +5673,7 @@ def _deriveMasterEquation(stoichiometry):

rhs = 0
sol_dict_rhs = {}
f = lambdify((x(y, v - w)), x(y, v - w), modules='sympy')
f = lambdify(z(y, v - w), z(y, v - w), modules='sympy')
g = lambdify((x, y, v), (factorial(x) / factorial(x - y)) / v**y, modules='sympy')
for key1 in stoich:
prod1 = 1
Expand All @@ -5692,7 +5700,9 @@ def _deriveMasterEquation(stoichiometry):

def _doVanKampenExpansion(rhs, stoich):
"""Return the left-hand side and right-hand side of van Kampen expansion."""
P, E_op, x, y, v, w, t, m = symbols('P E_op x y v w t m')
x, y, v, w, t, m = symbols('x y v w t m')
E_op = Function('E_op')
P = Function('P')
V = Symbol(r'\overline{V}', real=True, constant=True)
nvec = []
nconstvec = []
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
'pydstool>=0.90.3', # min version that allows scipy >= 1.0.0 to be used
'pyzmq<17', # needed if using tornado < 5
'scipy',
'sympy >= 1.1.1, < 1.3', # see https://github.com/DiODeProject/MuMoT/issues/170
'sympy>=1.4',
'tornado<5' # needed to avoid errors with older ipykernel
],
extras_require={
Expand Down

0 comments on commit 1679c57

Please sign in to comment.