Changeset 12176 in project
- Timestamp:
- 10/16/08 04:51:51 (12 years ago)
- Location:
- release/3/nemo/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
release/3/nemo/trunk/examples/AKP06/PotIhCa.scm
r12171 r12176 15 15 (/ (* 1e-6 (* 2 zeta F) (- ci (* co (exp (neg zeta))))) (- 1.0 (exp (neg zeta)))))))) 16 16 17 (decaying-pool (ca ( depth 0.1) (beta 1)))17 (decaying-pool (ca (initial 1e-4) (depth 0.1) (beta 1) (temp-adj temp_adj))) 18 18 19 19 (component (type ion-channel) (name Kv1) … … 267 267 268 268 269 269 #| 270 270 (component (type ion-channel) (name Narsg) 271 271 … … 384 384 385 385 ) ;; end Narsg current 386 |# 386 387 387 388 -
release/3/nemo/trunk/examples/AKP06/morphology_mechanisms.hoc
r11997 r12176 15 15 insert Kbin 16 16 //insert CaBK 17 insert Caint17 //insert Caint 18 18 //insert CaP 19 19 //insert Ih -
release/3/nemo/trunk/nemo-core.scm
r12167 r12176 16 16 ;; A full copy of the GPL license can be found at 17 17 ;; <http://www.gnu.org/licenses/>. 18 ;; 19 ;; TODO: * check that open states in state complexes are valid 18 20 ;; 19 21 -
release/3/nemo/trunk/nemo-nmodl.scm
r12172 r12176 1 2 ;; TODO: * check that open states are valid3 1 ;; 4 2 ;; … … 727 725 (let* ((indent 0) 728 726 (indent+ (+ 2 indent )) 727 (eval-const (dis 'eval-const)) 729 728 (sysname (nmodl-name ((dis 'sysname) sys))) 730 729 (deps* ((dis 'depgraph*) sys)) … … 777 776 778 777 (for-each 779 (lambda (a p) 780 (let ((acc-ion (car a)) 781 (pool-ion (car p))) 782 (if (alist-ref acc-ion perm-ions) 778 (lambda (a) 779 (let ((acc-ion (car a))) 780 (if (assoc acc-ion perm-ions) 783 781 (nemo:error 'nemo:nmodl-translator 784 ": ion species " ion " cannot be declared as both accumulating and permeating")) 785 (if (alist-ref pool-ion perm-ions) 782 ": ion species " acc-ion " cannot be declared as both accumulating and permeating")))) 783 acc-ions) 784 785 (for-each 786 (lambda (p) 787 (let ((pool-ion (car p))) 788 (if (assoc pool-ion perm-ions) 786 789 (nemo:error 'nemo:nmodl-translator 787 ": ion species " ion " cannot be declared as both pool and permeating"))))788 acc-ions)790 ": ion species " pool-ion " cannot be declared as both pool and permeating")))) 791 pool-ions) 789 792 790 793 (pp indent ,nl (TITLE ,sysname)) … … 801 804 (USEION ,(first x) READ ,(third x) WRITE ,(second x)))))) 802 805 perm-ions) 803 (for-each (lambda (x) 804 (pp indent+ (RANGE ,(second x)) 805 (USEION ,(first x) READ ,(third x) ", " ,(fourth x) WRITE ,(second x)))) 806 acc-ions) 807 (for-each (lambda (x) 808 (pp indent+ (RANGE ,(first x)) 809 (USEION ,(first x) READ ,(second x) WRITE ,(third x)))) 810 pool-ions) 806 (for-each (lambda (acc-ion) 807 (let ((pool-ion (assoc (first acc-ion) pool-ions))) 808 (if pool-ion 809 (pp indent+ (RANGE ,(second acc-ion)) 810 (USEION ,(first acc-ion) 811 READ ,(sl\ ", " (list (third acc-ion) (fourth acc-ion) (second pool-ion))) 812 WRITE ,(sl\ ", " (list (second acc-ion) (third pool-ion ))))) 813 (pp indent+ (RANGE ,(second acc-ion)) 814 (USEION ,(first acc-ion) 815 READ ,(sl\ ", " (list (third acc-ion) (fourth acc-ion) )) 816 WRITE ,(second acc-ion)))))) 817 acc-ions) 818 811 819 (let* ((const-names (map first consts)) 812 820 (is-const? (lambda (x) (member x const-names))) … … 834 842 (for-each (lambda (def) 835 843 (let ((n (first def)) (b (second def))) 836 (pp indent+ ,(expr->string/NMODL b n)))) const-defs)) 844 (pp indent+ ,(expr->string/NMODL b n)))) const-defs) 845 (for-each (lambda (ep) 846 (let* ((ep-name (first ep)) 847 (ep-props (second ep)) 848 (init-expr (lookup-def 'initial ep-props)) 849 (temp-expr (lookup-def 'temp-adj ep-props)) 850 (beta-expr (lookup-def 'beta ep-props)) 851 (depth-expr (lookup-def 'depth ep-props)) 852 (init-name (nmodl-name (s+ ep-name '-init))) 853 (temp-name (nmodl-name (s+ ep-name '-temp-adj))) 854 (beta-name (nmodl-name (s+ ep-name '-beta))) 855 (depth-name (nmodl-name (s+ ep-name '-depth)))) 856 (if (or (not beta-expr) (not depth-expr) (not init-expr)) 857 (nemo:error 'nemo:nmodl-translator 858 ": ion pool " ep-name " requires initial value, depth and beta parameters")) 859 (let ((temp-val (and temp-expr (eval-const sys temp-expr))) 860 (init-val (eval-const sys init-expr)) 861 (beta-val (eval-const sys beta-expr)) 862 (depth-val (eval-const sys depth-expr))) 863 (pp indent+ ,(expr->string/NMODL init-val init-name)) 864 (pp indent+ ,(expr->string/NMODL temp-val temp-name)) 865 (pp indent+ ,(expr->string/NMODL beta-val beta-name)) 866 (pp indent+ ,(expr->string/NMODL depth-val depth-name))))) 867 epools)) 837 868 (pp indent "}") 838 869 … … 853 884 (for-each (lambda (st) (apply define-state (list indent+ st))) 854 885 stcomps) 886 (for-each (lambda (pool-ion) (apply define-state (list indent+ (first pool-ion)))) 887 pool-ions) 855 888 (pp indent "}") 856 889 … … 858 891 (let* ((asgns0 (append asgns (map first imports) 859 892 (map second perm-ions) (map third perm-ions) 860 (map second acc-ions) (map fourth acc-ions))) 893 (map second acc-ions) (map fourth acc-ions) 894 (map second pool-ions) (map third pool-ions) 895 )) 861 896 (asgns1 (delete-duplicates asgns0))) 862 897 (for-each (lambda (x) (pp indent+ ,(nmodl-name x))) asgns1) 863 (pp indent "}") 898 (pp indent "}")) 899 900 (if (not (null? asgns)) 901 (begin 902 (pp indent ,nl (PROCEDURE rates () "{")) 903 (let ((locals (find-locals (map second asgn-eq-defs))) ) 904 (if (not (null? locals)) (pp indent+ (LOCAL ,(sl\ ", " locals))))) 905 (for-each (lambda (def) 906 (let ((n (nmodl-name (first def)) ) 907 (b (second def))) 908 (pp indent+ ,(expr->string/NMODL b n)))) asgn-eq-defs) 909 (pp indent "}"))) 864 910 865 (if (not (null? asgns)) 866 (begin 867 (pp indent ,nl (PROCEDURE rates () "{")) 868 (let ((locals (find-locals (map second asgn-eq-defs))) ) 869 (if (not (null? locals)) (pp indent+ (LOCAL ,(sl\ ", " locals))))) 911 (if (not (null? stcomps)) 912 (begin 913 (pp indent ,nl (PROCEDURE stcomps () "{")) 914 (let* ((eq-defs (poset->stcomp-eq-defs poset sys)) 915 (locals (find-locals (map second eq-defs))) ) 916 (if (not (null? locals)) (pp indent+ (LOCAL ,(sl\ ", " locals)))) 870 917 (for-each (lambda (def) 871 (let ((n (nmodl-name (first def)) ) 872 (b (second def))) 873 (pp indent+ ,(expr->string/NMODL b n)))) asgn-eq-defs) 874 (pp indent "}"))) 918 (let ((n (first def)) (b (second def))) 919 (pp indent+ ,(expr->string/NMODL b n)))) eq-defs)) 920 921 (pp indent "}"))) 922 923 (if (not (null? pool-ions)) 924 (begin 925 (pp indent ,nl (PROCEDURE pools () "{")) 926 (for-each (lambda (pool-ion) 927 (pp indent+ (,(third pool-ion) = ,(first pool-ion)))) 928 pool-ions) 929 (pp indent "}"))) 875 930 876 (if (not (null? stcomps)) 877 (begin 878 (pp indent ,nl (PROCEDURE stcomps () "{")) 879 (let* ((eq-defs (poset->stcomp-eq-defs poset sys)) 880 (locals (find-locals (map second eq-defs))) ) 881 (if (not (null? locals)) (pp indent+ (LOCAL ,(sl\ ", " locals)))) 882 (for-each (lambda (def) 883 (let ((n (first def)) (b (second def))) 884 (pp indent+ ,(expr->string/NMODL b n)))) eq-defs)) 885 886 (pp indent "}"))) 887 888 (pp indent ,nl (BREAKPOINT "{")) 889 (let* ((i-eqs (filter-map 890 (lambda (ionch) 891 (let* ((n (second ionch)) 892 (subcomps ((dis 'component-subcomps) sys n)) 893 (acc (lookup-def 'accumulating-substance subcomps)) 894 (perm (lookup-def 'permeating-substance subcomps)) 895 (pore (lookup-def 'pore subcomps)) 896 (gate (lookup-def 'gate subcomps)) 897 (sts (and gate ((dis 'component-exports) sys (cid gate))))) 898 (cond ((and perm pore gate) 899 (case (cn perm) 900 ((non-specific) 901 (let* ((i (nmodl-name 'i)) 902 (e (nmodl-name 'e)) 903 (gmax (car ((dis 'component-exports) sys (cid pore)))) 904 (pwrs (map (lambda (n) (state-power sys n)) sts)) 931 (pp indent ,nl (BREAKPOINT "{")) 932 (let* ((i-eqs (filter-map 933 (lambda (ionch) 934 (let* ((n (second ionch)) 935 (subcomps ((dis 'component-subcomps) sys n)) 936 (acc (lookup-def 'accumulating-substance subcomps)) 937 (perm (lookup-def 'permeating-substance subcomps)) 938 (pore (lookup-def 'pore subcomps)) 939 (gate (lookup-def 'gate subcomps)) 940 (sts (and gate ((dis 'component-exports) sys (cid gate))))) 941 (cond ((and perm pore gate) 942 (case (cn perm) 943 ((non-specific) 944 (let* ((i (nmodl-name 'i)) 945 (e (nmodl-name 'e)) 946 (gmax (car ((dis 'component-exports) sys (cid pore)))) 947 (pwrs (map (lambda (n) (state-power sys n)) sts)) 948 (gion `(* ,gmax . ,(map (lambda (st pwr) `(pow ,st ,pwr)) sts pwrs)))) 949 (list i e gion))) 950 (else 951 (let* ((i (nmodl-name (s+ 'i (cn perm)))) 952 (e (nmodl-name (s+ 'e (cn perm)))) 953 (gmax (car ((dis 'component-exports) sys (cid pore)))) 954 (pwrs (map (lambda (n) (state-power sys n)) sts)) 905 955 (gion `(* ,gmax . ,(map (lambda (st pwr) `(pow ,st ,pwr)) sts pwrs)))) 906 (list i e gion))) 907 (else 908 (let* ((i (nmodl-name (s+ 'i (cn perm)))) 909 (e (nmodl-name (s+ 'e (cn perm)))) 910 (gmax (car ((dis 'component-exports) sys (cid pore)))) 911 (pwrs (map (lambda (n) (state-power sys n)) sts)) 912 (gion `(* ,gmax . ,(map (lambda (st pwr) `(pow ,st ,pwr)) sts pwrs)))) 913 (list i e gion))))) 956 (list i e gion))))) 914 957 ((and acc pore gate) 915 958 (let* ((i (nmodl-name (s+ 'i (cn acc)))) … … 920 963 (else (nemo:error 'nemo:nmodl-translator ": invalid ion channel definition " n)) 921 964 ))) 922 923 924 925 926 927 928 929 930 931 965 ionchs)) 966 (i-bkts (bucket-partition (lambda (x y) (eq? (car x) (car y))) i-eqs)) 967 (i-eqs (fold (lambda (b ax) 968 (match b 969 ((and ps ((i e gion) . rst)) 970 (let* ((sum (if e `(* ,(sum (map third ps)) (- v ,e)) 971 (sum (map third ps)))) 972 (sum0 (rhsexpr sum)) 973 (sum1 (canonicalize-expr/NMODL sum0))) 974 (cons (list i sum1) ax))) 932 975 933 934 935 976 ((i e gion) 977 (let* ((expr0 (rhsexpr (if e `(* ,gion (- v ,e)) gion))) 978 (expr1 (canonicalize-expr/NMODL expr0))) 936 979 (cons (list i expr1) ax))) 937 938 939 (else ax))) 940 (list) i-bkts)) 941 (locals (find-locals (map second i-eqs)))) 942 (if (not (null? locals)) (pp indent+ (LOCAL ,(sl\ ", " locals)))) 943 (if (not (null? asgns)) (pp indent+ (rates ()))) 944 (if (not method) (pp indent+ (SOLVE states)) 945 (pp indent+ (SOLVE states METHOD ,method))) 946 (if (not (null? kinetic)) 947 (pp indent+ (SOLVE kstates METHOD sparse))) 948 (if (not (null? stcomps)) (pp indent+ (stcomps ()))) 949 (for-each (lambda (p) (pp indent+ ,(expr->string/NMODL (second p) (first p)))) i-eqs) 950 (pp indent "}")) 951 952 (if (not (null? states)) 953 (begin 954 (pp indent ,nl (DERIVATIVE states "{")) 955 (let* ((eq-defs (reverse (poset->state-eq-defs poset sys kinetic))) 956 (locals (find-locals (map second eq-defs))) ) 957 (if (not (null? locals)) (pp indent+ (LOCAL ,(sl\ ", " locals)))) 958 (for-each (lambda (def) 959 (let ((n (first def)) (b (second def))) 960 (pp indent+ ,(expr->string/NMODL b n)))) eq-defs)) 961 (pp indent "}"))) 962 963 (if (not (null? kinetic)) 980 981 982 (else ax))) 983 (list) i-bkts)) 984 (locals (find-locals (map second i-eqs)))) 985 (if (not (null? locals)) (pp indent+ (LOCAL ,(sl\ ", " locals)))) 986 (if (not (null? asgns)) (pp indent+ (rates ()))) 987 (if (not method) (pp indent+ (SOLVE states)) 988 (pp indent+ (SOLVE states METHOD ,method))) 989 (if (not (null? kinetic)) 990 (pp indent+ (SOLVE kstates METHOD sparse))) 991 (if (not (null? stcomps)) (pp indent+ (stcomps ()))) 992 (if (not (null? pool-ions)) (pp indent+ (pools ()))) 993 (for-each (lambda (p) (pp indent+ ,(expr->string/NMODL (second p) (first p)))) i-eqs) 994 (pp indent "}")) 995 996 (if (or (not (null? states)) (not (null? pool-ions))) 997 (begin 998 (pp indent ,nl (DERIVATIVE states "{")) 999 (let* ((state-eq-defs (reverse (poset->state-eq-defs poset sys kinetic))) 1000 (pool-eq-defs 1001 (map (lambda (ep) 1002 (let* ((ep-name (first ep)) 1003 (pool-ion (assoc ep-name pool-ions)) 1004 (i-name (second pool-ion)) 1005 (init-name (nmodl-name (s+ ep-name '-init))) 1006 (temp-name (nmodl-name (s+ ep-name '-temp-adj))) 1007 (beta-name (nmodl-name (s+ ep-name '-beta))) 1008 (depth-name (nmodl-name (s+ ep-name '-depth))) 1009 (rhs `(let ((F 96485.0)) 1010 (- (/ (neg ,i-name) (* 2 F ,init-name ,depth-name)) 1011 (* ,beta-name ,ep-name . 1012 ,(if temp-name (list temp-name) (list))))))) 1013 `(,(s+ ep-name "'") ,rhs))) 1014 epools)) 1015 (eq-defs (append pool-eq-defs state-eq-defs)) 1016 (locals (find-locals (map second eq-defs)))) 1017 (if (not (null? locals)) (pp indent+ (LOCAL ,(sl\ ", " locals)))) 1018 (for-each (lambda (def) 1019 (let ((n (first def)) (b (second def))) 1020 (pp indent+ ,(expr->string/NMODL b n)))) eq-defs)) 1021 1022 (pp indent "}"))) 1023 1024 (if (not (null? kinetic)) 964 1025 (begin 965 1026 (pp indent ,nl (KINETIC kstates "{")) … … 977 1038 keq-defs)) 978 1039 (pp indent "}"))) 979 980 981 982 983 1040 1041 1042 (let* ((init-defs (poset->state-init-defs poset sys)) 1043 (init-eq-defs (poset->state-init-eq-defs poset sys)) 1044 (locals (concatenate (find-locals (map second init-defs)))) ) 984 1045 (pp indent ,nl (INITIAL "{")) 985 1046 (if (not (null? locals)) (pp indent+ (LOCAL ,(sl\ ", " locals)))) … … 1005 1066 (pp indent "}"))) 1006 1067 )))) 1007 )))) )1068 ))))
Note: See TracChangeset
for help on using the changeset viewer.