JMI Documentation

This page contains the Jmi Module documentation.

The jmi Module

Module containing the JMI interface Python wrappers.

exception jmodelica.jmi.JMIException[source]

Bases: exceptions.Exception

A JMI exception.

class jmodelica.jmi.JMIModel(libname, path='.', is_jmu=True)[source]

Bases: object

A JMI Model loaded from a binary file.

dae_F(res)[source]

Evaluates the DAE residual.

Parameters:

res --
    DAE residual vector. (Return variable)
dae_R(res)[source]

Evaluate the DAE event indicators.

Parameters:

res -- 
    DAE residual vector. (Return variable)
dae_dF(eval_alg, sparsity, independent_vars, mask, jac)[source]

Evaluate the Jacobian of the DAE residual function.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity --
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
jac --
    The Jacobian. (Return variable)
dae_dF_dim(eval_alg, sparsity, independent_vars, mask)[source]

Get the number of columns and non-zero elements in the Jacobian of the DAE residual.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity --
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.

Returns:

Tuple with number of columns and non-zeros resp. of the resulting 
Jacobian.
dae_dF_n_nz(eval_alg)[source]

Get the number of non-zeros in the full DAE residual Jacobian.

Parameters:

eval_alg --
    For which Jacobian the number of non-zero elements should be 
    returned: Symbolic (JMI_DER_SYMBOLIC) or CppAD (JMI_DER_CPPAD).

Returns:

The number of non-zero Jacobian entries.
dae_dF_nz_indices(eval_alg, independent_vars, mask, row, col)[source]

Get the row and column indices of the non-zero elements in the DAE residual Jacobian.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
row --
    Row indices of the non-zeros in the DAE residual Jacobian. 
    (Return variable)
    
col --
    Column indices of the non-zeros in the DAE residual Jacobian. 
    (Return variable)
dae_derivative_checker(sparsity, independent_vars, screen_use, mask)[source]

Compare the evaluated CAD derivative with the FD evaluation

Parameters::
sparsity –

Compare the result with different jacobian formats: JMI_DER_SPARSE, JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.

independent_vars –

Indicates which columns of the full Jacobian should be evaluated (for example JMI_DER_DX or JMI_DER_X).

Can either be a list of columns or a bitmask of the columns or:ed (|) together. Using a list is prefered as it is more Pythonesque.

dae_directional_dF(eval_alg, res, dF, dz)[source]

Evaluate the directional derivative of the DAE residual function.

The directional derivative is defined as

dF = dF/dz * dz

where dF/dz is the Jacobian of the residual function F, dF is the directional derivative and dz is the seed vector.

Parameters::
eval_alg –
JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or

JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD. JMI_DER_CAD to evaluate the Jacobian using CAD JMI_DER_FD to evaluate using finite differences

res –
DAE residual vector. The size of res is equal to the number of equations in the DAE residual. (Return variable)
dF –
The directional derivative of the DAE residual function. The size of res is equal to the number of equations in the DAE residual. (Return variable)
dz –
The seed vector. The size of dz is equal to 2*n_x + n_u + n_w.
dae_get_sizes()[source]

Get the number of equations of the DAE.

Returns:

The number of equations of the DAE.
get_boolean_cd()[source]

Get the boolean dependent constants vector.

Returns:

A reference to the boolean dependent constants vector.
get_boolean_ci()[source]

Get the boolean independent constants vector.

Returns:

A reference to the boolean independent constants vector.
get_boolean_d()[source]

Get the boolean variable vector.

Returns:

A reference to the boolean variables vector.
get_boolean_pd()[source]

Get the boolean dependent parameters vector.

Returns:

A reference to the boolean dependent parameters vector.
get_boolean_pi()[source]

Get the boolean independent parameters vector.

Returns:

A reference to the boolean independent parameters vector.
get_boolean_u()[source]

Get the boolean input vector.

Returns:

A reference to the boolean input variables vector.
get_integer_cd()[source]

Get the integer dependent constants vector.

Returns:

A reference to the integer dependent constants vector.
get_integer_ci()[source]

Get the integer independent constants vector.

Returns:

A reference to the integer independent constants vector.
get_integer_d()[source]

Get the integer variable vector.

Returns:

A reference to the integer variables vector.
get_integer_pd()[source]

Get the integer dependent parameters vector.

Returns:

A reference to the integer dependent parameters vector.
get_integer_pi()[source]

Get the integer independent parameters vector.

Returns:

A reference to the integer independent parameters vector.
get_integer_u()[source]

Get the integer input vector.

Returns:

A reference to the integer input variables vector.
get_n_tp(n_tp)[source]

Get the number of time points in the model.

Parameters:

n_tp --
    The number of time points (return variable).
get_offsets(offs_real_ci, offs_real_cd, offs_real_pi, offs_real_pd, offs_integer_ci, offs_integer_cd, offs_integer_pi, offs_integer_pd, offs_boolean_ci, offs_boolean_cd, offs_boolean_pi, offs_boolean_pd, offs_real_dx, offs_real_x, offs_real_u, offs_real_w, offs_t, offs_real_dx_p, offs_real_x_p, offs_real_u_p, offs_real_w_p, offs_real_d, offs_integer_d, offs_integer_u, offs_boolean_d, offs_boolean_u, offs_sw, offs_sw_init, offs_guards, offs_guards_init, offs_pre_real_dx, offs_pre_real_x, offs_pre_real_u, offs_pre_real_w, offs_pre_real_d, offs_pre_integer_d, offs_pre_integer_u, offs_pre_boolean_d, offs_pre_boolean_u, offs_pre_sw, offs_pre_sw_init, offs_pre_guards, offs_pre_guards_init)[source]

Get the offsets for the variable types in the z vector.

Parameters:

The offsets for all varibles in the z vector (return variables).
get_output_vrefs(output_vrefs)

Get the value references of the outputs.

Parameters:

output_vrefs --         
    A list of value references for the outputs (Output variable).
get_real_cd()[source]

Get the real dependent constants vector.

Returns:

A reference to the real dependent constants vector.
get_real_ci()[source]

Get the real independent constants vector.

Returns:

A reference to the real independent constants vector.
get_real_d()[source]

Get the real discrete variable vector.

Returns:

A reference to the real discrete variables vector.
get_real_dx()[source]

Get the real derivatives vector.

Returns:

A reference to the real derivatives vector.
get_real_dx_p(i)[source]

Get the real derivatives variables vector corresponding to the i:th time point.

Parameters:

i --
    The time point.

Returns:

A reference to the real derivatives variables vector for time point 
i.
get_real_pd()[source]

Get the real dependent parameters vector.

Returns:

A reference to the real dependent parameters vector.
get_real_pi()[source]

Get the real independent parameters vector.

Returns:

A reference to the real independent parameters vector.
get_real_u()[source]

Get the real inputs vector.

Returns:

A reference to the real inputs variables vector.
get_real_u_p(i)[source]

Get the real inputs vector corresponding to the i:th time point.

Parameters:

i --
    The time point.

Returns:

A reference to the real inputs variables vector for time point i.
get_real_w()[source]

Get the real algebraic variables vector.

Returns:

A reference to the real algebraic variables vector.
get_real_w_p(i)[source]

Get the real algebraic variables vector corresponding to the i:th time point.

Parameters:

i --
    The time point.

Returns:

A reference to the real algebraic variables vector for time point i.
get_real_x()[source]

Get the real differentiated variables vector.

Returns:

A reference to the real differentiated variables vector.
get_real_x_p(i)[source]

Get the real differentiated variables vector corresponding to the i:th time point.

Parameters:

i --
    The time point.

Returns:

A reference to the real differentiated variables vector for time 
point i.
get_scaling_method()[source]

Get the scaling method. Valid values are JMI_SCALING_NONE and JMI_SCALING_VARIABLES.

Returns:

The scaling method currently used.
get_sizes(n_real_ci, n_real_cd, n_real_pi, n_real_pd, n_integer_ci, n_integer_cd, n_integer_pi, n_integer_pd, n_boolean_ci, n_boolean_cd, n_boolean_pi, n_boolean_pd, n_real_dx, n_real_x, n_real_u, n_real_w, n_tp, n_real_d, n_integer_d, n_integer_u, n_boolean_d, n_boolean_u, n_outputs, n_sw, n_sw_init, n_guards, n_guards_init, n_z)[source]

Get the sizes of the variable vectors.

Parameters:

The sizes of the variable vectors (return variables).
get_sw()[source]

Get the switching function vector of the DAE. A switch value of 1 corresponds to true and 0 corresponds to false.

Returns:

A reference to the switch function vector of the DAE.
get_sw_init()[source]

Get the switching function vector of the DAE initialization system. A switch value of 1 corresponds to true and 0 corresponds to false.

Returns:

A reference to the switch function vector of the DAE initialization.
get_t()[source]

Get the time value.

Returns:

The time value, a NumPy array of length 1.
get_tp(tp)[source]

Get the vector of time points.

Parameters:

The vector of time points (return variable).
get_variable_scaling_factors()[source]

Get the variable scaling factor vector.

Returns:

A reference to the variable scaling factor vector.
get_z()[source]

Get the vector containing all parameters, variables and point-wise evalutated variables vector.

Returns:

A reference to the z-vector.
initAD()[source]

Initialize the Algorithmic Differential package.

Raises:

JMIException on failure.
init_F0(res)[source]

Evaluate the F0 residual function of the initialization system.

Parameters:

res -- 
    The residual of F0. (Return variable)
init_F1(res)[source]

Evaluate the F1 residual function of the initialization system.

Parameters:

res -- 
    The residual of F1. (Return variable)
init_Fp(res)[source]

Evaluate the Fp residual function of the initialization system.

Parameters:

res --
    The residual of Fp. (Return variable)
init_R0(res)[source]

Evaluate the DAE initialization event indicators.

Parameters:

res --
    DAE residual vector. (Return variable)
init_dF0(eval_alg, sparsity, independent_vars, mask, jac)[source]

Evaluate the Jacobian of the DAE initialization residual function F0.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity --
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
jac --
    The Jacobian. (Return variable)
init_dF0_dim(eval_alg, sparsity, independent_vars, mask)[source]

Get the number of columns and non-zero elements in the Jacobian of the DAE initialization residual function F0.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity --
   Output format of the Jacobian. Use JMI_DER_SPARSE, 
   JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
   
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.

Returns:

Tuple with number of columns and non-zeros resp. of the resulting 
Jacobian.
init_dF0_n_nz(eval_alg)[source]

Get the number of non-zeros in the full Jacobian of the DAE initialization residual function F0.

Parameters:

eval_alg --
    For which Jacobian the number of non-zero elements should be 
    returned: Symbolic (JMI_DER_SYMBOLIC) or CppAD (JMI_DER_CPPAD).

Returns:

The number of non-zero Jacobian entries in the full Jacobian.
init_dF0_nz_indices(eval_alg, independent_vars, mask, row, col)[source]

Get the row and column indices of the non-zero elements in the Jacobian of the DAE initialization residual function F0.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
row --
    Row indices of the non-zeros in the Jacobian. (Return 
    variable)
col --
    Column indices of the non-zeros in the Jacobian. (Return 
    variable)
init_dF1(eval_alg, sparsity, independent_vars, mask, jac)[source]

Evaluate the Jacobian of the DAE initialization residual function F1.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity --
   Output format of the Jacobian. Use JMI_DER_SPARSE, 
   JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
   
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
jac --
    The Jacobian. (Return variable)
init_dF1_dim(eval_alg, sparsity, independent_vars, mask)[source]

Get the number of columns and non-zero elements in the Jacobian of the DAE initialization residual function F1.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity --
   Output format of the Jacobian. Use JMI_DER_SPARSE, 
   JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
   
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.

Returns:

Tuple with number of columns and non-zeros resp. of the resulting 
Jacobian.
init_dF1_n_nz(eval_alg)[source]

Get the number of non-zeros in the full Jacobian of the DAE initialization residual function F1.

Parameters:

eval_alg --
    For which Jacobian the number of non-zero elements should be 
    returned: Symbolic (JMI_DER_SYMBOLIC) or CppAD (JMI_DER_CPPAD).

Returns:

The number of non-zero Jacobian entries in the full Jacobian.
init_dF1_nz_indices(eval_alg, independent_vars, mask, row, col)[source]

Get the row and column indices of the non-zero elements in the Jacobian of the DAE initialization residual function F1.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
row --
    Row indices of the non-zeros in the Jacobian. (Return variable)
    
col --
    Column indices of the non-zeros in the Jacobian. (Return 
    variable)
init_dFp(eval_alg, sparsity, independent_vars, mask, jac)[source]

Evaluate the Jacobian of the DAE initialization residual function F1.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity --
   Output format of the Jacobian. Use JMI_DER_SPARSE, 
   JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
   
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
  
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
jac --
    The Jacobian. (Return variable)
init_dFp_dim(eval_alg, sparsity, independent_vars, mask)[source]

Get the number of columns and non-zero elements in the Jacobian of the DAE initialization residual function Fp.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity --
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
  
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.

Returns:

Tuple with number of columns and non-zeros resp. of the resulting 
Jacobian.
init_dFp_n_nz(eval_alg)[source]

Get the number of non-zeros in the full Jacobian of the DAE initialization residual function Fp.

Parameters:

eval_alg --
    For which Jacobian the number of non-zero elements should be 
    returned: Symbolic (JMI_DER_SYMBOLIC) or CppAD (JMI_DER_CPPAD).

Returns:

The number of non-zero Jacobian entries in the full Jacobian.
init_dFp_nz_indices(eval_alg, independent_vars, mask, row, col)[source]

Get the row and column indices of the non-zero elements in the Jacobian of the DAE initialization residual function Fp.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
  
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
row --
    Row indices of the non-zeros in the Jacobian. (Return variable)
    
col --
    Column indices of the non-zeros in the Jacobian. (Return 
    variable)
init_eval_parameters()[source]

Compute the dependent parameters.

init_get_sizes()[source]

Get the number of equations in the DAE initialization functions.

Returns:

The number of equations in F0, F1 and Fp resp.
ode_derivatives()[source]

Compute the derivatives of the ODE.

ode_derivatives_dir_der(dv)

Compute the directional derivative of the ODE.

Parameters:

dv --
    The seed vector
ode_df(eval_alg, sparsity, independent_vars, mask, jac)[source]

Evaluate the Jacobian of the right hand side of the ODE.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity --
   Output format of the Jacobian. Use JMI_DER_SPARSE, 
   JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
   
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
jac --
    The Jacobian. (Return variable)
ode_df_dim(eval_alg, sparsity, independent_vars, mask)[source]

Get the number of columns and non-zero elements in the Jacobian of the right hand side of the ODE.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity --
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.

Returns:

Tuple with number of columns and non-zeros resp. of the resulting 
Jacobian.
ode_df_n_nz(eval_alg)[source]

Get the number of non-zeros in the Jacobian of the right hand side of the ODE.

Parameters:

eval_alg --
    For which Jacobian the number of non-zero elements should be 
    returned: Symbolic (JMI_DER_SYMBOLIC) or CppAD (JMI_DER_CPPAD).

Returns:

The number of non-zero Jacobian entries.
ode_df_nz_indices(eval_alg, independent_vars, mask, row, col)[source]

Get the row and column indices of the non-zero elements in the Jacobian of the right hand side of the ODE.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
row --
    Row indices of the non-zeros in the Jacobian. (Return variable)
    
col --
    Column indices of the non-zeros in the Jacobian. (Return 
    variable)
ode_f()[source]

Evalutate the right hand side of the ODE.

The results is saved to the internal states and can be accessed by accessing ‘my_model.real_x’.

ode_guards()[source]

Evaluate the guard expressions of the ODE.

ode_guards_init()[source]

Evaluate the guard expressions of the initial equations.

ode_initialize()[source]

Initialize the ODE.

ode_next_time_event()[source]

Compute the next time event.

ode_outputs()[source]

Compute the outputs of the ODE.

opt_Ceq(res)[source]

Evaluate the residual of the equality path constraint Ceq.

Parameters:

res -- 
    The residual. (Return variable)
opt_Cineq(res)[source]

Evaluate the residual of the inequality path constraint Cineq.

Parameters:

res -- 
    The residual. (Return variable)
opt_Ffdp(res)[source]

Evaluate the residual of the free dependent parameter residuals Ffdp.

Parameters:

res -- 
    The residual. (Return variable)
opt_Heq(res)[source]

Evaluate the residual of the equality point constraint Heq.

Parameters:

res -- 
    The residual. (Return variable)
opt_Hineq(res)[source]

Evaluate the residual of the inequality point constraint Hineq.

Parameters:

res -- 
    The residual. (Return variable)
opt_J()[source]

Evaluate the cost function J.

opt_dCeq(eval_alg, sparsity, independent_vars, mask, jac)[source]

Evaluate the Jacobian of the equality path constraint Ceq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity -- 
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
jac --
    The Jacobian. (Return variable)
opt_dCeq_dim(eval_alg, sparsity, independent_vars, mask)[source]

Compute the number of columns and non-zero elements in the Jacobian of the equality path constraint residual function Ceq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity -- 
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.

Returns:

Tuple with number of columns and non-zeros resp. of the resulting 
Jacobian.
opt_dCeq_n_nz(eval_alg)[source]

Get the number of non-zeros in the full Jacobian of the equality path constraint Ceq.

Parameters:

eval_alg --
    For which Jacobian the number of non-zero elements should be 
    returned: Symbolic (JMI_DER_SYMBOLIC) or CppAD (JMI_DER_CPPAD).

Returns:

The number of non-zero entries in the full Jacobian.
opt_dCeq_nz_indices(eval_alg, independent_vars, mask, row, col)[source]

Get the row and column indices of the non-zero elements in the Jacobian of the equality path constraint residual Ceq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
row --
    Row indices of the non-zeros in the Jacobian. (Return variable)
    
col --
    Column indices of the non-zeros in the Jacobian. (Return 
    variable)
opt_dCineq(eval_alg, sparsity, independent_vars, mask, jac)[source]

Evaluate the Jacobian of the inequality path constraint Cineq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity -- 
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
jac --
    The Jacobian. (Return variable)
opt_dCineq_dim(eval_alg, sparsity, independent_vars, mask)[source]

Compute the number of columns and non-zero elements in the Jacobian of the inequality path constraint residual function Cineq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity -- 
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.

Returns:

Tuple with number of columns and non-zeros resp. of the resulting 
Jacobian.
opt_dCineq_n_nz(eval_alg)[source]

Get the number of non-zeros in the full Jacobian of the inequality path constraint Cineq.

Parameters:

eval_alg --
    For which Jacobian the number of non-zero elements should be 
    returned: Symbolic (JMI_DER_SYMBOLIC) or CppAD (JMI_DER_CPPAD).

Returns:

The number of non-zero entries in the full Jacobian.
opt_dCineq_nz_indices(eval_alg, independent_vars, mask, row, col)[source]

Get the row and column indices of the non-zero elements in the Jacobian of the inequality path constraint residual Cineq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (JMI_DER_DX or JMI_DER_X).
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
row --
    Row indices of the non-zeros in the Jacobian. (Return variable)
    
col --
    Column indices of the non-zeros in the Jacobian. (Return 
    variable)
opt_dFfdp(eval_alg, sparsity, independent_vars, mask, jac)[source]

Evaluate the Jacobian of the free dependent parameter residual Ffdp.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity -- 
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
jac --
    The Jacobian. (Return variable)
opt_dFfdp_dim(eval_alg, sparsity, independent_vars, mask)[source]

Compute the number of columns and non-zero elements in the Jacobian of the free dependent parameter residual Ffdp.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity -- 
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.

Returns:

Tuple with number of columns and non-zeros resp. of the resulting 
Jacobian.
opt_dFfdp_n_nz(eval_alg)[source]

Get the number of non-zeros in the full Jacobian of the free dependent parameter residual Ffdp.

Parameters:

eval_alg -- 
    For which Jacobian the number of non-zero elements should be 
    returned: Symbolic (JMI_DER_SYMBOLIC) or CppAD (JMI_DER_CPPAD).

Returns:

The number of non-zero entries in the full Jacobian.
opt_dFfdp_nz_indices(eval_alg, independent_vars, mask, row, col)[source]

Get the row and column indices of the non-zero elements in the Jacobian of the free dependent parameter residual Ffdp.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
row --
    Row indices of the non-zeros in the Jacobian. (Return variable)
    
col --
    Column indices of the non-zeros in the Jacobian. (Return 
    variable)
opt_dHeq(eval_alg, sparsity, independent_vars, mask, jac)[source]

Evaluate the Jacobian of the equality point constraint Heq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity -- 
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
jac --
    The Jacobian. (Return variable)
opt_dHeq_dim(eval_alg, sparsity, independent_vars, mask)[source]

Compute the number of columns and non-zero elements in the Jacobian of the equality point constraint residual function Heq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity -- 
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.

Returns:

Tuple with number of columns and non-zeros resp. of the resulting 
Jacobian.
opt_dHeq_n_nz(eval_alg)[source]

Get the number of non-zeros in the full Jacobian of the equality point constraint Heq.

Parameters:

eval_alg --
    For which Jacobian the number of non-zero elements should be 
    returned: Symbolic (JMI_DER_SYMBOLIC) or CppAD (JMI_DER_CPPAD).

Returns:

The number of non-zero entries in the full Jacobian.
opt_dHeq_nz_indices(eval_alg, independent_vars, mask, row, col)[source]

Get the row and column indices of the non-zero elements in the Jacobian of the equality point constraint residual Heq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
row --
    Row indices of the non-zeros in the Jacobian. (Return variable)
    
col --
    Column indices of the non-zeros in the Jacobian. (Return 
    variable)
opt_dHineq(eval_alg, sparsity, independent_vars, mask, jac)[source]

Evaluate the Jacobian of the inequality point constraint Hineq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity -- 
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
jac --
    The Jacobian. (Return variable)
opt_dHineq_dim(eval_alg, sparsity, independent_vars, mask)[source]

Compute the number of columns and non-zero elements in the Jacobian of the inequality point constraint residual function Hineq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity -- 
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.

Returns:

Tuple with number of columns and non-zeros resp. of the resulting 
Jacobian.
opt_dHineq_n_nz(eval_alg)[source]

Get the number of non-zeros in the full Jacobian of the inequality point constraint Hineq.

Parameters:

eval_alg --
    For which Jacobian the number of non-zero elements should be 
    returned: Symbolic (JMI_DER_SYMBOLIC) or CppAD (JMI_DER_CPPAD).

Returns:

The number of non-zero entries in the full Jacobian.
opt_dHineq_nz_indices(eval_alg, independent_vars, mask, row, col)[source]

Get the row and column indices of the non-zero elements in the Jacobian of the inequality point constraint residual Hineq.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
row --
    Row indices of the non-zeros in the Jacobian. (Return variable)
    
col --
    Column indices of the non-zeros in the Jacobian. (Return 
    variable)
opt_dJ(eval_alg, sparsity, independent_vars, mask, jac)[source]

Evaluate the gradient of the cost function.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity --
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
jac --
    The gradient. (Return variable)
opt_dJ_dim(eval_alg, sparsity, independent_vars, mask)[source]

Compute the number of columns and non-zero elements in the gradient of the cost function.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
sparsity -- 
    Output format of the Jacobian. Use JMI_DER_SPARSE, 
    JMI_DER_DENSE_COL_MAJOR, or JMI_DER_DENS_ROW_MAJOR.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.

Returns:

Tuple with number of columns and non-zeros resp. of the resulting 
Jacobian.
opt_dJ_n_nz(eval_alg)[source]

Get the number of non-zeros in the gradient of the cost function J.

Parameters:

eval_alg --
    For which Jacobian the number of non-zero elements should be 
    returned: Symbolic (JMI_DER_SYMBOLIC) or CppAD (JMI_DER_CPPAD).

Returns:

The number of non-zero entries in the full gradient.
opt_dJ_nz_indices(eval_alg, independent_vars, mask, row, col)[source]

Get the row and column indices of the non-zero elements in the gradient of the cost function J.

Parameters:

eval_alg -- 
    JMI_DER_SYMBOLIC to evaluate a symbolic Jacobian or 
    JMI_DER_CPPAD to evaluate the Jacobian by means of CppAD.
    
independent_vars -- 
    Indicates which columns of the full Jacobian should be evaluated 
    (for example JMI_DER_DX or JMI_DER_X).
    
    Can either be a list of columns or a bitmask of the columns 
    or:ed (|) together. Using a list is prefered as it is more 
    Pythonesque.
    
mask --
    Vector containing ones for the Jacobian columns that should be 
    included in the Jacobian and zeros for those which should not.
    
row --
    Row indices of the non-zeros in the gradient. (Return variable)
    
col --
    Column indices of the non-zeros in the gradient. (Return 
    variable)
opt_get_n_p_opt()[source]

Get the number of optimization parameters.

Returns:

The number of optimization parameters.
opt_get_optimization_interval()[source]

Get the optimization interval.

Returns:

Tuple with start time of optimization interval, 0 if start time is 
fixed and 1 if free, final time of optimization interval, 0 if final 
time is fixed and 1 if free, respectively. 
opt_get_p_opt_indices(p_opt_indices)[source]

Get the optimization parameter indices.

Parameters:

p_opt_indices -- 
    Indices of parameters to be optimized. (Return variable)
opt_get_sizes()[source]

Get the sizes of the optimization functions.

Returns:

Tuple with number of equations in the J, L, Ffdp, Ceq, Cineq, Heq 
and Hineq residual respectively. 
opt_set_optimization_interval(start_time, start_time_free, final_time, final_time_free)[source]

Set the optimization interval.

Parameters:

start_time -- 
    Start time of optimization interval.
    
start_time_free -- 
    0 if start time should be fixed or 1 if free.
    
final_time -- 
    Final time of optimization interval.
    
final_time_free -- 
    0 if final time should be fixed or 1 if free.
opt_set_p_opt_indices(n_p_opt, p_opt_indices)[source]

Specify optimization parameters for the model.

Parameters:

n_p_opt -- 
    Number of parameters to be optimized.
    
p_opt_indices -- 
    Indices of parameters to be optimized in pi vector.
set_tp(tp)[source]

Set the vector of time points.

Parameters:

The new vector of time points.
with_cad_derivatives()

Check if there is support for CAD derivatives or not.

Returns:

1 if there is CAD support, 0 otherwise.
with_cppad_derivatives()[source]

Check if there is support for CppAD derivatives or not.

Returns:

1 if there is CppAD support, 0 otherwise.
jmodelica.jmi.JMI_DER_ALL

Evaluate derivatives w.r.t. all variables in $p $.

jmodelica.jmi.JMI_DER_ALL_P

Evaluate derivatives w.r.t. all variables in $v $.

jmodelica.jmi.JMI_DER_ALL_Q

No scaling.

jmodelica.jmi.JMI_DER_ALL_V

Evaluate derivatives w.r.t. all variables in $q $.

jmodelica.jmi.JMI_DER_CAD

Use finite differentiation (FD) to evaluate derivatives.

jmodelica.jmi.JMI_DER_CD

Evaluate derivatives w.r.t. independent parameters, $p_i $.

jmodelica.jmi.JMI_DER_CHECK_SCREEN_OFF

Flags for evaluation of Jacobians w.r.t. parameters in the p vector

jmodelica.jmi.JMI_DER_CHECK_SCREEN_ON

Interrupt when evaluation error is found

jmodelica.jmi.JMI_DER_CI

Evaluate derivatives w.r.t. dependent constants, $c_d $.

jmodelica.jmi.JMI_DER_CPPAD

Use automatic differentiation (CAD) to evaluate derivatives.

jmodelica.jmi.JMI_DER_DENSE_COL_MAJOR

Dense evaluation (row major) of derivatives.

jmodelica.jmi.JMI_DER_DENSE_ROW_MAJOR

Print evaluation errors on screen

jmodelica.jmi.JMI_DER_DX

Evaluate derivatives w.r.t. differentiated variables, $x $.

jmodelica.jmi.JMI_DER_DX_P

Evaluate derivatives w.r.t. differentiated variables at time points, $x_p $.

jmodelica.jmi.JMI_DER_FD

Sparse evaluation of derivatives.

jmodelica.jmi.JMI_DER_PD

Flags for evaluation of Jacobians w.r.t. variables in the v vector

jmodelica.jmi.JMI_DER_PI

Evaluate derivatives w.r.t. dependent constants, $p_d $.

jmodelica.jmi.JMI_DER_P_OPT

Evaluate derivatives w.r.t. derivatives, $dot x $.

jmodelica.jmi.JMI_DER_SPARSE

Dense evaluation (column major) of derivatives

jmodelica.jmi.JMI_DER_SYMBOLIC

Use automatic differentiation (CppAD) to evaluate derivatives.

jmodelica.jmi.JMI_DER_T

Flags for evaluation of Jacobians w.r.t. variables in the q vector.

jmodelica.jmi.JMI_DER_U

Evaluate derivatives w.r.t. algebraic variables, $w $.

jmodelica.jmi.JMI_DER_U_P

Evaluate derivatives w.r.t. algebraic variables at time points, $w_p $.

jmodelica.jmi.JMI_DER_W

Evaluate derivatives w.r.t. time, $t $.

jmodelica.jmi.JMI_DER_W_P

Evaluate derivatives w.r.t. all variables, $z $.

jmodelica.jmi.JMI_DER_X

Evaluate derivatives w.r.t. inputs, $u $.

jmodelica.jmi.JMI_DER_X_P

Evaluate derivatives w.r.t. inputs at time points, $u_p $.

jmodelica.jmi.JMI_SCALING_NONE

Scale real variables by multiplying incoming variables in residual functions by the scaling factors in jmi_t->variable_scaling_factors

class jmodelica.jmi.JMUModel(jmu_name, reload_dll=True)[source]

Bases: jmodelica.core.BaseModel

High-level interface to a JMIModel.

boolean_cd

Property for accessing the dependent boolean constants vector.

boolean_ci

Property for accessing the integer independent constants vector.

boolean_d

Property for accessing the boolean discrete variables vector.

boolean_pd

Property for accessing the boolean dependent parameters vector.

boolean_pi

Property for accessing the boolean independent parameters vector.

boolean_u

Property for accessing the boolean input variables vector.

eval_ode_f()[source]

Evaluate an ODE.

The ODE is of the form:
dx = f(x, t, ...)

The input variables to f are expected to be set BEFORE calling this function. The calculated dx can be accessed in two ways:

  1. By accessing is through the member Model.dx; or
  2. By using return value of this function which is the same.

Returns:

Model.dx on success.

Raises:

JMIException evaluation failed.
get_aliases_for_variable(variable)[source]

Get a list of all alias variables belonging to the aliased variable passed as argument to the function along with a list of booleans indicating whether the alias variable should be negated or not.

Parameters:

variable --
    The aliased variable. 

Returns:

Tuple of lists, the first containing the names of the alias 
variables, the second containing booleans for each alias 
variable indicating whether the variable is a negated variable 
or not.

Tuple of empty lists if the variable has no alias variables. 

None if variable cannot be found in model.
get_dx_variable_names(include_alias=True)[source]

Get the names of the derivatives in the model.

Parameters:

include_alias --
    If True then include all alias variables if False then only the 
    names of the non-alias variables will be returned.
    Default: True

Returns:

List of tuples containing value reference and name respectively.

Raises:

XMLException if variable is not found in XML document.
get_n_tp()[source]

Get the number of time points in the model.

Returns:

The number of time points.
get_name()[source]

Get the name of the model that has been loaded.

Returns:

The name of the model.
get_offsets()[source]

Get all offsets for the variable types in the z vector.

Returns:

A list of the offsets for the variable types in the z vector.
get_p_opt_variable_names(include_alias=True)[source]

Get the names of the optimized parameters in the model.

Parameters:

include_alias --
    If True then include all alias variables if False then only the 
    names of the non-alias variables will be returned.
    Default: True

Returns:

List of tuples containing value reference and name respectively.

Raises:

XMLException if variable is not found in XML document.
get_real_dx_p(i)[source]

Get the real derivatives variables vector corresponding to the i:th time point.

Parameters:

i --
    Point in time.

Returns:

A reference to the real derivatives variables vector for time point 
i.
get_real_u_p(i)[source]

Get the real inputs vector corresponding to the i:th time point.

Parameters:

i --
    Point in time.

Returns:

A reference to the real inputs variables vector for time point i.
get_real_w_p(i)[source]

Get the real algebraic variables vector corresponding to the i:th time point.

Parameters:

i --
    Point in time.

Returns:

A reference to the real algebraic variables vector for time point i.
get_real_x_p(i)[source]

Get the real differentiated variables vector corresponding to the i:th time point.

Parameters:

i --
    Point in time.

Returns:

A reference to the real differentiated variables vector for time 
point i.
get_scaling_method()[source]

Get the scaling_method. Valid values are JMI_SCALING_NONE and JMI_SCALING_VARIABLES.

Returns:

The scaling method currently used.
get_sizes()[source]

Get the sizes of all variable vectors.

Returns:

A list of the sizes of the variable vectors.
get_u_variable_names(include_alias=True)[source]

Get the names of the inputs in the model.

Parameters:

include_alias --
    If True then include all alias variables if False then only the 
    names of the non-alias variables will be returned.
    Default: True

Returns:

List of tuples containing value reference and name respectively.

Raises:

XMLException if variable is not found in XML document.
get_value_reference(variablename)[source]

Get the value reference of the variable given the variable name.

Parameters:

variablename --
    The name of the variable for which the value reference should be 
    found.

Returns:

Value reference of the specific variable.

Raises:

XMLException if variable was not found.
get_variability(variablename)[source]

Get variability of variable.

Parameters:

variablename --
    The name of the variable.

Returns:

The variability of the variable, CONTINUOUS(0), CONSTANT(1), 
PARAMETER(2) or DISCRETE(3).

Raises:

XMLException if variable was not found.
get_variable_descriptions(include_alias=True)[source]

Extract the descriptions of the variables in a model.

Parameters:

include_alias --
    If True then include all alias variables if False then only the 
    descriptions of the non-alias variables will be returned.
    Default: True

Returns:

List of tuples containing value reference and description 
respectively.

Raises:

XMLException if variable is not found in XML document.
get_variable_names(include_alias=True)[source]

Get the names of all variables in the model.

Parameters:

include_alias -- 
    If True then include all alias variables if False then only the 
    names of the non-alias variables will be returned.
    Default: True

Returns:

List of tuples containing value references and names respectively.
get_w_variable_names(include_alias=True)[source]

Get the names of the algebraic variables in the model.

Parameters:

include_alias --
    If True then include all alias variables if False then only the 
    names of the non-alias variables will be returned.
    Default: True

Returns:

List of tuples containing value reference and name respectively.

Raises:

XMLException if variable is not found in XML document.
get_x_variable_names(include_alias=True)[source]

Get the names of the differentiated_variables in the model.

Parameters:

include_alias --
    If True then include all alias variables if False then only the 
    names of the non-alias variables will be returned.
    Default: True

Returns:

List of tuples containing value reference and name respectively.

Raises:

XMLException if variable is not found in XML document.
has_cad_derivatives()

Check if there is support for CAD derivatives.

Returns:

True if there is support for CAD derivatives, otherwise False.
has_cppad_derivatives()[source]

Check if there is support for CppAD derivatives.

Returns:

True if there is support for CppAD derivatives, otherwise False.
initialize(algorithm='IpoptInitializationAlg', options={})[source]

Compact function for model initialization.

The initialization method depends on which algorithm is used, this can be set with the function argument ‘algorithm’. Options for the algorithm are passed as option classes or as pure dicts. See JMUModel.initialize_options for more details.

The default algorithm for this function is IpoptInitializationAlg.

Parameters:

algorithm --
    The algorithm which will be used for the initialization is 
    specified by passing the algorithm class as string or class 
    object in this argument. 'algorithm' can be any class which 
    implements the abstract class AlgorithmBase (found in 
    algorithm_drivers.py). In this way it is possible to write own 
    algorithms and use them with this function.
    Default: 'IpoptInitializationAlg'
    
options -- 
    The options that should be used in the algorithm. For details on 
    the options do:
    
        >> myModel = JMUModel(...)
        >> opts = myModel.initialize_options()
        >> opts?

    Valid values are: 
        - A dict which gives IpoptInitializationAlgOptions with 
          default values on all options except the ones listed in 
          the dict. Empty dict will thus give all options with 
          default values.
        - An options object.
    Default: Empty dict

Returns:

Result object, subclass of algorithm_drivers.ResultBase.
initialize_from_data(res, time=0.0)[source]

Initialize the JMUModel from a result data object. All variables, but not the parametes, in the model are initialized with variable values extracted from the data at a time instant specified by the argument time. Linear interpolation is used to compute the variable values from the trajectory data.

Parameters::
res –
A result data object of the class jmodelica.io.ResultDymolaTextual
time –
The time at which variable values are extracted from the result data.
Limitations::
Only real variables are initialized.
integer_cd

Property for accessing the dependent integer constants vector.

integer_ci

Property for accessing the integer independent constants vector.

integer_d

Property for accessing the integer discrete variables vector.

integer_pd

Property for accessing the integer dependent parameters vector.

integer_pi

Property for accessing the integer independent parameters vector.

integer_u

Property for accessing the integer input variables vector.

is_negated_alias(variablename)[source]

Find out if variable is a negated alias or not.

Parameters:

variablename -- 
    The name of the variable.

Returns:

True if the variable is a negated alias, otherwise False.

Raises:

XMLException if variable is not found in XML document.
load_parameters_from_XML(filename='')[source]

Reset the pi vector with values from the XML file created when the model was compiled. If an XML file other than this should be used instead, set the filename of the file to load.

Parameters:

filename -- 
    The name of XML file that should be loaded.
    Default: Empty string.

Raises:

IOError if file could not be found.
opt_eval_J()[source]

Get the evaluted optimization cost function, J.

All values (such as u, u_p, x_p etc.) are expected to be set before calling this function.

Returns:

The optimization cost function J.
opt_eval_jac_J(independent_variables, mask=None)[source]

Evaluate the jacobian of the cost function.

Parameters:

independent_variables -- 
    The variables witch the jacobian will be based on.
    
mask -- 
    If only some independent variables should be 
    (re)evaluated.
    Default: None

Please refer to the JMI documentation for more info.

opt_interval_finaltime_fixed()[source]

Evaluate if the optimization final time is fixed.

Returns:

True if the optimization final time is fixed, False otherwise.
opt_interval_finaltime_free()[source]

Evaluate if the optimization final time is free.

Returns:

True if the optimization final time is free, False otherwise.
opt_interval_get_final_time()[source]

Get the final time of the optimization interval.

Returns:

The final time of the optimization interval.
opt_interval_get_start_time()[source]

Get the start time of the optimization interval.

Returns:

The start time of the optimization interval.
opt_interval_starttime_fixed()[source]

Evaluate if the optimization start time is fixed.

Returns:

True if the optimization start time is fixed, False otherwise.
opt_interval_starttime_free()[source]

Evaluate if the optimization start time is free.

Returns:

True if optimization start time is free, False otherwise.
optimize(algorithm='CollocationLagrangePolynomialsAlg', options={})[source]

Solve an optimization problem.

Parameters:

algorithm --
    The algorithm which will be used for the optimization is 
    specified by passing the algorithm class name as string or class 
    object in this argument. 'algorithm' can be any class which 
    implements the abstract class AlgorithmBase (found in 
    algorithm_drivers.py). In this way it is possible to write 
    custom algorithms and to use them with this function.

    The following algorithms are available:
    - 'CollocationLagrangePolynomialsAlg'. This algorithm is based 
      on direct collocation on finite elements and the algorithm 
      IPOPT is used to obtain a numerical solution to the problem.
    Default: 'CollocationLagrangePolynomialsAlg'
    
options -- 
    The options that should be used in the algorithm. The options
    documentation can be retrieved from an options object:
    
        >>> myModel = JMUModel(...)
        >>> opts = myModel.optimize_options()
        >>> opts?

    Valid values are: 
    - A dict that overrides some or all of the default values
      provided by CollocationLagrangePolynomialsAlgOptions. An empty
      dict will thus give all options with default values.
    - A CollocationLagrangePolynomialsAlgOptions object.
    Default: Empty dict

Returns:

A result object, subclass of algorithm_drivers.ResultBase.
real_cd

Property for accessing the dependent real constants vector.

real_ci

Property for accessing the real independent constants vector.

real_d

Property for accessing the real discrete variables vector.

real_dx

Property for accessing the real derivatives vector.

real_pd

Property for accessing the real dependent parameters vector.

real_pi

Property for accessing the real independent parameters vector.

real_u

Property for accessing the real inputs vector.

real_w

Property for accessing the real algebraic variables vector.

real_x

Property for accessing the real differentiated variables vector.

reset()[source]

Reset the internal states of the DLL.

Calling this function is equivalent to reopening the model.

set_real_dx_p(real_dx_p, i)[source]

Set the derivatives variables vector corresponding to the i:th time point.

Parameters:

real_dx_p --
    The new real derivatives variables vector for time point i.
    
i --
    Point in time.
set_real_u_p(real_u_p, i)[source]

Set the real inputs vector corresponding to the i:th time point.

Parameters:

real_u_p --
    The new real inputs variables vector for time point i.
    
i --
    Point in time.
set_real_w_p(real_w_p, i)[source]

Set the real algebraic variables vector corresponding to the i:th time point.

Parameters:

real_w_p --
    The new real algebraic variables vector for time point i.
    
i --
    Point in time.
set_real_x_p(real_x_p, i)[source]

Set the real differentiated variables vector corresponding to the i:th time point.

Parameters:

real_x_p --
    The new real differentiated variables vector for time point i.
    
i --
    Point in time.
simulate(start_time=0.0, final_time=1.0, input=(), algorithm='AssimuloAlg', options={})[source]

Simulation of a model.

The simulation method depends on which algorithm is used, which can be set by the function argument ‘algorithm’. Options for the simulation algorithm are passed as option classes or as pure dicts. See JMUModel.simulate_options for more details.

The default algorithm for this function is AssimuloAlg.

Parameters:

start_time --
    Start time for the simulation.
    Default: 0.0
    
final_time --
    Final time for the simulation.
    Default: 1.0
    
input --
    Input signal for the simulation. The input should be a 2-tuple 
    consisting of first the names of the input variable(s) and then 
    the data matrix.
    Default: Empty tuple.
    
algorithm --
    The algorithm that will be used for the simulation is specified 
    by passing the algorithm class as string or class object in this 
    argument. 'algorithm' can be any class which implements the 
    abstract class AlgorithmBase which is found in the module 
    jmodelica.algorithm_drivers. In this way it is possible to write 
    custom algorithms and use them with this function.
    Default: 'AssimuloAlg'
    
options -- 
    The options to be used in the algorithm. For details on 
    available options do:
    
        >> myModel = JMUModel(...)
        >> opts = myModel.simulate_options()
        >> opts?

    Valid values are: 
    - A dict that overrides some or all of the default values 
      provided by AssimuloAlgOptions. An empty dict will thus give 
      all options with default values.
    - A AssimuloAlgOptions object.
    Default: Empty dict

Returns:

A result object, subclass of algorithm_drivers.ResultBase.
sw

Property for accessing the switch function vector of the DAE. A switch value of 1 corresponds to true and 0 corresponds to false.

sw_init

Property for accessing the switch function vector of the DAE initialization system. A switch value of 1 corresponds to true and 0 corresponds to false.

t

Property for accessing the time value.

variable_scaling_factors

Property for accessing the variable scaling vector of the DAE initialization system. The scaling variable vector has the same size as the z vector: scaling factors for booleans, integers and switches are ignored.

write_parameters_to_XML(filename='')[source]

Write parameter values (real, integer, boolean supported) in the pi vector to XML. The default behaviour is to overwrite the XML file created when model was compiled. To write to a new file, set the file name of the new file to write to.

Parameters:

filename -- 
    The filename of the XML file that the parameter vector should be 
    written to.
    Default: Empty string.
z

Property for accessing the z vector. (The vector containing all parameters, variables and point-wise evalutated variables vector.

jmodelica.jmi.compile_jmu(class_name, file_name=[], compiler='auto', target='ipopt', compiler_options={}, compile_to='.', compiler_log_level='warning')[source]

Compile a Modelica or Optimica model to a JMU.

A model class name must be passed, all other arguments have default values. The different scenarios are:

  • Only class_name is passed:
    • Default compiler is ModelicaCompiler.
    • Class is assumed to be in MODELICAPATH.
  • class_name and file_name is passed:
    • file_name can be a single file as a string or a list of file_names (strings).
    • Default compiler setting is ‘auto’ which means that the appropriate compiler will be selected based on model file ending, i.e. ModelicaCompiler if .mo file and OptimicaCompiler if a .mop file is found in file_name list.

Library directories can be added to MODELICAPATH by listing them in a special compiler option ‘extra_lib_dirs’, for example:

compiler_options =
{‘extra_lib_dirs’:[‘c:MyLibsMyLib1’,’c:MyLibsMyLib2’]}

Other options for the compiler should also be listed in the compiler_options dict.

The compiler target is ‘ipopt’ by default which means that libraries for AD and optimization/initialization algortihms will be available as well as the JMI. The other targets are:

‘model’ –
AD and JMI is included.
‘algorithm’ –
AD and algorithm but no Ipopt linking.
‘model_noad’ –
Only JMI, that is no AD interface. (Must currently be used when model includes external functions.)

Parameters:

class_name -- 
    The name of the model class.
    
file_name -- 
    Model file (string) or files (list of strings), can be both .mo or 
    .mop files.
    Default: Empty list.
    
compiler -- 
    'auto' if a compiler should be selected automatically depending on 
    file ending, 'modelica' if a ModelicaCompiler should be used or 
    'optimica' if a OptimicaCompiler should be used.
    Default: 'auto' (i.e. depends on argument file_name)
    
target --
    Compiler target. 'model', 'algorithm', 'ipopt' or 'model_noad'.
    Default: 'ipopt'
    
compiler_options --
    Options for the compiler.
    Default: Empty dict.
    
compile_to --
    Specify location of the compiled JMU. Directory will be created if 
    it does not exist.
    Default: Current directory.
    
compiler_log_level --
    Set the log level for the compiler. Valid options are 'warning'/'w', 
    'error'/'e' or 'info'/'i'.
    Default: 'warning'

Returns:

Name of the JMU which has been created.
jmodelica.jmi.der_name(name)[source]
jmodelica.jmi.fail_error_check(message)[source]

A ctypes errcheck that always fails.

jmodelica.jmi.get_jmu_name(class_name)[source]

Computes the JMU name from a class name.

Parameters:

class_name -- 
    The name of the model.

Returns:

The JMU name (replaced dots with underscores).
jmodelica.jmi.load_DLL(libname, path)[source]

Loads a model from a DLL file and returns it.

The filepath can be be both with or without file suffixes (as long as standard file suffixes are used, that is).

Example inputs that should work:
>> lib = loadDLL(‘model’) >> lib = loadDLL(‘model.dll’) >> lib = loadDLL(‘model.so’)

. All of the above should work on the JModelica supported platforms. However, the first one is recommended as it is the most platform independent syntax.

Parameters:

libname -- 
    Name of the library without prefix.
    
path -- 
    The relative or absolute path to the library.

See also http://docs.python.org/library/ct.html

jmodelica.jmi.strip_der(name)[source]
jmodelica.jmi.unzip_jmu(archive, path='.', random_name=True)