pydae.core.model_class¶
The Model class orchestrates the interaction between Python and the compiled C solver. It handles memory allocation, data loading, and provides the API for steady-state initialization and time-domain simulation.
Sparse backend support¶
The compiled shared library may use one of four linear-algebra backends:
dense– built-in LU with partial pivoting (default)
klu– SuiteSparse KLU (0-based CSC)
pardiso– Intel MKL PARDISO (1-based CSR)
accelerate– Apple Accelerate Sparse Solvers (0-based CSC, macOS)
The backend that was selected at build time is recorded in the JSON
metadata file under the key "sparse_backend" (null for dense).
At runtime the Model class reads this value to allocate the correct
Jacobian buffer size: NNZ entries for any sparse backend, or
N_xy * N_xy for the dense fallback.
Functions
|
Classes
|
- class pydae.core.model_class.Model(model_name, matrices_folder='./build', data_folder='.')[source]¶
Bases:
object- A_eval()[source]¶
Compute the reduced linearized state matrix
A.Eliminates the algebraic variables from the DAE linearization via the Schur complement:
A = F_x - F_y @ inv(G_y) @ G_x
Requires that
jac_run_evalhas been called (or calls it lazily) so thatF_x,F_y,G_x,G_yare available.- Returns:
The
(N_x, N_x)state matrix of the linearized systemdx/dt = A @ dxaround the current operating point.- Return type:
- get_values(name)[source]¶
Gets a time-series array of a variable from the stored simulation history.
- jac_run_eval()[source]¶
Evaluate the run Jacobian
jac_run = [[F_x, F_y], [G_x, G_y]].Calls the compiled
jac_trap_evalat the current operating point to obtainjac_trap:jac_trap = [[I - alpha*Dt*F_x, -alpha*Dt*F_y], [ G_x, G_y ]]
then recovers the run-Jacobian blocks:
F_x = (I - jac_trap[:N_x, :N_x]) / (alpha*Dt) F_y = -jac_trap[:N_x, N_x:] / (alpha*Dt) G_x = jac_trap[N_x:, :N_x] G_y = jac_trap[N_x:, N_x:]