Skip to content
Merged
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
19 changes: 17 additions & 2 deletions spatialpy/Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def decorate(header):
print_string += f"\n{str(species)}"
if len(self.listOfInitialConditions):
print_string += decorate("Initial Conditions")
for _, initial_condition in self.listOfInitialConditions.items():
for _, initial_condition in self.listOfInitialConditions:
print_string += f"\n{str(initial_condition)}"
if len(self.listOfDiffusionRestrictions):
print_string += decorate("Diffusion Restrictions")
Expand Down Expand Up @@ -123,7 +123,7 @@ def set_timesteps(self, step_size, num_steps):
self.num_timesteps = math.ceil(num_steps * steps_per_output)
self.output_freq = steps_per_output

def timespan(self, time_span):
def timespan(self, time_span, timestep_size=None):
"""
Set the time span of simulation. The SSA-SDPD engine does not support
non-uniform timespans.
Expand All @@ -134,6 +134,8 @@ def timespan(self, time_span):
"""

self.tspan = time_span
if timestep_size is not None:
self.timestep_size = timestep_size

items_diff = numpy.diff(time_span)
items = map(lambda x: round(x, 10), items_diff)
Expand Down Expand Up @@ -198,6 +200,19 @@ def restrict(self, species, listOfTypes):
else:
self.listOfDiffusionRestrictions[species] = listOfTypes

def add_mesh(self, mesh):
'''
Add a mesh to the model

mesh : Mesh
The Mesh to be added to the model
'''
if type(mesh).__name__ != 'Mesh':
raise ModelError("Unexpected parameter for add_mesh. Parameter must be a Mesh.")

self.mesh = mesh
self.listOfTypeIDs = list(set(mesh.type))

def add_data_function(self, data_function):
""" Add a scalar spatial function to the simulation. This is useful if you have a
spatially varying in put to your model. Argument is a instances of subclass of the
Expand Down