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
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)
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)
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
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]
- TIME
- [double precision]
- PAR
- [double precision]
- NPAR
- [integer]
- DFLAG
- [logical]
- IFLAG
- [logical]
- NSTATE
- [integer]
- STATES
- [double precision]
- NINPUT
- [integer]
- INPUT
- [double precision]
- NOUTPT
- [integer]
Output
- STATED
- [double precision]
- OUTPUT
- [double precision]
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