def test_get_spin_directions(self): configuration.PlusZ(self.p_state) nos = system.Get_NOS(self.p_state) arr = system.Get_Spin_Directions(self.p_state) for i in range(nos): self.assertAlmostEqual(arr[i][0], 0.) self.assertAlmostEqual(arr[i][1], 0.) self.assertAlmostEqual(arr[i][2], 1.)
def test_read(self): nos = system.Get_NOS(self.p_state) configuration.PlusZ(self.p_state) io.Image_Write(self.p_state, io_image_test, 6, "python io test") io.Image_Read(self.p_state, io_image_test) spins = system.Get_Spin_Directions(self.p_state) for i in range(nos): self.assertAlmostEqual(spins[i][0], 0.) self.assertAlmostEqual(spins[i][1], 0.) self.assertAlmostEqual(spins[i][2], 1.) configuration.MinusZ(self.p_state) io.Image_Write(self.p_state, io_image_test, 6, "python io test") io.Image_Read(self.p_state, io_image_test) spins = system.Get_Spin_Directions(self.p_state) for i in range(nos): self.assertAlmostEqual(spins[i][0], 0.) self.assertAlmostEqual(spins[i][1], 0.) self.assertAlmostEqual(spins[i][2], -1.)
def snapshots(p_state): ### Test na, nb, nc = geometry.Get_N_Cells(p_state) spins = system.Get_Spin_Directions(p_state) spins.shape = (nc, nb, na, 3) positions = geometry.Get_Spin_Positions(p_state) positions.shape = (nc, nb, na, 3) n_layer_spins = nb * nc n_layers = na if (n_layers > 2): layer_x = n_layers / 2 else: layer_x = 1 n_layer_spins = na * nc n_layers = nb if (n_layers > 2): layer_y = n_layers / 2 else: layer_y = 1 n_layer_spins = na * nb n_layers = nc if (n_layers > 2): layer_z = n_layers / 2 else: layer_z = 1 print(layer_x, layer_y, layer_z) with open("data_x.txt", "w") as outfile: for j in range(nc): for i in range(nb): outfile.write( "%s, %s, %s, %s, %s, %s,\n" % (positions[j, i, layer_x, 1], positions[j, i, layer_x, 2], 0.0, spins[j, i, layer_x, 1], spins[j, i, layer_x, 2], spins[j, i, layer_x, 0])) with open("data_y.txt", "w") as outfile: for j in range(nc): for i in range(na): outfile.write( "%s, %s, %s, %s, %s, %s,\n" % (positions[j, layer_y, i, 0], positions[j, layer_y, i, 2], 0.0, spins[j, layer_y, i, 0], spins[j, layer_y, i, 2], spins[j, layer_y, i, 1])) with open("data_z.txt", "w") as outfile: for j in range(nb): for i in range(na): outfile.write( "%s, %s, %s, %s, %s, %s,\n" % (positions[layer_z, j, i, 0], positions[layer_z, j, i, 1], 0.0, spins[layer_z, j, i, 0], spins[layer_z, j, i, 1], spins[layer_z, j, i, 2])) from subprocess import call call("cp data_x.txt data.txt", shell=True) Run_PovRay_Script("Show_Spins", 1000, 1000) call("cp Show_Spins.png spins_x.png", shell=True) call("cp data_y.txt data.txt", shell=True) Run_PovRay_Script("Show_Spins", 1000, 1000) call("cp Show_Spins.png spins_y.png", shell=True) call("cp data_z.txt data.txt", shell=True) Run_PovRay_Script("Show_Spins", 1000, 1000) call("cp Show_Spins.png spins_z.png", shell=True) call("rm -f Data.txt Show_Spins.png", shell=True)