-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1353 from StochSS/develop
Release v2.4.10
- Loading branch information
Showing
102 changed files
with
5,700 additions
and
6,284 deletions.
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
199 changes: 199 additions & 0 deletions
199
public_models/3D-Cylinder.proj/3D_cylinder.wkgp/3D_cylinder.ipynb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# 3D Cylinder Demo\n", | ||
"***\n", | ||
"This is an example of a 3D reaction diffusion system.\n", | ||
"\n", | ||
"- The domain is a cylinder\n", | ||
"- Species A is created at the right end of the cylinder\n", | ||
"- Species B is created at the left end of the cylinder\n", | ||
"- Diffusion occurs throughout the volume of the cylinder\n", | ||
"- A and B are destroyed on contact\n", | ||
"- Deterministic and Stochastic simulations are run\n", | ||
"\n", | ||
"This example allows us to check if reaction diffusion dynamics are accurate.\n", | ||
"***\n", | ||
"## Setup the Environment\n", | ||
"***" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import spatialpy" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"***\n", | ||
"## Create the 3D Cylinder Model\n", | ||
"***" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def create_3D_cylinder():\n", | ||
" model = spatialpy.Model(\"3D_cylinder\")\n", | ||
" \n", | ||
" # Define Domain Type IDs as constants of the Model\n", | ||
" model.MIDDLE = 'Middle'\n", | ||
" model.EDGE1 = 'Edge1'\n", | ||
" model.EDGE2 = 'Edge2'\n", | ||
" \n", | ||
" # Domain\n", | ||
" domain = spatialpy.Domain.read_stochss_domain('3D_cylinder.smdl')\n", | ||
" model.add_domain(domain)\n", | ||
"\n", | ||
" model.staticDomain = True\n", | ||
"\n", | ||
" # Variables\n", | ||
" A = spatialpy.Species(name=\"A\", diffusion_coefficient=0.1, restrict_to=[model.MIDDLE, model.EDGE1])\n", | ||
" B = spatialpy.Species(name=\"B\", diffusion_coefficient=0.1, restrict_to=[model.MIDDLE, model.EDGE2])\n", | ||
" model.add_species([A, B])\n", | ||
"\n", | ||
" # Parameters\n", | ||
" k_react = spatialpy.Parameter(name=\"k_react\", expression=\"1\")\n", | ||
" k_creat1 = spatialpy.Parameter(name=\"k_creat1\", expression=\"100\")\n", | ||
" k_creat2 = spatialpy.Parameter(name=\"k_creat2\", expression=\"100\")\n", | ||
" left = spatialpy.Parameter(name=\"left\", expression=\"0.5092013833059308\")\n", | ||
" right = spatialpy.Parameter(name=\"right\", expression=\"0.505804729089437\")\n", | ||
" model.add_parameter([k_react, k_creat1, k_creat2, left, right])\n", | ||
"\n", | ||
" # Reactions\n", | ||
" r1 = spatialpy.Reaction(\n", | ||
" name=\"r1\", restrict_to=[model.EDGE1],\n", | ||
" reactants={}, products={'A': 1},\n", | ||
" propensity_function=\"k_creat1 / left * vol\",\n", | ||
" ode_propensity_function=\"k_creat1\"\n", | ||
" )\n", | ||
" r2 = spatialpy.Reaction(\n", | ||
" name=\"r2\", restrict_to=[model.EDGE2],\n", | ||
" reactants={}, products={'B': 1},\n", | ||
" propensity_function=\"k_creat2 / right * vol\",\n", | ||
" ode_propensity_function=\"k_creat2\"\n", | ||
" )\n", | ||
" r3 = spatialpy.Reaction(\n", | ||
" name=\"r3\", rate=\"k_react\",\n", | ||
" reactants={'A': 1, 'B': 1}, products={}\n", | ||
" )\n", | ||
" model.add_reaction([r1, r2, r3])\n", | ||
"\n", | ||
" # Timespan\n", | ||
"# tspan = spatialpy.TimeSpan.arange(1, t=500, timestep_size=1e-3)\n", | ||
" tspan = spatialpy.TimeSpan.arange(1, t=500, timestep_size=1)\n", | ||
" model.timespan(tspan)\n", | ||
" return model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Instantiate the Model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model = create_3D_cylinder()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"***\n", | ||
"## Simulation Parameters\n", | ||
"***" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def configure_simulation():\n", | ||
" kwargs = {\n", | ||
" # \"number_of_trajectories\":1,\n", | ||
" # \"seed\":None,\n", | ||
" }\n", | ||
" return kwargs" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"***\n", | ||
"## Run the Simulation\n", | ||
"***" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"kwargs = configure_simulation()\n", | ||
"results = model.run(**kwargs)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"***\n", | ||
"## Visualization\n", | ||
"***" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"results.plot_species('A', animated=True, width=None, height=None)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
1 change: 1 addition & 0 deletions
1
public_models/3D-Cylinder.proj/3D_cylinder.wkgp/3D_cylinder.smdl
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.