DYNAMICS C API
C-compatible interface to the DYNAMICS library
Loading...
Searching...
No Matches
Transfer functions and state-space models

Functions

int c_alloc_polynomial (int order, c_polynomial *p)
 Allocate a polynomial.
 
void c_free_polynomial (c_polynomial *p)
 Release a polynomial.
 
int c_alloc_transfer_function (int numer_order, int denom_order, c_transfer_function *tf)
 Allocate a transfer function.
 
void c_free_transfer_function (c_transfer_function *tf)
 Release a transfer function.
 
int c_alloc_state_space_model (int dimension, int n_inputs, int n_outputs, c_state_space_model *mdl)
 Allocate a continuous state-space model.
 
void c_free_state_space_model (c_state_space_model *mdl)
 Release a state-space model.
 
void c_evaluate_transfer_function (const c_transfer_function *tf, int n, const double complex *s, double complex *z)
 Evaluate a transfer function at complex points.
 
void c_transfer_function_poles (const c_transfer_function *tf, int n, double complex *p)
 Compute transfer-function poles.
 
void c_transfer_function_zeros (const c_transfer_function *tf, int n, double complex *z)
 Compute transfer-function zeros.
 
void c_to_ccf_state_space (const c_transfer_function *tf, c_state_space_model *ss)
 Convert a transfer function to controllable canonical state space.
 
void c_to_ocf_state_space (const c_transfer_function *tf, c_state_space_model *ss)
 Convert a transfer function to observable canonical state space.
 
void c_create_state_space_model (int n, int n_out, const double *m, int ldm, const double *b, int ldb, const double *k, int ldk, c_state_space_model *mdl)
 Create a state-space model from mass, damping, and stiffness matrices.
 
void c_create_pid_state_space_model (double kp, double ki, double kd, double tau, const c_state_space_model *plant, c_state_space_model *mdl)
 Create a PID-controlled plant state-space model.
 
void c_transfer_function_multiply (const c_transfer_function *tf1, const c_transfer_function *tf2, c_transfer_function *tf)
 Multiply two transfer functions.
 
void c_scale_transfer_function (double x, const c_transfer_function *tf1, c_transfer_function *tf)
 Scale a transfer function.
 
void c_lti_solve (const c_state_space_model *mdl, const c_ss_excitation u, int n, const double *t, int ndof, const double *ic, int solver, int nout, double *y, int ldy, void *user_data)
 Integrate a continuous state-space model.
 
void c_state_space_poles (const c_state_space_model *mdl, int n, double complex *p)
 Compute state-space poles.
 
void c_state_space_zeros (const c_state_space_model *mdl, int n, double complex *z, int *nz)
 Compute state-space zeros.
 
void c_state_space_transfer_function (const c_state_space_model *mdl, int nin, int nout, int n, const double complex *s, double complex *z, int ldz)
 Evaluate the state-space transfer matrix.
 

Detailed Description

Function Documentation

◆ c_alloc_polynomial()

int c_alloc_polynomial ( int  order,
c_polynomial *  p 
)

Allocate a polynomial.

Parameters
orderPolynomial order.
pPolynomial initialized by the routine.
Returns
Zero on success; nonzero on allocation failure.

◆ c_free_polynomial()

void c_free_polynomial ( c_polynomial *  p)

Release a polynomial.

Parameters
pPolynomial to release.

◆ c_alloc_transfer_function()

int c_alloc_transfer_function ( int  numer_order,
int  denom_order,
c_transfer_function *  tf 
)

Allocate a transfer function.

Parameters
numer_orderNumerator order.
denom_orderDenominator order.
tfTransfer function initialized by the routine.
Returns
Zero on success; nonzero on allocation failure.

◆ c_free_transfer_function()

void c_free_transfer_function ( c_transfer_function *  tf)

Release a transfer function.

Parameters
tfTransfer function to release.

◆ c_alloc_state_space_model()

int c_alloc_state_space_model ( int  dimension,
int  n_inputs,
int  n_outputs,
c_state_space_model *  mdl 
)

Allocate a continuous state-space model.

Parameters
dimensionState dimension.
n_inputsInput count.
n_outputsOutput count.
mdlModel initialized by the routine.
Returns
Zero on success; nonzero on allocation failure.

◆ c_free_state_space_model()

void c_free_state_space_model ( c_state_space_model *  mdl)

Release a state-space model.

Parameters
mdlModel to release.

◆ c_evaluate_transfer_function()

void c_evaluate_transfer_function ( const c_transfer_function *  tf,
int  n,
const double complex *  s,
double complex *  z 
)

Evaluate a transfer function at complex points.

Parameters
tfTransfer function.
nEvaluation count.
sComplex evaluation points.
zOutput complex values.

◆ c_transfer_function_poles()

void c_transfer_function_poles ( const c_transfer_function *  tf,
int  n,
double complex *  p 
)

Compute transfer-function poles.

Parameters
tfTransfer function.
nPole count.
pOutput poles.

◆ c_transfer_function_zeros()

void c_transfer_function_zeros ( const c_transfer_function *  tf,
int  n,
double complex *  z 
)

Compute transfer-function zeros.

Parameters
tfTransfer function.
nZero count.
zOutput zeros.

◆ c_to_ccf_state_space()

void c_to_ccf_state_space ( const c_transfer_function *  tf,
c_state_space_model *  ss 
)

Convert a transfer function to controllable canonical state space.

Parameters
tfTransfer function.
ssOutput state-space model.

◆ c_to_ocf_state_space()

void c_to_ocf_state_space ( const c_transfer_function *  tf,
c_state_space_model *  ss 
)

Convert a transfer function to observable canonical state space.

Parameters
tfTransfer function.
ssOutput state-space model.

◆ c_create_state_space_model()

void c_create_state_space_model ( int  n,
int  n_out,
const double *  m,
int  ldm,
const double *  b,
int  ldb,
const double *  k,
int  ldk,
c_state_space_model *  mdl 
)

Create a state-space model from mass, damping, and stiffness matrices.

Parameters
nState dimension.
n_outOutput count.
mMass matrix.
ldmLeading dimension of m.
bDamping matrix.
ldbLeading dimension of b.
kStiffness matrix.
ldkLeading dimension of k.
mdlOutput model.

◆ c_create_pid_state_space_model()

void c_create_pid_state_space_model ( double  kp,
double  ki,
double  kd,
double  tau,
const c_state_space_model *  plant,
c_state_space_model *  mdl 
)

Create a PID-controlled plant state-space model.

Parameters
kpProportional gain.
kiIntegral gain.
kdDerivative gain.
tauDerivative filter time constant.
plantPlant model.
mdlOutput model.

◆ c_transfer_function_multiply()

void c_transfer_function_multiply ( const c_transfer_function *  tf1,
const c_transfer_function *  tf2,
c_transfer_function *  tf 
)

Multiply two transfer functions.

Parameters
tf1First transfer function.
tf2Second transfer function.
tfOutput product.

◆ c_scale_transfer_function()

void c_scale_transfer_function ( double  x,
const c_transfer_function *  tf1,
c_transfer_function *  tf 
)

Scale a transfer function.

Parameters
xScale factor.
tf1Input transfer function.
tfOutput scaled transfer function.

◆ c_lti_solve()

void c_lti_solve ( const c_state_space_model *  mdl,
const c_ss_excitation  u,
int  n,
const double *  t,
int  ndof,
const double *  ic,
int  solver,
int  nout,
double *  y,
int  ldy,
void *  user_data 
)

Integrate a continuous state-space model.

Parameters
mdlState-space model.
uInput callback.
nTime-sample count.
tTime samples.
ndofInput degrees of freedom.
icInitial state.
solverIntegration method.
noutOutput count.
yOutput samples.
ldyLeading dimension of y.
user_dataOpaque caller data forwarded to u.

◆ c_state_space_poles()

void c_state_space_poles ( const c_state_space_model *  mdl,
int  n,
double complex *  p 
)

Compute state-space poles.

Parameters
mdlState-space model.
nPole count.
pOutput poles.

◆ c_state_space_zeros()

void c_state_space_zeros ( const c_state_space_model *  mdl,
int  n,
double complex *  z,
int *  nz 
)

Compute state-space zeros.

Parameters
mdlState-space model.
nZero count.
zOutput zeros.
nzOutput number of zeros.

◆ c_state_space_transfer_function()

void c_state_space_transfer_function ( const c_state_space_model *  mdl,
int  nin,
int  nout,
int  n,
const double complex *  s,
double complex *  z,
int  ldz 
)

Evaluate the state-space transfer matrix.

Parameters
mdlState-space model.
ninInput count.
noutOutput count.
nEvaluation count.
sComplex evaluation points.
zOutput transfer values.
ldzLeading dimension of z.