transiflow.interface.SciPy

class Interface(parameters, nx, ny, nz=1, dim=None, dof=None, x=None, y=None, z=None, boundary_conditions=None)

Bases: BaseInterface

This class defines an interface to the SciPy backend for the discretization. This backend can be used for low-resolution serial runs as well as implementing new problems in the discretization.

See Discretization for the descriptions of the constructor arguments.

Parameters:
parametersdict

Key-value pairs that can be used to modify parameters in the discretization as well as the linear solver and eigenvalue solver.

array_from_vector(vector)

Create a numpy array suitable for postprocessing from a state vector.

compute_bordered_matrix(jac, V=None, W=None, C=None, fix_pressure_row=False)

Helper to compute a bordered matrix of the form [A, V; W^T, C].

direct_solve(jac, rhs, rhs2=None, V=None, W=None, C=None)

Solve $J(u, p) y = x$ for $y$ using a direct solver. See the solve() function.

eigs(state, return_eigenvectors=False, enable_recycling=False)

Compute the generalized eigenvalues of $\beta * J(u, p) * v = \alpha * M(p) * v$.

Parameters:
statearray_like

State $u$ at which to evaluate $J(u, p)$.

return_eigenvectorsbool, optional

Whether to return the eigenvectors $v$.

enable_recyclingbool, optional

Whether to use the previous eigenvalue space as initial search space.

Returns:
eigsarray_like

Eigenvalues $\alpha / \beta$.

varray_like

Corresponding eigenvectors in case return_eigenvectors is True.

get_parameter(name)

Get a parameter value from the discretization.

Parameters:
namestr

Name of the parameter in the parameter list.

iterative_solve(jac, rhs, rhs2=None, V=None, W=None, C=None)

Solve $J(u, p) y = x$ for $y$ using an iterative solver. See the solve() function.

jacobian(state)

Compute the Jacobian matrix $J(u, p)$ of the right-hand side of the DAE. That is the Jacobian matrix of $F(u, p)$ in

\[M(p) \frac{\d u}{\d t} = F(u, p)\]
Parameters:
statearray_like

State $u$ at which to evaluate $J(u, p)$

Returns:
jacMatrix

The matrix $J(u, p)$ in a suitable sparse format

load_json(name)

Load the an object from a json file.

Parameters:
namestr

Name of the file without extension.

load_parameters(name)

Load the parameter set from a file.

Parameters:
namestr

Name of the file without extension.

load_state(name)

Load the state x along with the current parameter set.

Parameters:
namestr

Name of the file.

mass_matrix()

Compute the mass matrix of the DAE. That is the mass matrix $M(p)$ in

\[M(p) \frac{\d u}{\d t} = F(u, p)\]
Returns:
massMatrix

The matrix $M(p)$ in a suitable sparse format

rhs(state)

Compute the right-hand side of the DAE. That is the right-hand side $F(u, p)$ in

\[M(p) \frac{\d u}{\d t} = F(u, p)\]
Parameters:
statearray_like

State $u$ at which to evaluate $F(u, p)$

Returns:
rhsarray_like

The value of $F(u, p)$

save_json(name, obj)

Save an object to a json file

Parameters:
namestr

Name of the file.

objAny

Serializable object to save to the file.

save_parameters(name)

Save the current parameter set to a file.

Parameters:
namestr

Name of the file without extension.

save_state(name, x)

Save the state x along with the current parameter set.

Parameters:
namestr

Name of the file.

xarray_like

State at the current parameter values.

set_parameter(name, value)

Set a parameter in the discretization.

Parameters:
namestr

Name of the parameter in the parameter list.

valuescalar

Value of the parameter.

solve(jac, rhs, rhs2=None, V=None, W=None, C=None)

Solve $J(u, p) y = x$ for $y$.

Parameters:
jacMatrix

The Jacobian matrix $J(u, p)$ as returned by jacobian().

rhsarray_like

The right-hand side vector $x$.

rhs2array_like, optional

Extension of rhs in case a bordered system is solved.

Varray_like, optional

Border case a bordered system [A, V; W^T, C] [y; y2] = [x; x2] is solved.

Warray_like, optional

Border case a bordered system [A, V; W^T, C] [y; y2] = [x; x2] is solved.

Cmatrix_like, optional

Border case a bordered system [A, V; W^T, C] [y; y2] = [x; x2] is solved.

vector()

Return a zero-initialized state vector suitable for the currently defined problem type.

vector_from_array(array)

Create a state vector suitable for this interface from an array.

\[\]