Пример #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()
Пример #2
0
## 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))

# definition of the integration interval
t = np.arange(0,1.1,0.5)

# eva of the bilin appr. (2)
xBil = integrate.odeint(carlem.evarhsbilinsystem, X0bilin.flatten(), t, args = (A,NK,B,InpU))

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