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()
import modeltest as model #import modelmff as model #import modelvdposc as model ## reload for use in ipython shell reload(model) import carlem as carlem reload(carlem) # set up the order of approximation: Order = 2, we will solve for [x,x*x] Order = 2; ## Taylor Coefficients tfIJ = [] 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 = []