Skip to Content

BRUSSELATOR

Overview

The BRUSSELATOR function numerically solves the Brusselator system of ordinary differential equations, which models autocatalytic chemical reactions. The Brusselator is a classic example in nonlinear dynamics and chemical kinetics, describing the interaction of two species, X and Y, with parameters aa and bb controlling the reaction rates. The system is defined by:

dxdt=a(b+1)x+x2ydydt=bxx2y\begin{align*} \frac{dx}{dt} &= a - (b + 1)x + x^2y \\ \frac{dy}{dt} &= b x - x^2y \end{align*}

where xx and yy are the concentrations of the two species, and aa, bb are positive constants. The function uses SciPy’s ODE solver (scipy.integrate.solve_ivp ) to integrate the system over a specified time interval. Only the basic two-variable model is exposed; spatial extensions and complex networks are not supported. The integration method can be selected from several common solvers, but only the most used options are exposed. This example function is provided as-is without any representation of accuracy.

Usage

To use the function in Excel:

=BRUSSELATOR(x_initial, y_initial, a, b, t_start, t_end, [timesteps], [solve_ivp_method])
  • x_initial (float, required): Initial value of X.
  • y_initial (float, required): Initial value of Y.
  • a (float, required): Parameter a (reaction rate).
  • b (float, required): Parameter b (reaction rate).
  • t_start (float, required): Start time for integration.
  • t_end (float, required): End time for integration.
  • timesteps (int, optional, default=10): Number of timesteps to solve for.
  • solve_ivp_method (string (enum), optional, default=‘RK45’): Integration method. Valid options: RK45, RK23, DOP853, Radau, BDF, LSODA.

The function returns a 2D array (table) with columns: t, X, Y, representing time and the concentrations of X and Y at each step. If the input is invalid or integration fails, a string error message is returned.

Examples

Example 1: Basic Case

Inputs:

x_initialy_initialabt_startt_endtimestepsmethod
1.01.01.02.00.01.010RK45

Excel formula:

=BRUSSELATOR(1.0, 1.0, 1.0, 2.0, 0.0, 1.0, 10)

Expected output:

tXY
0.0001.0001.000
0.1110.8941.114
0.2220.8151.234
0.3330.7561.356
0.4440.7131.476
0.5560.6821.591
0.6670.6591.699
0.7780.6411.800
0.8890.6261.892
1.0000.6141.977

Example 2: RK23 Method

Inputs:

x_initialy_initialabt_startt_endtimestepsmethod
1.01.01.02.00.01.010RK23

Excel formula:

=BRUSSELATOR(1.0, 1.0, 1.0, 2.0, 0.0, 1.0, 10, "RK23")

Expected output:

tXY
0.0001.0001.000
0.1110.8891.135
0.2220.7981.279
0.3330.7261.428
0.4440.6711.578
0.5560.6311.724
0.6670.6041.861
0.7780.5871.985
0.8890.5772.093
1.0000.5722.184

Example 3: Different Parameters

Inputs:

x_initialy_initialabt_startt_endtimestepsmethod
2.01.02.03.00.01.010RK45

Excel formula:

=BRUSSELATOR(2.0, 1.0, 2.0, 3.0, 0.0, 1.0, 10)

Expected output:

tXY
0.0002.0001.000
0.1111.8051.232
0.2221.6421.487
0.3331.5161.754
0.4441.4272.022
0.5561.3742.281
0.6671.3532.522
0.7781.3592.738
0.8891.3872.924
1.0001.4313.076

Example 4: Longer Time Interval

Inputs:

x_initialy_initialabt_startt_endtimestepsmethod
1.02.01.02.00.02.010RK45

Excel formula:

=BRUSSELATOR(1.0, 2.0, 1.0, 2.0, 0.0, 2.0, 10)

Expected output:

tXY
0.0001.0002.000
0.0001.0002.000
0.0001.0002.000
0.0001.0002.000
0.0011.0002.000
0.0111.0002.000
0.1111.0002.000
1.1111.0002.000
2.0001.0002.000

Python Code

from scipy.integrate import solve_ivp as scipy_solve_ivp import numpy as np def brusselator(x_initial, y_initial, a, b, t_start, t_end, timesteps=10, solve_ivp_method='RK45'): """ Numerically solves the Brusselator system of ordinary differential equations for autocatalytic chemical reactions. This function is a thin wrapper that uses SciPy's ODE solver (scipy.integrate.solve_ivp) to integrate the system. Args: x_initial: Initial x value. y_initial: Initial y value. a: Parameter a. b: Parameter b. t_start: Start time of integration. t_end: End time of integration. timesteps: Number of timesteps to solve for. Default is 10. solve_ivp_method: Integration method ('RK45', 'RK23', 'DOP853', 'Radau', 'BDF', 'LSODA'). Default is 'RK45'. Returns: 2D list with header row: t, X, Y. Each row contains time and variable values, or an error message (str) if input is invalid. Wraps: scipy.integrate.solve_ivp Documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html This example function is provided as-is without any representation of accuracy. """ # Validate input types try: x0 = float(x_initial) y0 = float(y_initial) a = float(a) b = float(b) t0 = float(t_start) t1 = float(t_end) ntp = int(timesteps) except Exception: return "Invalid input: All initial values, parameters, and timesteps must be numbers." if t1 <= t0: return "Invalid input: t_end must be greater than t_start." if ntp <= 0: return "Invalid input: timesteps must be a positive integer." if solve_ivp_method not in ['RK45', 'RK23', 'DOP853', 'Radau', 'BDF', 'LSODA']: return "Invalid input: solve_ivp_method must be one of 'RK45', 'RK23', 'DOP853', 'Radau', 'BDF', 'LSODA'." # Create time array for evaluation t_eval = np.linspace(t0, t1, ntp) # Brusselator ODE system def brusselator_ode(t, y): x, yv = y dxdt = a - (b + 1) * x + x * x * yv dydt = b * x - x * x * yv return [dxdt, dydt] # Integrate try: sol = scipy_solve_ivp( brusselator_ode, [t0, t1], [x0, y0], method=solve_ivp_method, dense_output=False, t_eval=t_eval ) except Exception as e: return f"Integration error: {e}" if not sol.success: return f"Integration failed: {sol.message}" # Format output: header row then data rows result = [["t", "X", "Y"]] for i in range(len(sol.t)): t_val = float(sol.t[i]) x_val = float(sol.y[0][i]) y_val = float(sol.y[1][i]) # Disallow nan/inf if any([ not isinstance(t_val, float) or not isinstance(x_val, float) or not isinstance(y_val, float), t_val != t_val or x_val != x_val or y_val != y_val, # NaN check abs(t_val) == float('inf') or abs(x_val) == float('inf') or abs(y_val) == float('inf') ]): return "Invalid output: nan or inf detected." result.append([t_val, x_val, y_val]) return result

Example Workbook

Link to Workbook 

Last updated on