def gb_vs_iters_disp(sigma_0,iters,strength):
	"""
	Calculate Gilbert Damping versus number of iterations for displacement regime.
	"""
	with open('result_disp_'+str(strength)+'_'+str(iters)+'.txt', 'w') as f:					
		system = topological_insulator.make_topo_displacement(50.+0.j, 3.645+0.j, -68.6+0.j, -0.1+0.j, -51.2+0.j, -0.05+0.j, -0.067+0.j, 1.+0.j,sigma_0,0.5,500,20,1,strength)
		sys = system[0]
		sys.update_hamil_2(calc.build_fm_island(calc.make_hamil_layers(sys.hamil, 20, system[1],20),np.radians(0),0,0.02+0.j,20,20),20,20)		
		x_list = []
		y_list = []
		gb = calc.find_gb(0,0,sys)
		for num in range(2,iters+2):
			system = topological_insulator.make_topo_displacement(50.+0.j, 3.645+0.j, -68.6+0.j, -0.1+0.j, -51.2+0.j, -0.05+0.j, -0.067+0.j, 1.+0.j,sigma_0,0.5,500,20,1,strength)
			sys = system[0]
			sys.update_hamil_2(calc.build_fm_island(calc.make_hamil_layers(sys.hamil, 20, system[1],20),np.radians(0),0,0.02+0.j,20,20),20,20)			
			x_list.append(num)
			gb = (gb*(num-1) + calc.find_gb(0,0,sys)) / num
			y_list.append(gb)
			f.write(str(gb) + '\n')
		fig = plt.figure()
		ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
		ax.plot(x_list,y_list,color='g')
		fig.savefig('output_disp_'+str(strength)+'_'+str(iters)+'.png')
		plt.close(fig)		
		return gb
def build_fm_topo():
	"""
	Build a topological insulator with a ferromagnetic island.
	"""	
	sigma_0 = 1.e-4+1.e-4j
	topo = make_topo(50.+0.j, 3.645+0.j, -68.6+0.j, -0.1+0.j, -51.2+0.j, -0.05+0.j, -0.067+0.j, 1.+0.j,sigma_0,0.5,500,20,1)
	topo_sys = topo[0]
	topo_sys.update_hamil_2(calc.build_fm_island(calc.make_hamil_layers(topo_sys.hamil, 20, topo[1],20),np.radians(0),0,0.02+0.j,20,20),20,20)
	x_list = []
	y_list = []	
	for theta in range(0,180,18):
		theta_rad = np.radians(theta)	
		gb = calc.find_gb(theta_rad,0,topo_sys)
		x_list.append(theta)
		y_list.append(gb)
		
	fig = plt.figure()
	ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
	ax.plot(x_list,y_list,color='g')
	plt.show()