Example #1
0
def nonhomocarlem(xModBil,t,F,G,Order,parPlusVals,Vars,InpU):
	StateDim = len(Vars)
	xMod = xModBil[:StateDim]
	xD = xModBil[StateDim:]
	## Taylor Coefficients 
	tfIJ = [] 
	for fi in F:
		tfIJ.append(carlem.taylorcoeffs(fi,Vars,point=xModBil,Order=Order))
	
	tgKIJ = []
	for gkI in G:
		tgkIJ = []
		for gki in gkI:
			tgkIJ.append(carlem.taylorcoeffs(gki,Vars,point=xModBil,Order=Order))
		tgKIJ.append(tgkIJ)
	
	## compute the np matrices of the coefficients
	#  thereto possible parameters are substituted
	
	FJ = carlem.taylorcoeffs2matrix(tfIJ,Order=Order,parPlusVals=parPlusVals)
	GKJ = []
	for gk in tgKIJ:
		GKJ.append(carlem.taylorcoeffs2matrix(gk,Order=Order,parPlusVals=parPlusVals))
	
	
	# setup of the coefficients of the approximation (2)
	A, NK, B = carlem.setupbilinsystem(FJ,GKJ)
	
	xdDot = carlem.evarhsbilinsystem( xD.flatten(), t, A,NK,B,InpU )

	# eva of the actual nonlinear model (1)
	xModDot = carlem.evarhsmodel( xMod.flatten(),t,F,G,parPlusVals,Vars,InpU)

	xDot = np.concatenate((xModDot,xdDot),0)

	return xDot.flatten()
Example #2
0
for fi in model.F:
	tfIJ.append(carlem.taylorcoeffs(fi,model.Vars,Order=Order))

tgKIJ = []
for gkI in model.G:
	tgkIJ = []
	for gki in gkI:
		tgkIJ.append(carlem.taylorcoeffs(gki,model.Vars,Order=Order))
	tgKIJ.append(tgkIJ)

## compute the np matrices of the coefficients
#  thereto possible parameters are substituted
#TODO parameter handling
parPlusVals = dict(zip(model.Pars,[1]*len(model.Pars)))

FJ = carlem.taylorcoeffs2matrix(tfIJ,Order=Order,parPlusVals=parPlusVals)
GKJ = []
for gk in tgKIJ:
	GKJ.append(carlem.taylorcoeffs2matrix(gk,Order=Order,parPlusVals=parPlusVals))

# the initial value is to be extended as well
X0bilin = carlem.var0tobilinx0(model.Var0,Order)

# setup of the coefficients of the approximation (2)
A, NK, B = carlem.setupbilinsystem(FJ,GKJ)

## Evaluation 
#  TODO handling and definition of control functions

InpU = np.ones((1,1))