PyCoBi.pycobi

Module that contains the base class ODESystem that represents the main user interface of PyCoBi for parameter continuations, results visualization and results storage.

class pycobi.pycobi.ODESystem(eq_file: str, working_dir: str | None = None, auto_dir: str | None = None, init_cont: bool = True, params: list | None = None, state_vars: list | None = None, **kwargs)[source]

Bases: object

additional_attributes
auto_solutions
blocked_indices = (10, 15)
close_session(clear_files: bool = False, **kwargs)[source]
dir
extract(keys: list, cont: Any | str | int, point: str | int | None = None) tuple[source]

Extract properties from a solution.

Parameters:
  • keys – Keys of the properties (e.g. state variable names, parameter names, …).

  • cont – Key of the solution branch.

  • point – Key of the solution on the branch.

Returns:

Tuple with 2 entries: (1) a DataFrame that contains the requested properties of the solution. (2) A map between the passed parameter/variable keys and the column names in the DataFrame.

Return type:

tuple

classmethod from_file(filename: str, auto_dir: str | None = None)[source]

Load ODESystem from file using pickle.

Parameters:
  • filename – Name of the file that contains summary and solution data of an ODESystem instance.

  • auto_dir – Installation directory of auto-07p.

Returns:

ODESystem instance containing all the attributes that are available as dictionary entries in filename.

Return type:

ODESystem

classmethod from_template(template: CircuitTemplate, working_dir: str | None = None, auto_dir: str | None = None, init_cont: bool = True, init_kwargs: dict | None = None, **kwargs)[source]

Instantiates ODESystem from a pyrates.CircuitTemplate.

Parameters:
  • template – Instance of the class pyrates.CircuitTemplate.

  • working_dir – Directory in which all the fortran equation and auto-07p constant files are saved.

  • auto_dir – Installation directory of auto-07p.

  • init_cont – If true, an integration with respect to time will be performed, using the equation file provided via the keyword argument e=<fname> (a file named <fname>.f90 should exist in working_dir) and the auto constants provided via the keyword argument c=<fname> (a file named c.<fname> should exist in working_dir).

  • init_kwargs – Additional keyword arguments that will be provided to the ODESystem.run method for performing the time integration.

  • kwargs – Additional keyword arguments provided to the pyrates.CircuitTemplate.get_run_func method that is used to generate the fortran equation file and the auto constants file that will be used to initialize ODESystem.

Returns:

ODESystem instance.

Return type:

ODESystem

classmethod from_yaml(path: str, working_dir: str | None = None, auto_dir: str | None = None, init_cont: bool = True, init_kwargs: dict | None = None, **kwargs)[source]

Instantiates ODESystem from a YAML definition file.

Parameters:
  • path – Full path to a YAML model definition file for a pyrates.CircuitTemplate.

  • working_dir – Directory in which all the fortran equation and auto-07p constant files are saved.

  • auto_dir – Installation directory of auto-07p.

  • init_cont – If true, an integration with respect to time will be performed, using the equation file provided via the keyword argument e=<fname> (a file named <fname>.f90 should exist in working_dir) and the auto constants provided via the keyword argument c=<fname> (a file named c.<fname> should exist in working_dir).

  • init_kwargs – Additional keyword arguments that will be provided to the ODESystem.run method for performing the time integration.

  • kwargs – Additional keyword arguments provided to the pyrates.CircuitTemplate.get_run_func method that is used to generate the fortran equation file and the auto constants file that will be used to initialize ODESystem.

Returns:

ODESystem instance.

Return type:

ODESystem

get_solution(cont: Any | str | int, point: str | int | None = None) Any | tuple[source]

Extract auto solution object of a given solution/solution branch.

Parameters:
  • cont – Key of the solution branch.

  • point – Key of the solution on the branch.

Returns:

Solution type (only if point is provided), auto solution object.

Return type:

Union[Any, tuple]

get_summary(cont: Any | str | int | None = None, point=None) DataFrame[source]

Extract summary of continuation from PyCoBi.

Parameters:
  • cont – Key of the solution branch.

  • point – Key of the solution on the branch.

Returns:

All recorded state variables, parameters, etc. for the solution/solution branch.

Return type:

DataFrame

merge(key: int, cont, icp: tuple)[source]

Merges two solutions from two separate auto continuations.

Parameters:
  • key – PyCoBi identifier under which the merged solution should be stored. Must be equal to identifier of first continuation.

  • cont – auto continuation object that should be merged with the continuation object under key.

  • icp – Continuation parameter that was used in both continuations that are to be merged.

plot_bifurcation_points(solution_types: DataFrame, x_vals: DataFrame, y_vals: DataFrame, ax: Axes, default_color: str = 'k', default_marker: str = '*', default_size: float = 10, ignore: list | None = None, custom_bf_styles: dict | None = None) tuple[source]

Plot markers for special solutions at coordinates in 2D space.

Parameters:
  • solution_types – Type of each solution, entries of DataFrame should be strings.

  • x_vals – X-coordinates of each solution.

  • y_vals – Y-coordinates of each special solution

  • ax – Axis in which to plot the data. If not provided, a new figure will be created.

  • default_color – Default color to be used if bifurcation style is not known.

  • default_marker – Default marker style to be used if bifurcation style is not known.

  • default_size – Default marker size.

  • ignore – List of solution types that should not be displayed.

  • custom_bf_styles – Dictionary containing adjustments to the default bifurcation markers and colors.

Returns:

A 2-entry tuple of (1) a list of PathCollections that correspond to bifurcation points, and (2) a list of corresponding bifurcation types.

Return type:

tuple

plot_continuation(x: str, y: str, cont: Any | str | int, ax: Axes | None = None, force_axis_lim_update: bool = False, bifurcation_legend: bool = True, **kwargs) LineCollection[source]

Line plot of 1D/2D parameter continuations and the respective codimension 1/2 bifurcations.

Parameters:
  • x – Key of the parameter/variable plotted on the x-axis.

  • y – Key of the variable/parameter plotted on the y-axis.

  • cont – Key of the solution branch to be plotted.

  • ax – Axis in which to plot the data. If not provided, a new figure will be created.

  • force_axis_lim_update – If true, the axis limits of x and y axis will be updated after creating the line plots.

  • bifurcation_legend – If true, a legend will be plotted that lists the type of all special solutions on a continuation curve.

  • kwargs – Additional keyword arguments that allow to control the appearance of the line plot.

Returns:

Line object that was created.

Return type:

LineCollection

plot_timeseries(var: str, cont: Any | str | int, points: list | None = None, ax: Axes | None = None, linespecs: list | None = None, **kwargs) Axes[source]

Plot state variable of a periodic solution over time.

Parameters:
  • var – Key of the state variable.

  • cont – Key of the solution branch.

  • points – List with keys of the solutions for which to create time series plots.

  • ax – Axis in which to plot the data. If not provided, a new figure will be created.

  • linespecs – Keyword arguments that control the appearance of the line created for each entry in points.

  • kwargs – Additional keyword arguments that control the appearance of the plot.

Returns:

Axis object that contains the plotted timeseries.

Return type:

plt.Axes

plot_trajectory(variables: list | tuple, cont: Any | str | int, point: str | int | None = None, ax: Axes | None = None, force_axis_lim_update: bool = False, cutoff: float | None = None, **kwargs) LineCollection[source]

Plot trajectory of state variables through phase space over time.

Parameters:
  • variables – State variables for which to create the trajectory. If 2, a 2D plot will be created, if 3, a 3D plot.

  • cont – Key of the solution branch to be plotted.

  • point – Key of the solution on the solution branch for which to plot the trajectories.

  • ax – Axis in which to plot the data. If not provided, a new figure will be created.

  • force_axis_lim_update – If true, the axis limits of x and y-axis will be updated after creating the line plots.

  • cutoff – Initial time to be disregarded for plotting.

  • kwargs – Additional keyword arguments that allow to control the appearance of the line plot.

Returns:

Line object that was created.

Return type:

LineCollection

property pyrates_template
results
run(origin: int | str | object | None = None, starting_point: str | int | None = None, variables: list | None = None, params: list | None = None, get_stability: bool = True, get_period: bool = False, get_timeseries: bool = False, get_eigenvals: bool = False, get_lyapunov_exp: bool = False, reduce_limit_cycle: bool = True, bidirectional: bool = False, name: str | None = None, **auto_kwargs) tuple[source]

Wraps auto-07p command run and stores requested solution details on instance.

Parameters:
  • origin – Key of the solution branch that contains the solution starting_point, from which the new continuation will be started.

  • starting_point – Key of the solution on the solution branch origin, from which the continuation procedure will be initiated.

  • variables – Keys of the state variables that should be recorded for each continuation recording step.

  • params – Keys of the parameters that should be recorded for each continuation recording step.

  • get_stability – If true, the stability of each solution will be stored in the results under the key ‘stability’.

  • get_period – If true, the period of periodic solutions will be stored in the results under the key ‘period’.

  • get_timeseries – If true, the time vector associated with the state variables of a periodic solution will be stored under the key ‘time’.

  • get_eigenvals – If true, the eigenvalues (floquet multipliers) or steady-state (periodic) solutions will be stored under the key ‘eigenvalues’.

  • get_lyapunov_exp – If true, the local lyapunov exponents of solutions will be stored under the key ‘lyapunov’.

  • reduce_limit_cycle – If true, the values of each state variable will be reduced to the minimum and maximum for limit cycle solutions. Else, the state variable values will be stored for multiple discretized points along the limit cycle solution (number depends on the arguments passed to Auto).

  • bidirectional – If true, parameter continuation will be performed into both directions for a given continuation parameter.

  • name – Name, under which the resulting solution branch will be accessible for future continuations.

  • auto_kwargs – Additional keyword arguments to be passed to the auto command run.

Returns:

DataFrame with the results, auto solution branch object.

Return type:

tuple

to_file(filename: str, results_only: bool = True, **kwargs) None[source]

Save continuation results on disc via pickle.

Parameters:
  • filename – Name of the file to which the results should be saved.

  • results_only – If true, only the PyCoBi recordings will be saved.

  • kwargs – Additional data/information to be saved to file. Will be available under the key ‘additional_attributes’.

Return type:

None

update_bifurcation_style(bf_type: str, marker: str | None = None, color: str | None = None) None[source]

Update the default marker and color of a given special solution type.

Parameters:
  • bf_type – Type of the special solution.

  • marker – New marker type.

  • color – New color.

Return type:

None