Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
docs/
.vscode/
environment/
tests/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The template system was created in an effort to decrease the risk of entering in
* timesteps: integer > 0.
* sim_type: str takes value of 'visual' or 'full'.
* tempurature: int between 1 and 5
* struct_mode: str takes values of 'static', 'blinker', 'toad', 'glider', 'pulsar', 'beacon', 'gun', 'pentadecon', 'heavyglider' and 'none' (no structure added).
* struct_mode: str takes values of 'static', 'blinker', 'toad', 'glider' and 'none' (no structure added).
* dyn_mode: str takes values of 'cyclic', 'absorbing', 'half', 'dynamic', 'cut' and 'none' (default start state)
* prob: list (array object in json terms) of length 3.
* *cahn simulation*: all values other than the default first three are floating point numbers.
Expand Down
Binary file added docs/Checkpoint 1.pdf
Binary file not shown.
Binary file added docs/Checkpoint 2.pdf
Binary file not shown.
Binary file added docs/Checkpoint 3.pdf
Binary file not shown.
Binary file added docs/Checkpoint Practice.pdf
Binary file not shown.
Binary file added docs/Lecture 1.pdf
Binary file not shown.
Binary file added docs/Lecture 2.pdf
Binary file not shown.
Binary file added docs/Lecture 3.pdf
Binary file not shown.
Binary file added help/reactionDiffusion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def main():
general_utils.check_directories()

# gets name of module python files tools/utils
modules = general_utils.get_py_files(general_utils.MODULEPATH)
modules = general_utils.get_py_files(general_utils.MODULE_PATH)

# resolves module class names into a list (references to classes)
module_class = [general_utils.str_to_class("tools", module) for module in modules]
Expand Down
2 changes: 1 addition & 1 deletion packages/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from tools.utils import general_utils

__all__ = general_utils.get_py_files(general_utils.SIMPATH)
__all__ = general_utils.get_py_files(general_utils.SIM_PATH)

5 changes: 2 additions & 3 deletions packages/controller/simulationPlane.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def __init__(self, dimensions, timesteps):

def create_figure(self):
""" Creates the figure elements for the simulations """
plt.rcParams.update(general_utils.returnGraphConfigs("anim"))
self.fig = plt.figure()
self.axes = plt.axes()
self.axes.set_xlabel("Cells In X (Columns)")
Expand Down Expand Up @@ -74,11 +73,11 @@ def check_all_nieghbours(self, coordinate):

def d_index(self, coord):
"""Decrease index number in array in up or right directions"""
return coord - 1 if coord - 1 < 0 else self.dimensions - 1
return coord - 1 if coord - 1 >= 0 else self.dimensions - 1

def i_index(self, coord):
"""Increase index number in array in down or left directions"""
return coord + 1 if coord + 1 > self.dimensions - 1 else 0
return coord + 1 if coord + 1 <= self.dimensions - 1 else 0

def end_simulation(self):
time.sleep(1)
Expand Down
60 changes: 60 additions & 0 deletions packages/reaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import numpy as np
from packages.controller import SimulationPlane
from tools.utils import sim_utils

class Reaction(SimulationPlane):
def __init__(self, dimensions, timesteps, k, sigma, dt):
super().__init__(dimensions, timesteps)
self.k = k
self.sigma = sigma
self.dt = dt

#override
def start_sim(self):
self.create_cells()
self.create_figure()
super().start_sim()

#override
def create_figure(self):
super().create_figure()
self.axes.set_title("Reaction-Diffusion Simulation For {} Cells".format(self.dimensions ** 2))
self.im = self.axes.imshow(self.cells, interpolation = "nearest", animated = True)
self.fig.colorbar(self.im)
#override
def create_cells(self):
self.cells = np.random.uniform(low=-0.1, high=0.1, size=(self.dimensions, self.dimensions))
for i in range(self.dimensions):
for j in range(self.dimensions):
self.cells[i, j] += 0.5

#override
def anim_func(self, i):
self.new_cells = np.copy(self.cells)
for i in range(self.dimensions):
for j in range(self.dimensions):
self.new_cells[i, j] = self.reaction_procedure(i, j)
self.cells = np.copy(self.new_cells)
self.im.set_array(self.cells)
self.check_sim()
yield self.im

def reaction_procedure(self, i , j):
laplacian = self.dt * (
self.cells[self.i_index(i), j] + \
self.cells[self.d_index(i), j] + \
self.cells[i, self.i_index(j)] + \
self.cells[i, self.d_index(j)] - \
4 * self.cells[i, j]
)
constants = self.dt * self.calc_row(i, j) - self.k * self.cells[i, j]
new_value = laplacian + constants
return new_value

def calc_row(self, i , j):
i_component = i - (self.dimensions / 2)
j_component = j - (self.dimensions / 2)
mag_r = np.sqrt(i_component ** 2 + j_component ** 2)
row = np.exp(-(mag_r ** 2) / (self.sigma ** 2))
return row

13 changes: 0 additions & 13 deletions params/cahn - 2019,04,04 23,05,18.996745.json

This file was deleted.

2 changes: 1 addition & 1 deletion params/gol - 2019,04,05 12,20,40.124700.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"default_values": [50, 100, null, "glider"],
"timesteps": null,
"percentage": null,
"struct_mode": "fafaf"
"struct_mode": "glider"
}
10 changes: 0 additions & 10 deletions params/poisson - 2019,04,05 14,49,36.424985.json

This file was deleted.

11 changes: 0 additions & 11 deletions params/poisson - 2019,04,05 16,24,04.260395.json

This file was deleted.

9 changes: 9 additions & 0 deletions params/reaction - 2019,04,24 11,42,32.211440.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"mode": "reaction",
"dimensions": 50,
"timesteps": 1000,
"default_values":[50, 10000, 0, 0, 0],
"k": 1,
"sigma": 0.1,
"dt": 0.1
}
6 changes: 6 additions & 0 deletions templates/files/commands.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--new-template <arguement>: creates new template file
--new-simulation <arguement>: creates new simulation and corresponding template file
--new-module <arguement>: creates new module
--shortcut <arguement>: jumps to module
--readme: opens the programme readme
--help-commands: displays command line call syntax (You Just Called It)
6 changes: 6 additions & 0 deletions templates/files/module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import numpy as np
from tools.utils import UtilityBase, general_utils

class {}(UtilityBase):
def __init__(self):
super().__init__()
6 changes: 6 additions & 0 deletions templates/files/params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"mode": null,
"dimensions": null,
"timesteps": null,
"default_values": []
}
35 changes: 35 additions & 0 deletions templates/files/sim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import numpy as np
from tools.utils import sim_utils
from packages.controller import SimulationPlane

class {}(SimulationPlane):
def __init__(self, dimensions, timesteps):
super().__init__(dimensions, timesteps)

#override
def start_sim(self):
# override to add different simulation types visual or full
super().start_sim()

#override
def create_figure(self):
super().create_figure()
self.im = self.axes.imshow(self.cells, interpolation = "nearest", animated = True)
self.fig.colorbar(self.im)

#override
def create_cells(self):
"""
self.cells = np.random.normal(
size=(self.dimensions, self.dimensions)) # loc and scale for noise
self.cells = np.random.uniform(
size=self.dimensions, self.dimensions) # high or low
"""
pass

#override
def anim_func(self, i):
yield self.im



File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions templates/sims/reaction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"mode": "reaction",
"dimensions": null,
"timesteps": null,
"default_values":[50, 10000, 0, 0, 0],
"k": null,
"sigma": null,
"dt": null
}
File renamed without changes.
2 changes: 1 addition & 1 deletion tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from tools.utils import general_utils

__all__ = general_utils.get_py_files(general_utils.MODULEPATH)
__all__ = general_utils.get_py_files(general_utils.MODULE_PATH)
1 change: 0 additions & 1 deletion tools/grapher.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def setup(self):
def create_figure(self):
"""Creates figure for plotting and subplotting"""
self.figure = plt.figure()
plt.rcParams.update(general_utils.returnGraphConfigs("subplots"))

def plot_data(self, file_name):
"""Plots the data based on simulations chosen"""
Expand Down
Loading