GSESUB/GSEXX/GSEXU/GSEYX/GSEYU

ModelingUsed to represent any generic system that has defined inputs, internal states, and outputs.

Definition

It can be used to model a nonlinear time varying system. Typically, a General State Equation can be used to integrate automatic control theory or third party software packages. In its most generic implementation, a GSESUB is used to represent an arbitrary system of algebraic or differential equations.

Use

General state equation entity:

<Control_StateEqn
     id                  = "301001"
     type                = "USERSUB"
     x_solver_array_id   = "30100200"
     y_solver_array_id   = "30100300"
     u_solver_array_id   = "30100100"
     ic_solver_array_id  = "0"
     num_state           = "2"
     num_output          = "1"
     usrsub_param_string = "USER(0,1,-10,.1,10,0,0,1)"
     usrsub_dll_name     = "NULL"
     is_static_hold      = "FALSE"
/>

Format

Fortran Calling Syntax
SUBROUTINE GSESUB (ID, TIME, PAR, NPAR, DFLAG, IFLAG,NSTATE, STATES, NINPUT, INPUT, NOUTPT, STATED, OUTPUT)
SUBROUTINE GSEXU (ID, TIME, PAR, NPAR, IFLAG, NSTATE,STATES, NINPUT, INPUT, NOUTPT, PXUMAT)
SUBROUTINE GSEXX (ID, TIME, PAR, NPAR, IFLAG, NSTATE,STATES, NINPUT, INPUT, NOUTPT, PXXMAT)
SUBROUTINE GSEYU (ID, TIME, PAR, NPAR, IFLAG, NSTATE, STATES, NINPUT, INPUT, NOUTPT, PYUMAT)
SUBROUTINE GSEYX (ID, TIME, PAR, NPAR, IFLAG, NSTATE, STATES, NINPUT, INPUT, NOUTPT, PYXMAT)
C Calling Syntax
void STDCALL GSESUB (int *id, double *time, double *par, int *npar,int *dflag, int *iflag, int 
*nstate, double *states,int *ninput, double *input, int *noutpt, double *stated,double *output)
void STDCALL GSEXU (int *id, double *time, double *par, int *npar, int *iflag, int 
*nstate,double *states, int *ninput, double *input, int *noutpt, double *pxumat)
void STDCALL GSEXX (int *id, double *time, double *par, int *npar, int *iflag, int 
*nstate, double *states, int *ninput, double *input, int *noutpt, double *pxxmat)
void STDCALL GSEYU (int *id, double *time, double *par, int *npar, int *iflag, int
*nstate, double *states, int *ninput, double *input, int *noutpt, double *pyumat)
void STDCALL GSEYX (int *id, double *time, double *par, int *npar, int *iflag, int
*nstate, double *states, int *ninput, double *input, int *noutpt, double *pyxmat)
Python Calling Syntax
def GSESUB(id, time, par, npar, dflag, iflag, nstate, states, ninput,input, noutpt):
    return [stated, output]
def GSEXU(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt):
    return pxumat
def GSEXX(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt):
    return pxxmat
def GSEYU(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt):
    return pyumat
def GSEYX(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt):
    return pyxmat
MATLAB Calling Syntax
function [stated, output] = GSESUB(id, time, par, npar, dflag, iflag, nstate, states, ninput, input, noutpt)
function pxumat = GSEXU(id, time, par, npar, iflag, nstate, states, ninput, input, noutpt)
function pxxmat = GSEXX(id, time, par, npar, iflag, nstate, states, ninput, input, noutpt)
function pyumat = GSEYU(id, time, par, npar, iflag, nstate, states, ninput, input, noutpt)
function pyxmat = GSEYX(id, time, par, npar, iflag, nstate, states, ninput, input, noutpt)

GSESUB evaluates the f and g functions in the following general state equation:

x' = f(x,u,t)

y = g(x,u,t)

where x is the vector of states, x' is the vector of state derivatives, u is the input, and y is the output.

Attributes

ID
[integer]
The general force element identifier.
TIME
[double precision]
The current simulation time.
PAR
[double precision]
An array that contains the constant arguments from the list provided in the user-defined statement.
NPAR
[integer]
The number of entries in the PAR array.
DFLAG
[logical]
The differencing flag.
IFLAG
[logical]
The initialization flag.
NSTATE
[integer]
The number of state variables taken from the num_state attribute of the Control_StateEqn entity.
STATES
[double precision]
An array of size NSTATE containing current values of state variables.
NINPUT
[integer]
The size of the input (U) array.
INPUT
[double precision]
An array containing the current values of the inputs.
NOUTPT
[integer]
The number of outputs taken from the num_output attribute of the Control_StateEqn entity.

Output

STATED
[double precision]
Array of size NSTATE containing the current values of the derivatives of the state variables.
OUTPUT
[double precision]
An array of size NOUTPT containing current values of the derivatives of outputs.

Example

def GSESUB(id, time, par, npar, dflag, iflag, nstate, states, ninput,input, noutpt):
    
    stated = []
    for i in xrange (nstate):
        stated.append(0.0)
    output = []
    for i in xrange(noutpt):
         output.append(0.0)
         ax = int(par[1])
         au = int(par[2])
         A = [[0.0, 0.0], [0.0, 0.0]]
         A[0][0] = -1.0e3
         A[0][1] = -2.0e4
         A[1][0] = 0.0
         A[1][1] = -1.0e3
         B = []
         B.append([0.0, -1.0])
         B.append([1.0,0.0])
         C = []
         C.append(1.0e3)
         C.append(0.0)
         stated[0] = A[0][0]*states[0] + A[0][1]*states[1] + B[0][0]*input[0] + B [0][1]*input[1]
         stated[1] = A[1][0]*states[0] + A[1][1]*states[1] + B[1][0]*input[0] + B [1][1]*input[1]
         output[0] = C[0]*states[0] + C[1]*states[1];
    return [stated, output]

def GSEXX(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt):

    pxxmat = []
    for i in xrange(nstate*nstate):
        pxxmat.append(0.0)
        pxxmat[0] = -1.0e3
        pxxmat[1] =0.0
        pxxmat[2] = -2.0e4
        pxxmat[3] = -1.0e3

    return pxxmat

def GSEXU(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt):
        
        pxumat = []
    for i in xrange(nstate*ninput):
        pxumat.append(0.0)
        pxumat[0] = 0.0
        pxumat[1] = 1.0
        pxumat[2] = -1.0
        pxumat[3] =  0.0
   
    return pxumat