Simulation class for regular equations¶
-
class
oneD_simulation.
simulation
[source]¶ Simulator object for regular equations.
Uses finite-difference method of solving PDE defined in Supplementary Modelling
-
centre_solution
()[source]¶ Given the simulation is performed on Periodic Boundary Conditions, the central location is undefined. For clarity, this function centres the solution such that the maximal E at the final time-step lies at self.num_x/2.
Over-writes self.y_sol and also saves in self.ysolshift as a copy.
-
del_1d
(y, dx)[source]¶ Central difference discretisation of the Laplacian.
Parameters: - y – Spatially discretised 1D function (i.e. a np.ndarray of dtype np.float32) on which the function is applied
- dx – Spatial discretisation lengthscale (np.float32)
Returns: Spatially discretised Laplacian of y
-
f
(y, t)[source]¶ System of partial differential equations as defined in the Supplementary Modelling, describing the spatio-temporal evolution of E.
Parameters: - y – Spatially discretised 1D function of E (i.e. a np.ndarray of dtype np.float32) of length self.num_x
- t – Time-point at which to evaluate (np.float32)
Returns: Time differential of E at each spatial block (np.ndarray of dtype np.float32 and length self.num_x)
-
f_apical_on
(y, t)[source]¶ System of partial differential equations as defined in the Supplementary Modelling, describing the spatio-temporal evolution of E modelling cell-cell contacts, where E can load only on the apical membrane.
Parameters: - y – Spatially discretised 1D function of E (i.e. a np.ndarray of dtype np.float32) of length self.num_x
- t – Time-point at which to evaluate (np.float32)
Returns: Time differential of E at each spatial block (np.ndarray of dtype np.float32 and length self.num_x)
-
find_peaks
(y)[source]¶ Count the number of peaks in a solution.
Parameters: y – 1D array of concentrations (i.e. E at a given time t) (np.ndarray of size (self.num_x x 1) and dtype np.float32) Returns: Number of peaks (np.int32)
-
get_apical_solution
()[source]¶ Crop the solution down to just the apical membrane (as defined by self.l_apical versus self.L).
The solution is first centred before cropping.
-
get_peaks
()[source]¶ Find the number of peaks for all time-points.
Number of peaks = 0 when the relative height is too low (i.e. discounting spurious multi-peak solutions, where variations are miniscule). The threshold is set by self.pol_thresh.
Returns: Number of peaks self.peaks a np.ndarray of size (n_t x 1) and dtype np.int32
-
get_rel_height
()[source]¶ Find ∆E, the difference between the maximum and minimum value of E at the final time-step.
Returns: ∆E, self.rel_height (a np.float32)
-
get_rel_heights
()[source]¶ Find ∆E for all time-points
Returns: self.rel_heights (**np.ndarray of shape (n_t x 1) and dtype np.float32)
-
make_directory
(dir)[source]¶ Makes a new directory, specified by the string dir
Parameters: dir – Directory name (string)
-
norm
(x)[source]¶ Generic function to normalize a 1D np.ndarray, calculating the normalized array y as:
y = (x-min(x))/(max(x) - min(x))
Parameters: x – A 1D np.ndarray to be normalized. Returns: Normalized np.ndarray, y.
-
plot_time_series
(cmap, show=True, filename=False, apical=False, ylim=(0, 150))[source]¶ Plot time-series of the simulation, as an overlayed set of lines.
The number of time-points that are sampled is set by the parameter cmap, a (n_sample x 4) np.ndarray of RGBA colour points. cmap can be generated using plt.cm.Reds(np.linspace(0,1,n_sample)) for example.
Parameters: - cmap – The colormap used to plot the solution (a np.ndarray)
- show – If True, then show the plot.
- filename – str defining the file-name of the plot if is being saved. If False then the plot is not saved.
- apical – Determines whether to plot the whole membrane (False) or just the apical membrane (True) (np.bool)
- ylim – Axis limits on the y-axis (i.e. the concentration of E) (tuple)
-
set_initial
(mean=False, SD=False, override=False, apical_on=False)[source]¶ Set the initial conditions of E.
If override is False, then the initial condition of E, self.y0, is given by a normal distribution, with mean mean and standard deviation SD
If overide is not False but instead a 1D array of length (self.num_x), then self.y0 is defined as override
If apical_on is True, then outside the apical membrane, self.y0 is set to 1e-17 (<<1)
Parameters: - mean – Mean value used in normal distribution (np.float32)
- SD – Standard deviation used in normal distribution (np.float32)
- override – Override 1D array if provided (np.ndarray of dtype np.float32), else False
- apical_on – Sets self.y0 to (approx.) 0 outside the apical membrane.
Returns:
-
set_num_x
(n, apical_on=False)[source]¶ Sets spatial discretisation of number num_x
if apical_on is True, then n specifies the number of spatial blocks within the apical domain (of length self.l_apical), and self.num_x is computed with respect to the ratio of self.l_apical and self.L (the full domain length i.e. cell perimeter)
if apical_on is False, then n defines self.num_x
Parameters: - n – Number of spatial blocks (np.int32)
- apical_on – Specifies whether apical membrane is considered specifically or not (np.bool)
Returns:
-
set_t_span
(dt, tfin)[source]¶ Sets temporal discretisation. Saves a 1D array of time-points to self.t_span
Parameters: - dt – Time-step (np.float32)
- tfin – Final time-step (np.float32)
Returns:
-
solve
(apical_on=False)[source]¶ Perform the simulation. Uses the scipy.integrate.odeint package to integrate the defined system of PDEs.
If apical_on is True, then simulate with cell-cell contacts (where loading is restricted to the apical membrane)
If apical_on is False, then simulate without cell-cell contacts.
Parameters: apical_on – Specifies whether to simulate with or without cell-cell contacts (np.bool) Returns: self.y_sol, a 2D np.ndarray array (n_t x self.num_x), where n_t is the number of time-steps (as defined by self.t_span).
-