non_dimensional.simulation¶
-
class
non_dimensional.
simulation
[source]¶ Simulator object for dimensionless form of equations.
Uses operator-splitting Fourier transform method of solving PDE defined in Supplementary Modelling
Methods
__init__
()Initialize self. centre_solution
()Given the simulation is performed on Periodic Boundary Conditions, the central location is undefined. diffuse
(X, dt, coeffs)Perform the diffusion operation, given the spatial distribution of the function being integrated X (“e” here) f
(e, t)Reaction function, describing the transport terms. find_peaks
(y)Count the number of peaks in a solution. get_amount
()Find self.amount = int_0^L {e} dx get_apical_solution
()Crop the solution down to just the apical membrane (as defined by self.l_apical versus self.L). get_peaks
()Find the number of peaks for all time-points. get_polarisation_timescale
()Find the relative polarization time-scale, the amount of (dimensionless) time until the simulation surpasses a critical polarity threshold (defined by self.pol_thresh) get_rel_height
()Find ∆e, the difference between the maximum and minimum value of e at the final time-step. get_rel_heights
()Find ∆e for all time-points :return: self.rel_heights (**np.ndarray of shape (n_t x 1) and dtype np.float32) make_coeffs
(D)Used in the operator-splitting Fourier method for simulation. norm
(x)Generic function to normalize a 1D np.ndarray, calculating the normalized array y as: plot_time_series
(cmap[, show, filename, apical])Plot time-series of the simulation, as an overlayed set of lines. react
(e, dt)Perform one iteration of the reaction operation. react_and_diffuse
(e, dt, coeffs)Perform one complete iteration of the integration, both reacting and diffusing (see Supplementary Modeling Appendix IV) set_initial
([mean, SD, override])Set the initial conditions of e in the dimensionless equations. set_num_x
(n[, apical_on])Sets spatial discretisation of number num_x for dimensionless equations set_t_span
(dt, tfin)Sets temporal discretisation for the dimensionless equations. simulate
()Perform full simulation, given parameters, using operator-splitting Fourier method -
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.
-
diffuse
(X, dt, coeffs)[source]¶ Perform the diffusion operation, given the spatial distribution of the function being integrated X (“e” here)
Parameters: - X – Function to be integrated (np.ndarray of dtype np.float32 and size (self.num_x x 1)
- dt – Temporal discretization (Strictly “ds” in the Supplementary Modeling)
- coeffs – Coefficients for the Fourier transform, as supplied by the self.make_coeffs function
Returns: Spatial distribution of the function after integration by 1 time-step (by amount dt)
-
f
(e, t)[source]¶ Reaction function, describing the transport terms.
Parameters: - e – 1D np.ndarray of dtype np.float32 and size (self.num_x x 1) describing the spatially discretized distribution of e
- t – Time-point
Returns: de/dt – 1D np.ndarray of dtype np.float32 and size (self.num_x x 1)
-
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_polarisation_timescale
()[source]¶ Find the relative polarization time-scale, the amount of (dimensionless) time until the simulation surpasses a critical polarity threshold (defined by self.pol_thresh)
Returns: self.polarisation_timescale
-
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 :return: self.rel_heights (**np.ndarray of shape (n_t x 1) and dtype np.float32)
-
make_coeffs
(D)[source]¶ Used in the operator-splitting Fourier method for simulation. Details provided in Supplementary Modeling Appendix IV
Parameters: D – Diffusion coefficient (**np.float32) Returns: Coefficients for the operator-splitting Fourier method of simulation
-
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)[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)
-
react
(e, dt)[source]¶ Perform one iteration of the reaction operation.
Parameters: - e – 1D np.ndarray of dtype np.float32 and size (self.num_x x 1) describing the spatially discretized distribution of e
- dt – Temporal discretization (Strictly “ds” in the Supplementary Modeling)
Returns: Spatial distribution of the function after integration by 1 time-step (by amount dt)
-
react_and_diffuse
(e, dt, coeffs)[source]¶ Perform one complete iteration of the integration, both reacting and diffusing (see Supplementary Modeling Appendix IV)
Parameters: - e – 1D np.ndarray of dtype np.float32 and size (self.num_x x 1) describing the spatially discretized distribution of e
- dt – Temporal discretization (Strictly “ds” in the Supplementary Modeling)
- coeffs – Coefficients for the Fourier transform, as supplied by the self.make_coeffs function
Returns: Spatial distribution of the function after integration by 1 time-step (by amount dt)
-
set_initial
(mean=False, SD=False, override=False)[source]¶ Set the initial conditions of e in the dimensionless equations.
e is measured with respect to the saturation threshold E_{crit}: e = E/E_{crit}
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 for dimensionless equations
Lengthscales are measured with respect to the circumference of the cell L = 100microns.
y = x/L
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:
-