'''
Created on May 1, 2017

@author: Alec Daling

function definitions for dynamically adding heat_models to plot
'''
from matplotlib import animation as anim, pyplot, cm, text
from heat_model import heat_model
from mpl_toolkits.mplot3d import Axes3D


def add_fd_basic_1d(model_id, fig, models, num_models):
	'''
	create dense fd 1d model
	'''
	m = heat_model([0,19],model_id, fig) #create model
	ax = fig.add_subplot(1,num_models,model_id) #create axis
	#configure axes
	ax.set_xlabel('x')
	ax.set_ylabel('u(x,t)')
	ax.set_xlim(0.,m.x_max)
	ax.set_ylim(0,10)
	line, = ax.plot(m.x,m.u,lw=4) #create line
	models["lines"].append({"axis":ax,"model":m,"line":line}) #add to buffer
	
def add_fd_basic_2d(model_id,fig,models, num_models):
	'''
	create dense 2d fd model
	'''
	m = heat_model([0,19,0,19], model_id, fig)
	ax = fig.add_subplot(1,num_models,model_id,projection='3d')
	ax.set_xlabel('x')
	ax.set_ylabel('y')
	ax.set_zlabel('u(x,y,t)')
	surf = ax.plot_surface(m.X,m.Y,m.u,rstride=1,cstride=1,cmap=cm.autumn,linewidth=1,antialiased=False)
	models["surfs"].append({"axis":ax,"model":m,"surf":surf})
	
def add_fd_sparse_1d(model_id,fig,models,num_models):
	'''
	create sparse fd 1d model
	'''
	m = heat_model([0,19],model_id, fig, sparse=True)
	ax = fig.add_subplot(1,num_models,model_id)
	ax.set_xlabel('x')
	ax.set_xlim(0.,m.x_max)
	ax.set_ylim(0,10)
	ax.set_ylabel('u(x,t)')
	line, = ax.plot(m.x,m.u,lw=4)
	models["lines"].append({"axis":ax,"model":m,"line":line})

def add_fd_sparse_2d(model_id,fig,models,num_models):
	'''
	create sparse fd 2d model
	'''
	m = heat_model([0,19,0,19], model_id, fig, sparse=True)
	ax = fig.add_subplot(1,num_models,model_id,projection='3d')
	ax.set_xlabel('x')
	ax.set_ylabel('y')
	ax.set_zlabel('u(x,y,t)')
	surf = ax.plot_surface(m.X,m.Y,m.u,rstride=1,cstride=1,cmap=cm.autumn,linewidth=1,antialiased=False)
	models["surfs"].append({"axis":ax,"model":m,"surf":surf})

def add_bd_basic_1d(model_id,fig,models,num_models):
	'''
	create basic bd 1d model
	'''
	m = heat_model([0,19],model_id, fig,method='bd')
	ax = fig.add_subplot(1,num_models,model_id) 
	ax.set_xlabel('x')
	ax.set_ylabel('u(x,t)')
	ax.set_xlim(0.,m.x_max)
	ax.set_ylim(0,10)
	line, = ax.plot(m.x,m.u,lw=4)
	models["lines"].append({"axis":ax,"model":m,"line":line})
	
def add_bd_basic_2d(model_id,fig,models,num_models):
	'''
	create sparse 2d bd model
	'''
	#create sparse bd 1d model
	m = heat_model([0,19],model_id, fig,method='bd',sparse=True)
	ax = fig.add_subplot(1,num_models,model_id)
	ax.set_xlabel('x')
	ax.set_ylabel('u(x,t)')
	ax.set_xlim(0.,m.x_max)
	ax.set_ylim(0,10)
	line, = ax.plot(m.x,m.u,lw=4)
	models["lines"].append({"axis":ax,"model":m,"line":line})
	
def add_bd_sparse_1d(model_id,fig,models,num_models):
	'''
	create sparse 1d bd model
	'''
	test = 0

def add_bd_sparse_2d(model_id,fig,models,num_models):
	'''
	crate sparse 2d bd model
	'''
	test = 0

def add_cn_basic_1d(model_id,fig,models,num_models):
	'''
	create 1d dense crank-nicholson model
	'''
	test = 0
	
def add_cn_basic_2d(model_id,fig,models,num_models):
	'''
	create 2d dense crank-nicholson model
	'''
	test = 0