pydae.core¶
pydae.core - Core DAE solver engine¶
This is the main entry point for building and running DAE models.
Quick start:
from pydae.core import Builder, Model
# Define your system symbolically
sys_dict = { ... }
# Build (generates compiled C code)
builder = Builder(sys_dict, target='ctypes')
builder.build()
# Run
model = Model('my_system')
model.ini({'param': value}, xy_0=initial_guess)
model.run(t_end, {'input': new_value})
model.post()
- class pydae.core.Builder(system_dict, verbose=False, API=False, target='cffi', sparse=True)[source]¶
Bases:
object
- class pydae.core.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:]
Modules
The Model class orchestrates the interaction between Python and the compiled C solver. |