Created
April 7, 2015 09:31
-
-
Save kaizu/dd00c3b3f75727dd5062 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"from ecell4 import *" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"m = NetworkModel()\n", | |
"m.add_species_attribute(Species(\"A\", \"0.005\", \"1\")) # name, radius, D\n", | |
"m.add_species_attribute(Species(\"B\", \"0.005\", \"1\"))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"w = lattice.LatticeWorld(Real3(1, 1, 1), 0.005) # edge_lengths, voxel_radius\n", | |
"w.bind_to(m)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"w.add_molecules(Species(\"A\"), 120)\n", | |
"w.add_molecules(Species(\"B\"), 120)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<html>\n", | |
" <head>\n", | |
" <script type=\"text/javascript\">\n", | |
" (function(){\n", | |
" if(window[\"THREE\"] === undefined || window[\"d3\"] === undefined){\n", | |
"\t require.config({\n", | |
"\t paths:{\n", | |
"\t d3: [\n", | |
"\t 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.4/d3.min',\n", | |
"\t 'custom/d3.min'\n", | |
"\t ],\n", | |
"\t THREE: [\n", | |
"\t 'https://cdnjs.cloudflare.com/ajax/libs/three.js/r66/three.min',\n", | |
"\t 'custom/three.min'\n", | |
"\t ],\n", | |
" Elegans: [\n", | |
"\t 'https://rawgit.com/domitry/elegans/master/release/elegans',\n", | |
"\t 'custom/elegans'\n", | |
"\t ]\n", | |
"\t },\n", | |
"\t shim:{\n", | |
"\t THREE: {\n", | |
"\t exports: 'THREE'\n", | |
"\t },\n", | |
"\t Elegans: {\n", | |
"\t deps: ['THREE'],\n", | |
"\t exports: 'Elegans'\n", | |
"\t }\n", | |
"\t }\n", | |
"\t });\n", | |
"\n", | |
"\t require([\"d3\", \"THREE\"], function(d3){\n", | |
"\t window[\"d3\"] = d3;\n", | |
"\t });\n", | |
" }\n", | |
"\n", | |
" require([\"Elegans\"], function(){\n", | |
"\t console.log(\"Begin rendering...\");\n", | |
"\t var model = {\"plots\": [{\"data\": {\"y\": [0.9526279441628825, 0.40125843708678993, 0.7736493607140986, 0.9786087062764157, 0.6062177826491071, 0.42723919920032305, 0.35795716689756796, 0.5888972745734182, 0.4416729559300637, 0.89489291724392, 0.40125843708678993, 0.2540341184434353, 0.2598076211353316, 0.18475208614068023, 0.11258330249197702, 0.3204293994002423, 0.2800148805569685, 0.874685657822283, 0.6697263122599659, 0.0808290376865476, 0.7649891066762542, 0.046188021535170064, 0.9612881982007269, 0.5455960043841963, 0.4792007234273894, 0.9035531712817644, 0.40125843708678993, 0.5744635178436777, 0.9786087062764157, 0.6437455501464328, 0.29733538863265724, 0.48497422611928565, 0.16743157806499148, 0.7130275824491878, 0.9093266739736606, 0.8169506309033205, 0.7476685986005654, 0.5715767664977295, 0.16454482671904336, 0.6610660582221216, 0.2107328482542134, 0.028867513459481287, 0.7649891066762542, 0.15877132402714708, 0.5744635178436777, 0.1905255888325765, 0.6928203230275509, 0.21939310229205777, 0.20207259421636903, 0.6668395609140177, 0.08660254037844387, 0.06350852961085883, 0.8054036255195279, 0.49363448015713, 0.23382685902179845, 0.9728352035845195, 0.4416729559300637, 0.12413030787576954, 0.7447818472546173, 0.8573651497465943, 0.05196152422706632, 0.17320508075688773, 0.6581793068761734, 0.5629165124598852, 0.5658032638058333, 0.16743157806499148, 0.5484827557301445, 0.8140638795573724, 0.15877132402714708, 0.11547005383792515, 0.20784609690826528, 0.9728352035845195, 0.49363448015713, 0.7563288526384098, 0.2944486372867091, 0.8920061658979718, 0.9122134253196088, 0.6841600689897065, 0.8487048957087499, 0.7101408311032397, 0.2713546265191241, 0.4532199613138562, 0.002886751345948129, 0.6668395609140177, 0.7563288526384098, 0.034641016151377546, 0.4243524478543749, 0.12124355652982141, 0.7043673284113435, 0.8140638795573724, 0.48786097746523377, 0.2800148805569685, 0.7736493607140986, 0.4358994532381674, 0.5109549882328188, 0.5802370205355739, 0.3117691453623979, 0.06350852961085883, 0.9555146955088307, 0.7880831174438392, 0.7361215932167728, 0.5455960043841963, 0.7476685986005654, 0.2540341184434353, 0.30310889132455354, 0.7909698687897874, 0.9814954576223639, 0.23382685902179845, 0.6928203230275509, 0.3377499074759311, 0.851591647054698, 0.9179869280115049, 0.7476685986005654, 0.4532199613138562, 0.08660254037844387, 0.17609183210283585, 0.11547005383792515, 0.4792007234273894, 0.04330127018922193, 0.9728352035845195], \"x\": [0.22861904265976332, 0.7430118886442307, 0.8246615467370034, 0.5552176750308537, 0.48989794855663565, 0.3347635981803677, 0.3837533930360313, 0.9797958971132713, 0.04898979485566357, 0.6613622305514582, 0.8409914783555579, 0.3347635981803677, 0.0, 0.4000833246545858, 0.6531972647421809, 0.26127890589687236, 0.12247448713915891, 0.19595917942265428, 0.2531139400875951, 0.8409914783555579, 0.563382640840131, 0.6776921621700127, 0.718516991216399, 0.9634659654947169, 0.7103520254071217, 0.9716309313039941, 0.8573214099741124, 0.024494897427831785, 0.5715476066494083, 0.024494897427831785, 0.05715476066494083, 0.47356801693808115, 0.26944387170614964, 0.13880441875771343, 0.1469693845669907, 0.22045407685048604, 0.30210373494325865, 0.2122891110412088, 0.8654863757833897, 0.23678400846904057, 0.1714642819948225, 0.49806291436591293, 0.4000833246545858, 0.13880441875771343, 0.44907311951024936, 0.9471360338761623, 0.9471360338761623, 0.7266819570256763, 0.9553009996854396, 0.68585712797929, 0.9797958971132713, 0.938971068066885, 0.5225578117937447, 0.032659863237109045, 0.09797958971132714, 0.9553009996854396, 0.4082482904638631, 0.44907311951024936, 0.1469693845669907, 0.5552176750308537, 0.7838367176906171, 0.13063945294843618, 0.2939387691339814, 0.8164965809277261, 0.8083316151184489, 0.5470527092215764, 0.8246615467370034, 0.6368673331236264, 0.008164965809277261, 0.187794213613377, 0.8818163074019442, 0.6776921621700127, 0.2939387691339814, 0.4000833246545858, 0.9144761706390533, 0.9797958971132713, 0.3510935297989222, 0.9634659654947169, 0.5062278801751902, 0.8981462390204987, 0.9879608629225486, 0.3184336665618132, 0.040824829046386304, 0.9144761706390533, 0.05715476066494083, 0.8981462390204987, 0.48989794855663565, 0.8491564441648352, 0.6450322989329036, 0.09797958971132714, 0.7920016834998943, 0.3837533930360313, 0.6450322989329036, 0.7103520254071217, 0.032659863237109045, 0.8001666493091716, 0.68585712797929, 0.23678400846904057, 0.6776921621700127, 0.31026870075253593, 0.13063945294843618, 0.0, 0.5143928459844674, 0.2531139400875951, 0.8818163074019442, 0.7756717518813399, 0.530722777603022, 0.2122891110412088, 0.2939387691339814, 0.342928563989645, 0.6613622305514582, 0.8001666493091716, 0.05715476066494083, 0.6287023673143491, 0.9144761706390533, 0.187794213613377, 0.3674234614174768, 0.3184336665618132, 0.09797958971132714, 0.187794213613377], \"z\": [0.8, 0.555, 0.19, 0.145, 0.34, 0.89, 0.13, 0.99, 0.835, 0.9, 0.025, 0.5, 0.85, 0.4, 0.125, 0.17500000000000002, 0.8250000000000001, 0.41500000000000004, 0.55, 0.46, 0.765, 0.48, 0.045, 0.555, 0.74, 0.885, 0.8150000000000001, 0.155, 0.41500000000000004, 0.055, 0.185, 0.8200000000000001, 0.9400000000000001, 0.085, 0.515, 0.8150000000000001, 0.925, 0.13, 0.515, 0.625, 0.985, 0.48, 0.055, 0.5650000000000001, 0.935, 0.59, 0.22, 0.5700000000000001, 0.13, 0.855, 0.37, 0.98, 0.23500000000000001, 0.265, 0.5650000000000001, 0.085, 0.385, 0.255, 0.74, 0.385, 0.74, 0.43, 0.7000000000000001, 0.645, 0.8, 0.37, 0.19, 0.7000000000000001, 0.265, 0.34, 0.48, 0.125, 0.185, 0.66, 0.61, 0.5750000000000001, 0.9, 0.775, 0.87, 0.7000000000000001, 0.93, 0.28500000000000003, 0.865, 0.525, 0.1, 0.65, 0.895, 0.26, 0.14, 0.16, 0.8250000000000001, 0.135, 0.51, 0.6950000000000001, 0.105, 0.125, 0.63, 0.7000000000000001, 0.665, 0.865, 0.895, 0.995, 0.655, 0.26, 0.265, 0.03, 0.62, 0.585, 0.78, 0.915, 0.615, 0.79, 0.155, 0.225, 0.2, 0.065, 0.6, 0.37, 0.265, 0.315]}, \"type\": \"Particles\", \"options\": {\"color\": \"#a6cee3\", \"name\": \"A\", \"size\": 0.15}}, {\"data\": {\"y\": [0.5109549882328188, 0.45899346400575247, 0.8602519010925425, 0.20207259421636903, 0.7909698687897874, 0.19341234017852463, 0.7736493607140986, 0.9699484522385713, 0.017320508075688773, 0.268467875173176, 0.7303480905248766, 0.30599564267050167, 0.14722431864335456, 0.6841600689897065, 0.9555146955088307, 0.19341234017852463, 0.6870468203356547, 0.046188021535170064, 0.8775724091682312, 0.16743157806499148, 0.7274613391789284, 0.5109549882328188, 0.3377499074759311, 0.6928203230275509, 0.5225019936166114, 0.060621778264910706, 0.7014805770653953, 0.6350852961085884, 0.7967433714816836, 0.470540469389545, 0.5109549882328188, 0.9468544414709863, 0.011547005383792516, 0.5975575286112627, 0.1818653347947321, 0.8573651497465943, 0.381051177665153, 0.4792007234273894, 0.4792007234273894, 0.8833459118601275, 0.7823096147519429, 0.046188021535170064, 0.851591647054698, 0.002886751345948129, 0.7216878364870323, 0.4358994532381674, 0.034641016151377546, 0.16454482671904336, 0.6581793068761734, 0.89489291724392, 0.6321985447626403, 0.9786087062764157, 0.23671361036774657, 0.1299038105676658, 0.3377499074759311, 0.09814954576223638, 0.5571430097679889, 0.35507041555161983, 0.44455970727601185, 0.24537386440559095, 0.5311622476544557, 0.470540469389545, 0.21939310229205777, 0.7303480905248766, 0.4358994532381674, 0.7707626093681504, 0.33197640478403484, 0.6841600689897065, 0.6350852961085884, 0.8400446416709055, 0.9208736793574531, 0.1818653347947321, 0.8862326632060756, 0.23671361036774657, 0.3117691453623979, 0.28578838324886474, 0.8573651497465943, 0.6783865662978104, 0.19341234017852463, 0.6062177826491071, 0.49363448015713, 0.381051177665153, 0.008660254037844387, 0.6437455501464328, 0.0, 0.2944486372867091, 0.15877132402714708, 0.22516660498395405, 0.9699484522385713, 0.11258330249197702, 0.22805335632990217, 0.13279056191361394, 0.31465589670834604, 0.8833459118601275, 0.8775724091682312, 0.7736493607140986, 0.8400446416709055, 0.002886751345948129, 0.4358994532381674, 0.45899346400575247, 0.513841739578767, 0.9295339333952976, 0.6004442799572108, 0.5802370205355739, 0.06350852961085883, 0.8227241335952167, 0.24248711305964282, 0.10680979980008076, 0.5109549882328188, 0.8602519010925425, 0.21650635094610965, 0.16454482671904336, 0.48786097746523377, 0.13279056191361394, 0.1818653347947321, 0.24537386440559095, 0.2713546265191241, 0.011547005383792516, 0.14722431864335456, 0.6004442799572108], \"x\": [0.31026870075253593, 0.342928563989645, 0.187794213613377, 0.13880441875771343, 0.906311204829776, 0.3674234614174768, 0.43274318789169486, 0.6042074698865173, 0.48989794855663565, 0.06531972647421809, 0.15513435037626797, 0.8573214099741124, 0.5878775382679629, 0.39191835884530857, 0.20412414523193154, 0.28577380332470415, 0.9879608629225486, 0.3510935297989222, 0.07348469228349536, 0.040824829046386304, 0.375588427226754, 0.7348469228349536, 0.342928563989645, 0.8654863757833897, 0.7103520254071217, 0.09797958971132714, 0.16329931618554522, 0.08981462390204988, 0.3592584956081995, 0.7430118886442307, 0.2122891110412088, 0.20412414523193154, 0.3184336665618132, 0.0, 0.8981462390204987, 0.7838367176906171, 0.3592584956081995, 0.05715476066494083, 0.530722777603022, 0.0, 0.13880441875771343, 0.7593418202627853, 0.9716309313039941, 0.873651341592667, 0.07348469228349536, 0.938971068066885, 0.09797958971132714, 0.9308061022576077, 0.6042074698865173, 0.23678400846904057, 0.8164965809277261, 0.19595917942265428, 0.6123724356957946, 0.68585712797929, 0.9144761706390533, 0.8083316151184489, 0.1714642819948225, 0.68585712797929, 0.9879608629225486, 0.13880441875771343, 0.7266819570256763, 0.3184336665618132, 0.3674234614174768, 0.8573214099741124, 0.008164965809277261, 0.8001666493091716, 0.3184336665618132, 0.8981462390204987, 0.1714642819948225, 0.04898979485566357, 0.4164132562731403, 0.342928563989645, 0.5143928459844674, 0.024494897427831785, 0.6531972647421809, 0.09797958971132714, 0.26127890589687236, 0.43274318789169486, 0.5797125724586856, 0.4409081537009721, 0.13063945294843618, 0.342928563989645, 0.8818163074019442, 0.8083316151184489, 0.5878775382679629, 0.5715476066494083, 0.59604250407724, 0.342928563989645, 0.751176854453508, 0.17962924780409975, 0.1061445555206044, 0.8083316151184489, 0.15513435037626797, 0.2939387691339814, 0.8409914783555579, 0.6940220937885672, 0.8164965809277261, 0.6613622305514582, 0.563382640840131, 0.8654863757833897, 0.7593418202627853, 0.12247448713915891, 0.3184336665618132, 0.9144761706390533, 0.9716309313039941, 0.26127890589687236, 0.06531972647421809, 0.1061445555206044, 0.32659863237109044, 0.906311204829776, 0.06531972647421809, 0.8818163074019442, 0.8899812732112214, 0.5470527092215764, 0.4082482904638631, 0.6123724356957946, 0.4164132562731403, 0.23678400846904057, 0.8328265125462806, 0.3837533930360313], \"z\": [0.125, 0.635, 0.27, 0.63, 0.06, 0.035, 0.79, 0.8300000000000001, 0.28, 0.865, 0.305, 0.65, 0.435, 0.635, 0.335, 0.495, 0.16, 0.04, 0.84, 0.29, 0.12, 0.5750000000000001, 0.865, 0.86, 0.775, 0.015, 0.245, 0.58, 0.47000000000000003, 0.545, 0.505, 0.21, 0.49, 0.925, 0.985, 0.625, 0.06, 0.9400000000000001, 0.16, 0.86, 0.485, 0.75, 0.745, 0.855, 0.46, 0.375, 0.79, 0.465, 0.22, 0.85, 0.135, 0.255, 0.35000000000000003, 0.045, 0.185, 0.8, 0.725, 0.925, 0.44, 0.265, 0.85, 0.765, 0.16, 0.165, 0.8150000000000001, 0.375, 0.875, 0.135, 0.77, 0.005, 0.905, 0.775, 0.975, 0.08, 0.54, 0.055, 0.035, 0.515, 0.5650000000000001, 0.48, 0.935, 0.24, 0.495, 0.385, 0.38, 0.44, 0.23500000000000001, 0.86, 0.01, 0.665, 0.365, 0.09, 0.41500000000000004, 0.02, 0.6900000000000001, 0.79, 0.8150000000000001, 0.405, 0.105, 0.105, 0.18, 0.01, 0.92, 0.935, 0.36, 0.485, 0.66, 0.465, 0.9450000000000001, 0.6, 0.225, 0.135, 0.635, 0.18, 0.985, 0.735, 0.9500000000000001, 0.98, 0.17500000000000002, 0.84]}, \"type\": \"Particles\", \"options\": {\"color\": \"#1f78b4\", \"name\": \"B\", \"size\": 0.15}}], \"options\": {\"width\": 500, \"range\": {\"y\": [0.0, 1.0], \"x\": [0.0, 1.0], \"z\": [0.0, 1.0]}, \"grid\": true, \"autorange\": false, \"height\": 500}};\n", | |
"\t Elegans.Embed.parse(\"#\"+\"viz609342fa-ae39-4626-a8d6-1a19341b30ac\",model).render();\n", | |
" });\n", | |
" })();\n", | |
" </script>\n", | |
" </head>\n", | |
" <body>\n", | |
" <div id=\"viz609342fa-ae39-4626-a8d6-1a19341b30ac\"></div>\n", | |
" </body>\n", | |
"</html>" | |
], | |
"text/plain": [ | |
"<IPython.core.display.HTML object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"cfg = viz.plot_world(w)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.6" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment