#######x[:,n+1] = mod.lorenz96(x[:,n],random,dt) + dt*dx #4)n2500m4 (peaks) #8)n1m7 ########xtran2 = mod.l95(x[:,n],dt) + dx #n4m3 ########x[:,n+1] = mod.lorenz96(xtran2,random,dt) ########xtran2 = mod.l95(x[:,n],dt) + dt*dx ##4)n2500m4 (damping) #8)n1m7 ########x[:,n+1] = mod.lorenz96(xtran2,random,dt) ##########xtran2 = mod.l95(x[:,n],dt) + dx #n4m4 ##########x[:,n+1] = mod.rk4(xtran2,dt) ###########xtran2 = mod.l95(x[:,n],dt) + dt*dx ##4)n2500m4 (damping) #8)n1m7 ###########x[:,n+1] = mod.rk4(xtran2,dt) x[:,n+1] = mod.rk4_end(x[:,n],dx,dt) #+ dx0 #4)n4m2 #4)n2500m4 (peaks) for dt*dx in rk4 #############ddx = dx*dt #4)n2500m4 (peaks) #8)n1m7 #############x[:,n+1] = mod.rk4_end(x[:,n],ddx,dt) ##############x[:,n+1] = dt*(mod.lorenz96(x[:,n],random,dt) + dx) ##4)n2500m4 (damping) #8)n1m7 ###############xtran2 = dt*(x[:,n] + dx) ##4)n2500m4 (damping) ###############x[:,n+1] = mod.lorenz96(xtran2,random,dt) #print 'x[:,n+1] at', n+1, 'is', x[:,n+1] #Calculating SE (synchronisation error) ##if np.mod(n+1,10) == 1: ##SE = np.zeros([D,n+1])
####Jac = Jac0 random = np.zeros(N) #x[:,t+1] = x[:,t] + dt*(x[:,t] + coup) #x[:,t+1] = x[:,t] + dt*coup #x[:,t+1] = dt*(x[:,t] + coup) #x[:,t+1] = x[:,t] + coup ##xtran = x[:,t] + coup ##x[:,t+1] = mod.lorenz96(xtran,random,dt) ####xtran2 = mod.l95(x[:,t],dt) + coup ####x[:,t+1] = mod.rk4(xtran2,dt) #######x[:,t+1] = mod.lorenz96(x[:,t],random,dt) + coup #x[:,t+1] = mod.lorenz96(x[:,t],random,dt) + dt*coup x[:,t+1] = mod.rk4_end(x[:,t],coup,dt) #x[:,t+1] = mod.lorenz96(x[:,t],random,dt) + tau*coup #dd = np.zeros([N,t+1]) dd = np.zeros([N,1]) dd[:,0] = xtrue[:,t+1] - x[:,t+1] #for d in range(t+1): ##dd = np.zeros([N,t+1]) ##dd[:,d] = xtrue[:,d] - x[:,d] #dd = np.zeros([1,t+1]) #dd[:,d] = xtrue[0,d] - x[0,d] SE = np.sqrt(np.mean(np.square(dd))) print 'SE for', t, 'is', SE plt.plot(t+1,SE,'b*') #plt.plot(d,SE,'b*')
#dx2 = np.dot(Ks,np.transpose((Y-S))) # For all formulations apart from 5th #dx2 = np.dot(dx1,np.transpose(dYS)) # For the 5th formulation #dx = np.dot(dx1,dx2) # For all formulations apart from 5th #dx = np.dot(A,dx2) # For the 5th formulation ##dx3 = dx3.reshape(D) #dx = dx.reshape(D) #print 'dx', dx #print 'x[:,n]shape', x[:,n].shape #print 'x[:,n]', x[:,n] #print 'DX', DX #### Evolving variables with time ####### random = np.zeros(D) #x[:,n+1] = mod.rk4_end(x[:,n],dx,dt) x[:,n+1] = mod.rk4_end(x[:,n],DX,dt) #x[:,n+1] = mod.lorenz96(x[:,n],random,dt) + dx #x[:,n+1] = mod.lorenz96(x[:,n],random,dt) + dt*dx #print 'x[:,n+1] at', n+1, 'is', x[:,n+1] #print 'x[:,n+1] at', n+1, 'is', x[:,n+1] ####### Calculating the synchronisation error (RMSE) ####### ##if np.mod(n+1,10) == 1: ##SE = np.zeros([D,n+1]) ##for d in range(n+1): ##SE[:,d] = xtrue[:,d] - x[:,d] #SE = xtrue(:,1:n+1) - x(:,1:n+1)
#### Calculating the coupling term in coupled dynamics ###### dx1 = np.dot(K,dxds) #print 'dx1', dx1 dx2 = np.dot(Ks,np.transpose((Y-S))) dx = np.dot(dx1,dx2) dx = dx.reshape(D) #print 'dx', dx #print 'x[:,n]shape', x[:,n].shape ddd = Y-S #print 'ddd', ddd #### Evolving variables with time ####### random = np.zeros(D) x[:,n+1] = mod.rk4_end(x[:,n],dx,dt) #x[:,n+1] = mod.lorenz96(x[:,n],random,dt) + dx #x[:,n+1] = mod.lorenz96(x[:,n],random,dt) + dt*dx #print 'x[:,n+1] at', n+1, 'is', x[:,n+1] ####### Calculating the synchronisation error (RMSE) ####### ##if np.mod(n+1,10) == 1: ##SE = np.zeros([D,n+1]) ##for d in range(n+1): ##SE[:,d] = xtrue[:,d] - x[:,d] #SE = xtrue(:,1:n+1) - x(:,1:n+1) ##SE = np.sqrt(np.mean(np.square(SE))) ##print 'SE at', n, 'is', SE
####### Calculating the coupling term in coupled dynamics ###### dx1 = np.dot(K, dxds) #print 'dx1', dx1 dx2 = np.dot(Ks, np.transpose((Y - S))) dx = np.dot(dx1, dx2) dx = dx.reshape(D) #print 'dx', dx #print 'x[:,n]shape', x[:,n].shape ddd = Y - S #print 'ddd', ddd random = np.zeros(D) x[:, n + 1] = mod.rk4_end( x[:, n], dx, dt ) #+ dx0 #4)n4m2 #4)n2500m4 (peaks) for dt*dx in rk4 ###################Calculating and plotting Lyapunov exponents ######################## dlya = x[:, n + 1] - xtrue[:, n + 1] #print 'dlya', dlya dl = abs(dlya / dlyaini) #print 'dl', dl lya = (1 / float(n)) * (np.log(dl)) #lyaposit = 0 #for i in range(D): # if lya[i] > 0: # lyaposit = lyaposit + 1 #print 'Lyapositive', lyaposit
#dx = np.dot(dx1,np.transpose(Y)) dx = np.dot(dx1, np.transpose(diff)) #dx = np.dot(dx1,ddd) #dx = np.dot(dx1,(Y-S)) #dx2 = np.dot(dx1,np.transpose((Y-S))) #dx2 = np.dot(dx1,np.transpose(diff)) #dx2 = np.dot(dx1,np.transpose(Y)) #dx = np.dot(K,dx2) dx = dx.reshape(D) #print 'x[:,n]', x[:,n] #print 'dx', dx ############ Running the coupled dynamics ########### random = np.zeros(D) x[:, n + 1] = mod.rk4_end(x[:, n], dx, dt) #x[:,n+1] = x[:,n] + dx #print 'xtrue[:,n+1]', xtrue[:,n+1] #print 'x[:,n+1]', x[:,n+1] ########################## Calculating SE ############################ dd = np.zeros([D, 1]) dd[:, 0] = xtrue[:, n + 1] - x[:, n + 1] SE = np.sqrt(np.mean(np.square(dd))) ##print '*************************************' print 'SE for', n, 'is', SE ##print '*************************************' ######### Plotting SE and other variables ########### #plt.figure(figsize=(12, 10)).suptitle('Synchronisation Error')
#dx2 = np.dot(Ks,np.transpose((Y-S))) # For all formulations apart from 5th #dx2 = np.dot(dx1,np.transpose(dYS)) # For the 5th formulation #dx = np.dot(dx1,dx2) # For all formulations apart from 5th #dx = np.dot(A,dx2) # For the 5th formulation ##dx3 = dx3.reshape(D) #dx = dx.reshape(D) #print 'dx', dx #print 'x[:,n]shape', x[:,n].shape #print 'x[:,n]', x[:,n] #print 'DX', DX #### Evolving variables with time ####### random = np.zeros(D) #x[:,n+1] = mod.rk4_end(x[:,n],dx,dt) x[:, n + 1] = mod.rk4_end(x[:, n], DX, dt) #x[:,n+1] = mod.lorenz96(x[:,n],random,dt) + dx #x[:,n+1] = mod.lorenz96(x[:,n],random,dt) + dt*dx #print 'x[:,n+1] at', n+1, 'is', x[:,n+1] #print 'x[:,n+1] at', n+1, 'is', x[:,n+1] ####### Calculating the synchronisation error (RMSE) ####### ##if np.mod(n+1,10) == 1: ##SE = np.zeros([D,n+1]) ##for d in range(n+1): ##SE[:,d] = xtrue[:,d] - x[:,d] #SE = xtrue(:,1:n+1) - x(:,1:n+1)
for k in range(M * L): i_dYS = dYS[:, k] i_newdYS = dloc[k] * i_dYS[0] # SCHUR Product!! newdYS[:, k] = i_newdYS #print 'New dYS to use in the variable equation to find var', i, ':', dYS dx3 = np.dot(dx2[i, :], np.transpose(newdYS)) #print 'dx3 for var',i, ':', dx3 DX[i] = dx3[0] #### Evolving variables with time ####### random = np.zeros(D) #x[:,n+1] = mod.rk4_end(x[:,n],dx,dt) x[:, n + 1] = mod.rk4_end(x[:, n], DX, dt) ####### Calculating the synchronisation error (RMSE) ####### ##if np.mod(n+1,10) == 1: ##SE = np.zeros([D,n+1]) ##for d in range(n+1): ##SE[:,d] = xtrue[:,d] - x[:,d] #SE = xtrue(:,1:n+1) - x(:,1:n+1) ##SE = np.sqrt(np.mean(np.square(SE))) ##print 'SE at', n, 'is', SE ##plt.plot(n+1,SE,'b*') ##plt.yscale('log') ##plt.hold(True) dd = np.zeros([D, 1]) dd[:, 0] = xtrue[:, n + 1] - x[:, n + 1] SE = np.sqrt(np.mean(np.square(dd)))
####Jac = Jac0 random = np.zeros(N) #x[:,t+1] = x[:,t] + dt*(x[:,t] + coup) #x[:,t+1] = x[:,t] + dt*coup #x[:,t+1] = dt*(x[:,t] + coup) #x[:,t+1] = x[:,t] + coup ##xtran = x[:,t] + coup ##x[:,t+1] = mod.lorenz96(xtran,random,dt) ####xtran2 = mod.l95(x[:,t],dt) + coup ####x[:,t+1] = mod.rk4(xtran2,dt) #######x[:,t+1] = mod.lorenz96(x[:,t],random,dt) + coup #x[:,t+1] = mod.lorenz96(x[:,t],random,dt) + dt*coup #print 'x[:,t]', x[:,t].shape x[:,t+1] = mod.rk4_end(x[:,t],coup,dt) #x[:,t+1] = mod.lorenz96(x[:,t],random,dt) + tau*coup #dd = np.zeros([N,t+1]) dd = np.zeros([N,1]) dd[:,0] = xtrue[:,t+1] - x[:,t+1] #for d in range(t+1): ##dd = np.zeros([N,t+1]) ##dd[:,d] = xtrue[:,d] - x[:,d] #dd = np.zeros([1,t+1]) #dd[:,d] = xtrue[0,d] - x[0,d] SE = np.sqrt(np.mean(np.square(dd))) print 'SE for', t, 'is', SE plt.plot(t+1,SE,'b*') #plt.plot(d,SE,'b*')