|
50 | 50 | import moose |
51 | 51 |
|
52 | 52 | def displayPlots(): |
53 | | - for x in moose.wildcardFind( '/model/graphs/conc#/#' ): |
54 | | - t = numpy.arange( 0, x.vector.size, 1 ) #sec |
55 | | - pylab.plot( t, x.vector, label=x.name ) |
56 | | - pylab.legend() |
57 | | - pylab.show() |
| 53 | + for x in moose.wildcardFind( '/model/graphs/conc#/#' ): |
| 54 | + t = numpy.arange( 0, x.vector.size, 1 ) #sec |
| 55 | + pylab.plot( t, x.vector, label=x.name ) |
| 56 | + pylab.legend() |
| 57 | + pylab.show() |
58 | 58 |
|
59 | 59 | def getState( ksolve, state ): |
60 | | - state.randomInit() |
61 | | - moose.start( 0.1 ) # Run the model for 2 seconds. |
62 | | - state.settle() |
63 | | - ''' |
64 | | - scale = 1.0 / ( 1e-15 * 6.022e23 ) |
65 | | - for x in ksolve.nVec[0]: |
66 | | - print x * scale, |
67 | | - # print ksolve.nVec[0] |
68 | | - print state.nIter, state.status, state.stateType, state.nNegEigenvalues, state.nPosEigenvalues, state.solutionStatus |
69 | | - ''' |
70 | | - moose.start( 20.0 ) # Run model for 10 seconds, just for display |
| 60 | + state.randomInit() |
| 61 | + moose.start( 0.1 ) # Run the model for 2 seconds. |
| 62 | + state.settle() |
| 63 | + |
| 64 | + ''' |
| 65 | + scale = 1.0 / ( 1e-15 * 6.022e23 ) |
| 66 | + for x in ksolve.nVec[0]: |
| 67 | + print x * scale, |
| 68 | + # print ksolve.nVec[0] |
| 69 | + print state.nIter, state.status, state.stateType, state.nNegEigenvalues, state.nPosEigenvalues, state.solutionStatus |
| 70 | + ''' |
| 71 | + moose.start( 20.0 ) # Run model for 10 seconds, just for display |
71 | 72 |
|
72 | 73 |
|
73 | 74 | def main(): |
74 | | - # Schedule the whole lot |
75 | | - moose.setClock( 4, 0.1 ) # for the computational objects |
76 | | - moose.setClock( 5, 0.2 ) # clock for the solver |
77 | | - moose.setClock( 8, 1.0 ) # for the plots |
78 | | - # The wildcard uses # for single level, and ## for recursive. |
79 | | - #compartment = makeModel() |
80 | | - moose.loadModel( '../../genesis/M1719.g', '/model', 'ee' ) |
81 | | - compartment = moose.element( 'model/kinetics' ) |
82 | | - compartment.name = 'compartment' |
83 | | - ksolve = moose.Ksolve( '/model/compartment/ksolve' ) |
84 | | - stoich = moose.Stoich( '/model/compartment/stoich' ) |
85 | | - stoich.compartment = compartment |
86 | | - stoich.ksolve = ksolve |
87 | | - #ksolve.stoich = stoich |
88 | | - stoich.path = "/model/compartment/##" |
89 | | - state = moose.SteadyState( '/model/compartment/state' ) |
90 | | - moose.useClock( 5, '/model/compartment/ksolve', 'process' ) |
91 | | - moose.useClock( 8, '/model/graphs/#', 'process' ) |
| 75 | + # Schedule the whole lot |
| 76 | + moose.setClock( 4, 0.1 ) # for the computational objects |
| 77 | + moose.setClock( 5, 0.2 ) # clock for the solver |
| 78 | + moose.setClock( 8, 1.0 ) # for the plots |
| 79 | + # The wildcard uses # for single level, and ## for recursive. |
| 80 | + #compartment = makeModel() |
| 81 | + moose.loadModel( '../../genesis/M1719.g', '/model', 'ee' ) |
| 82 | + compartment = moose.element( 'model/kinetics' ) |
| 83 | + compartment.name = 'compartment' |
| 84 | + ksolve = moose.Ksolve( '/model/compartment/ksolve' ) |
| 85 | + stoich = moose.Stoich( '/model/compartment/stoich' ) |
| 86 | + stoich.compartment = compartment |
| 87 | + stoich.ksolve = ksolve |
| 88 | + #ksolve.stoich = stoich |
| 89 | + stoich.path = "/model/compartment/##" |
| 90 | + state = moose.SteadyState( '/model/compartment/state' ) |
| 91 | + moose.useClock( 5, '/model/compartment/ksolve', 'process' ) |
| 92 | + moose.useClock( 8, '/model/graphs/#', 'process' ) |
92 | 93 |
|
93 | | - moose.reinit() |
94 | | - state.stoich = stoich |
95 | | - #state.showMatrices() |
96 | | - state.convergenceCriterion = 1e-7 |
| 94 | + moose.reinit() |
| 95 | + state.stoich = stoich |
| 96 | + #state.showMatrices() |
| 97 | + state.convergenceCriterion = 1e-7 |
97 | 98 |
|
98 | | - for i in range( 0, 50 ): |
99 | | - getState( ksolve, state ) |
100 | | - |
101 | | - moose.start( 100.0 ) # Run the model for 100 seconds. |
| 99 | + for i in range( 0, 50 ): |
| 100 | + getState( ksolve, state ) |
| 101 | + |
| 102 | + moose.start( 100.0 ) # Run the model for 100 seconds. |
102 | 103 |
|
103 | | - b = moose.element( '/model/compartment/b' ) |
104 | | - c = moose.element( '/model/compartment/c' ) |
| 104 | + b = moose.element( '/model/compartment/b' ) |
| 105 | + c = moose.element( '/model/compartment/c' ) |
105 | 106 |
|
106 | | - # move most molecules over to b |
107 | | - b.conc = b.conc + c.conc * 0.95 |
108 | | - c.conc = c.conc * 0.05 |
109 | | - moose.start( 100.0 ) # Run the model for 100 seconds. |
| 107 | + # move most molecules over to b |
| 108 | + b.conc = b.conc + c.conc * 0.95 |
| 109 | + c.conc = c.conc * 0.05 |
| 110 | + moose.start( 100.0 ) # Run the model for 100 seconds. |
110 | 111 |
|
111 | | - # move most molecules back to a |
112 | | - c.conc = c.conc + b.conc * 0.95 |
113 | | - b.conc = b.conc * 0.05 |
114 | | - moose.start( 100.0 ) # Run the model for 100 seconds. |
| 112 | + # move most molecules back to a |
| 113 | + c.conc = c.conc + b.conc * 0.95 |
| 114 | + b.conc = b.conc * 0.05 |
| 115 | + moose.start( 100.0 ) # Run the model for 100 seconds. |
115 | 116 |
|
116 | | - # Iterate through all plots, dump their contents to data.plot. |
117 | | - displayPlots() |
| 117 | + # Iterate through all plots, dump their contents to data.plot. |
| 118 | + displayPlots() |
118 | 119 |
|
119 | | - quit() |
| 120 | + quit() |
120 | 121 |
|
121 | 122 | # Run the 'main' if this script is executed standalone. |
122 | 123 | if __name__ == '__main__': |
|
0 commit comments