From 90a8cfb26c47322d6d1892f1bfc7fde4a8f9395e Mon Sep 17 00:00:00 2001
From: Dilawar Singh <dilawars@ncbs.res.in>
Date: Mon, 20 May 2019 09:56:07 +0530
Subject: [PATCH] Squashed 'moose-examples/' changes from be8e726..fe0a2ce

fe0a2ce Merge pull request #63 from upibhalla/master
8d0c500 Merge branch 'master' into master
f49a6ee Merge branch 'master' of https://github.com/upibhalla/moose-examples
6ef6d7b Fixes to ex7.2_CICR.py Now it oscillates properly again
09a1135 Merge pull request #60 from upibhalla/master
7ff52e3 Merge branch 'master' into master
9c7bdf6 Update README.md (#53)
d5768b0 Fixed CICRspineDend.g model to use the corrected scaling for ConcChans. Affects Rdesigneur ex8.1_synTrigCICR.py
8aece01 Added Rdesigneur tutorial ex7.6_func_controls_reac_rate.py

git-subtree-dir: moose-examples
git-subtree-split: fe0a2ce87288f266f3348a86f6d3849f68cebdf2
---
 README.md                                     | 10 +++
 tutorials/Rdesigneur/chem/CICRspineDend.g     |  6 +-
 tutorials/Rdesigneur/chem/CICRwithConcChan.g  | 33 ++-------
 tutorials/Rdesigneur/ex7.2_CICR.py            |  2 +-
 .../ex7.6_func_controls_reac_rate.py          | 67 +++++++++++++++++++
 5 files changed, 85 insertions(+), 33 deletions(-)
 create mode 100644 tutorials/Rdesigneur/ex7.6_func_controls_reac_rate.py

diff --git a/README.md b/README.md
index d6f12fbe..b5e52fa0 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,13 @@
 [![Build Status](https://travis-ci.org/BhallaLab/moose-examples.svg?branch=master)](https://travis-ci.org/BhallaLab/moose-examples).
 
 Examples, tutorial and demo scripts.
+
+# How to run
+
+First install `pymoose` from PyPI using `pip`.
+
+     $ pip install pymoose --pre --user # get the latest version
+    
+Make sure that you have `matplotlib`, and `scipy` (optional) installed as well.
+
+Some scripts might require `PyQt4` or `PyQt5` as well.
diff --git a/tutorials/Rdesigneur/chem/CICRspineDend.g b/tutorials/Rdesigneur/chem/CICRspineDend.g
index b1211065..f57401f5 100644
--- a/tutorials/Rdesigneur/chem/CICRspineDend.g
+++ b/tutorials/Rdesigneur/chem/CICRspineDend.g
@@ -1,7 +1,7 @@
 //genesis
 // kkit Version 11 flat dumpfile
  
-// Saved on Tue Aug 21 06:59:07 2018
+// Saved on Sat Feb 16 15:40:53 2019
  
 include kkit {argv 1}
  
@@ -141,7 +141,7 @@ simundump kpool /kinetics/ActIP3R 0 0.0 0 0 0 0 0 0 1866.9 0 \
 simundump text /kinetics/ActIP3R/notes 0 ""
 call /kinetics/ActIP3R/notes LOAD \
 ""
-simundump kchan /kinetics/ActIP3R/chan 0 8000 0.1 0 1 0 "" brown 8 2 2 0
+simundump kchan /kinetics/ActIP3R/chan 0 8 0.1 0 1 0 "" brown 8 2 2 0
 simundump text /kinetics/ActIP3R/chan/notes 0 ""
 call /kinetics/ActIP3R/chan/notes LOAD \
 ""
@@ -207,7 +207,7 @@ simundump kpool /kinetics/DEND_ER/leakPool 0 0 1 1 234 234 0 0 234 0 \
 simundump text /kinetics/DEND_ER/leakPool/notes 0 ""
 call /kinetics/DEND_ER/leakPool/notes LOAD \
 ""
-simundump kchan /kinetics/DEND_ER/leakPool/leakChan 0 40 0.1 0 1 0 "" brown \
+simundump kchan /kinetics/DEND_ER/leakPool/leakChan 0 0.04 0.1 0 1 0 "" brown \
   45 4 5 0
 simundump text /kinetics/DEND_ER/leakPool/leakChan/notes 0 ""
 call /kinetics/DEND_ER/leakPool/leakChan/notes LOAD \
diff --git a/tutorials/Rdesigneur/chem/CICRwithConcChan.g b/tutorials/Rdesigneur/chem/CICRwithConcChan.g
index a8c3792c..136de825 100644
--- a/tutorials/Rdesigneur/chem/CICRwithConcChan.g
+++ b/tutorials/Rdesigneur/chem/CICRwithConcChan.g
@@ -1,7 +1,7 @@
 //genesis
 // kkit Version 11 flat dumpfile
  
-// Saved on Fri Aug 17 04:02:55 2018
+// Saved on Fri Mar 29 19:34:16 2019
  
 include kkit {argv 1}
  
@@ -71,16 +71,6 @@ simundump kpool /kinetics/CaCyt 0 1e-13 0.079999 0.079999 149.35 149.35 0 0 \
 simundump text /kinetics/CaCyt/notes 0 ""
 call /kinetics/CaCyt/notes LOAD \
 ""
-simundump kpool /kinetics/phase 0 0.0 100 100 1.8669e+05 1.8669e+05 0 0 \
-  1866.9 0 /kinetics/geometry 49 black 9 9 0
-simundump text /kinetics/phase/notes 0 ""
-call /kinetics/phase/notes LOAD \
-""
-simundump kpool /kinetics/ampl 0 0.0 0 0 0 0 0 0 1866.9 0 /kinetics/geometry \
-  63 black 10 5 0
-simundump text /kinetics/ampl/notes 0 ""
-call /kinetics/ampl/notes LOAD \
-""
 simundump kpool /kinetics/CaIP3_3_R 0 0.0 0 0 0 0 0 0 1866.9 0 \
   /kinetics/geometry 20 black 4 7 0
 simundump text /kinetics/CaIP3_3_R/notes 0 ""
@@ -146,11 +136,6 @@ simundump kpool /kinetics/Ca2_IP3_3_R 0 0.0 0 0 0 0 0 0 1866.9 0 \
 simundump text /kinetics/Ca2_IP3_3_R/notes 0 ""
 call /kinetics/Ca2_IP3_3_R/notes LOAD \
 ""
-simundump kpool /kinetics/CaStim 0 0.0 0 0 0 0 0 0 1866.9 4 \
-  /kinetics/geometry 61 black 7 5 0
-simundump text /kinetics/CaStim/notes 0 ""
-call /kinetics/CaStim/notes LOAD \
-""
 simundump kpool /kinetics/Mirror_CaIP3_3_R 0 0.0 0 0 0 0 0 0 1866.9 0 \
   /kinetics/geometry 4 black -1 4 0
 simundump text /kinetics/Mirror_CaIP3_3_R/notes 0 ""
@@ -161,20 +146,10 @@ simundump kpool /kinetics/ActIP3R 0 0.0 0 0 0 0 0 0 1866.9 0 \
 simundump text /kinetics/ActIP3R/notes 0 ""
 call /kinetics/ActIP3R/notes LOAD \
 ""
-simundump kchan /kinetics/ActIP3R/chan 0 12720 0.1 0 1 0 "" brown 8 2 2 0
+simundump kchan /kinetics/ActIP3R/chan 0 8 0.1 0 1 0 "" brown 8 2 2 0
 simundump text /kinetics/ActIP3R/chan/notes 0 ""
 call /kinetics/ActIP3R/chan/notes LOAD \
 ""
-simundump kpool /kinetics/basal 0 0.0 0 0 0 0 0 0 1866.9 0 /kinetics/geometry \
-  8 black 2 -1 0
-simundump text /kinetics/basal/notes 0 ""
-call /kinetics/basal/notes LOAD \
-""
-simundump kpool /kinetics/BufPool 0 0.0 0 0 0 0 0 0 1866.9 4 \
-  /kinetics/geometry 26 black 1 9 0
-simundump text /kinetics/BufPool/notes 0 ""
-call /kinetics/BufPool/notes LOAD \
-""
 simundump kreac /kinetics/CaMreac1 0 0.0045449 8.4853 "" white black 5 0 0
 simundump text /kinetics/CaMreac1/notes 0 ""
 call /kinetics/CaMreac1/notes LOAD \
@@ -212,7 +187,7 @@ simundump kpool /kinetics/leakPool 0 0 1 1 234 234 0 0 234 0 \
 simundump text /kinetics/leakPool/notes 0 ""
 call /kinetics/leakPool/notes LOAD \
 ""
-simundump kchan /kinetics/leakPool/leakChan 0 15.3 0.1 0 1 0 "" brown 45 4 5 \
+simundump kchan /kinetics/leakPool/leakChan 0 0.04 0.1 0 1 0 "" brown 45 4 5 \
   0
 simundump text /kinetics/leakPool/leakChan/notes 0 ""
 call /kinetics/leakPool/leakChan/notes LOAD \
@@ -229,7 +204,7 @@ simundump xplot /graphs/conc2/CaER.Co 3 524288 \
   "delete_plot.w <s> <d>; edit_plot.D <w>" 0 0 0 1
 simundump xgraph /moregraphs/conc3 0 0 100 0 1 0
 simundump xgraph /moregraphs/conc4 0 0 100 0 1 0
-simundump xcoredraw /edit/draw 0 -3 12 -3 11
+simundump xcoredraw /edit/draw 0 -1.5666 11.334 -1.8008 10.24
 simundump xtree /edit/draw/tree 0 \
   /kinetics/#[],/kinetics/#[]/#[],/kinetics/#[]/#[]/#[][TYPE!=proto],/kinetics/#[]/#[]/#[][TYPE!=linkinfo]/##[] \
   "edit_elm.D <v>; drag_from_edit.w <d> <S> <x> <y> <z>" auto 0.6
diff --git a/tutorials/Rdesigneur/ex7.2_CICR.py b/tutorials/Rdesigneur/ex7.2_CICR.py
index 38447a8d..a9725b6f 100644
--- a/tutorials/Rdesigneur/ex7.2_CICR.py
+++ b/tutorials/Rdesigneur/ex7.2_CICR.py
@@ -37,6 +37,6 @@ IP3 = moose.element( '/model/chem/dend/IP3' )
 IP3.vec.concInit = 0.004
 IP3.vec[0].concInit = 0.02
 moose.reinit()
-moose.start( 40 )
+moose.start( 20 )
 
 rdes.display()
diff --git a/tutorials/Rdesigneur/ex7.6_func_controls_reac_rate.py b/tutorials/Rdesigneur/ex7.6_func_controls_reac_rate.py
new file mode 100644
index 00000000..b8c8fb4c
--- /dev/null
+++ b/tutorials/Rdesigneur/ex7.6_func_controls_reac_rate.py
@@ -0,0 +1,67 @@
+########################################################################
+# This example illustrates how a function can be used to control a reaction
+# rate. This kind of calculation is appropriate when we need to link 
+# different kinds of physical processses with chemical reactions, for  
+# example, membrane curvature with molecule accumulation. The use of
+# functions to modify reaction rates should be avoided in purely chemical 
+# systems since they obscure the underlying chemistry, and do not map
+# cleanly to stochastic calculations.
+#
+# In this example we simply have a molecule C that controls the forward
+# rate of a reaction that converts A to B. C is a function of location
+# on the cylinder, and is fixed. In more elaborate computations we could
+# have a function of multiple molecules, some of which could be changing and
+# others could be buffered.
+#  
+#  Copyright (C) Upinder S. Bhalla NCBS 2018
+#  Released under the terms of the GNU Public License V3.
+########################################################################
+
+import numpy as np
+import moose
+import pylab
+import rdesigneur as rd
+
+
+def makeFuncRate():
+    model = moose.Neutral( '/library' )
+    model = moose.Neutral( '/library/chem' )
+    compt = moose.CubeMesh( '/library/chem/compt' )
+    compt.volume = 1e-15
+    A = moose.Pool( '/library/chem/compt/A' )
+    B = moose.Pool( '/library/chem/compt/B' )
+    C = moose.Pool( '/library/chem/compt/C' )
+    reac = moose.Reac( '/library/chem/compt/reac' )
+    func = moose.Function( '/library/chem/compt/reac/func' )
+    func.x.num = 1
+    func.expr = "(x0/1e8)^2"
+    moose.connect( C, 'nOut', func.x[0], 'input' )
+    moose.connect( func, 'valueOut', reac, 'setNumKf' )
+    moose.connect( reac, 'sub', A, 'reac' )
+    moose.connect( reac, 'prd', B, 'reac' )
+
+    A.concInit = 1
+    B.concInit = 0
+    C.concInit = 0
+    reac.Kb = 1
+
+
+makeFuncRate()
+
+rdes = rd.rdesigneur(
+        turnOffElec = True,
+        #This subdivides the 50-micron cylinder into 2 micron voxels
+        diffusionLength = 2e-6,
+        cellProto = [['somaProto', 'soma', 5e-6, 50e-6]],
+        chemProto = [['chem', 'chem']],
+        chemDistrib = [['chem', 'soma', 'install', '1' ]],
+        plotList = [['soma', '1', 'dend/A', 'conc', 'A conc', 'wave'],
+            ['soma', '1', 'dend/C', 'conc', 'C conc', 'wave']],
+)
+rdes.buildModel()
+
+C = moose.element( '/model/chem/dend/C' )
+C.vec.concInit = [ 1+np.sin(x/5.0) for x in range( len(C.vec) ) ]
+moose.reinit()
+moose.start(10)
+rdes.display()
-- 
GitLab